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

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

Issue 1734383002: Modernize SkSpinlock. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: std::atomic<bool> Created 4 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 | « src/gpu/GrProcessor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBatch.h" 8 #include "GrBatch.h"
9 9
10 #include "GrMemoryPool.h" 10 #include "GrMemoryPool.h"
11 #include "SkSpinlock.h" 11 #include "SkSpinlock.h"
12 12
13 // 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,
14 // 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
15 // revisit this when batch is everywhere 15 // revisit this when batch is everywhere
16 16
17 17
18 // We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on 18 // We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
19 // different threads. The GrContext is not used concurrently on different thread s and there is a 19 // different threads. The GrContext is not used concurrently on different thread s and there is a
20 // memory barrier between accesses of a context on different threads. Also, ther e may be multiple 20 // memory barrier between accesses of a context on different threads. Also, ther e may be multiple
21 // 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 .
22 namespace { 22 namespace {
23 SK_DECLARE_STATIC_SPINLOCK(gBatchSpinlock); 23 static SkSpinlock gBatchSpinlock;
24 class MemoryPoolAccessor { 24 class MemoryPoolAccessor {
25 public: 25 public:
26 MemoryPoolAccessor() { gBatchSpinlock.acquire(); } 26 MemoryPoolAccessor() { gBatchSpinlock.acquire(); }
27 27
28 ~MemoryPoolAccessor() { gBatchSpinlock.release(); } 28 ~MemoryPoolAccessor() { gBatchSpinlock.release(); }
29 29
30 GrMemoryPool* pool() const { 30 GrMemoryPool* pool() const {
31 static GrMemoryPool gPool(16384, 16384); 31 static GrMemoryPool gPool(16384, 16384);
32 return &gPool; 32 return &gPool;
33 } 33 }
(...skipping 15 matching lines...) Expand all
49 GrBatch::GrBatch(uint32_t classID) 49 GrBatch::GrBatch(uint32_t classID)
50 : fClassID(classID) 50 : fClassID(classID)
51 #if GR_BATCH_SPEW 51 #if GR_BATCH_SPEW
52 , fUniqueID(GenBatchID()) 52 , fUniqueID(GenBatchID())
53 #endif 53 #endif
54 { 54 {
55 SkDEBUGCODE(fUsed = false;) 55 SkDEBUGCODE(fUsed = false;)
56 } 56 }
57 57
58 GrBatch::~GrBatch() {} 58 GrBatch::~GrBatch() {}
OLDNEW
« no previous file with comments | « src/gpu/GrProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698