OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLGeometryProcessor_DEFINED | 8 #ifndef GrGLGeometryProcessor_DEFINED |
9 #define GrGLGeometryProcessor_DEFINED | 9 #define GrGLGeometryProcessor_DEFINED |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; | 121 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; |
122 | 122 |
123 private: | 123 private: |
124 UniformHandle fViewMatrixUniform; | 124 UniformHandle fViewMatrixUniform; |
125 SkMatrix fViewMatrix; | 125 SkMatrix fViewMatrix; |
126 const char* fViewMatrixName; | 126 const char* fViewMatrixName; |
127 }; | 127 }; |
128 | 128 |
129 class GrGLPathRendering; | 129 class GrGLPathRendering; |
| 130 class GrGLVertexBuilder; |
130 /** | 131 /** |
131 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the
n it must inherit | 132 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the
n it must inherit |
132 * from this class. Since paths don't have vertices, this class is only meant to
be used internally | 133 * from this class. Since paths don't have vertices, this class is only meant to
be used internally |
133 * by skia, for special cases. | 134 * by skia, for special cases. |
134 */ | 135 */ |
135 class GrGLGeometryProcessor : public GrGLPrimitiveProcessor { | 136 class GrGLGeometryProcessor : public GrGLPrimitiveProcessor { |
136 public: | 137 public: |
137 /* Any general emit code goes in the base class emitCode. Subclasses overri
de onEmitCode */ | 138 /* Any general emit code goes in the base class emitCode. Subclasses overri
de onEmitCode */ |
138 void emitCode(EmitArgs&) SK_OVERRIDE; | 139 void emitCode(EmitArgs&) SK_OVERRIDE; |
139 | 140 |
140 void setTransformData(const GrPrimitiveProcessor*, | 141 void setTransformData(const GrPrimitiveProcessor*, |
141 const GrGLProgramDataManager&, | 142 const GrGLProgramDataManager&, |
142 int index, | 143 int index, |
143 const SkTArray<const GrCoordTransform*, true>& transfo
rms); | 144 const SkTArray<const GrCoordTransform*, true>& transfo
rms); |
144 | 145 |
145 protected: | 146 protected: |
146 const char* position() const { return "pos3"; } | |
147 | |
148 // Many GrGeometryProcessors do not need explicit local coords | 147 // Many GrGeometryProcessors do not need explicit local coords |
149 void emitTransforms(GrGLGPBuilder* gp, | 148 void emitTransforms(GrGLGPBuilder* gp, |
150 const char* position, | 149 const GrShaderVar& posVar, |
151 const SkMatrix& localMatrix, | 150 const SkMatrix& localMatrix, |
152 const TransformsIn& tin, | 151 const TransformsIn& tin, |
153 TransformsOut* tout) { | 152 TransformsOut* tout) { |
154 this->emitTransforms(gp, position, position, localMatrix, tin, tout); | 153 this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout)
; |
155 } | 154 } |
156 | 155 |
157 void emitTransforms(GrGLGPBuilder*, | 156 void emitTransforms(GrGLGPBuilder*, |
158 const char* position, | 157 const GrShaderVar& posVar, |
159 const char* localCoords, | 158 const char* localCoords, |
160 const SkMatrix& localMatrix, | 159 const SkMatrix& localMatrix, |
161 const TransformsIn&, | 160 const TransformsIn&, |
162 TransformsOut*); | 161 TransformsOut*); |
163 | 162 |
| 163 struct GrGPArgs { |
| 164 // The variable used by a GP to store its position. It can be |
| 165 // either a vec2 or a vec3 depending on the presence of perspective. |
| 166 GrShaderVar fPositionVar; |
| 167 }; |
| 168 |
| 169 // Create the correct type of position variable given the CTM |
| 170 static void SetupPosition(GrGLVertexBuilder* vsBuilder, |
| 171 GrGPArgs* gpArgs, |
| 172 const char* posName, |
| 173 const SkMatrix& mat, |
| 174 const char* matName); |
| 175 |
| 176 static uint32_t ComputePosKey(const SkMatrix& mat) { |
| 177 if (mat.isIdentity()) { |
| 178 return 0x0; |
| 179 } else if (!mat.hasPerspective()) { |
| 180 return 0x01; |
| 181 } else { |
| 182 return 0x02; |
| 183 } |
| 184 } |
| 185 |
164 private: | 186 private: |
165 virtual void onEmitCode(EmitArgs&) = 0; | 187 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; |
166 | 188 |
167 typedef GrGLPrimitiveProcessor INHERITED; | 189 typedef GrGLPrimitiveProcessor INHERITED; |
168 }; | 190 }; |
169 | 191 |
170 class GrGLGpu; | 192 class GrGLGpu; |
171 | 193 |
172 class GrGLPathProcessor : public GrGLPrimitiveProcessor { | 194 class GrGLPathProcessor : public GrGLPrimitiveProcessor { |
173 public: | 195 public: |
174 GrGLPathProcessor(const GrPathProcessor&, const GrBatchTracker&); | 196 GrGLPathProcessor(const GrPathProcessor&, const GrBatchTracker&); |
175 | 197 |
(...skipping 21 matching lines...) Expand all Loading... |
197 virtual void didSetData(GrGLPathRendering*) {} | 219 virtual void didSetData(GrGLPathRendering*) {} |
198 | 220 |
199 private: | 221 private: |
200 UniformHandle fColorUniform; | 222 UniformHandle fColorUniform; |
201 GrColor fColor; | 223 GrColor fColor; |
202 | 224 |
203 typedef GrGLPrimitiveProcessor INHERITED; | 225 typedef GrGLPrimitiveProcessor INHERITED; |
204 }; | 226 }; |
205 | 227 |
206 #endif | 228 #endif |
OLD | NEW |