From 4f6ba2e522bcc3f84c02c9b7dd834b9b5476968b Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 15 Jun 2018 15:59:38 +0000 Subject: Revert "Move op memory storage to GrContext" This reverts commit c8cee446bf9c07da8848bbd032abf26e79966ac1. Reason for revert: TSAN issues Original change's description: > Move op memory storage to GrContext > > TBR=bsalomon@google.com > Change-Id: Ifa95bf0073b9d948f2c937d10088b7734b971f90 > Reviewed-on: https://skia-review.googlesource.com/131500 > Reviewed-by: Brian Salomon > Reviewed-by: Greg Daniel > Commit-Queue: Robert Phillips TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: Ia0d2b7408314d9b67d57388315376bbea23d3780 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/135181 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- gm/atlastext.cpp | 2 -- gm/beziereffects.cpp | 13 +++------ gm/convexpolyeffect.cpp | 4 +-- include/atlastext/SkAtlasTextTarget.h | 4 +-- include/gpu/GrContext.h | 3 -- include/private/GrCCPerOpListPaths.h | 2 +- include/private/GrOpList.h | 17 ++++-------- src/atlastext/SkAtlasTextTarget.cpp | 20 +------------- src/gpu/GrContext.cpp | 17 ------------ src/gpu/GrContextPriv.h | 4 --- src/gpu/GrDrawingManager.cpp | 12 -------- src/gpu/GrMemoryPool.h | 2 -- src/gpu/GrOpList.cpp | 11 +++----- src/gpu/GrRenderTargetContext.cpp | 3 -- src/gpu/GrRenderTargetOpList.cpp | 25 +++-------------- src/gpu/GrRenderTargetOpList.h | 12 ++------ src/gpu/GrTextureOpList.cpp | 23 ++-------------- src/gpu/GrTextureOpList.h | 6 +--- src/gpu/ccpr/GrCCDrawPathsOp.cpp | 16 ++++------- src/gpu/ccpr/GrCCPerFlushResources.cpp | 5 ++-- src/gpu/ops/GrAtlasTextOp.cpp | 9 ++---- src/gpu/ops/GrClearOp.cpp | 8 ++---- src/gpu/ops/GrClearStencilClipOp.cpp | 4 +-- src/gpu/ops/GrCopySurfaceOp.cpp | 5 ++-- src/gpu/ops/GrDashOp.cpp | 6 ++-- src/gpu/ops/GrDebugMarkerOp.cpp | 4 +-- src/gpu/ops/GrDrawPathOp.cpp | 5 ++-- src/gpu/ops/GrOp.cpp | 50 +++++++++++++++++++++++++++------- src/gpu/ops/GrOp.h | 3 -- src/gpu/ops/GrSemaphoreOp.cpp | 11 ++++---- src/gpu/ops/GrShadowRRectOp.cpp | 14 ++++------ src/gpu/ops/GrSimpleMeshDrawOpHelper.h | 11 +++----- src/gpu/ops/GrStencilPathOp.cpp | 6 ++-- src/gpu/ops/GrTextureOp.cpp | 8 ++---- tests/DrawOpAtlasTest.cpp | 3 -- tests/GrMeshTest.cpp | 4 +-- tests/GrPipelineDynamicStateTest.cpp | 5 ++-- tests/LazyProxyTest.cpp | 15 +++------- tests/PrimitiveProcessorTest.cpp | 4 +-- tests/ProcessorTest.cpp | 4 +-- 40 files changed, 116 insertions(+), 264 deletions(-) diff --git a/gm/atlastext.cpp b/gm/atlastext.cpp index c30a6754db..226b83fdd7 100644 --- a/gm/atlastext.cpp +++ b/gm/atlastext.cpp @@ -8,7 +8,6 @@ #include "gm.h" #if SK_SUPPORT_ATLAS_TEXT -#include "GrContext.h" #include "SkAtlasTextContext.h" #include "SkAtlasTextFont.h" @@ -73,7 +72,6 @@ protected: if (!targetHandle) { return; } - fTarget = SkAtlasTextTarget::Make(fContext, kSize, kSize, targetHandle); fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()); diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index 1c26989df2..dea6150549 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -80,9 +80,7 @@ public: sk_sp gp, const SkRect& rect, GrColor color) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(gp), rect, color); + return std::unique_ptr(new BezierCubicTestOp(std::move(gp), rect, color)); } private: @@ -266,9 +264,8 @@ public: const SkRect& rect, GrColor color, const SkMatrix& klm) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(gp), rect, color, klm); + return std::unique_ptr( + new BezierConicTestOp(std::move(gp), rect, color, klm)); } private: @@ -488,9 +485,7 @@ public: const SkRect& rect, GrColor color, const GrPathUtils::QuadUVMatrix& devToUV) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(gp), rect, color, devToUV); + return std::unique_ptr(new BezierQuadTestOp(std::move(gp), rect, color, devToUV)); } private: diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index 18c5ebdcdc..8f8d1b4d50 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -45,9 +45,7 @@ public: static std::unique_ptr Make(GrContext* context, GrPaint&& paint, const SkRect& rect) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(paint), rect); + return std::unique_ptr(new PolyBoundsOp(std::move(paint), rect)); } const char* name() const override { return "PolyBoundsOp"; } diff --git a/include/atlastext/SkAtlasTextTarget.h b/include/atlastext/SkAtlasTextTarget.h index 7e4ae449ed..c29f381dc8 100644 --- a/include/atlastext/SkAtlasTextTarget.h +++ b/include/atlastext/SkAtlasTextTarget.h @@ -27,9 +27,7 @@ public: * Creates a text drawing target. ‘handle’ is used to identify this rendering surface when * draws are flushed to the SkAtlasTextContext's SkAtlasTextRenderer. */ - static std::unique_ptr Make(sk_sp, - int width, - int height, + static std::unique_ptr Make(sk_sp, int width, int height, void* handle); /** diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 517e23a627..5a2ba4780f 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -33,7 +33,6 @@ class GrGlyphCache; class GrGpu; class GrIndexBuffer; struct GrMockOptions; -class GrOpMemoryPool; class GrOvalRenderer; class GrPath; class GrProxyProvider; @@ -308,8 +307,6 @@ private: GrProxyProvider* fProxyProvider; std::unique_ptr fTextureStripAtlasManager; - // All the GrOp-derived classes use this pool. - sk_sp fOpMemoryPool; GrGlyphCache* fGlyphCache; std::unique_ptr fTextBlobCache; diff --git a/include/private/GrCCPerOpListPaths.h b/include/private/GrCCPerOpListPaths.h index 6e53a1ff5c..b94e82c548 100644 --- a/include/private/GrCCPerOpListPaths.h +++ b/include/private/GrCCPerOpListPaths.h @@ -25,7 +25,7 @@ class GrCCPerOpListPaths : public SkRefCnt { public: ~GrCCPerOpListPaths(); - SkTInternalLList fDrawOps; // This class does not own these ops. + SkTInternalLList fDrawOps; std::map fClipPaths; SkSTArenaAlloc<10 * 1024> fAllocator{10 * 1024 * 2}; sk_sp fFlushResources; diff --git a/include/private/GrOpList.h b/include/private/GrOpList.h index 0d5a1a245a..846a5834f7 100644 --- a/include/private/GrOpList.h +++ b/include/private/GrOpList.h @@ -17,7 +17,6 @@ class GrAuditTrail; class GrCaps; class GrOpFlushState; -class GrOpMemoryPool; class GrRenderTargetOpList; class GrResourceAllocator; class GrResourceProvider; @@ -29,7 +28,7 @@ struct SkIRect; class GrOpList : public SkRefCnt { public: - GrOpList(GrResourceProvider*, sk_sp, GrSurfaceProxy*, GrAuditTrail*); + GrOpList(GrResourceProvider*, GrSurfaceProxy*, GrAuditTrail*); ~GrOpList() override; // These four methods are invoked at flush time @@ -103,16 +102,12 @@ public: protected: bool isInstantiated() const; - // This is a backpointer to the GrOpMemoryPool that holds the memory for this opLists' ops. - // In the DDL case, these back pointers keep the DDL's GrOpMemoryPool alive as long as its - // constituent opLists survive. - sk_sp fOpMemoryPool; - GrSurfaceProxyRef fTarget; - GrAuditTrail* fAuditTrail; + GrSurfaceProxyRef fTarget; + GrAuditTrail* fAuditTrail; - GrLoadOp fColorLoadOp = GrLoadOp::kLoad; - GrColor fLoadClearColor = 0x0; - GrLoadOp fStencilLoadOp = GrLoadOp::kLoad; + GrLoadOp fColorLoadOp = GrLoadOp::kLoad; + GrColor fLoadClearColor = 0x0; + GrLoadOp fStencilLoadOp = GrLoadOp::kLoad; // List of texture proxies whose contents are being prepared on a worker thread SkTArray fDeferredProxies; diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp index f4cda548af..0fb9a79ee7 100644 --- a/src/atlastext/SkAtlasTextTarget.cpp +++ b/src/atlastext/SkAtlasTextTarget.cpp @@ -83,11 +83,6 @@ public: void* handle) : GrTextUtils::Target(width, height, kColorSpaceInfo) , SkAtlasTextTarget(std::move(context), width, height, handle) { - fOpMemoryPool = fContext->internal().grContext()->contextPriv().refOpMemoryPool(); - } - - ~SkInternalAtlasTextTarget() override { - this->deleteOps(); } /** GrTextUtils::Target overrides */ @@ -115,13 +110,10 @@ public: void flush() override; private: - void deleteOps(); - uint32_t fColor; using SkAtlasTextTarget::fWidth; using SkAtlasTextTarget::fHeight; SkTArray, true> fOps; - sk_sp fOpMemoryPool; }; ////////////////////////////////////////////////////////////////////////////// @@ -170,7 +162,6 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptrcombineIfPossible(op.get(), caps)) { - fOpMemoryPool->release(std::move(op)); return; } if (GrRectsOverlap(op->bounds(), other->bounds())) { @@ -181,21 +172,12 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptrrelease(std::move(fOps[i])); - } - } - fOps.reset(); -} - void SkInternalAtlasTextTarget::flush() { for (int i = 0; i < fOps.count(); ++i) { fOps[i]->executeForTextTarget(this); } this->context()->internal().flush(); - this->deleteOps(); + fOps.reset(); } void GrAtlasTextOp::finalizeForTextTarget(uint32_t color, const GrCaps& caps) { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 897f3847db..1697c07938 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -12,7 +12,6 @@ #include "GrContextPriv.h" #include "GrDrawingManager.h" #include "GrGpu.h" -#include "GrMemoryPool.h" #include "GrProxyProvider.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetProxy.h" @@ -813,22 +812,6 @@ void GrContextPriv::flushSurfaceIO(GrSurfaceProxy* proxy) { //////////////////////////////////////////////////////////////////////////////// -sk_sp GrContextPriv::refOpMemoryPool() { - if (!fContext->fOpMemoryPool) { - // DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory - // consumed in DDL mode vs. normal mode for a single skp might be a good metric of wasted - // memory. - fContext->fOpMemoryPool = sk_sp(new GrOpMemoryPool(16384, 16384)); - } - - SkASSERT(fContext->fOpMemoryPool); - return fContext->fOpMemoryPool; -} - -GrOpMemoryPool* GrContextPriv::opMemoryPool() { - return this->refOpMemoryPool().get(); -} - sk_sp GrContextPriv::makeWrappedSurfaceContext(sk_sp proxy, sk_sp colorSpace, const SkSurfaceProps* props) { diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index 8d4b1ed28f..84de0560fa 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -13,7 +13,6 @@ #include "text/GrAtlasManager.h" class GrBackendRenderTarget; -class GrOpMemoryPool; class GrOnFlushCallbackObject; class GrSemaphore; class GrSurfaceProxy; @@ -33,9 +32,6 @@ public: const GrCaps* caps() const { return fContext->fCaps.get(); } - sk_sp refOpMemoryPool(); - GrOpMemoryPool* opMemoryPool(); - GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); } sk_sp makeWrappedSurfaceContext(sk_sp, diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 7c6338f3d2..99eb04b918 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -10,7 +10,6 @@ #include "GrContext.h" #include "GrContextPriv.h" #include "GrGpu.h" -#include "GrMemoryPool.h" #include "GrOnFlushResourceProvider.h" #include "GrOpList.h" #include "GrRenderTargetContext.h" @@ -237,15 +236,6 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, #endif fOpLists.reset(); -#ifdef SK_DEBUG - // In non-DDL mode this checks that all the flushed ops have been freed from the memory pool. - // When we move to partial flushes this assert will no longer be valid. - // In DDL mode this check is somewhat superfluous since the memory for most of the ops/opLists - // will be stored in the DDL's GrOpMemoryPools. - GrOpMemoryPool* opMemoryPool = fContext->contextPriv().opMemoryPool(); - opMemoryPool->isEmpty(); -#endif - GrSemaphoresSubmitted result = gpu->finishFlush(numSemaphores, backendSemaphores); flushState.uninstantiateProxyTracker()->uninstantiateAllProxies(); @@ -430,7 +420,6 @@ sk_sp GrDrawingManager::newRTOpList(GrRenderTargetProxy* r sk_sp opList(new GrRenderTargetOpList( resourceProvider, - fContext->contextPriv().refOpMemoryPool(), rtp, fContext->contextPriv().getAuditTrail())); SkASSERT(rtp->getLastOpList() == opList.get()); @@ -453,7 +442,6 @@ sk_sp GrDrawingManager::newTextureOpList(GrTextureProxy* textur } sk_sp opList(new GrTextureOpList(fContext->contextPriv().resourceProvider(), - fContext->contextPriv().refOpMemoryPool(), textureProxy, fContext->contextPriv().getAuditTrail())); diff --git a/src/gpu/GrMemoryPool.h b/src/gpu/GrMemoryPool.h index 15399b6852..67991d3fa0 100644 --- a/src/gpu/GrMemoryPool.h +++ b/src/gpu/GrMemoryPool.h @@ -146,8 +146,6 @@ public: void release(std::unique_ptr op); - bool isEmpty() const { return fMemoryPool.isEmpty(); } - private: GrMemoryPool fMemoryPool; }; diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp index b9f425576e..6fed34a38c 100644 --- a/src/gpu/GrOpList.cpp +++ b/src/gpu/GrOpList.cpp @@ -9,7 +9,6 @@ #include "GrContext.h" #include "GrDeferredProxyUploader.h" -#include "GrMemoryPool.h" #include "GrSurfaceProxy.h" #include "GrTextureProxyPriv.h" @@ -25,13 +24,11 @@ uint32_t GrOpList::CreateUniqueID() { return id; } -GrOpList::GrOpList(GrResourceProvider* resourceProvider, sk_sp opMemoryPool, +GrOpList::GrOpList(GrResourceProvider* resourceProvider, GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail) - : fOpMemoryPool(std::move(opMemoryPool)) - , fAuditTrail(auditTrail) - , fUniqueID(CreateUniqueID()) - , fFlags(0) { - SkASSERT(fOpMemoryPool); + : fAuditTrail(auditTrail) + , fUniqueID(CreateUniqueID()) + , fFlags(0) { fTarget.setProxy(sk_ref_sp(surfaceProxy), kWrite_GrIOType); fTarget.get()->setLastOpList(this); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 3e5fb49bc0..d8298108ab 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -1727,7 +1727,6 @@ static void op_bounds(SkRect* bounds, const GrOp* op) { uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr op) { ASSERT_SINGLE_OWNER if (this->drawingManager()->wasAbandoned()) { - fContext->contextPriv().opMemoryPool()->release(std::move(op)); return SK_InvalidUniqueID; } SkDEBUGCODE(this->validate();) @@ -1741,7 +1740,6 @@ uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptrcontextPriv().opMemoryPool()->release(std::move(op)); return SK_InvalidUniqueID; } @@ -1758,7 +1756,6 @@ uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptrfinalize(*this->caps(), &appliedClip, dstIsClamped)) { if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, op->bounds(), &dstProxy)) { - fContext->contextPriv().opMemoryPool()->release(std::move(op)); return SK_InvalidUniqueID; } } diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 423b71ca10..b04ec3629a 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -26,29 +26,14 @@ static const int kMaxOpLookback = 10; static const int kMaxOpLookahead = 10; GrRenderTargetOpList::GrRenderTargetOpList(GrResourceProvider* resourceProvider, - sk_sp opMemoryPool, GrRenderTargetProxy* proxy, GrAuditTrail* auditTrail) - : INHERITED(resourceProvider, std::move(opMemoryPool), proxy, auditTrail) + : INHERITED(resourceProvider, proxy, auditTrail) , fLastClipStackGenID(SK_InvalidUniqueID) SkDEBUGCODE(, fNumClips(0)) { } -void GrRenderTargetOpList::RecordedOp::deleteOp(GrOpMemoryPool* opMemoryPool) { - opMemoryPool->release(std::move(fOp)); -} - -void GrRenderTargetOpList::deleteOps() { - for (int i = 0; i < fRecordedOps.count(); ++i) { - if (fRecordedOps[i].fOp) { - fRecordedOps[i].deleteOp(fOpMemoryPool.get()); - } - } - fRecordedOps.reset(); -} - GrRenderTargetOpList::~GrRenderTargetOpList() { - this->deleteOps(); } //////////////////////////////////////////////////////////////////////////////// @@ -203,7 +188,7 @@ bool GrRenderTargetOpList::onExecute(GrOpFlushState* flushState) { void GrRenderTargetOpList::endFlush() { fLastClipStackGenID = SK_InvalidUniqueID; - this->deleteOps(); + fRecordedOps.reset(); fClipAllocator.reset(); INHERITED::endFlush(); } @@ -225,7 +210,7 @@ void GrRenderTargetOpList::fullClear(GrContext* context, GrColor color) { // Beware! If we ever add any ops that have a side effect beyond modifying the stencil // buffer we will need a more elaborate tracking system (skbug.com/7002). if (this->isEmpty() || !fTarget.get()->asRenderTargetProxy()->needsStencil()) { - this->deleteOps(); + fRecordedOps.reset(); fDeferredProxies.reset(); fColorLoadOp = GrLoadOp::kClear; fLoadClearColor = color; @@ -272,7 +257,7 @@ void GrRenderTargetOpList::purgeOpsWithUninstantiatedProxies() { recordedOp.visitProxies(checkInstantiation); if (hasUninstantiatedProxy) { // When instantiation of the proxy fails we drop the Op - recordedOp.deleteOp(fOpMemoryPool.get()); + recordedOp.fOp = nullptr; } } } @@ -375,7 +360,6 @@ uint32_t GrRenderTargetOpList::recordOp(std::unique_ptr op, GrOP_INFO("\t\t\tBackward: Combined op info:\n"); GrOP_INFO(SkTabString(candidate.fOp->dumpInfo(), 4).c_str()); GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, candidate.fOp.get(), op.get()); - fOpMemoryPool->release(std::move(op)); return SK_InvalidUniqueID; } // Stop going backwards if we would cause a painter's order violation. @@ -421,7 +405,6 @@ void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) { i, op->name(), op->uniqueID(), candidate.fOp->name(), candidate.fOp->uniqueID()); GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get()); - fOpMemoryPool->release(std::move(fRecordedOps[j].fOp)); fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp); break; } diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 8629a7cb1f..00b9f5eb27 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -32,8 +32,7 @@ private: using DstProxy = GrXferProcessor::DstProxy; public: - GrRenderTargetOpList(GrResourceProvider*, sk_sp, - GrRenderTargetProxy*, GrAuditTrail*); + GrRenderTargetOpList(GrResourceProvider*, GrRenderTargetProxy*, GrAuditTrail*); ~GrRenderTargetOpList() override; @@ -123,8 +122,6 @@ public: private: friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive - void deleteOps(); - struct RecordedOp { RecordedOp(std::unique_ptr op, GrAppliedClip* appliedClip, const DstProxy* dstProxy) : fOp(std::move(op)), fAppliedClip(appliedClip) { @@ -133,12 +130,7 @@ private: } } - ~RecordedOp() { - // The ops are stored in a GrMemoryPool so had better have been handled separately - SkASSERT(!fOp); - } - - void deleteOp(GrOpMemoryPool* opMemoryPool); + ~RecordedOp() { } void visitProxies(const GrOp::VisitProxyFunc& func) const { if (fOp) { diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index 6a601aa83c..a868b5d393 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -11,7 +11,6 @@ #include "GrContext.h" #include "GrContextPriv.h" #include "GrGpu.h" -#include "GrMemoryPool.h" #include "GrResourceAllocator.h" #include "GrTextureProxy.h" #include "SkStringUtils.h" @@ -20,28 +19,12 @@ //////////////////////////////////////////////////////////////////////////////// GrTextureOpList::GrTextureOpList(GrResourceProvider* resourceProvider, - sk_sp opMemoryPool, GrTextureProxy* proxy, GrAuditTrail* auditTrail) - : INHERITED(resourceProvider, std::move(opMemoryPool), proxy, auditTrail) { - SkASSERT(fOpMemoryPool); -} - -void GrTextureOpList::deleteOp(int index) { - SkASSERT(index >= 0 && index < fRecordedOps.count()); - fOpMemoryPool->release(std::move(fRecordedOps[index])); -} - -void GrTextureOpList::deleteOps() { - for (int i = 0; i < fRecordedOps.count(); ++i) { - fOpMemoryPool->release(std::move(fRecordedOps[i])); - } - fRecordedOps.reset(); - fOpMemoryPool = nullptr; + : INHERITED(resourceProvider, proxy, auditTrail) { } GrTextureOpList::~GrTextureOpList() { - this->deleteOps(); } //////////////////////////////////////////////////////////////////////////////// @@ -124,7 +107,7 @@ bool GrTextureOpList::onExecute(GrOpFlushState* flushState) { } void GrTextureOpList::endFlush() { - this->deleteOps(); + fRecordedOps.reset(); INHERITED::endFlush(); } @@ -169,7 +152,7 @@ void GrTextureOpList::purgeOpsWithUninstantiatedProxies() { } if (hasUninstantiatedProxy) { // When instantiation of the proxy fails we drop the Op - this->deleteOp(i); + fRecordedOps[i] = nullptr; } } } diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index 83ec22c602..d3e3e87ef3 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -23,7 +23,7 @@ struct SkIRect; class GrTextureOpList final : public GrOpList { public: - GrTextureOpList(GrResourceProvider*, sk_sp, GrTextureProxy*, GrAuditTrail*); + GrTextureOpList(GrResourceProvider*, GrTextureProxy*, GrAuditTrail*); ~GrTextureOpList() override; /** @@ -61,16 +61,12 @@ public: SkDEBUGCODE(int numOps() const override { return fRecordedOps.count(); }) private: - void deleteOp(int index); - void deleteOps(); - void purgeOpsWithUninstantiatedProxies() override; void gatherProxyIntervals(GrResourceAllocator*) const override; void recordOp(std::unique_ptr); - // The memory for the ops in 'fRecordedOps' is actually stored in 'fOpMemoryPool' SkSTArray<2, std::unique_ptr, true> fRecordedOps; typedef GrOpList INHERITED; diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp index 35494b7a6d..16a2c663a5 100644 --- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp +++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp @@ -23,22 +23,16 @@ static bool has_coord_transforms(const GrPaint& paint) { return false; } -std::unique_ptr GrCCDrawPathsOp::Make(GrContext* context, - const SkIRect& clipIBounds, - const SkMatrix& m, - const SkPath& path, - const SkRect& devBounds, - GrPaint&& paint) { +std::unique_ptr GrCCDrawPathsOp::Make(GrContext*, const SkIRect& clipIBounds, + const SkMatrix& m, const SkPath& path, + const SkRect& devBounds, GrPaint&& paint) { SkIRect looseClippedIBounds; devBounds.roundOut(&looseClippedIBounds); // GrCCPathParser might find slightly tighter bounds. if (!looseClippedIBounds.intersect(clipIBounds)) { return nullptr; } - - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(looseClippedIBounds, m, path, - devBounds, std::move(paint)); + return std::unique_ptr( + new GrCCDrawPathsOp(looseClippedIBounds, m, path, devBounds, std::move(paint))); } GrCCDrawPathsOp::GrCCDrawPathsOp(const SkIRect& looseClippedIBounds, const SkMatrix& m, diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp index ef09df84a9..5b3dec0622 100644 --- a/src/gpu/ccpr/GrCCPerFlushResources.cpp +++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp @@ -27,9 +27,8 @@ public: static std::unique_ptr Make(GrContext* context, sk_sp resources, CoverageCountBatchID batchID, const SkISize& drawBounds) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(resources), batchID, drawBounds); + return std::unique_ptr(new RenderAtlasOp(std::move(resources), batchID, + drawBounds)); } // GrDrawOp interface. diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index 1ea3ddfae6..eb39079423 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -8,7 +8,6 @@ #include "GrAtlasTextOp.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrMemoryPool.h" #include "GrOpFlushState.h" #include "GrResourceProvider.h" @@ -28,9 +27,7 @@ std::unique_ptr GrAtlasTextOp::MakeBitmap(GrContext* context, GrMaskFormat maskFormat, int glyphCount, bool needsTransform) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - std::unique_ptr op = pool->allocate(std::move(paint)); + std::unique_ptr op(new GrAtlasTextOp(std::move(paint))); switch (maskFormat) { case kA8_GrMaskFormat: @@ -60,9 +57,7 @@ std::unique_ptr GrAtlasTextOp::MakeDistanceField( const SkSurfaceProps& props, bool isAntiAliased, bool useLCD) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - std::unique_ptr op = pool->allocate(std::move(paint)); + std::unique_ptr op(new GrAtlasTextOp(std::move(paint))); bool isBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); bool isLCD = useLCD && SkPixelGeometryIsH(props.pixelGeometry()); diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp index 612ff2085d..70fc160c95 100644 --- a/src/gpu/ops/GrClearOp.cpp +++ b/src/gpu/ops/GrClearOp.cpp @@ -21,9 +21,7 @@ std::unique_ptr GrClearOp::Make(GrContext* context, return nullptr; } - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(clip, color, dstProxy); + return std::unique_ptr(new GrClearOp(clip, color, dstProxy)); } std::unique_ptr GrClearOp::Make(GrContext* context, @@ -32,9 +30,7 @@ std::unique_ptr GrClearOp::Make(GrContext* context, bool fullScreen) { SkASSERT(fullScreen || !rect.isEmpty()); - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(rect, color, fullScreen); + return std::unique_ptr(new GrClearOp(rect, color, fullScreen)); } GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* proxy) diff --git a/src/gpu/ops/GrClearStencilClipOp.cpp b/src/gpu/ops/GrClearStencilClipOp.cpp index 64985b707d..9a0e75a019 100644 --- a/src/gpu/ops/GrClearStencilClipOp.cpp +++ b/src/gpu/ops/GrClearStencilClipOp.cpp @@ -14,9 +14,7 @@ std::unique_ptr GrClearStencilClipOp::Make(GrContext* context, const GrFixedClip& clip, bool insideStencilMask, GrRenderTargetProxy* proxy) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(clip, insideStencilMask, proxy); + return std::unique_ptr(new GrClearStencilClipOp(clip, insideStencilMask, proxy)); } void GrClearStencilClipOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrCopySurfaceOp.cpp b/src/gpu/ops/GrCopySurfaceOp.cpp index a90579bdfe..da8e910025 100644 --- a/src/gpu/ops/GrCopySurfaceOp.cpp +++ b/src/gpu/ops/GrCopySurfaceOp.cpp @@ -78,9 +78,8 @@ std::unique_ptr GrCopySurfaceOp::Make(GrContext* context, return nullptr; } - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(dstProxy, srcProxy, clippedSrcRect, clippedDstPoint); + return std::unique_ptr(new GrCopySurfaceOp(dstProxy, srcProxy, + clippedSrcRect, clippedDstPoint)); } void GrCopySurfaceOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index cafb3e54c9..b784b0590e 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -271,10 +271,8 @@ public: SkPaint::Cap cap, AAMode aaMode, bool fullDash, const GrUserStencilSettings* stencilSettings) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(paint), geometry, cap, - aaMode, fullDash, stencilSettings); + return std::unique_ptr( + new DashOp(std::move(paint), geometry, cap, aaMode, fullDash, stencilSettings)); } const char* name() const override { return "DashOp"; } diff --git a/src/gpu/ops/GrDebugMarkerOp.cpp b/src/gpu/ops/GrDebugMarkerOp.cpp index 712e625d0b..ed54965e10 100644 --- a/src/gpu/ops/GrDebugMarkerOp.cpp +++ b/src/gpu/ops/GrDebugMarkerOp.cpp @@ -17,9 +17,7 @@ std::unique_ptr GrDebugMarkerOp::Make(GrContext* context, GrRenderTargetProxy* proxy, const SkString& str) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(proxy, str); + return std::unique_ptr(new GrDebugMarkerOp(proxy, str)); } void GrDebugMarkerOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp index a8081fcff8..a5a98f2e87 100644 --- a/src/gpu/ops/GrDrawPathOp.cpp +++ b/src/gpu/ops/GrDrawPathOp.cpp @@ -69,9 +69,8 @@ std::unique_ptr GrDrawPathOp::Make(GrContext* context, GrPaint&& paint, GrAAType aaType, GrPath* path) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(viewMatrix, std::move(paint), aaType, path); + return std::unique_ptr( + new GrDrawPathOp(viewMatrix, std::move(paint), aaType, path)); } void GrDrawPathOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrOp.cpp b/src/gpu/ops/GrOp.cpp index cab8ca1d18..f020cdef67 100644 --- a/src/gpu/ops/GrOp.cpp +++ b/src/gpu/ops/GrOp.cpp @@ -7,27 +7,57 @@ #include "GrOp.h" +#include "GrMemoryPool.h" +#include "SkSpinlock.h" +#include "SkTo.h" + +// TODO I noticed a small benefit to using a larger exclusive pool for ops. Its very small, but +// seems to be mostly consistent. There is a lot in flux right now, but we should really revisit +// this. + + +// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on +// different threads. The GrContext is not used concurrently on different threads and there is a +// memory barrier between accesses of a context on different threads. Also, there may be multiple +// GrContexts and those contexts may be in use concurrently on different threads. +namespace { +#if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) +static SkSpinlock gOpPoolSpinLock; +#endif +class MemoryPoolAccessor { +public: + +// We know in the Android framework there is only one GrContext. +#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) + MemoryPoolAccessor() {} + ~MemoryPoolAccessor() {} +#else + MemoryPoolAccessor() { gOpPoolSpinLock.acquire(); } + ~MemoryPoolAccessor() { gOpPoolSpinLock.release(); } +#endif + + GrMemoryPool* pool() const { + static GrMemoryPool gPool(16384, 16384); + return &gPool; + } +}; +} + int32_t GrOp::gCurrOpClassID = GrOp::kIllegalOpID; int32_t GrOp::gCurrOpUniqueID = GrOp::kIllegalOpID; -#ifdef SK_DEBUG void* GrOp::operator new(size_t size) { - // All GrOp-derived class should be allocated in a GrMemoryPool - SkASSERT(0); - return ::operator new(size); + return MemoryPoolAccessor().pool()->allocate(size); } void GrOp::operator delete(void* target) { - // All GrOp-derived class should be released from their owning GrMemoryPool - SkASSERT(0); - ::operator delete(target); + return MemoryPoolAccessor().pool()->release(target); } -#endif GrOp::GrOp(uint32_t classID) - : fClassID(classID) - , fUniqueID(kIllegalOpID) { + : fClassID(classID) + , fUniqueID(kIllegalOpID) { SkASSERT(classID == SkToU32(fClassID)); SkDEBUGCODE(fBoundsFlags = kUninitialized_BoundsFlag); } diff --git a/src/gpu/ops/GrOp.h b/src/gpu/ops/GrOp.h index 5c776fc05d..5d7922374c 100644 --- a/src/gpu/ops/GrOp.h +++ b/src/gpu/ops/GrOp.h @@ -104,8 +104,6 @@ public: return SkToBool(fBoundsFlags & kZeroArea_BoundsFlag); } -#ifdef SK_DEBUG - // All GrOp-derived classes should be allocated in and deleted from a GrMemoryPool void* operator new(size_t size); void operator delete(void* target); @@ -115,7 +113,6 @@ public: void operator delete(void* target, void* placement) { ::operator delete(target, placement); } -#endif /** * Helper for safely down-casting to a GrOp subclass diff --git a/src/gpu/ops/GrSemaphoreOp.cpp b/src/gpu/ops/GrSemaphoreOp.cpp index 9beb2a606b..fedf6b723a 100644 --- a/src/gpu/ops/GrSemaphoreOp.cpp +++ b/src/gpu/ops/GrSemaphoreOp.cpp @@ -21,9 +21,9 @@ public: sk_sp semaphore, GrRenderTargetProxy* proxy, bool forceFlush) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(semaphore), proxy, forceFlush); + return std::unique_ptr(new GrSignalSemaphoreOp(std::move(semaphore), + proxy, + forceFlush)); } const char* name() const override { return "SignalSemaphore"; } @@ -51,9 +51,8 @@ public: static std::unique_ptr Make(GrContext* context, sk_sp semaphore, GrRenderTargetProxy* proxy) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(semaphore), proxy); + return std::unique_ptr(new GrWaitSemaphoreOp(std::move(semaphore), + proxy)); } const char* name() const override { return "WaitSemaphore"; } diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index f61d11dd53..a2ec23000d 100644 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -678,14 +678,12 @@ std::unique_ptr Make(GrContext* context, SkScalar scaledRadius = SkScalarAbs(radius*matrixFactor); SkScalar scaledInsetWidth = SkScalarAbs(insetWidth*matrixFactor); - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(color, bounds, - scaledRadius, - rrect.isOval(), - blurWidth, - scaledInsetWidth, - blurClamp); + return std::unique_ptr(new ShadowCircularRRectOp(color, bounds, + scaledRadius, + rrect.isOval(), + blurWidth, + scaledInsetWidth, + blurClamp)); } } diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h index e5229a713a..b63728fe0f 100644 --- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h +++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h @@ -174,22 +174,19 @@ template std::unique_ptr GrSimpleMeshDrawOpHelper::FactoryHelper(GrContext* context, GrPaint&& paint, OpArgs... opArgs) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - MakeArgs makeArgs; makeArgs.fSRGBFlags = GrPipeline::SRGBFlagsFromPaint(paint); GrColor color = paint.getColor(); if (paint.isTrivial()) { makeArgs.fProcessorSet = nullptr; - return pool->allocate(makeArgs, color, std::forward(opArgs)...); + return std::unique_ptr(new Op(makeArgs, color, std::forward(opArgs)...)); } else { - char* mem = (char*) pool->allocate(sizeof(Op) + sizeof(GrProcessorSet)); + char* mem = (char*)GrOp::operator new(sizeof(Op) + sizeof(GrProcessorSet)); char* setMem = mem + sizeof(Op); makeArgs.fProcessorSet = new (setMem) GrProcessorSet(std::move(paint)); - - return std::unique_ptr(new (mem) Op(makeArgs, color, - std::forward(opArgs)...)); + return std::unique_ptr( + new (mem) Op(makeArgs, color, std::forward(opArgs)...)); } } diff --git a/src/gpu/ops/GrStencilPathOp.cpp b/src/gpu/ops/GrStencilPathOp.cpp index 25dbf311e5..5b712cffbc 100644 --- a/src/gpu/ops/GrStencilPathOp.cpp +++ b/src/gpu/ops/GrStencilPathOp.cpp @@ -21,10 +21,8 @@ std::unique_ptr GrStencilPathOp::Make(GrContext* context, bool hasStencilClip, const GrScissorState& scissor, const GrPath* path) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(viewMatrix, useHWAA, fillType, - hasStencilClip, scissor, path); + return std::unique_ptr(new GrStencilPathOp(viewMatrix, useHWAA, fillType, + hasStencilClip, scissor, path)); } void GrStencilPathOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index e06d94f806..80174bcb7d 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -621,11 +621,9 @@ public: SkCanvas::SrcRectConstraint constraint, const SkMatrix& viewMatrix, sk_sp csxf) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(proxy), filter, color, - srcRect, dstRect, aaType, constraint, - viewMatrix, std::move(csxf)); + return std::unique_ptr(new TextureOp(std::move(proxy), filter, color, srcRect, + dstRect, aaType, constraint, viewMatrix, + std::move(csxf))); } ~TextureOp() override { diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp index e065bf0249..0a5f991e69 100644 --- a/tests/DrawOpAtlasTest.cpp +++ b/tests/DrawOpAtlasTest.cpp @@ -13,7 +13,6 @@ #include "GrDeferredUpload.h" #include "GrDrawOpAtlas.h" #include "GrDrawingManager.h" -#include "GrMemoryPool.h" #include "GrOnFlushResourceProvider.h" #include "GrOpFlushState.h" #include "GrRenderTargetContext.h" @@ -182,7 +181,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo) auto resourceProvider = context->contextPriv().resourceProvider(); auto drawingManager = context->contextPriv().drawingManager(); auto textContext = drawingManager->getTextContext(); - auto opMemoryPool = context->contextPriv().opMemoryPool(); auto rtc = context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 32, 32, @@ -224,5 +222,4 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo) flushState.setOpArgs(&opArgs); op->prepare(&flushState); flushState.setOpArgs(nullptr); - opMemoryPool->release(std::move(op)); } diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 4d9773b1a9..4535f13975 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -258,9 +258,7 @@ public: static std::unique_ptr Make(GrContext* context, std::function testFn) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(testFn); + return std::unique_ptr(new GrMeshTestOp(testFn)); } private: diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index a197650c4f..0f786e7c23 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -109,9 +109,8 @@ public: static std::unique_ptr Make(GrContext* context, ScissorState scissorState, sk_sp vbuff) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(scissorState, std::move(vbuff)); + return std::unique_ptr(new GrPipelineDynamicStateTestOp(scissorState, + std::move(vbuff))); } private: diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp index 796e4870db..c0dcbf9647 100644 --- a/tests/LazyProxyTest.cpp +++ b/tests/LazyProxyTest.cpp @@ -59,9 +59,7 @@ public: GrProxyProvider* proxyProvider, LazyProxyTest* test, bool nullTexture) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(proxyProvider, test, nullTexture); + return std::unique_ptr(new Op(proxyProvider, test, nullTexture)); } void visitProxies(const VisitProxyFunc& func) const override { @@ -272,11 +270,8 @@ public: GrProxyProvider* proxyProvider, int* testExecuteValue, bool shouldFailInstantiation) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(proxyProvider, - testExecuteValue, - shouldFailInstantiation); + return std::unique_ptr(new LazyFailedInstantiationTestOp( + proxyProvider, testExecuteValue, shouldFailInstantiation)); } void visitProxies(const VisitProxyFunc& func) const override { @@ -372,9 +367,7 @@ public: DEFINE_OP_CLASS_ID static std::unique_ptr Make(GrContext* context, sk_sp proxy) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(proxy)); + return std::unique_ptr(new LazyUninstantiateTestOp(std::move(proxy))); } void visitProxies(const VisitProxyFunc& func) const override { diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 74a73a66a9..3a76e6c5e0 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -33,9 +33,7 @@ public: const char* name() const override { return "Dummy Op"; } static std::unique_ptr Make(GrContext* context, int numAttribs) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(numAttribs); + return std::unique_ptr(new Op(numAttribs)); } FixedFunctionFlags fixedFunctionFlags() const override { diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index e52070b7d2..3916436cfc 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -29,9 +29,7 @@ public: DEFINE_OP_CLASS_ID static std::unique_ptr Make(GrContext* context, std::unique_ptr fp) { - GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); - - return pool->allocate(std::move(fp)); + return std::unique_ptr(new TestOp(std::move(fp))); } const char* name() const override { return "TestOp"; } -- cgit v1.2.3