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 class GrEffectStage { | 20 class GrEffectStage { |
21 public: | 21 public: |
22 explicit GrEffectStage(const GrEffect* effect, int attrIndex0 = -1, int attr
Index1 = -1) | 22 explicit GrEffectStage(const GrEffect* effect) |
23 : fEffect(SkRef(effect)) { | 23 : fEffect(SkRef(effect)) { |
24 fCoordChangeMatrixSet = false; | 24 fCoordChangeMatrixSet = false; |
25 fVertexAttribIndices[0] = attrIndex0; | |
26 fVertexAttribIndices[1] = attrIndex1; | |
27 } | 25 } |
28 | 26 |
29 GrEffectStage(const GrEffectStage& other) { | 27 GrEffectStage(const GrEffectStage& other) { |
30 *this = other; | 28 *this = other; |
31 } | 29 } |
32 | 30 |
33 GrEffectStage& operator= (const GrEffectStage& other) { | 31 GrEffectStage& operator= (const GrEffectStage& other) { |
34 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; | 32 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; |
35 if (other.fCoordChangeMatrixSet) { | 33 if (other.fCoordChangeMatrixSet) { |
36 fCoordChangeMatrix = other.fCoordChangeMatrix; | 34 fCoordChangeMatrix = other.fCoordChangeMatrix; |
37 } | 35 } |
38 fEffect.reset(SkRef(other.fEffect.get())); | 36 fEffect.reset(SkRef(other.fEffect.get())); |
39 memcpy(fVertexAttribIndices, other.fVertexAttribIndices, sizeof(fVertexA
ttribIndices)); | |
40 return *this; | 37 return *this; |
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; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const SkMatrix& getCoordChangeMatrix() const { | 122 const SkMatrix& getCoordChangeMatrix() const { |
126 if (fCoordChangeMatrixSet) { | 123 if (fCoordChangeMatrixSet) { |
127 return fCoordChangeMatrix; | 124 return fCoordChangeMatrix; |
128 } else { | 125 } else { |
129 return SkMatrix::I(); | 126 return SkMatrix::I(); |
130 } | 127 } |
131 } | 128 } |
132 | 129 |
133 const GrEffect* getEffect() const { return fEffect.get(); } | 130 const GrEffect* getEffect() const { return fEffect.get(); } |
134 | 131 |
135 const int* getVertexAttribIndices() const { return fVertexAttribIndices; } | |
136 int getVertexAttribIndexCount() const { return fEffect->numVertexAttribs();
} | |
137 | |
138 void convertToPendingExec() { fEffect.convertToPendingExec(); } | 132 void convertToPendingExec() { fEffect.convertToPendingExec(); } |
139 | 133 |
140 private: | 134 private: |
141 bool fCoordChangeMatrixSet; | 135 bool fCoordChangeMatrixSet; |
142 SkMatrix fCoordChangeMatrix; | 136 SkMatrix fCoordChangeMatrix; |
143 GrProgramElementRef<const GrEffect> fEffect; | 137 GrProgramElementRef<const GrEffect> fEffect; |
144 int fVertexAttribIndices[2]; | |
145 }; | 138 }; |
146 | 139 |
147 #endif | 140 #endif |
OLD | NEW |