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 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 #include "SkTemplates.h" | 12 #include "SkTemplates.h" |
13 #include "SkThread.h" | 13 #include "SkThread.h" |
14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
15 #include "SkTArray.h" | 15 #include "SkTArray.h" |
16 | 16 |
17 class GrGLEffect; | 17 class GrGLEffect; |
18 class GrGLCaps; | 18 class GrGLCaps; |
19 class GrDrawEffect; | 19 class GrEffect; |
20 | 20 |
21 /** | 21 /** |
22 * Used by effects to build their keys. It incorporates each per-effect key into
a larger shader key. | 22 * Used by effects to build their keys. It incorporates each per-effect key into
a larger shader key. |
23 */ | 23 */ |
24 class GrEffectKeyBuilder { | 24 class GrEffectKeyBuilder { |
25 public: | 25 public: |
26 GrEffectKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCoun
t(0) { | 26 GrEffectKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCoun
t(0) { |
27 SkASSERT(0 == fData->count() % sizeof(uint32_t)); | 27 SkASSERT(0 == fData->count() % sizeof(uint32_t)); |
28 } | 28 } |
29 | 29 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 * | 89 * |
90 * Using GrTBackendEffectFactory places a few constraints on the effect. See tha
t class's comments. | 90 * Using GrTBackendEffectFactory places a few constraints on the effect. See tha
t class's comments. |
91 */ | 91 */ |
92 class GrBackendEffectFactory : SkNoncopyable { | 92 class GrBackendEffectFactory : SkNoncopyable { |
93 public: | 93 public: |
94 /** | 94 /** |
95 * Generates an effect's key. The key is based on the aspects of the GrEffec
t object's | 95 * Generates an effect's key. The key is based on the aspects of the GrEffec
t object's |
96 * configuration that affect GLSL code generation. Two GrEffect instances th
at would cause | 96 * configuration that affect GLSL code generation. Two GrEffect instances th
at would cause |
97 * this->createGLInstance()->emitCode() to produce different code must produ
ce different keys. | 97 * this->createGLInstance()->emitCode() to produce different code must produ
ce different keys. |
98 */ | 98 */ |
99 virtual void getGLEffectKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKe
yBuilder*) const = 0; | 99 virtual void getGLEffectKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBui
lder*) const = 0; |
100 | 100 |
101 /** | 101 /** |
102 * Creates a GrGLEffect instance that is used both to generate code for the
GrEffect in a GLSL | 102 * Creates a GrGLEffect instance that is used both to generate code for the
GrEffect in a GLSL |
103 * program and to manage updating uniforms for the program when it is used. | 103 * program and to manage updating uniforms for the program when it is used. |
104 */ | 104 */ |
105 virtual GrGLEffect* createGLInstance(const GrDrawEffect&) const = 0; | 105 virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0; |
106 | 106 |
107 /** | 107 /** |
108 * Produces a human-reable name for the effect. | 108 * Produces a human-reable name for the effect. |
109 */ | 109 */ |
110 virtual const char* name() const = 0; | 110 virtual const char* name() const = 0; |
111 | 111 |
112 /** | 112 /** |
113 * A unique value for every instance of this factory. It is automatically in
corporated into the | 113 * A unique value for every instance of this factory. It is automatically in
corporated into the |
114 * effect's key. This allows keys generated by getGLEffectKey() to only be u
nique within a | 114 * effect's key. This allows keys generated by getGLEffectKey() to only be u
nique within a |
115 * GrEffect subclass and not necessarily across subclasses. | 115 * GrEffect subclass and not necessarily across subclasses. |
(...skipping 19 matching lines...) Expand all Loading... |
135 "subclass."); | 135 "subclass."); |
136 } | 136 } |
137 return id; | 137 return id; |
138 } | 138 } |
139 | 139 |
140 const uint32_t fEffectClassID; | 140 const uint32_t fEffectClassID; |
141 static int32_t fCurrEffectClassID; | 141 static int32_t fCurrEffectClassID; |
142 }; | 142 }; |
143 | 143 |
144 #endif | 144 #endif |
OLD | NEW |