Using the spinlock is only necessary when we multiple threads
might use a GrContext. Android uses the GrContext from a
single thread, so these locks are not needed.
This is a temporary fix until we can refactor to avoid
creating GrContexts in a global memory pool.
BUG=skia:5696
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=
2293633003
Review-Url: https://codereview.chromium.org/
2293633003
static SkSpinlock gProcessorSpinlock;
class MemoryPoolAccessor {
public:
- MemoryPoolAccessor() { gProcessorSpinlock.acquire(); }
+// We know in the Android framework there is only one GrContext.
+#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
+ MemoryPoolAccessor() {}
+ ~MemoryPoolAccessor() {}
+#else
+ MemoryPoolAccessor() { gProcessorSpinlock.acquire(); }
~MemoryPoolAccessor() { gProcessorSpinlock.release(); }
+#endif
GrMemoryPool* pool() const {
static GrMemoryPool gPool(4096, 4096);
static SkSpinlock gBatchSpinlock;
class MemoryPoolAccessor {
public:
- MemoryPoolAccessor() { gBatchSpinlock.acquire(); }
+// We know in the Android framework there is only one GrContext.
+#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
+ MemoryPoolAccessor() {}
+ ~MemoryPoolAccessor() {}
+#else
+ MemoryPoolAccessor() { gBatchSpinlock.acquire(); }
~MemoryPoolAccessor() { gBatchSpinlock.release(); }
+#endif
GrMemoryPool* pool() const {
static GrMemoryPool gPool(16384, 16384);