Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: src/gpu/GrBatch.cpp

Issue 990953003: Use global GrMemoryPools protected by mutex for GrProcessor/GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@m42
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "GrBatch.h" 1 #include "GrBatch.h"
2 2
3 #include "GrMemoryPool.h" 3 #include "GrMemoryPool.h"
4 #include "SkTLS.h" 4 #include "SkMutex.h"
5 5
6 // TODO I noticed a small benefit to using a larger exclusive pool for batches. Its very small, 6 // TODO I noticed a small benefit to using a larger exclusive pool for batches. Its very small,
7 // but seems to be mostly consistent. There is a lot in flux right now, but we should really 7 // but seems to be mostly consistent. There is a lot in flux right now, but we should really
8 // revisit this when batch is everywhere 8 // revisit this when batch is everywhere
9 9
10 class GrBatch_Globals { 10
11 // We use a global pool protected by a mutex. Chrome may use the same GrContext on different
12 // threads. The GrContext is not used concurrently on different threads and ther e is a memory
13 // barrier between accesses of a context on different threads. Also, there may b e multiple
14 // GrContexts and those contexts may be in use concurrently on different threads .
15 namespace {
16 SK_DECLARE_STATIC_MUTEX(gBatchPoolMutex);
17 class MemoryPoolAccessor {
11 public: 18 public:
12 static GrMemoryPool* GetTLS() { 19 MemoryPoolAccessor() { gBatchPoolMutex.acquire(); }
13 return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
14 }
15 20
16 private: 21 ~MemoryPoolAccessor() { gBatchPoolMutex.release(); }
17 static void* CreateTLS() {
18 return SkNEW_ARGS(GrMemoryPool, (16384, 16384));
19 }
20 22
21 static void DeleteTLS(void* pool) { 23 GrMemoryPool* pool() const {
22 SkDELETE(reinterpret_cast<GrMemoryPool*>(pool)); 24 static GrMemoryPool gPool(16384, 16384);
25 return &gPool;
23 } 26 }
24 }; 27 };
28 }
25 29
26 int32_t GrBatch::gCurrBatchClassID = 30 int32_t GrBatch::gCurrBatchClassID = GrBatch::kIllegalBatchClassID;
27 GrBatch::kIllegalBatchClassID;
28 31
29 void* GrBatch::operator new(size_t size) { 32 void* GrBatch::operator new(size_t size) {
30 return GrBatch_Globals::GetTLS()->allocate(size); 33 return MemoryPoolAccessor().pool()->allocate(size);
31 } 34 }
32 35
33 void GrBatch::operator delete(void* target) { 36 void GrBatch::operator delete(void* target) {
34 GrBatch_Globals::GetTLS()->release(target); 37 return MemoryPoolAccessor().pool()->release(target);
35 } 38 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698