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

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

Issue 1040133002: Small change to move GrProcessor and GrBatch pools over to SkSpinlock (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 8 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 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include "GrBatch.h" 8 #include "GrBatch.h"
2 9
3 #include "GrMemoryPool.h" 10 #include "GrMemoryPool.h"
4 #include "SkMutex.h" 11 #include "SkSpinlock.h"
5 12
6 // TODO I noticed a small benefit to using a larger exclusive pool for batches. Its very small, 13 // 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 14 // 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 15 // revisit this when batch is everywhere
9 16
10 17
11 // We use a global pool protected by a mutex. Chrome may use the same GrContext on different 18 // We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
12 // threads. The GrContext is not used concurrently on different threads and ther e is a memory 19 // different threads. The GrContext is not used concurrently on different thread s and there is a
13 // barrier between accesses of a context on different threads. Also, there may b e multiple 20 // memory barrier between accesses of a context on different threads. Also, ther e may be multiple
14 // GrContexts and those contexts may be in use concurrently on different threads . 21 // GrContexts and those contexts may be in use concurrently on different threads .
15 namespace { 22 namespace {
16 SK_DECLARE_STATIC_MUTEX(gBatchPoolMutex); 23 SK_DECLARE_STATIC_SPINLOCK(gBatchSpinlock);
17 class MemoryPoolAccessor { 24 class MemoryPoolAccessor {
18 public: 25 public:
19 MemoryPoolAccessor() { gBatchPoolMutex.acquire(); } 26 MemoryPoolAccessor() { gBatchSpinlock.acquire(); }
20 27
21 ~MemoryPoolAccessor() { gBatchPoolMutex.release(); } 28 ~MemoryPoolAccessor() { gBatchSpinlock.release(); }
22 29
23 GrMemoryPool* pool() const { 30 GrMemoryPool* pool() const {
24 static GrMemoryPool gPool(16384, 16384); 31 static GrMemoryPool gPool(16384, 16384);
25 return &gPool; 32 return &gPool;
26 } 33 }
27 }; 34 };
28 } 35 }
29 36
30 int32_t GrBatch::gCurrBatchClassID = GrBatch::kIllegalBatchClassID; 37 int32_t GrBatch::gCurrBatchClassID = GrBatch::kIllegalBatchClassID;
31 38
32 void* GrBatch::operator new(size_t size) { 39 void* GrBatch::operator new(size_t size) {
33 return MemoryPoolAccessor().pool()->allocate(size); 40 return MemoryPoolAccessor().pool()->allocate(size);
34 } 41 }
35 42
36 void GrBatch::operator delete(void* target) { 43 void GrBatch::operator delete(void* target) {
37 return MemoryPoolAccessor().pool()->release(target); 44 return MemoryPoolAccessor().pool()->release(target);
38 } 45 }
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