Revert "Reland "cache the creation of one GrAtlasTextOp""
This reverts commitdc3d678712
. Reason for revert: Crashing on exit thread handler Original change's description: > Reland "cache the creation of one GrAtlasTextOp" > > This is a reland of4b1fb7ca90
> > 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> > > Change-Id: I935a2965062b1fddb28806e85eb0fe055ba46ec2 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380320 > Commit-Queue: Herb Derby <herb@google.com> > Reviewed-by: Michael Ludwig <michaelludwig@google.com> TBR=bsalomon@google.com,herb@google.com,michaelludwig@google.com Change-Id: I3bc3329580460fcf8c0b49f655a88cb902da3d58 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382556 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
dc3d678712
commit
cc1cbcf9e0
@ -20,9 +20,6 @@ flutter_defines = [
|
||||
"SK_DISABLE_LEGACY_SHADERCONTEXT",
|
||||
"SK_DISABLE_LOWP_RASTER_PIPELINE",
|
||||
"SK_FORCE_RASTER_PIPELINE_BLITTER",
|
||||
|
||||
# Signal that we are building for Flutter.
|
||||
"SK_BUILD_FOR_FLUTTER",
|
||||
]
|
||||
|
||||
if (!is_fuchsia) {
|
||||
|
@ -31,50 +31,7 @@
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
#endif
|
||||
|
||||
// This class was determined through experimentation. You would expect to use operator new/delete
|
||||
// in this code, but this crashed thread_local implementations of Android. Using malloc/free
|
||||
// seems to work on Android.
|
||||
namespace {
|
||||
struct CachedVoidPointer {
|
||||
~CachedVoidPointer() { free(fPtr); }
|
||||
void* doNew(size_t size) {
|
||||
if (fPtr != nullptr) {
|
||||
void* result = fPtr;
|
||||
fPtr = nullptr;
|
||||
return result;
|
||||
}
|
||||
|
||||
void* result = malloc(size);
|
||||
if (result == nullptr) {
|
||||
SK_ABORT("Out of memory.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void doDelete(void* ptr) {
|
||||
if (fPtr == nullptr) {
|
||||
fPtr = ptr;
|
||||
return;
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void* fPtr = nullptr;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
// If we have thread local, then cache memory for a single GrAtlasTextOp.
|
||||
#if !defined(GR_OP_ALLOCATE_USE_POOL) && defined(GR_HAS_THREAD_LOCAL)
|
||||
static thread_local CachedVoidPointer gGrAtlasTextOpCache;
|
||||
void* GrAtlasTextOp::operator new(size_t s) {
|
||||
return gGrAtlasTextOpCache.doNew(s);
|
||||
}
|
||||
|
||||
void GrAtlasTextOp::operator delete(void* b) noexcept {
|
||||
return gGrAtlasTextOpCache.doDelete(b);
|
||||
}
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
|
||||
bool needsTransform,
|
||||
|
@ -13,12 +13,6 @@
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/text/GrTextBlob.h"
|
||||
|
||||
#if !defined(SK_BUILD_FOR_FLUTTER) && \
|
||||
(!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 {
|
||||
@ -31,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) noexcept;
|
||||
#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