| 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 "GrProcessor.h" | 10 #include "GrProcessor.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 GLProcessor::GenKey(*this, bt, caps, b); | 150 GLProcessor::GenKey(*this, bt, caps, b); |
| 151 } | 151 } |
| 152 | 152 |
| 153 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 153 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { |
| 154 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 154 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 157 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 158 BatchTracker* local = bt->cast<BatchTracker>(); | 158 BatchTracker* local = bt->cast<BatchTracker>(); |
| 159 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 159 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 160 | 160 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool onCanMakeEqual(const GrBatchTracker& m, const GrBatchTracker& t) const
SK_OVERRIDE { | 163 bool onCanMakeEqual(const GrBatchTracker& m, |
| 164 const GrGeometryProcessor& that, |
| 165 const GrBatchTracker& t) const SK_OVERRIDE { |
| 164 const BatchTracker& mine = m.cast<BatchTracker>(); | 166 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 165 const BatchTracker& theirs = t.cast<BatchTracker>(); | 167 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 166 return CanCombineOutput(mine.fInputColorType, mine.fColor, | 168 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 169 that, theirs.fUsesLocalCoords) && |
| 170 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 167 theirs.fInputColorType, theirs.fColor); | 171 theirs.fInputColorType, theirs.fColor); |
| 168 } | 172 } |
| 169 | 173 |
| 170 private: | 174 private: |
| 171 CircleEdgeEffect(GrColor color, bool stroke) : INHERITED(color) { | 175 CircleEdgeEffect(GrColor color, bool stroke) : INHERITED(color) { |
| 172 this->initClassID<CircleEdgeEffect>(); | 176 this->initClassID<CircleEdgeEffect>(); |
| 173 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 177 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
| 174 fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge", | 178 fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge", |
| 175 kVec4f_GrVertexAttrib
Type)); | 179 kVec4f_GrVertexAttrib
Type)); |
| 176 fStroke = stroke; | 180 fStroke = stroke; |
| 177 } | 181 } |
| 178 | 182 |
| 179 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 183 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 180 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); | 184 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); |
| 181 return cee.fStroke == fStroke; | 185 return cee.fStroke == fStroke; |
| 182 } | 186 } |
| 183 | 187 |
| 184 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 188 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
| 185 out->setUnknownSingleComponent(); | 189 out->setUnknownSingleComponent(); |
| 186 } | 190 } |
| 187 | 191 |
| 188 struct BatchTracker { | 192 struct BatchTracker { |
| 189 GrGPInput fInputColorType; | 193 GrGPInput fInputColorType; |
| 190 GrColor fColor; | 194 GrColor fColor; |
| 195 bool fUsesLocalCoords; |
| 191 }; | 196 }; |
| 192 | 197 |
| 193 const GrAttribute* fInPosition; | 198 const GrAttribute* fInPosition; |
| 194 const GrAttribute* fInCircleEdge; | 199 const GrAttribute* fInCircleEdge; |
| 195 bool fStroke; | 200 bool fStroke; |
| 196 | 201 |
| 197 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 202 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 198 | 203 |
| 199 typedef GrGeometryProcessor INHERITED; | 204 typedef GrGeometryProcessor INHERITED; |
| 200 }; | 205 }; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 GLProcessor::GenKey(*this, bt, caps, b); | 334 GLProcessor::GenKey(*this, bt, caps, b); |
| 330 } | 335 } |
| 331 | 336 |
| 332 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 337 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { |
| 333 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 338 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 334 } | 339 } |
| 335 | 340 |
| 336 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 341 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 337 BatchTracker* local = bt->cast<BatchTracker>(); | 342 BatchTracker* local = bt->cast<BatchTracker>(); |
| 338 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 343 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 344 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 339 } | 345 } |
| 340 | 346 |
| 341 bool onCanMakeEqual(const GrBatchTracker& m, const GrBatchTracker& t) const
SK_OVERRIDE { | 347 bool onCanMakeEqual(const GrBatchTracker& m, |
| 348 const GrGeometryProcessor& that, |
| 349 const GrBatchTracker& t) const SK_OVERRIDE { |
| 342 const BatchTracker& mine = m.cast<BatchTracker>(); | 350 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 343 const BatchTracker& theirs = t.cast<BatchTracker>(); | 351 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 344 return CanCombineOutput(mine.fInputColorType, mine.fColor, | 352 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 353 that, theirs.fUsesLocalCoords) && |
| 354 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 345 theirs.fInputColorType, theirs.fColor); | 355 theirs.fInputColorType, theirs.fColor); |
| 346 } | 356 } |
| 347 | 357 |
| 348 private: | 358 private: |
| 349 EllipseEdgeEffect(GrColor color, bool stroke) : INHERITED(color) { | 359 EllipseEdgeEffect(GrColor color, bool stroke) : INHERITED(color) { |
| 350 this->initClassID<EllipseEdgeEffect>(); | 360 this->initClassID<EllipseEdgeEffect>(); |
| 351 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 361 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
| 352 fInEllipseOffset = &this->addVertexAttrib(GrAttribute("inEllipseOffset", | 362 fInEllipseOffset = &this->addVertexAttrib(GrAttribute("inEllipseOffset", |
| 353 kVec2f_GrVertexAtt
ribType)); | 363 kVec2f_GrVertexAtt
ribType)); |
| 354 fInEllipseRadii = &this->addVertexAttrib(GrAttribute("inEllipseRadii", | 364 fInEllipseRadii = &this->addVertexAttrib(GrAttribute("inEllipseRadii", |
| 355 kVec4f_GrVertexAttr
ibType)); | 365 kVec4f_GrVertexAttr
ibType)); |
| 356 fStroke = stroke; | 366 fStroke = stroke; |
| 357 } | 367 } |
| 358 | 368 |
| 359 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 369 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 360 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); | 370 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); |
| 361 return eee.fStroke == fStroke; | 371 return eee.fStroke == fStroke; |
| 362 } | 372 } |
| 363 | 373 |
| 364 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 374 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
| 365 out->setUnknownSingleComponent(); | 375 out->setUnknownSingleComponent(); |
| 366 } | 376 } |
| 367 | 377 |
| 368 struct BatchTracker { | 378 struct BatchTracker { |
| 369 GrGPInput fInputColorType; | 379 GrGPInput fInputColorType; |
| 370 GrColor fColor; | 380 GrColor fColor; |
| 381 bool fUsesLocalCoords; |
| 371 }; | 382 }; |
| 372 | 383 |
| 373 const GrAttribute* fInPosition; | 384 const GrAttribute* fInPosition; |
| 374 const GrAttribute* fInEllipseOffset; | 385 const GrAttribute* fInEllipseOffset; |
| 375 const GrAttribute* fInEllipseRadii; | 386 const GrAttribute* fInEllipseRadii; |
| 376 bool fStroke; | 387 bool fStroke; |
| 377 | 388 |
| 378 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 389 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 379 | 390 |
| 380 typedef GrGeometryProcessor INHERITED; | 391 typedef GrGeometryProcessor INHERITED; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 GLProcessor::GenKey(*this, bt, caps, b); | 538 GLProcessor::GenKey(*this, bt, caps, b); |
| 528 } | 539 } |
| 529 | 540 |
| 530 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 541 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { |
| 531 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 542 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 532 } | 543 } |
| 533 | 544 |
| 534 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 545 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 535 BatchTracker* local = bt->cast<BatchTracker>(); | 546 BatchTracker* local = bt->cast<BatchTracker>(); |
| 536 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 547 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 548 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 537 } | 549 } |
| 538 | 550 |
| 539 bool onCanMakeEqual(const GrBatchTracker& m, const GrBatchTracker& t) const
SK_OVERRIDE { | 551 bool onCanMakeEqual(const GrBatchTracker& m, |
| 552 const GrGeometryProcessor& that, |
| 553 const GrBatchTracker& t) const SK_OVERRIDE { |
| 540 const BatchTracker& mine = m.cast<BatchTracker>(); | 554 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 541 const BatchTracker& theirs = t.cast<BatchTracker>(); | 555 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 542 return CanCombineOutput(mine.fInputColorType, mine.fColor, | 556 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 557 that, theirs.fUsesLocalCoords) && |
| 558 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 543 theirs.fInputColorType, theirs.fColor); | 559 theirs.fInputColorType, theirs.fColor); |
| 544 } | 560 } |
| 545 | 561 |
| 546 private: | 562 private: |
| 547 DIEllipseEdgeEffect(GrColor color, Mode mode) : INHERITED(color) { | 563 DIEllipseEdgeEffect(GrColor color, Mode mode) : INHERITED(color) { |
| 548 this->initClassID<DIEllipseEdgeEffect>(); | 564 this->initClassID<DIEllipseEdgeEffect>(); |
| 549 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 565 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
| 550 fInEllipseOffsets0 = &this->addVertexAttrib(GrAttribute("inEllipseOffset
s0", | 566 fInEllipseOffsets0 = &this->addVertexAttrib(GrAttribute("inEllipseOffset
s0", |
| 551 kVec2f_GrVertexA
ttribType)); | 567 kVec2f_GrVertexA
ttribType)); |
| 552 fInEllipseOffsets1 = &this->addVertexAttrib(GrAttribute("inEllipseOffset
s1", | 568 fInEllipseOffsets1 = &this->addVertexAttrib(GrAttribute("inEllipseOffset
s1", |
| 553 kVec2f_GrVertexA
ttribType)); | 569 kVec2f_GrVertexA
ttribType)); |
| 554 fMode = mode; | 570 fMode = mode; |
| 555 } | 571 } |
| 556 | 572 |
| 557 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 573 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 558 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); | 574 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); |
| 559 return eee.fMode == fMode; | 575 return eee.fMode == fMode; |
| 560 } | 576 } |
| 561 | 577 |
| 562 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 578 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
| 563 out->setUnknownSingleComponent(); | 579 out->setUnknownSingleComponent(); |
| 564 } | 580 } |
| 565 | 581 |
| 566 struct BatchTracker { | 582 struct BatchTracker { |
| 567 GrGPInput fInputColorType; | 583 GrGPInput fInputColorType; |
| 568 GrColor fColor; | 584 GrColor fColor; |
| 585 bool fUsesLocalCoords; |
| 569 }; | 586 }; |
| 570 | 587 |
| 571 const GrAttribute* fInPosition; | 588 const GrAttribute* fInPosition; |
| 572 const GrAttribute* fInEllipseOffsets0; | 589 const GrAttribute* fInEllipseOffsets0; |
| 573 const GrAttribute* fInEllipseOffsets1; | 590 const GrAttribute* fInEllipseOffsets1; |
| 574 Mode fMode; | 591 Mode fMode; |
| 575 | 592 |
| 576 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 593 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 577 | 594 |
| 578 typedef GrGeometryProcessor INHERITED; | 595 typedef GrGeometryProcessor INHERITED; |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : | 1360 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : |
| 1344 SK_ARRAY_COUNT(gRRectIndices); | 1361 SK_ARRAY_COUNT(gRRectIndices); |
| 1345 target->setIndexSourceToBuffer(indexBuffer); | 1362 target->setIndexSourceToBuffer(indexBuffer); |
| 1346 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy
pe, 1, 16, indexCnt, | 1363 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy
pe, 1, 16, indexCnt, |
| 1347 &bounds); | 1364 &bounds); |
| 1348 } | 1365 } |
| 1349 | 1366 |
| 1350 target->resetIndexSource(); | 1367 target->resetIndexSource(); |
| 1351 return true; | 1368 return true; |
| 1352 } | 1369 } |
| OLD | NEW |