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 "GrBackendProcessorFactory.h" | 9 #include "GrBackendProcessorFactory.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
11 #include "GrCoordTransform.h" | 11 #include "GrCoordTransform.h" |
12 #include "GrMemoryPool.h" | 12 #include "GrMemoryPool.h" |
13 #include "SkTLS.h" | 13 #include "SkTLS.h" |
14 | 14 |
| 15 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 16 |
| 17 /* |
| 18 * Originally these were both in the processor unit test header, but then it see
med to cause linker |
| 19 * problems on android. |
| 20 */ |
| 21 template<> |
| 22 SkTArray<GrProcessorTestFactory<GrFragmentProcessor>*, true>* GrProcessorTestFac
tory<GrFragmentProcessor>::GetFactories() { |
| 23 static SkTArray<GrProcessorTestFactory<GrFragmentProcessor>*, true> gFactori
es; |
| 24 return &gFactories; |
| 25 } |
| 26 |
| 27 template<> |
| 28 SkTArray<GrProcessorTestFactory<GrGeometryProcessor>*, true>* GrProcessorTestFac
tory<GrGeometryProcessor>::GetFactories() { |
| 29 static SkTArray<GrProcessorTestFactory<GrGeometryProcessor>*, true> gFactori
es; |
| 30 return &gFactories; |
| 31 } |
| 32 |
| 33 /* |
| 34 * To ensure we always have successful static initialization, before creating fr
om the factories |
| 35 * we verify the count is as expected. If a new factory is added, then these nu
mbers must be |
| 36 * manually adjusted |
| 37 */ |
| 38 static const int kFPFactoryCount = 36; |
| 39 static const int kGPFactoryCount = 14; |
| 40 |
| 41 template<> |
| 42 void GrProcessorTestFactory<GrFragmentProcessor>::VerifyFactoryCount() { |
| 43 if (kFPFactoryCount != GetFactories()->count()) { |
| 44 SkFAIL("Wrong number of fragment processor factories!"); |
| 45 } |
| 46 } |
| 47 |
| 48 template<> |
| 49 void GrProcessorTestFactory<GrGeometryProcessor>::VerifyFactoryCount() { |
| 50 if (kGPFactoryCount != GetFactories()->count()) { |
| 51 SkFAIL("Wrong number of geometry processor factories!"); |
| 52 } |
| 53 } |
| 54 |
| 55 #endif |
| 56 |
15 namespace GrProcessorUnitTest { | 57 namespace GrProcessorUnitTest { |
16 const SkMatrix& TestMatrix(SkRandom* random) { | 58 const SkMatrix& TestMatrix(SkRandom* random) { |
17 static SkMatrix gMatrices[5]; | 59 static SkMatrix gMatrices[5]; |
18 static bool gOnce; | 60 static bool gOnce; |
19 if (!gOnce) { | 61 if (!gOnce) { |
20 gMatrices[0].reset(); | 62 gMatrices[0].reset(); |
21 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); | 63 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); |
22 gMatrices[2].setRotate(SkIntToScalar(17)); | 64 gMatrices[2].setRotate(SkIntToScalar(17)); |
23 gMatrices[3].setRotate(SkIntToScalar(185)); | 65 gMatrices[3].setRotate(SkIntToScalar(185)); |
24 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); | 66 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 SkASSERT(this->numTransforms() == other.numTransforms()); | 124 SkASSERT(this->numTransforms() == other.numTransforms()); |
83 for (int i = 0; i < this->numTransforms(); ++i) { | 125 for (int i = 0; i < this->numTransforms(); ++i) { |
84 SkASSERT(this->coordTransform(i) == other.coordTransform(i)); | 126 SkASSERT(this->coordTransform(i) == other.coordTransform(i)); |
85 } | 127 } |
86 SkASSERT(this->numTextures() == other.numTextures()); | 128 SkASSERT(this->numTextures() == other.numTextures()); |
87 for (int i = 0; i < this->numTextures(); ++i) { | 129 for (int i = 0; i < this->numTextures(); ++i) { |
88 SkASSERT(this->textureAccess(i) == other.textureAccess(i)); | 130 SkASSERT(this->textureAccess(i) == other.textureAccess(i)); |
89 } | 131 } |
90 } | 132 } |
91 #endif | 133 #endif |
OLD | NEW |