Add flag to switch op allocation to new
Added a flag to switch from using the memory pool to
using new and delete for GrOp allocation.
Just add the following to your gn args.
extra_cflags = [
"-DGR_OP_ALLOCATE_USE_NEW",
]
Change-Id: Icea4a6df047cff2cd5e50032f0bd4b714a5740d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322625
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index bc6c399..6120ea1 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -249,13 +249,17 @@
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
// Allocate size based on proxyRunCnt, since that determines number of ViewCountPairs.
SkASSERT(proxyRunCnt <= cnt);
-
size_t size = sizeof(TextureOp) + sizeof(ViewCountPair) * (proxyRunCnt - 1);
- GrOpMemoryPool* pool = context->priv().opMemoryPool();
- void* mem = pool->allocate(size);
+ #if defined(GR_OP_ALLOCATE_USE_NEW)
+ void* mem = ::operator new(size);
+ #else
+ GrOpMemoryPool* pool = context->priv().opMemoryPool();
+ void* mem = pool->allocate(size);
+ #endif
return std::unique_ptr<GrDrawOp>(
- new (mem) TextureOp(set, cnt, proxyRunCnt, filter, mm, saturate, aaType, constraint,
- viewMatrix, std::move(textureColorSpaceXform)));
+ new (mem) TextureOp(
+ set, cnt, proxyRunCnt, filter, mm, saturate, aaType, constraint,
+ viewMatrix, std::move(textureColorSpaceXform)));
}
~TextureOp() override {