Move op memory storage to GrContext (take 2)
TBR=bsalomon@google.com
Change-Id: I4a448694d4114d83cd3a720cfc8bd37de51733d1
Reviewed-on: https://skia-review.googlesource.com/135707
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp
index 0a5f991..e065bf0 100644
--- a/tests/DrawOpAtlasTest.cpp
+++ b/tests/DrawOpAtlasTest.cpp
@@ -13,6 +13,7 @@
#include "GrDeferredUpload.h"
#include "GrDrawOpAtlas.h"
#include "GrDrawingManager.h"
+#include "GrMemoryPool.h"
#include "GrOnFlushResourceProvider.h"
#include "GrOpFlushState.h"
#include "GrRenderTargetContext.h"
@@ -181,6 +182,7 @@
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,
@@ -222,4 +224,5 @@
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 4535f13..4d9773b 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -258,7 +258,9 @@
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
std::function<void(DrawMeshHelper*)> testFn) {
- return std::unique_ptr<GrDrawOp>(new GrMeshTestOp(testFn));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<GrMeshTestOp>(testFn);
}
private:
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 0f786e7..a197650 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -109,8 +109,9 @@
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
ScissorState scissorState,
sk_sp<const GrBuffer> vbuff) {
- return std::unique_ptr<GrDrawOp>(new GrPipelineDynamicStateTestOp(scissorState,
- std::move(vbuff)));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<GrPipelineDynamicStateTestOp>(scissorState, std::move(vbuff));
}
private:
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 9349457..aaf1ab9 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -59,7 +59,9 @@
GrProxyProvider* proxyProvider,
LazyProxyTest* test,
bool nullTexture) {
- return std::unique_ptr<GrDrawOp>(new Op(proxyProvider, test, nullTexture));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<Op>(proxyProvider, test, nullTexture);
}
void visitProxies(const VisitProxyFunc& func) const override {
@@ -274,8 +276,11 @@
GrProxyProvider* proxyProvider,
int* testExecuteValue,
bool shouldFailInstantiation) {
- return std::unique_ptr<GrDrawOp>(new LazyFailedInstantiationTestOp(
- proxyProvider, testExecuteValue, shouldFailInstantiation));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<LazyFailedInstantiationTestOp>(proxyProvider,
+ testExecuteValue,
+ shouldFailInstantiation);
}
void visitProxies(const VisitProxyFunc& func) const override {
@@ -371,7 +376,9 @@
DEFINE_OP_CLASS_ID
static std::unique_ptr<GrDrawOp> Make(GrContext* context, sk_sp<GrTextureProxy> proxy) {
- return std::unique_ptr<GrDrawOp>(new LazyUninstantiateTestOp(std::move(proxy)));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<LazyUninstantiateTestOp>(std::move(proxy));
}
void visitProxies(const VisitProxyFunc& func) const override {
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 3a76e6c..74a73a6 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -33,7 +33,9 @@
const char* name() const override { return "Dummy Op"; }
static std::unique_ptr<GrDrawOp> Make(GrContext* context, int numAttribs) {
- return std::unique_ptr<GrDrawOp>(new Op(numAttribs));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<Op>(numAttribs);
}
FixedFunctionFlags fixedFunctionFlags() const override {
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 3916436..e52070b 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -29,7 +29,9 @@
DEFINE_OP_CLASS_ID
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
std::unique_ptr<GrFragmentProcessor> fp) {
- return std::unique_ptr<GrDrawOp>(new TestOp(std::move(fp)));
+ GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
+
+ return pool->allocate<TestOp>(std::move(fp));
}
const char* name() const override { return "TestOp"; }