diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrContextPriv.h | 9 | ||||
-rw-r--r-- | src/gpu/GrDrawingManager.cpp | 47 | ||||
-rw-r--r-- | src/gpu/GrDrawingManager.h | 8 | ||||
-rw-r--r-- | src/gpu/GrPreFlushResourceProvider.cpp | 65 | ||||
-rw-r--r-- | src/gpu/GrPreFlushResourceProvider.h | 77 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 21 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureOpList.cpp | 6 | ||||
-rw-r--r-- | src/gpu/ops/GrTestMeshDrawOp.h | 2 |
10 files changed, 13 insertions, 229 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index bcb93b30be..c0d63a33b0 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -711,11 +711,6 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend surfaceProps); } -void GrContextPriv::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject) { - fContext->fDrawingManager->addPreFlushCallbackObject(std::move(preFlushCBObject)); -} - - static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) { switch (config) { case kAlpha_8_GrPixelConfig: diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index 3357636605..c70381fe43 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -13,7 +13,6 @@ class GrSemaphore; class GrSurfaceProxy; -class GrPreFlushCallbackObject; /** Class that adds methods to GrContext that are only intended for use internal to Skia. This class is purely a privileged window into GrContext. It should never have additional @@ -59,15 +58,9 @@ public: bool disableGpuYUVConversion() const { return fContext->fDisableGpuYUVConversion; } - /* - * A ref will be taken on the preFlushCallbackObject which will be removed when the - * context is destroyed. - */ - void addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject>); - private: explicit GrContextPriv(GrContext* context) : fContext(context) {} - GrContextPriv(const GrContextPriv&); // unimpl + GrContextPriv(const GrContextPriv&) {} // unimpl GrContextPriv& operator=(const GrContextPriv&); // unimpl // No taking addresses of this type. diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 449cae6b61..d670e16b73 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -75,53 +75,10 @@ void GrDrawingManager::internalFlush(GrResourceCache::FlushType type) { } fFlushing = true; bool flushed = false; - - for (int i = 0; i < fOpLists.count(); ++i) { - // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh - // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed - // but need to be flushed anyway. Closing such GrOpLists here will mean new - // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again. - fOpLists[i]->makeClosed(); - } - SkDEBUGCODE(bool result =) SkTTopoSort<GrOpList, GrOpList::TopoSortTraits>(&fOpLists); SkASSERT(result); - GrPreFlushResourceProvider preFlushProvider(this); - - if (fPreFlushCBObjects.count()) { - // MDB TODO: pre-MDB '1' is the correct pre-allocated size. Post-MDB it will need - // to be larger. - SkAutoSTArray<1, uint32_t> opListIds(fOpLists.count()); - for (int i = 0; i < fOpLists.count(); ++i) { - opListIds[i] = fOpLists[i]->uniqueID(); - } - - SkSTArray<1, sk_sp<GrRenderTargetContext>> renderTargetContexts; - for (int i = 0; i < fPreFlushCBObjects.count(); ++i) { - fPreFlushCBObjects[i]->preFlush(&preFlushProvider, - opListIds.get(), opListIds.count(), - &renderTargetContexts); - if (!renderTargetContexts.count()) { - continue; // This is fine. No atlases of this type are required for this flush - } - - for (int j = 0; j < renderTargetContexts.count(); ++j) { - GrRenderTargetOpList* opList = renderTargetContexts[j]->getOpList(); - if (!opList) { - continue; // Odd - but not a big deal - } - SkDEBUGCODE(opList->validateTargetsSingleRenderTarget()); - opList->prepareOps(&fFlushState); - if (!opList->executeOps(&fFlushState)) { - continue; // This is bad - } - } - renderTargetContexts.reset(); - } - } - for (int i = 0; i < fOpLists.count(); ++i) { fOpLists[i]->prepareOps(&fFlushState); } @@ -188,10 +145,6 @@ void GrDrawingManager::prepareSurfaceForExternalIO(GrSurface* surface) { } } -void GrDrawingManager::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject) { - fPreFlushCBObjects.push_back(preFlushCBObject); -} - GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) { SkASSERT(fContext); diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index d914b03a75..061e878793 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -11,10 +11,9 @@ #include "GrOpFlushState.h" #include "GrPathRenderer.h" #include "GrPathRendererChain.h" -#include "GrPreFlushResourceProvider.h" #include "GrRenderTargetOpList.h" #include "GrResourceCache.h" -#include "SkTArray.h" +#include "SkTDArray.h" #include "text/GrAtlasTextContext.h" class GrContext; @@ -68,8 +67,6 @@ public: void prepareSurfaceForExternalIO(GrSurface*); - void addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject); - private: GrDrawingManager(GrContext* context, const GrRenderTargetOpList::Options& optionsForOpLists, @@ -95,7 +92,6 @@ private: void internalFlush(GrResourceCache::FlushType); friend class GrContext; // for access to: ctor, abandon, reset & flush - friend class GrPreFlushResourceProvider; // this is just a shallow wrapper around this class static const int kNumPixelGeometries = 5; // The different pixel geometries static const int kNumDFTOptions = 2; // DFT or no DFT @@ -119,8 +115,6 @@ private: bool fFlushing; bool fIsImmediateMode; - - SkTArray<sk_sp<GrPreFlushCallbackObject>> fPreFlushCBObjects; }; #endif diff --git a/src/gpu/GrPreFlushResourceProvider.cpp b/src/gpu/GrPreFlushResourceProvider.cpp deleted file mode 100644 index e907f3925d..0000000000 --- a/src/gpu/GrPreFlushResourceProvider.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrPreFlushResourceProvider.h" - -#include "GrDrawingManager.h" -#include "GrSurfaceProxy.h" - -sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext( - const GrSurfaceDesc& desc, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props) { - GrSurfaceDesc tmpDesc = desc; - tmpDesc.fFlags |= kRenderTarget_GrSurfaceFlag; - - // Because this is being allocated at the start of a flush we must ensure the proxy - // will, when instantiated, have no pending IO. - // TODO: fold the kNoPendingIO_Flag into GrSurfaceFlags? - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred( - fDrawingMgr->getContext()->resourceProvider(), - tmpDesc, - SkBackingFit::kExact, - SkBudgeted::kYes, - GrResourceProvider::kNoPendingIO_Flag); - if (!proxy->asRenderTargetProxy()) { - return nullptr; - } - - sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList( - proxy->asRenderTargetProxy(), - fDrawingMgr->fContext->getGpu(), - fDrawingMgr->fContext->resourceProvider(), - fDrawingMgr->fContext->getAuditTrail(), - fDrawingMgr->fOptionsForOpLists)); - proxy->setLastOpList(opList.get()); - - return fDrawingMgr->makeRenderTargetContext(std::move(proxy), - std::move(colorSpace), - props); -} - -// TODO: we only need this entry point as long as we have to pre-allocate the atlas. -// Remove it ASAP. -sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext( - sk_sp<GrSurfaceProxy> proxy, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props) { - - sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList( - proxy->asRenderTargetProxy(), - fDrawingMgr->fContext->getGpu(), - fDrawingMgr->fContext->resourceProvider(), - fDrawingMgr->fContext->getAuditTrail(), - fDrawingMgr->fOptionsForOpLists)); - proxy->setLastOpList(opList.get()); - - return fDrawingMgr->makeRenderTargetContext(std::move(proxy), - std::move(colorSpace), - props); -} - diff --git a/src/gpu/GrPreFlushResourceProvider.h b/src/gpu/GrPreFlushResourceProvider.h deleted file mode 100644 index 86a299a422..0000000000 --- a/src/gpu/GrPreFlushResourceProvider.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrPreFlushResourceProvider_DEFINED -#define GrPreFlushResourceProvider_DEFINED - -#include "GrTypes.h" -#include "GrNonAtomicRef.h" - -// These two are just for GrPreFlushCallbackObject -#include "SkRefCnt.h" -#include "SkTDArray.h" - -class GrDrawingManager; -class GrOpList; -class GrPreFlushResourceProvider; -class GrRenderTargetOpList; -class GrRenderTargetContext; -class GrSurfaceProxy; - -class SkColorSpace; -class SkSurfaceProps; - -/* - * This is the base class from which all per-flush callback objects must be derived. It - * provides the "preFlush" interface. - */ -class GrPreFlushCallbackObject : public GrNonAtomicRef<GrPreFlushCallbackObject> { -public: - virtual ~GrPreFlushCallbackObject() { } - - /* - * The preFlush callback allows subsystems (e.g., text, path renderers) to create atlases - * for a specific flush. All the GrOpList IDs required for the flush are passed into the - * callback. The callback should return the render target contexts used to render the atlases - * in 'results'. - */ - virtual void preFlush(GrPreFlushResourceProvider*, - const uint32_t* opListIDs, int numOpListIDs, - SkTArray<sk_sp<GrRenderTargetContext>>* results) = 0; - -private: - typedef SkRefCnt INHERITED; -}; - -/* - * This class is a shallow wrapper around the drawing manager. It is passed into the - * preFlush callbacks and is intended to limit the functionality available to them. - * It should never have additional data members or virtual methods. - */ -class GrPreFlushResourceProvider { -public: - sk_sp<GrRenderTargetContext> makeRenderTargetContext(const GrSurfaceDesc& desc, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props); - - // TODO: we only need this entry point as long as we have to pre-allocate the atlas. - // Remove it ASAP. - sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy> proxy, - sk_sp<SkColorSpace> colorSpace, - const SkSurfaceProps* props); - -private: - explicit GrPreFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {} - GrPreFlushResourceProvider(const GrPreFlushResourceProvider&); // unimpl - GrPreFlushResourceProvider& operator=(const GrPreFlushResourceProvider&); // unimpl - - GrDrawingManager* fDrawingMgr; - - friend class GrDrawingManager; // to construct this type. -}; - -#endif diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 8d47ffffce..1c9835389e 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -70,25 +70,14 @@ void GrRenderTargetOpList::dump() const { } } } - -void GrRenderTargetOpList::validateTargetsSingleRenderTarget() const { - GrRenderTarget* rt = nullptr; - for (int i = 0; i < fRecordedOps.count(); ++i) { - if (!fRecordedOps[i].fOp) { - continue; // combined forward - } - - if (!rt) { - rt = fRecordedOps[i].fRenderTarget.get(); - } else { - SkASSERT(fRecordedOps[i].fRenderTarget.get() == rt); - } - } -} #endif void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) { - // MDB TODO: add SkASSERT(this->isClosed()); + // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh + // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed + // but need to be flushed anyway. Closing such GrOpLists here will mean new + // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again. + this->makeClosed(); // Loop over the ops that haven't yet been prepared. for (int i = 0; i < fRecordedOps.count(); ++i) { diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index ab744f35e6..f4458b5775 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -102,8 +102,6 @@ public: SkDEBUGCODE(void dump() const override;) - SkDEBUGCODE(void validateTargetsSingleRenderTarget() const;) - private: friend class GrRenderTargetContextPriv; // for clearStencilClip and stencil clip state. diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index d396b2a5ea..d70daa2c79 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -45,7 +45,11 @@ void GrTextureOpList::dump() const { #endif void GrTextureOpList::prepareOps(GrOpFlushState* flushState) { - // MDB TODO: add SkASSERT(this->isClosed()); + // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh + // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed + // but need to be flushed anyway. Closing such GrOpLists here will mean new + // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again. + this->makeClosed(); // Loop over the ops that haven't yet generated their geometry for (int i = 0; i < fRecordedOps.count(); ++i) { diff --git a/src/gpu/ops/GrTestMeshDrawOp.h b/src/gpu/ops/GrTestMeshDrawOp.h index 039f88d672..d78d3e9164 100644 --- a/src/gpu/ops/GrTestMeshDrawOp.h +++ b/src/gpu/ops/GrTestMeshDrawOp.h @@ -19,7 +19,7 @@ */ class GrTestMeshDrawOp : public GrMeshDrawOp { public: - const char* name() const override = 0; + virtual const char* name() const override = 0; protected: GrTestMeshDrawOp(uint32_t classID, const SkRect& bounds, GrColor color) |