Revert "cache the creation of one GrAtlasTextOp"
This reverts commit 4b1fb7ca90
.
Reason for revert: breaking chrome roll (android-pie)?
Original change's description:
> cache the creation of one GrAtlasTextOp
>
> GrAtlasTextOp has a high probability of being merged with the
> previous op. This cache keeps using the same op to merge with
> keeping memory warm.
>
> This show about 5.75% improvement in skpbench on desk_nytimes.
>
> When compiling for ios 9 or earlier, this optimization is
> disabled.
>
> Change-Id: I13ccbef6dcd4b9d82103bf20bba7d94f3e4fb6f4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376718
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
TBR=bsalomon@google.com,herb@google.com,michaelludwig@google.com
Change-Id: I2def6e1043dcca2fd41c40facd20b4d18971ed17
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379840
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
9edff53a73
commit
48bfa48809
@ -31,24 +31,7 @@
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
#endif
|
||||
|
||||
#if !defined(GR_OP_ALLOCATE_USE_POOL) && defined(GR_HAS_THREAD_LOCAL)
|
||||
static thread_local std::unique_ptr<char> gGrAtlasTextOpCache = nullptr;
|
||||
void* GrAtlasTextOp::operator new(size_t s) {
|
||||
if (gGrAtlasTextOpCache != nullptr) {
|
||||
return gGrAtlasTextOpCache.release();
|
||||
} else {
|
||||
return ::operator new(s);
|
||||
}
|
||||
}
|
||||
|
||||
void GrAtlasTextOp::operator delete(void* b) noexcept {
|
||||
if (gGrAtlasTextOpCache == nullptr) {
|
||||
gGrAtlasTextOpCache.reset(static_cast<char*>(b));
|
||||
} else {
|
||||
::operator delete(b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
|
||||
bool needsTransform,
|
||||
|
@ -13,11 +13,6 @@
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/text/GrTextBlob.h"
|
||||
|
||||
#if !defined(SK_BUILD_FOR_IOS) || \
|
||||
(defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_9_0)
|
||||
#define GR_HAS_THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
class GrRecordingContext;
|
||||
|
||||
class GrAtlasTextOp final : public GrMeshDrawOp {
|
||||
@ -30,11 +25,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(GR_OP_ALLOCATE_USE_POOL) && defined(GR_HAS_THREAD_LOCAL)
|
||||
void* operator new(size_t s);
|
||||
void operator delete(void* b);
|
||||
#endif
|
||||
|
||||
static const int kVerticesPerGlyph = GrAtlasSubRun::kVerticesPerGlyph;
|
||||
static const int kIndicesPerGlyph = 6;
|
||||
|
||||
|
@ -82,14 +82,7 @@ public:
|
||||
|
||||
template<typename Op, typename... Args>
|
||||
static Owner Make(GrRecordingContext* context, Args&&... args) {
|
||||
#if defined(GR_OP_ALLOCATE_USE_POOL)
|
||||
GrMemoryPool* pool = context->priv().opMemoryPool();
|
||||
void* mem = pool->allocate(sizeof(Op));
|
||||
GrOp* op = new (mem) Op(std::forward<Args>(args)...);
|
||||
return Owner{op, pool};
|
||||
#else
|
||||
return Owner{new Op(std::forward<Args>(args)...)};
|
||||
#endif
|
||||
return MakeWithExtraMemory<Op>(context, 0, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename Op, typename... Args>
|
||||
@ -169,17 +162,25 @@ public:
|
||||
return SkToBool(fBoundsFlags & kZeroArea_BoundsFlag);
|
||||
}
|
||||
|
||||
#if defined(GR_OP_ALLOCATE_USE_POOL) && defined(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);
|
||||
#if defined(GR_OP_ALLOCATE_USE_POOL)
|
||||
#if defined(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);
|
||||
|
||||
void* operator new(size_t size, void* placement) {
|
||||
return ::operator new(size, placement);
|
||||
}
|
||||
void operator delete(void* target, void* placement) {
|
||||
::operator delete(target, placement);
|
||||
}
|
||||
void* operator new(size_t size, void* placement) {
|
||||
return ::operator new(size, placement);
|
||||
}
|
||||
void operator delete(void* target, void* placement) {
|
||||
::operator delete(target, placement);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// GrOps are allocated using ::operator new in the GrMemoryPool. Doing this style of memory
|
||||
// allocation defeats the delete with size optimization.
|
||||
void* operator new(size_t) { SK_ABORT("All GrOps are created by placement new."); }
|
||||
void* operator new(size_t, void* p) { return p; }
|
||||
void operator delete(void* p) { ::operator delete(p); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user