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 #ifndef GrBackendEffectFactory_DEFINED | 8 #ifndef GrBackendEffectFactory_DEFINED |
9 #define GrBackendEffectFactory_DEFINED | 9 #define GrBackendEffectFactory_DEFINED |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 class GrEffectRef; | 26 class GrEffectRef; |
27 class GrGLEffect; | 27 class GrGLEffect; |
28 class GrGLCaps; | 28 class GrGLCaps; |
29 class GrDrawEffect; | 29 class GrDrawEffect; |
30 | 30 |
31 class GrBackendEffectFactory : public GrNoncopyable { | 31 class GrBackendEffectFactory : public GrNoncopyable { |
32 public: | 32 public: |
33 typedef uint32_t EffectKey; | 33 typedef uint32_t EffectKey; |
34 enum { | 34 enum { |
35 kNoEffectKey = 0, | 35 kNoEffectKey = 0, |
36 kEffectKeyBits = 16, | 36 kEffectKeyBits = 15, |
37 /** | 37 /** |
38 * Some aspects of the generated code may be determined by the particula
r textures that are | 38 * Some aspects of the generated code may be determined by the particula
r textures that are |
39 * associated with the effect. These manipulations are performed by GrGL
ShaderBuilder beyond | 39 * associated with the effect. These manipulations are performed by GrGL
ShaderBuilder beyond |
40 * GrGLEffects' control. So there is a dedicated part of the key which i
s combined | 40 * GrGLEffects' control. So there is a dedicated part of the key which i
s combined |
41 * automatically with the bits produced by GrGLEffect::GenKey(). | 41 * automatically with the bits produced by GrGLEffect::GenKey(). |
42 */ | 42 */ |
43 kTextureKeyBits = 6, | 43 kTextureKeyBits = 6, |
44 kAttribKeyBits = 6 | 44 kAttribKeyBits = 6 |
45 }; | 45 }; |
46 | 46 |
(...skipping 14 matching lines...) Expand all Loading... |
61 kIllegalEffectClassID = 0, | 61 kIllegalEffectClassID = 0, |
62 }; | 62 }; |
63 | 63 |
64 GrBackendEffectFactory() { | 64 GrBackendEffectFactory() { |
65 fEffectClassID = kIllegalEffectClassID; | 65 fEffectClassID = kIllegalEffectClassID; |
66 } | 66 } |
67 virtual ~GrBackendEffectFactory() {} | 67 virtual ~GrBackendEffectFactory() {} |
68 | 68 |
69 static EffectKey GenID() { | 69 static EffectKey GenID() { |
70 GR_DEBUGCODE(static const int32_t kClassIDBits = 8 * sizeof(EffectKey) - | 70 GR_DEBUGCODE(static const int32_t kClassIDBits = 8 * sizeof(EffectKey) - |
71 kTextureKeyBits - | 71 kTextureKeyBits - kEffectKeyBits - kAttribKeyBits); |
72 kEffectKeyBits); | |
73 // fCurrEffectClassID has been initialized to kIllegalEffectClassID. The | 72 // fCurrEffectClassID has been initialized to kIllegalEffectClassID. The |
74 // atomic inc returns the old value not the incremented value. So we add | 73 // atomic inc returns the old value not the incremented value. So we add |
75 // 1 to the returned value. | 74 // 1 to the returned value. |
76 int32_t id = sk_atomic_inc(&fCurrEffectClassID) + 1; | 75 int32_t id = sk_atomic_inc(&fCurrEffectClassID) + 1; |
77 GrAssert(id < (1 << kClassIDBits)); | 76 GrAssert(id < (1 << kClassIDBits)); |
78 return static_cast<EffectKey>(id); | 77 return static_cast<EffectKey>(id); |
79 } | 78 } |
80 | 79 |
81 EffectKey fEffectClassID; | 80 EffectKey fEffectClassID; |
82 | 81 |
83 private: | 82 private: |
84 static int32_t fCurrEffectClassID; | 83 static int32_t fCurrEffectClassID; |
85 }; | 84 }; |
86 | 85 |
87 #endif | 86 #endif |
OLD | NEW |