| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrProcessor.h" | 8 #include "GrProcessor.h" |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
| 11 #include "GrGeometryProcessor.h" | 11 #include "GrGeometryProcessor.h" |
| 12 #include "GrInvariantOutput.h" | 12 #include "GrInvariantOutput.h" |
| 13 #include "GrMemoryPool.h" | 13 #include "GrMemoryPool.h" |
| 14 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
| 15 #include "SkMutex.h" | 15 #include "SkSpinlock.h" |
| 16 | 16 |
| 17 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 17 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 18 | 18 |
| 19 class GrFragmentProcessor; | 19 class GrFragmentProcessor; |
| 20 class GrGeometryProcessor; | 20 class GrGeometryProcessor; |
| 21 | 21 |
| 22 /* | 22 /* |
| 23 * Originally these were both in the processor unit test header, but then it see
med to cause linker | 23 * Originally these were both in the processor unit test header, but then it see
med to cause linker |
| 24 * problems on android. | 24 * problems on android. |
| 25 */ | 25 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 gMatrices[4].setRotate(SkIntToScalar(215)); | 90 gMatrices[4].setRotate(SkIntToScalar(215)); |
| 91 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); | 91 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); |
| 92 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); | 92 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); |
| 93 gOnce = true; | 93 gOnce = true; |
| 94 } | 94 } |
| 95 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(
gMatrices)))]; | 95 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(
gMatrices)))]; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 // We use a global pool protected by a mutex. Chrome may use the same GrContext
on different | 100 // We use a global pool protected by a mutex(spinlock). Chrome may use the same
GrContext on |
| 101 // threads. The GrContext is not used concurrently on different threads and ther
e is a memory | 101 // different threads. The GrContext is not used concurrently on different thread
s and there is a |
| 102 // barrier between accesses of a context on different threads. Also, there may b
e multiple | 102 // memory barrier between accesses of a context on different threads. Also, ther
e may be multiple |
| 103 // GrContexts and those contexts may be in use concurrently on different threads
. | 103 // GrContexts and those contexts may be in use concurrently on different threads
. |
| 104 namespace { | 104 namespace { |
| 105 SK_DECLARE_STATIC_MUTEX(gProcessorPoolMutex); | 105 SK_DECLARE_STATIC_SPINLOCK(gProcessorSpinlock); |
| 106 class MemoryPoolAccessor { | 106 class MemoryPoolAccessor { |
| 107 public: | 107 public: |
| 108 MemoryPoolAccessor() { gProcessorPoolMutex.acquire(); } | 108 MemoryPoolAccessor() { gProcessorSpinlock.acquire(); } |
| 109 | 109 |
| 110 ~MemoryPoolAccessor() { gProcessorPoolMutex.release(); } | 110 ~MemoryPoolAccessor() { gProcessorSpinlock.release(); } |
| 111 | 111 |
| 112 GrMemoryPool* pool() const { | 112 GrMemoryPool* pool() const { |
| 113 static GrMemoryPool gPool(4096, 4096); | 113 static GrMemoryPool gPool(4096, 4096); |
| 114 return &gPool; | 114 return &gPool; |
| 115 } | 115 } |
| 116 }; | 116 }; |
| 117 } | 117 } |
| 118 | 118 |
| 119 int32_t GrProcessor::gCurrProcessorClassID = GrProcessor::kIllegalProcessorClass
ID; | 119 int32_t GrProcessor::gCurrProcessorClassID = GrProcessor::kIllegalProcessorClass
ID; |
| 120 | 120 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const
{ | 171 void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 172 this->onComputeInvariantOutput(inout); | 172 this->onComputeInvariantOutput(inout); |
| 173 } | 173 } |
| 174 | 174 |
| 175 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 175 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 176 | 176 |
| 177 // Initial static variable from GrXPFactory | 177 // Initial static variable from GrXPFactory |
| 178 int32_t GrXPFactory::gCurrXPFClassID = | 178 int32_t GrXPFactory::gCurrXPFClassID = |
| 179 GrXPFactory::kIllegalXPFClassID; | 179 GrXPFactory::kIllegalXPFClassID; |
| OLD | NEW |