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 #include "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 class CircleEdgeEffect : public GrGeometryProcessor { | 71 class CircleEdgeEffect : public GrGeometryProcessor { |
72 public: | 72 public: |
73 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { | 73 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { |
74 return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix)); | 74 return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix)); |
75 } | 75 } |
76 | 76 |
77 const Attribute* inPosition() const { return fInPosition; } | 77 const Attribute* inPosition() const { return fInPosition; } |
78 const Attribute* inCircleEdge() const { return fInCircleEdge; } | 78 const Attribute* inCircleEdge() const { return fInCircleEdge; } |
79 virtual ~CircleEdgeEffect() {} | 79 virtual ~CircleEdgeEffect() {} |
80 | 80 |
81 const char* name() const SK_OVERRIDE { return "CircleEdge"; } | 81 const char* name() const override { return "CircleEdge"; } |
82 | 82 |
83 inline bool isStroked() const { return fStroke; } | 83 inline bool isStroked() const { return fStroke; } |
84 | 84 |
85 class GLProcessor : public GrGLGeometryProcessor { | 85 class GLProcessor : public GrGLGeometryProcessor { |
86 public: | 86 public: |
87 GLProcessor(const GrGeometryProcessor&, | 87 GLProcessor(const GrGeometryProcessor&, |
88 const GrBatchTracker&) | 88 const GrBatchTracker&) |
89 : fColor(GrColor_ILLEGAL) {} | 89 : fColor(GrColor_ILLEGAL) {} |
90 | 90 |
91 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ | 91 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
92 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); | 92 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); |
93 GrGLGPBuilder* pb = args.fPB; | 93 GrGLGPBuilder* pb = args.fPB; |
94 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 94 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
95 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 95 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
96 | 96 |
97 // emit attributes | 97 // emit attributes |
98 vsBuilder->emitAttributes(ce); | 98 vsBuilder->emitAttributes(ce); |
99 | 99 |
100 GrGLVertToFrag v(kVec4f_GrSLType); | 100 GrGLVertToFrag v(kVec4f_GrSLType); |
101 args.fPB->addVarying("CircleEdge", &v); | 101 args.fPB->addVarying("CircleEdge", &v); |
(...skipping 29 matching lines...) Expand all Loading... |
131 const BatchTracker& local = bt.cast<BatchTracker>(); | 131 const BatchTracker& local = bt.cast<BatchTracker>(); |
132 const CircleEdgeEffect& circleEffect = gp.cast<CircleEdgeEffect>(); | 132 const CircleEdgeEffect& circleEffect = gp.cast<CircleEdgeEffect>(); |
133 uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0; | 133 uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0; |
134 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; | 134 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; |
135 key |= ComputePosKey(gp.viewMatrix()) << 2; | 135 key |= ComputePosKey(gp.viewMatrix()) << 2; |
136 b->add32(key << 16 | local.fInputColorType); | 136 b->add32(key << 16 | local.fInputColorType); |
137 } | 137 } |
138 | 138 |
139 virtual void setData(const GrGLProgramDataManager& pdman, | 139 virtual void setData(const GrGLProgramDataManager& pdman, |
140 const GrPrimitiveProcessor& gp, | 140 const GrPrimitiveProcessor& gp, |
141 const GrBatchTracker& bt) SK_OVERRIDE { | 141 const GrBatchTracker& bt) override { |
142 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | 142 this->setUniformViewMatrix(pdman, gp.viewMatrix()); |
143 | 143 |
144 const BatchTracker& local = bt.cast<BatchTracker>(); | 144 const BatchTracker& local = bt.cast<BatchTracker>(); |
145 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { | 145 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { |
146 GrGLfloat c[4]; | 146 GrGLfloat c[4]; |
147 GrColorToRGBAFloat(local.fColor, c); | 147 GrColorToRGBAFloat(local.fColor, c); |
148 pdman.set4fv(fColorUniform, 1, c); | 148 pdman.set4fv(fColorUniform, 1, c); |
149 fColor = local.fColor; | 149 fColor = local.fColor; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 GrColor fColor; | 154 GrColor fColor; |
155 UniformHandle fColorUniform; | 155 UniformHandle fColorUniform; |
156 typedef GrGLGeometryProcessor INHERITED; | 156 typedef GrGLGeometryProcessor INHERITED; |
157 }; | 157 }; |
158 | 158 |
159 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 159 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
160 const GrGLCaps& caps, | 160 const GrGLCaps& caps, |
161 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 161 GrProcessorKeyBuilder* b) const override { |
162 GLProcessor::GenKey(*this, bt, caps, b); | 162 GLProcessor::GenKey(*this, bt, caps, b); |
163 } | 163 } |
164 | 164 |
165 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 165 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
166 const GrGLCaps&) const SK_O
VERRIDE { | 166 const GrGLCaps&) const over
ride { |
167 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 167 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
168 } | 168 } |
169 | 169 |
170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
SK_OVERRIDE { | 170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
171 BatchTracker* local = bt->cast<BatchTracker>(); | 171 BatchTracker* local = bt->cast<BatchTracker>(); |
172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
173 local->fUsesLocalCoords = init.fUsesLocalCoords; | 173 local->fUsesLocalCoords = init.fUsesLocalCoords; |
174 } | 174 } |
175 | 175 |
176 bool onCanMakeEqual(const GrBatchTracker& m, | 176 bool onCanMakeEqual(const GrBatchTracker& m, |
177 const GrGeometryProcessor& that, | 177 const GrGeometryProcessor& that, |
178 const GrBatchTracker& t) const SK_OVERRIDE { | 178 const GrBatchTracker& t) const override { |
179 const BatchTracker& mine = m.cast<BatchTracker>(); | 179 const BatchTracker& mine = m.cast<BatchTracker>(); |
180 const BatchTracker& theirs = t.cast<BatchTracker>(); | 180 const BatchTracker& theirs = t.cast<BatchTracker>(); |
181 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, | 181 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
182 that, theirs.fUsesLocalCoords) && | 182 that, theirs.fUsesLocalCoords) && |
183 CanCombineOutput(mine.fInputColorType, mine.fColor, | 183 CanCombineOutput(mine.fInputColorType, mine.fColor, |
184 theirs.fInputColorType, theirs.fColor); | 184 theirs.fInputColorType, theirs.fColor); |
185 } | 185 } |
186 | 186 |
187 private: | 187 private: |
188 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 188 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
189 : INHERITED(color, SkMatrix::I(), localMatrix) { | 189 : INHERITED(color, SkMatrix::I(), localMatrix) { |
190 this->initClassID<CircleEdgeEffect>(); | 190 this->initClassID<CircleEdgeEffect>(); |
191 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 191 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
192 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", | 192 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", |
193 kVec4f_GrVertexAttrib
Type)); | 193 kVec4f_GrVertexAttrib
Type)); |
194 fStroke = stroke; | 194 fStroke = stroke; |
195 } | 195 } |
196 | 196 |
197 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 197 bool onIsEqual(const GrGeometryProcessor& other) const override { |
198 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); | 198 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); |
199 return cee.fStroke == fStroke; | 199 return cee.fStroke == fStroke; |
200 } | 200 } |
201 | 201 |
202 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { | 202 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
203 out->setUnknownSingleComponent(); | 203 out->setUnknownSingleComponent(); |
204 } | 204 } |
205 | 205 |
206 struct BatchTracker { | 206 struct BatchTracker { |
207 GrGPInput fInputColorType; | 207 GrGPInput fInputColorType; |
208 GrColor fColor; | 208 GrColor fColor; |
209 bool fUsesLocalCoords; | 209 bool fUsesLocalCoords; |
210 }; | 210 }; |
211 | 211 |
212 const Attribute* fInPosition; | 212 const Attribute* fInPosition; |
(...skipping 27 matching lines...) Expand all Loading... |
240 */ | 240 */ |
241 | 241 |
242 class EllipseEdgeEffect : public GrGeometryProcessor { | 242 class EllipseEdgeEffect : public GrGeometryProcessor { |
243 public: | 243 public: |
244 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { | 244 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { |
245 return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix)); | 245 return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix)); |
246 } | 246 } |
247 | 247 |
248 virtual ~EllipseEdgeEffect() {} | 248 virtual ~EllipseEdgeEffect() {} |
249 | 249 |
250 const char* name() const SK_OVERRIDE { return "EllipseEdge"; } | 250 const char* name() const override { return "EllipseEdge"; } |
251 | 251 |
252 const Attribute* inPosition() const { return fInPosition; } | 252 const Attribute* inPosition() const { return fInPosition; } |
253 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } | 253 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } |
254 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } | 254 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } |
255 | 255 |
256 inline bool isStroked() const { return fStroke; } | 256 inline bool isStroked() const { return fStroke; } |
257 | 257 |
258 class GLProcessor : public GrGLGeometryProcessor { | 258 class GLProcessor : public GrGLGeometryProcessor { |
259 public: | 259 public: |
260 GLProcessor(const GrGeometryProcessor&, | 260 GLProcessor(const GrGeometryProcessor&, |
261 const GrBatchTracker&) | 261 const GrBatchTracker&) |
262 : fColor(GrColor_ILLEGAL) {} | 262 : fColor(GrColor_ILLEGAL) {} |
263 | 263 |
264 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ | 264 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
265 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); | 265 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); |
266 GrGLGPBuilder* pb = args.fPB; | 266 GrGLGPBuilder* pb = args.fPB; |
267 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 267 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
268 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 268 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
269 | 269 |
270 // emit attributes | 270 // emit attributes |
271 vsBuilder->emitAttributes(ee); | 271 vsBuilder->emitAttributes(ee); |
272 | 272 |
273 GrGLVertToFrag ellipseOffsets(kVec2f_GrSLType); | 273 GrGLVertToFrag ellipseOffsets(kVec2f_GrSLType); |
274 args.fPB->addVarying("EllipseOffsets", &ellipseOffsets); | 274 args.fPB->addVarying("EllipseOffsets", &ellipseOffsets); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 const BatchTracker& local = bt.cast<BatchTracker>(); | 325 const BatchTracker& local = bt.cast<BatchTracker>(); |
326 const EllipseEdgeEffect& ellipseEffect = gp.cast<EllipseEdgeEffect>(
); | 326 const EllipseEdgeEffect& ellipseEffect = gp.cast<EllipseEdgeEffect>(
); |
327 uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0; | 327 uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0; |
328 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; | 328 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; |
329 key |= ComputePosKey(gp.viewMatrix()) << 2; | 329 key |= ComputePosKey(gp.viewMatrix()) << 2; |
330 b->add32(key << 16 | local.fInputColorType); | 330 b->add32(key << 16 | local.fInputColorType); |
331 } | 331 } |
332 | 332 |
333 virtual void setData(const GrGLProgramDataManager& pdman, | 333 virtual void setData(const GrGLProgramDataManager& pdman, |
334 const GrPrimitiveProcessor& gp, | 334 const GrPrimitiveProcessor& gp, |
335 const GrBatchTracker& bt) SK_OVERRIDE { | 335 const GrBatchTracker& bt) override { |
336 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | 336 this->setUniformViewMatrix(pdman, gp.viewMatrix()); |
337 | 337 |
338 const BatchTracker& local = bt.cast<BatchTracker>(); | 338 const BatchTracker& local = bt.cast<BatchTracker>(); |
339 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { | 339 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { |
340 GrGLfloat c[4]; | 340 GrGLfloat c[4]; |
341 GrColorToRGBAFloat(local.fColor, c); | 341 GrColorToRGBAFloat(local.fColor, c); |
342 pdman.set4fv(fColorUniform, 1, c); | 342 pdman.set4fv(fColorUniform, 1, c); |
343 fColor = local.fColor; | 343 fColor = local.fColor; |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 private: | 347 private: |
348 GrColor fColor; | 348 GrColor fColor; |
349 UniformHandle fColorUniform; | 349 UniformHandle fColorUniform; |
350 | 350 |
351 typedef GrGLGeometryProcessor INHERITED; | 351 typedef GrGLGeometryProcessor INHERITED; |
352 }; | 352 }; |
353 | 353 |
354 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 354 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
355 const GrGLCaps& caps, | 355 const GrGLCaps& caps, |
356 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 356 GrProcessorKeyBuilder* b) const override { |
357 GLProcessor::GenKey(*this, bt, caps, b); | 357 GLProcessor::GenKey(*this, bt, caps, b); |
358 } | 358 } |
359 | 359 |
360 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 360 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
361 const GrGLCaps&) const SK_O
VERRIDE { | 361 const GrGLCaps&) const over
ride { |
362 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 362 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
363 } | 363 } |
364 | 364 |
365 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
SK_OVERRIDE { | 365 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
366 BatchTracker* local = bt->cast<BatchTracker>(); | 366 BatchTracker* local = bt->cast<BatchTracker>(); |
367 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 367 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
368 local->fUsesLocalCoords = init.fUsesLocalCoords; | 368 local->fUsesLocalCoords = init.fUsesLocalCoords; |
369 } | 369 } |
370 | 370 |
371 bool onCanMakeEqual(const GrBatchTracker& m, | 371 bool onCanMakeEqual(const GrBatchTracker& m, |
372 const GrGeometryProcessor& that, | 372 const GrGeometryProcessor& that, |
373 const GrBatchTracker& t) const SK_OVERRIDE { | 373 const GrBatchTracker& t) const override { |
374 const BatchTracker& mine = m.cast<BatchTracker>(); | 374 const BatchTracker& mine = m.cast<BatchTracker>(); |
375 const BatchTracker& theirs = t.cast<BatchTracker>(); | 375 const BatchTracker& theirs = t.cast<BatchTracker>(); |
376 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, | 376 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
377 that, theirs.fUsesLocalCoords) && | 377 that, theirs.fUsesLocalCoords) && |
378 CanCombineOutput(mine.fInputColorType, mine.fColor, | 378 CanCombineOutput(mine.fInputColorType, mine.fColor, |
379 theirs.fInputColorType, theirs.fColor); | 379 theirs.fInputColorType, theirs.fColor); |
380 } | 380 } |
381 | 381 |
382 private: | 382 private: |
383 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 383 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
384 : INHERITED(color, SkMatrix::I(), localMatrix) { | 384 : INHERITED(color, SkMatrix::I(), localMatrix) { |
385 this->initClassID<EllipseEdgeEffect>(); | 385 this->initClassID<EllipseEdgeEffect>(); |
386 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 386 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
387 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", | 387 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", |
388 kVec2f_GrVertexAtt
ribType)); | 388 kVec2f_GrVertexAtt
ribType)); |
389 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", | 389 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", |
390 kVec4f_GrVertexAttr
ibType)); | 390 kVec4f_GrVertexAttr
ibType)); |
391 fStroke = stroke; | 391 fStroke = stroke; |
392 } | 392 } |
393 | 393 |
394 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 394 bool onIsEqual(const GrGeometryProcessor& other) const override { |
395 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); | 395 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); |
396 return eee.fStroke == fStroke; | 396 return eee.fStroke == fStroke; |
397 } | 397 } |
398 | 398 |
399 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { | 399 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
400 out->setUnknownSingleComponent(); | 400 out->setUnknownSingleComponent(); |
401 } | 401 } |
402 | 402 |
403 struct BatchTracker { | 403 struct BatchTracker { |
404 GrGPInput fInputColorType; | 404 GrGPInput fInputColorType; |
405 GrColor fColor; | 405 GrColor fColor; |
406 bool fUsesLocalCoords; | 406 bool fUsesLocalCoords; |
407 }; | 407 }; |
408 | 408 |
409 const Attribute* fInPosition; | 409 const Attribute* fInPosition; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 class DIEllipseEdgeEffect : public GrGeometryProcessor { | 441 class DIEllipseEdgeEffect : public GrGeometryProcessor { |
442 public: | 442 public: |
443 enum Mode { kStroke = 0, kHairline, kFill }; | 443 enum Mode { kStroke = 0, kHairline, kFill }; |
444 | 444 |
445 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, Mode mode) { | 445 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, Mode mode) { |
446 return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode)); | 446 return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode)); |
447 } | 447 } |
448 | 448 |
449 virtual ~DIEllipseEdgeEffect() {} | 449 virtual ~DIEllipseEdgeEffect() {} |
450 | 450 |
451 const char* name() const SK_OVERRIDE { return "DIEllipseEdge"; } | 451 const char* name() const override { return "DIEllipseEdge"; } |
452 | 452 |
453 const Attribute* inPosition() const { return fInPosition; } | 453 const Attribute* inPosition() const { return fInPosition; } |
454 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } | 454 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } |
455 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } | 455 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } |
456 | 456 |
457 inline Mode getMode() const { return fMode; } | 457 inline Mode getMode() const { return fMode; } |
458 | 458 |
459 class GLProcessor : public GrGLGeometryProcessor { | 459 class GLProcessor : public GrGLGeometryProcessor { |
460 public: | 460 public: |
461 GLProcessor(const GrGeometryProcessor&, | 461 GLProcessor(const GrGeometryProcessor&, |
462 const GrBatchTracker&) | 462 const GrBatchTracker&) |
463 : fColor(GrColor_ILLEGAL) {} | 463 : fColor(GrColor_ILLEGAL) {} |
464 | 464 |
465 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ | 465 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
466 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; | 466 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; |
467 GrGLGPBuilder* pb = args.fPB; | 467 GrGLGPBuilder* pb = args.fPB; |
468 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 468 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
469 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 469 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
470 | 470 |
471 // emit attributes | 471 // emit attributes |
472 vsBuilder->emitAttributes(ee); | 472 vsBuilder->emitAttributes(ee); |
473 | 473 |
474 GrGLVertToFrag offsets0(kVec2f_GrSLType); | 474 GrGLVertToFrag offsets0(kVec2f_GrSLType); |
475 args.fPB->addVarying("EllipseOffsets0", &offsets0); | 475 args.fPB->addVarying("EllipseOffsets0", &offsets0); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 const BatchTracker& local = bt.cast<BatchTracker>(); | 540 const BatchTracker& local = bt.cast<BatchTracker>(); |
541 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); | 541 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); |
542 uint16_t key = ellipseEffect.getMode(); | 542 uint16_t key = ellipseEffect.getMode(); |
543 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 << 8 : 0x0; | 543 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 << 8 : 0x0; |
544 key |= ComputePosKey(gp.viewMatrix()) << 9; | 544 key |= ComputePosKey(gp.viewMatrix()) << 9; |
545 b->add32(key << 16 | local.fInputColorType); | 545 b->add32(key << 16 | local.fInputColorType); |
546 } | 546 } |
547 | 547 |
548 virtual void setData(const GrGLProgramDataManager& pdman, | 548 virtual void setData(const GrGLProgramDataManager& pdman, |
549 const GrPrimitiveProcessor& gp, | 549 const GrPrimitiveProcessor& gp, |
550 const GrBatchTracker& bt) SK_OVERRIDE { | 550 const GrBatchTracker& bt) override { |
551 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | 551 this->setUniformViewMatrix(pdman, gp.viewMatrix()); |
552 | 552 |
553 const BatchTracker& local = bt.cast<BatchTracker>(); | 553 const BatchTracker& local = bt.cast<BatchTracker>(); |
554 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { | 554 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { |
555 GrGLfloat c[4]; | 555 GrGLfloat c[4]; |
556 GrColorToRGBAFloat(local.fColor, c); | 556 GrColorToRGBAFloat(local.fColor, c); |
557 pdman.set4fv(fColorUniform, 1, c); | 557 pdman.set4fv(fColorUniform, 1, c); |
558 fColor = local.fColor; | 558 fColor = local.fColor; |
559 } | 559 } |
560 } | 560 } |
561 | 561 |
562 private: | 562 private: |
563 GrColor fColor; | 563 GrColor fColor; |
564 UniformHandle fColorUniform; | 564 UniformHandle fColorUniform; |
565 | 565 |
566 typedef GrGLGeometryProcessor INHERITED; | 566 typedef GrGLGeometryProcessor INHERITED; |
567 }; | 567 }; |
568 | 568 |
569 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 569 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
570 const GrGLCaps& caps, | 570 const GrGLCaps& caps, |
571 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 571 GrProcessorKeyBuilder* b) const override { |
572 GLProcessor::GenKey(*this, bt, caps, b); | 572 GLProcessor::GenKey(*this, bt, caps, b); |
573 } | 573 } |
574 | 574 |
575 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 575 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
576 const GrGLCaps&) const SK_O
VERRIDE { | 576 const GrGLCaps&) const over
ride { |
577 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 577 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
578 } | 578 } |
579 | 579 |
580 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
SK_OVERRIDE { | 580 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
581 BatchTracker* local = bt->cast<BatchTracker>(); | 581 BatchTracker* local = bt->cast<BatchTracker>(); |
582 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 582 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
583 local->fUsesLocalCoords = init.fUsesLocalCoords; | 583 local->fUsesLocalCoords = init.fUsesLocalCoords; |
584 } | 584 } |
585 | 585 |
586 bool onCanMakeEqual(const GrBatchTracker& m, | 586 bool onCanMakeEqual(const GrBatchTracker& m, |
587 const GrGeometryProcessor& that, | 587 const GrGeometryProcessor& that, |
588 const GrBatchTracker& t) const SK_OVERRIDE { | 588 const GrBatchTracker& t) const override { |
589 const BatchTracker& mine = m.cast<BatchTracker>(); | 589 const BatchTracker& mine = m.cast<BatchTracker>(); |
590 const BatchTracker& theirs = t.cast<BatchTracker>(); | 590 const BatchTracker& theirs = t.cast<BatchTracker>(); |
591 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, | 591 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
592 that, theirs.fUsesLocalCoords) && | 592 that, theirs.fUsesLocalCoords) && |
593 CanCombineOutput(mine.fInputColorType, mine.fColor, | 593 CanCombineOutput(mine.fInputColorType, mine.fColor, |
594 theirs.fInputColorType, theirs.fColor); | 594 theirs.fInputColorType, theirs.fColor); |
595 } | 595 } |
596 | 596 |
597 private: | 597 private: |
598 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) | 598 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) |
599 : INHERITED(color, viewMatrix) { | 599 : INHERITED(color, viewMatrix) { |
600 this->initClassID<DIEllipseEdgeEffect>(); | 600 this->initClassID<DIEllipseEdgeEffect>(); |
601 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 601 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
602 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", | 602 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", |
603 kVec2f_GrVertexA
ttribType)); | 603 kVec2f_GrVertexA
ttribType)); |
604 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", | 604 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", |
605 kVec2f_GrVertexA
ttribType)); | 605 kVec2f_GrVertexA
ttribType)); |
606 fMode = mode; | 606 fMode = mode; |
607 } | 607 } |
608 | 608 |
609 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 609 bool onIsEqual(const GrGeometryProcessor& other) const override { |
610 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); | 610 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); |
611 return eee.fMode == fMode; | 611 return eee.fMode == fMode; |
612 } | 612 } |
613 | 613 |
614 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { | 614 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ |
615 out->setUnknownSingleComponent(); | 615 out->setUnknownSingleComponent(); |
616 } | 616 } |
617 | 617 |
618 struct BatchTracker { | 618 struct BatchTracker { |
619 GrGPInput fInputColorType; | 619 GrGPInput fInputColorType; |
620 GrColor fColor; | 620 GrColor fColor; |
621 bool fUsesLocalCoords; | 621 bool fUsesLocalCoords; |
622 }; | 622 }; |
623 | 623 |
624 const Attribute* fInPosition; | 624 const Attribute* fInPosition; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 SkScalar fInnerRadius; | 692 SkScalar fInnerRadius; |
693 SkScalar fOuterRadius; | 693 SkScalar fOuterRadius; |
694 bool fStroke; | 694 bool fStroke; |
695 SkRect fDevBounds; | 695 SkRect fDevBounds; |
696 }; | 696 }; |
697 | 697 |
698 static GrBatch* Create(const Geometry& geometry) { | 698 static GrBatch* Create(const Geometry& geometry) { |
699 return SkNEW_ARGS(CircleBatch, (geometry)); | 699 return SkNEW_ARGS(CircleBatch, (geometry)); |
700 } | 700 } |
701 | 701 |
702 const char* name() const SK_OVERRIDE { return "CircleBatch"; } | 702 const char* name() const override { return "CircleBatch"; } |
703 | 703 |
704 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 704 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
705 // When this is called on a batch, there is only one geometry bundle | 705 // When this is called on a batch, there is only one geometry bundle |
706 out->setKnownFourComponents(fGeoData[0].fColor); | 706 out->setKnownFourComponents(fGeoData[0].fColor); |
707 } | 707 } |
708 | 708 |
709 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 709 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
710 out->setUnknownSingleComponent(); | 710 out->setUnknownSingleComponent(); |
711 } | 711 } |
712 | 712 |
713 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 713 void initBatchTracker(const GrPipelineInfo& init) override { |
714 // Handle any color overrides | 714 // Handle any color overrides |
715 if (init.fColorIgnored) { | 715 if (init.fColorIgnored) { |
716 fGeoData[0].fColor = GrColor_ILLEGAL; | 716 fGeoData[0].fColor = GrColor_ILLEGAL; |
717 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 717 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
718 fGeoData[0].fColor = init.fOverrideColor; | 718 fGeoData[0].fColor = init.fOverrideColor; |
719 } | 719 } |
720 | 720 |
721 // setup batch properties | 721 // setup batch properties |
722 fBatch.fColorIgnored = init.fColorIgnored; | 722 fBatch.fColorIgnored = init.fColorIgnored; |
723 fBatch.fColor = fGeoData[0].fColor; | 723 fBatch.fColor = fGeoData[0].fColor; |
724 fBatch.fStroke = fGeoData[0].fStroke; | 724 fBatch.fStroke = fGeoData[0].fStroke; |
725 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 725 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
726 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 726 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
727 } | 727 } |
728 | 728 |
729 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 729 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
730 SkMatrix invert; | 730 SkMatrix invert; |
731 if (!this->viewMatrix().invert(&invert)) { | 731 if (!this->viewMatrix().invert(&invert)) { |
732 return; | 732 return; |
733 } | 733 } |
734 | 734 |
735 // Setup geometry processor | 735 // Setup geometry processor |
736 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 736 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
737 this->stro
ke(), | 737 this->stro
ke(), |
738 invert)); | 738 invert)); |
739 | 739 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 } | 829 } |
830 | 830 |
831 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 831 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
832 | 832 |
833 private: | 833 private: |
834 CircleBatch(const Geometry& geometry) { | 834 CircleBatch(const Geometry& geometry) { |
835 this->initClassID<CircleBatch>(); | 835 this->initClassID<CircleBatch>(); |
836 fGeoData.push_back(geometry); | 836 fGeoData.push_back(geometry); |
837 } | 837 } |
838 | 838 |
839 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 839 bool onCombineIfPossible(GrBatch* t) override { |
840 CircleBatch* that = t->cast<CircleBatch>(); | 840 CircleBatch* that = t->cast<CircleBatch>(); |
841 | 841 |
842 // TODO use vertex color to avoid breaking batches | 842 // TODO use vertex color to avoid breaking batches |
843 if (this->color() != that->color()) { | 843 if (this->color() != that->color()) { |
844 return false; | 844 return false; |
845 } | 845 } |
846 | 846 |
847 if (this->stroke() != that->stroke()) { | 847 if (this->stroke() != that->stroke()) { |
848 return false; | 848 return false; |
849 } | 849 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 SkScalar fInnerXRadius; | 948 SkScalar fInnerXRadius; |
949 SkScalar fInnerYRadius; | 949 SkScalar fInnerYRadius; |
950 bool fStroke; | 950 bool fStroke; |
951 SkRect fDevBounds; | 951 SkRect fDevBounds; |
952 }; | 952 }; |
953 | 953 |
954 static GrBatch* Create(const Geometry& geometry) { | 954 static GrBatch* Create(const Geometry& geometry) { |
955 return SkNEW_ARGS(EllipseBatch, (geometry)); | 955 return SkNEW_ARGS(EllipseBatch, (geometry)); |
956 } | 956 } |
957 | 957 |
958 const char* name() const SK_OVERRIDE { return "EllipseBatch"; } | 958 const char* name() const override { return "EllipseBatch"; } |
959 | 959 |
960 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 960 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
961 // When this is called on a batch, there is only one geometry bundle | 961 // When this is called on a batch, there is only one geometry bundle |
962 out->setKnownFourComponents(fGeoData[0].fColor); | 962 out->setKnownFourComponents(fGeoData[0].fColor); |
963 } | 963 } |
964 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 964 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
965 out->setUnknownSingleComponent(); | 965 out->setUnknownSingleComponent(); |
966 } | 966 } |
967 | 967 |
968 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 968 void initBatchTracker(const GrPipelineInfo& init) override { |
969 // Handle any color overrides | 969 // Handle any color overrides |
970 if (init.fColorIgnored) { | 970 if (init.fColorIgnored) { |
971 fGeoData[0].fColor = GrColor_ILLEGAL; | 971 fGeoData[0].fColor = GrColor_ILLEGAL; |
972 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 972 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
973 fGeoData[0].fColor = init.fOverrideColor; | 973 fGeoData[0].fColor = init.fOverrideColor; |
974 } | 974 } |
975 | 975 |
976 // setup batch properties | 976 // setup batch properties |
977 fBatch.fColorIgnored = init.fColorIgnored; | 977 fBatch.fColorIgnored = init.fColorIgnored; |
978 fBatch.fColor = fGeoData[0].fColor; | 978 fBatch.fColor = fGeoData[0].fColor; |
979 fBatch.fStroke = fGeoData[0].fStroke; | 979 fBatch.fStroke = fGeoData[0].fStroke; |
980 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 980 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
981 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 981 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
982 } | 982 } |
983 | 983 |
984 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 984 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
985 SkMatrix invert; | 985 SkMatrix invert; |
986 if (!this->viewMatrix().invert(&invert)) { | 986 if (!this->viewMatrix().invert(&invert)) { |
987 return; | 987 return; |
988 } | 988 } |
989 | 989 |
990 // Setup geometry processor | 990 // Setup geometry processor |
991 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 991 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
992 this->str
oke(), | 992 this->str
oke(), |
993 invert)); | 993 invert)); |
994 | 994 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 } | 1089 } |
1090 | 1090 |
1091 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1091 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1092 | 1092 |
1093 private: | 1093 private: |
1094 EllipseBatch(const Geometry& geometry) { | 1094 EllipseBatch(const Geometry& geometry) { |
1095 this->initClassID<EllipseBatch>(); | 1095 this->initClassID<EllipseBatch>(); |
1096 fGeoData.push_back(geometry); | 1096 fGeoData.push_back(geometry); |
1097 } | 1097 } |
1098 | 1098 |
1099 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 1099 bool onCombineIfPossible(GrBatch* t) override { |
1100 EllipseBatch* that = t->cast<EllipseBatch>(); | 1100 EllipseBatch* that = t->cast<EllipseBatch>(); |
1101 | 1101 |
1102 // TODO use vertex color to avoid breaking batches | 1102 // TODO use vertex color to avoid breaking batches |
1103 if (this->color() != that->color()) { | 1103 if (this->color() != that->color()) { |
1104 return false; | 1104 return false; |
1105 } | 1105 } |
1106 | 1106 |
1107 if (this->stroke() != that->stroke()) { | 1107 if (this->stroke() != that->stroke()) { |
1108 return false; | 1108 return false; |
1109 } | 1109 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 SkScalar fGeoDx; | 1249 SkScalar fGeoDx; |
1250 SkScalar fGeoDy; | 1250 SkScalar fGeoDy; |
1251 DIEllipseEdgeEffect::Mode fMode; | 1251 DIEllipseEdgeEffect::Mode fMode; |
1252 SkRect fDevBounds; | 1252 SkRect fDevBounds; |
1253 }; | 1253 }; |
1254 | 1254 |
1255 static GrBatch* Create(const Geometry& geometry) { | 1255 static GrBatch* Create(const Geometry& geometry) { |
1256 return SkNEW_ARGS(DIEllipseBatch, (geometry)); | 1256 return SkNEW_ARGS(DIEllipseBatch, (geometry)); |
1257 } | 1257 } |
1258 | 1258 |
1259 const char* name() const SK_OVERRIDE { return "DIEllipseBatch"; } | 1259 const char* name() const override { return "DIEllipseBatch"; } |
1260 | 1260 |
1261 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 1261 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1262 // When this is called on a batch, there is only one geometry bundle | 1262 // When this is called on a batch, there is only one geometry bundle |
1263 out->setKnownFourComponents(fGeoData[0].fColor); | 1263 out->setKnownFourComponents(fGeoData[0].fColor); |
1264 } | 1264 } |
1265 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 1265 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1266 out->setUnknownSingleComponent(); | 1266 out->setUnknownSingleComponent(); |
1267 } | 1267 } |
1268 | 1268 |
1269 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 1269 void initBatchTracker(const GrPipelineInfo& init) override { |
1270 // Handle any color overrides | 1270 // Handle any color overrides |
1271 if (init.fColorIgnored) { | 1271 if (init.fColorIgnored) { |
1272 fGeoData[0].fColor = GrColor_ILLEGAL; | 1272 fGeoData[0].fColor = GrColor_ILLEGAL; |
1273 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 1273 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
1274 fGeoData[0].fColor = init.fOverrideColor; | 1274 fGeoData[0].fColor = init.fOverrideColor; |
1275 } | 1275 } |
1276 | 1276 |
1277 // setup batch properties | 1277 // setup batch properties |
1278 fBatch.fColorIgnored = init.fColorIgnored; | 1278 fBatch.fColorIgnored = init.fColorIgnored; |
1279 fBatch.fColor = fGeoData[0].fColor; | 1279 fBatch.fColor = fGeoData[0].fColor; |
1280 fBatch.fMode = fGeoData[0].fMode; | 1280 fBatch.fMode = fGeoData[0].fMode; |
1281 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 1281 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1282 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 1282 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1283 } | 1283 } |
1284 | 1284 |
1285 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1285 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1286 // Setup geometry processor | 1286 // Setup geometry processor |
1287 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), | 1287 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), |
1288 this->v
iewMatrix(), | 1288 this->v
iewMatrix(), |
1289 this->m
ode())); | 1289 this->m
ode())); |
1290 | 1290 |
1291 batchTarget->initDraw(gp, pipeline); | 1291 batchTarget->initDraw(gp, pipeline); |
1292 | 1292 |
1293 // TODO this is hacky, but the only way we have to initialize the GP is
to use the | 1293 // TODO this is hacky, but the only way we have to initialize the GP is
to use the |
1294 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch | 1294 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch |
1295 // everywhere we can remove this nastiness | 1295 // everywhere we can remove this nastiness |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 } | 1381 } |
1382 | 1382 |
1383 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1383 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1384 | 1384 |
1385 private: | 1385 private: |
1386 DIEllipseBatch(const Geometry& geometry) { | 1386 DIEllipseBatch(const Geometry& geometry) { |
1387 this->initClassID<DIEllipseBatch>(); | 1387 this->initClassID<DIEllipseBatch>(); |
1388 fGeoData.push_back(geometry); | 1388 fGeoData.push_back(geometry); |
1389 } | 1389 } |
1390 | 1390 |
1391 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 1391 bool onCombineIfPossible(GrBatch* t) override { |
1392 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); | 1392 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); |
1393 | 1393 |
1394 // TODO use vertex color to avoid breaking batches | 1394 // TODO use vertex color to avoid breaking batches |
1395 if (this->color() != that->color()) { | 1395 if (this->color() != that->color()) { |
1396 return false; | 1396 return false; |
1397 } | 1397 } |
1398 | 1398 |
1399 if (this->mode() != that->mode()) { | 1399 if (this->mode() != that->mode()) { |
1400 return false; | 1400 return false; |
1401 } | 1401 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 SkScalar fInnerRadius; | 1636 SkScalar fInnerRadius; |
1637 SkScalar fOuterRadius; | 1637 SkScalar fOuterRadius; |
1638 bool fStroke; | 1638 bool fStroke; |
1639 SkRect fDevBounds; | 1639 SkRect fDevBounds; |
1640 }; | 1640 }; |
1641 | 1641 |
1642 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { | 1642 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { |
1643 return SkNEW_ARGS(RRectCircleRendererBatch, (geometry, indexBuffer)); | 1643 return SkNEW_ARGS(RRectCircleRendererBatch, (geometry, indexBuffer)); |
1644 } | 1644 } |
1645 | 1645 |
1646 const char* name() const SK_OVERRIDE { return "RRectCircleBatch"; } | 1646 const char* name() const override { return "RRectCircleBatch"; } |
1647 | 1647 |
1648 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 1648 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1649 // When this is called on a batch, there is only one geometry bundle | 1649 // When this is called on a batch, there is only one geometry bundle |
1650 out->setKnownFourComponents(fGeoData[0].fColor); | 1650 out->setKnownFourComponents(fGeoData[0].fColor); |
1651 } | 1651 } |
1652 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 1652 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1653 out->setUnknownSingleComponent(); | 1653 out->setUnknownSingleComponent(); |
1654 } | 1654 } |
1655 | 1655 |
1656 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 1656 void initBatchTracker(const GrPipelineInfo& init) override { |
1657 // Handle any color overrides | 1657 // Handle any color overrides |
1658 if (init.fColorIgnored) { | 1658 if (init.fColorIgnored) { |
1659 fGeoData[0].fColor = GrColor_ILLEGAL; | 1659 fGeoData[0].fColor = GrColor_ILLEGAL; |
1660 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 1660 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
1661 fGeoData[0].fColor = init.fOverrideColor; | 1661 fGeoData[0].fColor = init.fOverrideColor; |
1662 } | 1662 } |
1663 | 1663 |
1664 // setup batch properties | 1664 // setup batch properties |
1665 fBatch.fColorIgnored = init.fColorIgnored; | 1665 fBatch.fColorIgnored = init.fColorIgnored; |
1666 fBatch.fColor = fGeoData[0].fColor; | 1666 fBatch.fColor = fGeoData[0].fColor; |
1667 fBatch.fStroke = fGeoData[0].fStroke; | 1667 fBatch.fStroke = fGeoData[0].fStroke; |
1668 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 1668 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1669 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 1669 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1670 } | 1670 } |
1671 | 1671 |
1672 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1672 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1673 // reset to device coordinates | 1673 // reset to device coordinates |
1674 SkMatrix invert; | 1674 SkMatrix invert; |
1675 if (!this->viewMatrix().invert(&invert)) { | 1675 if (!this->viewMatrix().invert(&invert)) { |
1676 SkDebugf("Failed to invert\n"); | 1676 SkDebugf("Failed to invert\n"); |
1677 return; | 1677 return; |
1678 } | 1678 } |
1679 | 1679 |
1680 // Setup geometry processor | 1680 // Setup geometry processor |
1681 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 1681 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
1682 this->stro
ke(), | 1682 this->stro
ke(), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 | 1789 |
1790 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1790 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1791 | 1791 |
1792 private: | 1792 private: |
1793 RRectCircleRendererBatch(const Geometry& geometry, const GrIndexBuffer* inde
xBuffer) | 1793 RRectCircleRendererBatch(const Geometry& geometry, const GrIndexBuffer* inde
xBuffer) |
1794 : fIndexBuffer(indexBuffer) { | 1794 : fIndexBuffer(indexBuffer) { |
1795 this->initClassID<RRectCircleRendererBatch>(); | 1795 this->initClassID<RRectCircleRendererBatch>(); |
1796 fGeoData.push_back(geometry); | 1796 fGeoData.push_back(geometry); |
1797 } | 1797 } |
1798 | 1798 |
1799 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 1799 bool onCombineIfPossible(GrBatch* t) override { |
1800 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); | 1800 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); |
1801 | 1801 |
1802 // TODO use vertex color to avoid breaking batches | 1802 // TODO use vertex color to avoid breaking batches |
1803 if (this->color() != that->color()) { | 1803 if (this->color() != that->color()) { |
1804 return false; | 1804 return false; |
1805 } | 1805 } |
1806 | 1806 |
1807 if (this->stroke() != that->stroke()) { | 1807 if (this->stroke() != that->stroke()) { |
1808 return false; | 1808 return false; |
1809 } | 1809 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 SkScalar fInnerXRadius; | 1845 SkScalar fInnerXRadius; |
1846 SkScalar fInnerYRadius; | 1846 SkScalar fInnerYRadius; |
1847 bool fStroke; | 1847 bool fStroke; |
1848 SkRect fDevBounds; | 1848 SkRect fDevBounds; |
1849 }; | 1849 }; |
1850 | 1850 |
1851 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { | 1851 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { |
1852 return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry, indexBuffer)); | 1852 return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry, indexBuffer)); |
1853 } | 1853 } |
1854 | 1854 |
1855 const char* name() const SK_OVERRIDE { return "RRectEllipseRendererBatch"; } | 1855 const char* name() const override { return "RRectEllipseRendererBatch"; } |
1856 | 1856 |
1857 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 1857 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1858 // When this is called on a batch, there is only one geometry bundle | 1858 // When this is called on a batch, there is only one geometry bundle |
1859 out->setKnownFourComponents(fGeoData[0].fColor); | 1859 out->setKnownFourComponents(fGeoData[0].fColor); |
1860 } | 1860 } |
1861 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 1861 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1862 out->setUnknownSingleComponent(); | 1862 out->setUnknownSingleComponent(); |
1863 } | 1863 } |
1864 | 1864 |
1865 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 1865 void initBatchTracker(const GrPipelineInfo& init) override { |
1866 // Handle any color overrides | 1866 // Handle any color overrides |
1867 if (init.fColorIgnored) { | 1867 if (init.fColorIgnored) { |
1868 fGeoData[0].fColor = GrColor_ILLEGAL; | 1868 fGeoData[0].fColor = GrColor_ILLEGAL; |
1869 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 1869 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
1870 fGeoData[0].fColor = init.fOverrideColor; | 1870 fGeoData[0].fColor = init.fOverrideColor; |
1871 } | 1871 } |
1872 | 1872 |
1873 // setup batch properties | 1873 // setup batch properties |
1874 fBatch.fColorIgnored = init.fColorIgnored; | 1874 fBatch.fColorIgnored = init.fColorIgnored; |
1875 fBatch.fColor = fGeoData[0].fColor; | 1875 fBatch.fColor = fGeoData[0].fColor; |
1876 fBatch.fStroke = fGeoData[0].fStroke; | 1876 fBatch.fStroke = fGeoData[0].fStroke; |
1877 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 1877 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1878 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 1878 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1879 } | 1879 } |
1880 | 1880 |
1881 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1881 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1882 // reset to device coordinates | 1882 // reset to device coordinates |
1883 SkMatrix invert; | 1883 SkMatrix invert; |
1884 if (!this->viewMatrix().invert(&invert)) { | 1884 if (!this->viewMatrix().invert(&invert)) { |
1885 SkDebugf("Failed to invert\n"); | 1885 SkDebugf("Failed to invert\n"); |
1886 return; | 1886 return; |
1887 } | 1887 } |
1888 | 1888 |
1889 // Setup geometry processor | 1889 // Setup geometry processor |
1890 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 1890 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
1891 this->str
oke(), | 1891 this->str
oke(), |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 | 2008 |
2009 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 2009 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
2010 | 2010 |
2011 private: | 2011 private: |
2012 RRectEllipseRendererBatch(const Geometry& geometry, const GrIndexBuffer* ind
exBuffer) | 2012 RRectEllipseRendererBatch(const Geometry& geometry, const GrIndexBuffer* ind
exBuffer) |
2013 : fIndexBuffer(indexBuffer) { | 2013 : fIndexBuffer(indexBuffer) { |
2014 this->initClassID<RRectEllipseRendererBatch>(); | 2014 this->initClassID<RRectEllipseRendererBatch>(); |
2015 fGeoData.push_back(geometry); | 2015 fGeoData.push_back(geometry); |
2016 } | 2016 } |
2017 | 2017 |
2018 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 2018 bool onCombineIfPossible(GrBatch* t) override { |
2019 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); | 2019 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); |
2020 | 2020 |
2021 // TODO use vertex color to avoid breaking batches | 2021 // TODO use vertex color to avoid breaking batches |
2022 if (this->color() != that->color()) { | 2022 if (this->color() != that->color()) { |
2023 return false; | 2023 return false; |
2024 } | 2024 } |
2025 | 2025 |
2026 if (this->stroke() != that->stroke()) { | 2026 if (this->stroke() != that->stroke()) { |
2027 return false; | 2027 return false; |
2028 } | 2028 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 geometry.fInnerXRadius = innerXRadius; | 2220 geometry.fInnerXRadius = innerXRadius; |
2221 geometry.fInnerYRadius = innerYRadius; | 2221 geometry.fInnerYRadius = innerYRadius; |
2222 geometry.fStroke = isStrokeOnly; | 2222 geometry.fStroke = isStrokeOnly; |
2223 geometry.fDevBounds = bounds; | 2223 geometry.fDevBounds = bounds; |
2224 | 2224 |
2225 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2225 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
2226 target->drawBatch(pipelineBuilder, batch, &bounds); | 2226 target->drawBatch(pipelineBuilder, batch, &bounds); |
2227 } | 2227 } |
2228 return true; | 2228 return true; |
2229 } | 2229 } |
OLD | NEW |