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 GrBackendProcessorFactory_DEFINED | 8 #ifndef GrBackendProcessorFactory_DEFINED |
9 #define GrBackendProcessorFactory_DEFINED | 9 #define GrBackendProcessorFactory_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 size_t size() const { return sizeof(uint32_t) * fCount; } | 44 size_t size() const { return sizeof(uint32_t) * fCount; } |
45 | 45 |
46 private: | 46 private: |
47 SkTArray<uint8_t, true>* fData; // unowned ptr to the larger key. | 47 SkTArray<uint8_t, true>* fData; // unowned ptr to the larger key. |
48 int fCount; // number of uint32_ts added to fData by the
processor. | 48 int fCount; // number of uint32_ts added to fData by the
processor. |
49 }; | 49 }; |
50 | 50 |
51 /** | 51 /** |
52 * This class is used to pass the key that was created for a GrGLProcessor back
to it | |
53 * when it emits code. It may allow the emit step to skip calculations that were | |
54 * performed when computing the key. | |
55 */ | |
56 class GrProcessorKey { | |
57 public: | |
58 GrProcessorKey(const uint32_t* key, int count) : fKey(key), fCount(count) { | |
59 SkASSERT(0 == reinterpret_cast<intptr_t>(key) % sizeof(uint32_t)); | |
60 } | |
61 | |
62 /** Gets the uint32_t values that the processor inserted into the key. */ | |
63 uint32_t get32(int index) const { | |
64 SkASSERT(index >=0 && index < fCount); | |
65 return fKey[index]; | |
66 } | |
67 | |
68 /** Gets the number of uint32_t values that the processor inserted into the
key. */ | |
69 int count32() const { return fCount; } | |
70 | |
71 private: | |
72 const uint32_t* fKey; // unowned ptr into the larger key. | |
73 int fCount; // number of uint32_ts inserted by the proce
ssor into its key. | |
74 }; | |
75 | |
76 /** | |
77 * Given a GrProcessor of a particular type, creates the corresponding graphics-
backend-specific | 52 * Given a GrProcessor of a particular type, creates the corresponding graphics-
backend-specific |
78 * processor object. It also tracks equivalence of shaders generated via a key.
The factory for an | 53 * processor object. It also tracks equivalence of shaders generated via a key.
The factory for an |
79 * processor is accessed via GrProcessor::getFactory(). Each factory instance is
assigned an ID at | 54 * processor is accessed via GrProcessor::getFactory(). Each factory instance is
assigned an ID at |
80 * construction. The ID of GrProcessor::getFactory() is used as a type identifie
r. Thus, a | 55 * construction. The ID of GrProcessor::getFactory() is used as a type identifie
r. Thus, a |
81 * GrProcessor subclass must always return the same object from getFactory() and
that factory object | 56 * GrProcessor subclass must always return the same object from getFactory() and
that factory object |
82 * must be unique to the GrProcessor subclass (and unique from any further deriv
ed subclasses). | 57 * must be unique to the GrProcessor subclass (and unique from any further deriv
ed subclasses). |
83 * | 58 * |
84 * Rather than subclassing this class themselves, it is recommended that GrProce
ssor authors use | 59 * Rather than subclassing this class themselves, it is recommended that GrProce
ssor authors use |
85 * the templated subclass GrTBackendProcessorFactory by writing their getFactory
() method as: | 60 * the templated subclass GrTBackendProcessorFactory by writing their getFactory
() method as: |
86 * | 61 * |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory { | 135 class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory { |
161 public: | 136 public: |
162 /** | 137 /** |
163 * Creates a GrGLProcessor instance that is used both to generate code for t
he GrProcessor in a | 138 * Creates a GrGLProcessor instance that is used both to generate code for t
he GrProcessor in a |
164 * GLSL program and to manage updating uniforms for the program when it is u
sed. | 139 * GLSL program and to manage updating uniforms for the program when it is u
sed. |
165 */ | 140 */ |
166 virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&)
const = 0; | 141 virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&)
const = 0; |
167 }; | 142 }; |
168 | 143 |
169 #endif | 144 #endif |
OLD | NEW |