From: joshualitt Date: Mon, 30 Mar 2015 16:53:47 +0000 (-0700) Subject: Small change to move GrProcessor and GrBatch pools over to SkSpinlock X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~2979 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23ac62c83a49d675a38f1c20462b5537f3c8af01;p=platform%2Fupstream%2FlibSkiaSharp.git Small change to move GrProcessor and GrBatch pools over to SkSpinlock BUG=skia: Review URL: https://codereview.chromium.org/1040133002 --- diff --git a/src/gpu/GrBatch.cpp b/src/gpu/GrBatch.cpp index 4df765e..ce30499 100644 --- a/src/gpu/GrBatch.cpp +++ b/src/gpu/GrBatch.cpp @@ -1,24 +1,31 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + #include "GrBatch.h" #include "GrMemoryPool.h" -#include "SkMutex.h" +#include "SkSpinlock.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 -// We use a global pool protected by a mutex. Chrome may use the same GrContext on different -// threads. The GrContext is not used concurrently on different threads and there is a memory -// barrier between accesses of a context on different threads. Also, there may be multiple +// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on +// different threads. The GrContext is not used concurrently on different threads and there is a +// memory barrier between accesses of a context on different threads. Also, there may be multiple // GrContexts and those contexts may be in use concurrently on different threads. namespace { -SK_DECLARE_STATIC_MUTEX(gBatchPoolMutex); +SK_DECLARE_STATIC_SPINLOCK(gBatchSpinlock); class MemoryPoolAccessor { public: - MemoryPoolAccessor() { gBatchPoolMutex.acquire(); } + MemoryPoolAccessor() { gBatchSpinlock.acquire(); } - ~MemoryPoolAccessor() { gBatchPoolMutex.release(); } + ~MemoryPoolAccessor() { gBatchSpinlock.release(); } GrMemoryPool* pool() const { static GrMemoryPool gPool(16384, 16384); diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 3b8cb67..4bda2e1 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -12,7 +12,7 @@ #include "GrInvariantOutput.h" #include "GrMemoryPool.h" #include "GrXferProcessor.h" -#include "SkMutex.h" +#include "SkSpinlock.h" #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS @@ -97,17 +97,17 @@ const SkMatrix& TestMatrix(SkRandom* random) { } -// We use a global pool protected by a mutex. Chrome may use the same GrContext on different -// threads. The GrContext is not used concurrently on different threads and there is a memory -// barrier between accesses of a context on different threads. Also, there may be multiple +// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on +// different threads. The GrContext is not used concurrently on different threads and there is a +// memory barrier between accesses of a context on different threads. Also, there may be multiple // GrContexts and those contexts may be in use concurrently on different threads. namespace { -SK_DECLARE_STATIC_MUTEX(gProcessorPoolMutex); +SK_DECLARE_STATIC_SPINLOCK(gProcessorSpinlock); class MemoryPoolAccessor { public: - MemoryPoolAccessor() { gProcessorPoolMutex.acquire(); } + MemoryPoolAccessor() { gProcessorSpinlock.acquire(); } - ~MemoryPoolAccessor() { gProcessorPoolMutex.release(); } + ~MemoryPoolAccessor() { gProcessorSpinlock.release(); } GrMemoryPool* pool() const { static GrMemoryPool gPool(4096, 4096);