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 "GrCoordTransform.h" |
15 #include "GrEffect.h" | 16 #include "GrEffect.h" |
16 #include "GrProgramElementRef.h" | 17 #include "GrProgramElementRef.h" |
17 #include "SkMatrix.h" | 18 #include "SkMatrix.h" |
18 #include "SkShader.h" | 19 #include "SkShader.h" |
19 | 20 |
20 // TODO: Make two variations on this class: One for GrDrawState that only owns r
egular refs | 21 // 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, | 22 // 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 | 23 // 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 | 24 // class from GrDrawState and GrOptDrawState called GrRODrawState and converting
to GrOptDrawState |
24 // when draws are enqueued in the GrInOrderDrawBuffer. | 25 // when draws are enqueued in the GrInOrderDrawBuffer. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 * installed in the stage. | 122 * installed in the stage. |
122 */ | 123 */ |
123 const SkMatrix& getCoordChangeMatrix() const { | 124 const SkMatrix& getCoordChangeMatrix() const { |
124 if (fCoordChangeMatrixSet) { | 125 if (fCoordChangeMatrixSet) { |
125 return fCoordChangeMatrix; | 126 return fCoordChangeMatrix; |
126 } else { | 127 } else { |
127 return SkMatrix::I(); | 128 return SkMatrix::I(); |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
| 132 bool isPerspectiveCoordTransform(int matrixIndex, bool useExplicitLocalCoord
s) const { |
| 133 const GrCoordTransform& coordTransform = this->getEffect()->coordTransfo
rm(matrixIndex); |
| 134 SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType(); |
| 135 SkMatrix::TypeMask type1 = SkMatrix::kIdentity_Mask; |
| 136 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { |
| 137 type1 = useExplicitLocalCoords ? |
| 138 SkMatrix::kIdentity_Mask : this->getCoordChangeMatrix().getTyp
e(); |
| 139 } |
| 140 |
| 141 int combinedTypes = type0 | type1; |
| 142 if (SkMatrix::kPerspective_Mask & combinedTypes) { |
| 143 return true; |
| 144 } else { |
| 145 return false; |
| 146 } |
| 147 } |
| 148 |
131 const GrEffect* getEffect() const { return fEffect.get(); } | 149 const GrEffect* getEffect() const { return fEffect.get(); } |
132 | 150 |
133 void convertToPendingExec() { fEffect.convertToPendingExec(); } | 151 void convertToPendingExec() { fEffect.convertToPendingExec(); } |
134 | 152 |
135 private: | 153 private: |
136 bool fCoordChangeMatrixSet; | 154 bool fCoordChangeMatrixSet; |
137 SkMatrix fCoordChangeMatrix; | 155 SkMatrix fCoordChangeMatrix; |
138 GrProgramElementRef<const GrEffect> fEffect; | 156 GrProgramElementRef<const GrEffect> fEffect; |
139 }; | 157 }; |
140 | 158 |
141 #endif | 159 #endif |
OLD | NEW |