OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
11 #ifndef GrEffectStage_DEFINED | 11 #ifndef GrEffectStage_DEFINED |
12 #define GrEffectStage_DEFINED | 12 #define GrEffectStage_DEFINED |
13 | 13 |
14 #include "GrBackendEffectFactory.h" | 14 #include "GrBackendEffectFactory.h" |
15 #include "GrEffect.h" | 15 #include "GrEffect.h" |
16 #include "GrProgramElementRef.h" | 16 #include "GrProgramElementRef.h" |
17 #include "SkMatrix.h" | 17 #include "SkMatrix.h" |
18 #include "SkShader.h" | 18 #include "SkShader.h" |
19 | 19 |
20 // TODO: Make two variations on this class: One for GrDrawState that only owns r
egular refs | 20 // TODO: Make two variations on this class: One for GrDrawState that only owns r
egular refs |
21 // and supports compatibility checks and changing local coords. The second is fo
r GrOptDrawState, | 21 // and supports compatibility checks and changing local coords. The second is fo
r GrOptDrawState, |
22 // is immutable, and only owns pending execution refs. This requries removing th
e common base | 22 // is immutable, and only owns pending execution refs. This requries removing th
e common base |
23 // class from GrDrawState and GrOptDrawState called GrRODrawState and converting
to GrOptDrawState | 23 // class from GrDrawState and GrOptDrawState called GrRODrawState and converting
to GrOptDrawState |
24 // when draws are enqueued in the GrInOrderDrawBuffer. | 24 // when draws are enqueued in the GrInOrderDrawBuffer. |
25 class GrEffectStage { | 25 class GrEffectStage { |
26 public: | 26 public: |
27 explicit GrEffectStage(const GrEffect* effect, int attrIndex0 = -1, int attr
Index1 = -1) | 27 explicit GrEffectStage(const GrEffect* effect) |
28 : fEffect(SkRef(effect)) { | 28 : fEffect(SkRef(effect)) { |
29 fCoordChangeMatrixSet = false; | 29 fCoordChangeMatrixSet = false; |
30 fVertexAttribIndices[0] = attrIndex0; | |
31 fVertexAttribIndices[1] = attrIndex1; | |
32 } | 30 } |
33 | 31 |
34 GrEffectStage(const GrEffectStage& other) { | 32 GrEffectStage(const GrEffectStage& other) { |
35 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; | 33 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; |
36 if (other.fCoordChangeMatrixSet) { | 34 if (other.fCoordChangeMatrixSet) { |
37 fCoordChangeMatrix = other.fCoordChangeMatrix; | 35 fCoordChangeMatrix = other.fCoordChangeMatrix; |
38 } | 36 } |
39 fEffect.initAndRef(other.fEffect); | 37 fEffect.initAndRef(other.fEffect); |
40 memcpy(fVertexAttribIndices, other.fVertexAttribIndices, sizeof(fVertexA
ttribIndices)); | |
41 } | 38 } |
42 | 39 |
43 static bool AreCompatible(const GrEffectStage& a, const GrEffectStage& b, | 40 static bool AreCompatible(const GrEffectStage& a, const GrEffectStage& b, |
44 bool usingExplicitLocalCoords) { | 41 bool usingExplicitLocalCoords) { |
45 SkASSERT(a.fEffect.get()); | 42 SkASSERT(a.fEffect.get()); |
46 SkASSERT(b.fEffect.get()); | 43 SkASSERT(b.fEffect.get()); |
47 | 44 |
48 if (!a.getEffect()->isEqual(*b.getEffect())) { | 45 if (!a.getEffect()->isEqual(*b.getEffect())) { |
49 return false; | 46 return false; |
50 } | 47 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 const SkMatrix& getCoordChangeMatrix() const { | 123 const SkMatrix& getCoordChangeMatrix() const { |
127 if (fCoordChangeMatrixSet) { | 124 if (fCoordChangeMatrixSet) { |
128 return fCoordChangeMatrix; | 125 return fCoordChangeMatrix; |
129 } else { | 126 } else { |
130 return SkMatrix::I(); | 127 return SkMatrix::I(); |
131 } | 128 } |
132 } | 129 } |
133 | 130 |
134 const GrEffect* getEffect() const { return fEffect.get(); } | 131 const GrEffect* getEffect() const { return fEffect.get(); } |
135 | 132 |
136 const int* getVertexAttribIndices() const { return fVertexAttribIndices; } | |
137 int getVertexAttribIndexCount() const { return fEffect->numVertexAttribs();
} | |
138 | |
139 void convertToPendingExec() { fEffect.convertToPendingExec(); } | 133 void convertToPendingExec() { fEffect.convertToPendingExec(); } |
140 | 134 |
141 private: | 135 private: |
142 bool fCoordChangeMatrixSet; | 136 bool fCoordChangeMatrixSet; |
143 SkMatrix fCoordChangeMatrix; | 137 SkMatrix fCoordChangeMatrix; |
144 GrProgramElementRef<const GrEffect> fEffect; | 138 GrProgramElementRef<const GrEffect> fEffect; |
145 int fVertexAttribIndices[2]; | |
146 }; | 139 }; |
147 | 140 |
148 #endif | 141 #endif |
OLD | NEW |