Index: src/gpu/GrBatch.cpp |
diff --git a/src/gpu/GrBatch.cpp b/src/gpu/GrBatch.cpp |
index e1650a6bd31af3d6a5bd188c28b0ee7979889785..05eb2d6c6e782123e7ea5a39ac7ff69c37c9cf7c 100644 |
--- a/src/gpu/GrBatch.cpp |
+++ b/src/gpu/GrBatch.cpp |
@@ -1,35 +1,39 @@ |
#include "GrBatch.h" |
#include "GrMemoryPool.h" |
-#include "SkTLS.h" |
+#include "SkMutex.h" |
// TODO I noticed a small benefit to using a larger exclusive pool for batches. Its very small, |
// but seems to be mostly consistent. There is a lot in flux right now, but we should really |
// revisit this when batch is everywhere |
-class GrBatch_Globals { |
+ |
+namespace { |
robertphillips
2015/03/09 17:54:23
Maybe a comment somewhere explaining why we're doi
bsalomon
2015/03/09 17:55:12
Will add
|
+SK_DECLARE_STATIC_MUTEX(gBatchPoolMutex); |
+class MemoryPoolAccessor { |
public: |
- static GrMemoryPool* GetTLS() { |
- return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS); |
+ MemoryPoolAccessor() { |
+ gBatchPoolMutex.acquire(); |
robertphillips
2015/03/09 17:54:23
Why the change from 16384 to 4096?
bsalomon
2015/03/09 17:55:12
copy/paste error from other file. Will fix!
|
+ static SkAutoTDelete<GrMemoryPool> gPool(SkNEW_ARGS(GrMemoryPool, (4096, 4096))); |
+ fPool = gPool; |
} |
+ ~MemoryPoolAccessor() { gBatchPoolMutex.release(); } |
+ |
+ GrMemoryPool* pool() const { return fPool; } |
+ |
private: |
- static void* CreateTLS() { |
- return SkNEW_ARGS(GrMemoryPool, (16384, 16384)); |
- } |
+ GrMemoryPool* fPool; |
- static void DeleteTLS(void* pool) { |
- SkDELETE(reinterpret_cast<GrMemoryPool*>(pool)); |
- } |
}; |
+} |
-int32_t GrBatch::gCurrBatchClassID = |
- GrBatch::kIllegalBatchClassID; |
+int32_t GrBatch::gCurrBatchClassID = GrBatch::kIllegalBatchClassID; |
void* GrBatch::operator new(size_t size) { |
- return GrBatch_Globals::GetTLS()->allocate(size); |
+ return MemoryPoolAccessor().pool()->allocate(size); |
} |
void GrBatch::operator delete(void* target) { |
- GrBatch_Globals::GetTLS()->release(target); |
+ return MemoryPoolAccessor().pool()->release(target); |
} |