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 "GrBezierEffect.h" | 8 #include "GrBezierEffect.h" |
9 | 9 |
10 #include "gl/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) | 193 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) |
194 : INHERITED(color, viewMatrix, localMatrix) | 194 : INHERITED(color, viewMatrix, localMatrix) |
195 , fCoverageScale(coverage) | 195 , fCoverageScale(coverage) |
196 , fEdgeType(edgeType) { | 196 , fEdgeType(edgeType) { |
197 this->initClassID<GrConicEffect>(); | 197 this->initClassID<GrConicEffect>(); |
198 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 198 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
199 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", | 199 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", |
200 kVec4f_GrVertexAttribTyp
e)); | 200 kVec4f_GrVertexAttribTyp
e)); |
201 } | 201 } |
202 | 202 |
| 203 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
| 204 const GrConicEffect& ce = other.cast<GrConicEffect>(); |
| 205 return (ce.fEdgeType == fEdgeType); |
| 206 } |
| 207 |
203 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { | 208 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { |
204 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); | 209 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); |
205 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); | 210 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); |
206 local->fCoverageScale = fCoverageScale; | 211 local->fCoverageScale = fCoverageScale; |
207 local->fUsesLocalCoords = init.fUsesLocalCoords; | 212 local->fUsesLocalCoords = init.fUsesLocalCoords; |
208 } | 213 } |
209 | 214 |
| 215 bool GrConicEffect::onCanMakeEqual(const GrBatchTracker& m, |
| 216 const GrGeometryProcessor& that, |
| 217 const GrBatchTracker& t) const { |
| 218 const ConicBatchTracker& mine = m.cast<ConicBatchTracker>(); |
| 219 const ConicBatchTracker& theirs = t.cast<ConicBatchTracker>(); |
| 220 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 221 that, theirs.fUsesLocalCoords) && |
| 222 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 223 theirs.fInputColorType, theirs.fColor) && |
| 224 mine.fCoverageScale == theirs.fCoverageScale; |
| 225 } |
| 226 |
210 ////////////////////////////////////////////////////////////////////////////// | 227 ////////////////////////////////////////////////////////////////////////////// |
211 | 228 |
212 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); | 229 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); |
213 | 230 |
214 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, | 231 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, |
215 GrContext*, | 232 GrContext*, |
216 const GrDrawTargetCaps& caps, | 233 const GrDrawTargetCaps& caps, |
217 GrTexture*[]) { | 234 GrTexture*[]) { |
218 GrGeometryProcessor* gp; | 235 GrGeometryProcessor* gp; |
219 do { | 236 do { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) | 414 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) |
398 : INHERITED(color, viewMatrix, localMatrix) | 415 : INHERITED(color, viewMatrix, localMatrix) |
399 , fCoverageScale(coverage) | 416 , fCoverageScale(coverage) |
400 , fEdgeType(edgeType) { | 417 , fEdgeType(edgeType) { |
401 this->initClassID<GrQuadEffect>(); | 418 this->initClassID<GrQuadEffect>(); |
402 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 419 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
403 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", | 420 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", |
404 kVec4f_GrVertexAttribTyp
e)); | 421 kVec4f_GrVertexAttribTyp
e)); |
405 } | 422 } |
406 | 423 |
| 424 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const { |
| 425 const GrQuadEffect& ce = other.cast<GrQuadEffect>(); |
| 426 return (ce.fEdgeType == fEdgeType); |
| 427 } |
| 428 |
407 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in
it) const { | 429 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in
it) const { |
408 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); | 430 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); |
409 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); | 431 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); |
410 local->fCoverageScale = fCoverageScale; | 432 local->fCoverageScale = fCoverageScale; |
411 local->fUsesLocalCoords = init.fUsesLocalCoords; | 433 local->fUsesLocalCoords = init.fUsesLocalCoords; |
412 } | 434 } |
413 | 435 |
| 436 bool GrQuadEffect::onCanMakeEqual(const GrBatchTracker& m, |
| 437 const GrGeometryProcessor& that, |
| 438 const GrBatchTracker& t) const { |
| 439 const QuadBatchTracker& mine = m.cast<QuadBatchTracker>(); |
| 440 const QuadBatchTracker& theirs = t.cast<QuadBatchTracker>(); |
| 441 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 442 that, theirs.fUsesLocalCoords) && |
| 443 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 444 theirs.fInputColorType, theirs.fColor) && |
| 445 mine.fCoverageScale == theirs.fCoverageScale; |
| 446 } |
| 447 |
414 ////////////////////////////////////////////////////////////////////////////// | 448 ////////////////////////////////////////////////////////////////////////////// |
415 | 449 |
416 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); | 450 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); |
417 | 451 |
418 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, | 452 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, |
419 GrContext*, | 453 GrContext*, |
420 const GrDrawTargetCaps& caps, | 454 const GrDrawTargetCaps& caps, |
421 GrTexture*[]) { | 455 GrTexture*[]) { |
422 GrGeometryProcessor* gp; | 456 GrGeometryProcessor* gp; |
423 do { | 457 do { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 656 |
623 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, | 657 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, |
624 GrPrimitiveEdgeType edgeType) | 658 GrPrimitiveEdgeType edgeType) |
625 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { | 659 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { |
626 this->initClassID<GrCubicEffect>(); | 660 this->initClassID<GrCubicEffect>(); |
627 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 661 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
628 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs", | 662 fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs", |
629 kVec4f_GrVertexAttribTyp
e)); | 663 kVec4f_GrVertexAttribTyp
e)); |
630 } | 664 } |
631 | 665 |
| 666 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
| 667 const GrCubicEffect& ce = other.cast<GrCubicEffect>(); |
| 668 return (ce.fEdgeType == fEdgeType); |
| 669 } |
| 670 |
632 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { | 671 void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { |
633 CubicBatchTracker* local = bt->cast<CubicBatchTracker>(); | 672 CubicBatchTracker* local = bt->cast<CubicBatchTracker>(); |
634 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); | 673 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); |
635 local->fUsesLocalCoords = init.fUsesLocalCoords; | 674 local->fUsesLocalCoords = init.fUsesLocalCoords; |
636 } | 675 } |
637 | 676 |
| 677 bool GrCubicEffect::onCanMakeEqual(const GrBatchTracker& m, |
| 678 const GrGeometryProcessor& that, |
| 679 const GrBatchTracker& t) const { |
| 680 const CubicBatchTracker& mine = m.cast<CubicBatchTracker>(); |
| 681 const CubicBatchTracker& theirs = t.cast<CubicBatchTracker>(); |
| 682 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 683 that, theirs.fUsesLocalCoords) && |
| 684 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 685 theirs.fInputColorType, theirs.fColor); |
| 686 } |
| 687 |
638 ////////////////////////////////////////////////////////////////////////////// | 688 ////////////////////////////////////////////////////////////////////////////// |
639 | 689 |
640 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); | 690 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); |
641 | 691 |
642 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, | 692 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, |
643 GrContext*, | 693 GrContext*, |
644 const GrDrawTargetCaps& caps, | 694 const GrDrawTargetCaps& caps, |
645 GrTexture*[]) { | 695 GrTexture*[]) { |
646 GrGeometryProcessor* gp; | 696 GrGeometryProcessor* gp; |
647 do { | 697 do { |
648 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 698 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
649 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 699 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
650 gp = GrCubicEffect::Create(GrRandomColor(random), | 700 gp = GrCubicEffect::Create(GrRandomColor(random), |
651 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); | 701 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); |
652 } while (NULL == gp); | 702 } while (NULL == gp); |
653 return gp; | 703 return gp; |
654 } | 704 } |
655 | 705 |
OLD | NEW |