| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
| 10 | 10 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 * vertex coord is > 0 then the pixel is considered outside the edge. This is us
ed to | 521 * vertex coord is > 0 then the pixel is considered outside the edge. This is us
ed to |
| 522 * attempt to trim to a portion of the infinite quad. | 522 * attempt to trim to a portion of the infinite quad. |
| 523 * Requires shader derivative instruction support. | 523 * Requires shader derivative instruction support. |
| 524 */ | 524 */ |
| 525 | 525 |
| 526 class QuadEdgeEffect : public GrGeometryProcessor { | 526 class QuadEdgeEffect : public GrGeometryProcessor { |
| 527 public: | 527 public: |
| 528 | 528 |
| 529 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatri
x, | 529 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatri
x, |
| 530 bool usesLocalCoords) { | 530 bool usesLocalCoords) { |
| 531 return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix, usesLocalCoords))
; | 531 return new QuadEdgeEffect(color, localMatrix, usesLocalCoords); |
| 532 } | 532 } |
| 533 | 533 |
| 534 virtual ~QuadEdgeEffect() {} | 534 virtual ~QuadEdgeEffect() {} |
| 535 | 535 |
| 536 const char* name() const override { return "QuadEdge"; } | 536 const char* name() const override { return "QuadEdge"; } |
| 537 | 537 |
| 538 const Attribute* inPosition() const { return fInPosition; } | 538 const Attribute* inPosition() const { return fInPosition; } |
| 539 const Attribute* inQuadEdge() const { return fInQuadEdge; } | 539 const Attribute* inQuadEdge() const { return fInQuadEdge; } |
| 540 GrColor color() const { return fColor; } | 540 GrColor color() const { return fColor; } |
| 541 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 541 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 }; | 635 }; |
| 636 | 636 |
| 637 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 637 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 638 const GrGLSLCaps& caps, | 638 const GrGLSLCaps& caps, |
| 639 GrProcessorKeyBuilder* b) const override { | 639 GrProcessorKeyBuilder* b) const override { |
| 640 GLProcessor::GenKey(*this, bt, caps, b); | 640 GLProcessor::GenKey(*this, bt, caps, b); |
| 641 } | 641 } |
| 642 | 642 |
| 643 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 643 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 644 const GrGLSLCaps&) const ov
erride { | 644 const GrGLSLCaps&) const ov
erride { |
| 645 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 645 return new GLProcessor(*this, bt); |
| 646 } | 646 } |
| 647 | 647 |
| 648 private: | 648 private: |
| 649 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoo
rds) | 649 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoo
rds) |
| 650 : fColor(color) | 650 : fColor(color) |
| 651 , fLocalMatrix(localMatrix) | 651 , fLocalMatrix(localMatrix) |
| 652 , fUsesLocalCoords(usesLocalCoords) { | 652 , fUsesLocalCoords(usesLocalCoords) { |
| 653 this->initClassID<QuadEdgeEffect>(); | 653 this->initClassID<QuadEdgeEffect>(); |
| 654 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 654 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
| 655 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); | 655 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 } | 740 } |
| 741 | 741 |
| 742 class AAConvexPathBatch : public GrVertexBatch { | 742 class AAConvexPathBatch : public GrVertexBatch { |
| 743 public: | 743 public: |
| 744 struct Geometry { | 744 struct Geometry { |
| 745 GrColor fColor; | 745 GrColor fColor; |
| 746 SkMatrix fViewMatrix; | 746 SkMatrix fViewMatrix; |
| 747 SkPath fPath; | 747 SkPath fPath; |
| 748 }; | 748 }; |
| 749 | 749 |
| 750 static GrDrawBatch* Create(const Geometry& geometry) { | 750 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa
thBatch(geometry); } |
| 751 return SkNEW_ARGS(AAConvexPathBatch, (geometry)); | |
| 752 } | |
| 753 | 751 |
| 754 const char* name() const override { return "AAConvexBatch"; } | 752 const char* name() const override { return "AAConvexBatch"; } |
| 755 | 753 |
| 756 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 754 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 757 // When this is called on a batch, there is only one geometry bundle | 755 // When this is called on a batch, there is only one geometry bundle |
| 758 out->setKnownFourComponents(fGeoData[0].fColor); | 756 out->setKnownFourComponents(fGeoData[0].fColor); |
| 759 } | 757 } |
| 760 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 758 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 761 out->setUnknownSingleComponent(); | 759 out->setUnknownSingleComponent(); |
| 762 } | 760 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1013 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
| 1016 AAConvexPathBatch::Geometry geometry; | 1014 AAConvexPathBatch::Geometry geometry; |
| 1017 geometry.fColor = GrRandomColor(random); | 1015 geometry.fColor = GrRandomColor(random); |
| 1018 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1016 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 1019 geometry.fPath = GrTest::TestPathConvex(random); | 1017 geometry.fPath = GrTest::TestPathConvex(random); |
| 1020 | 1018 |
| 1021 return AAConvexPathBatch::Create(geometry); | 1019 return AAConvexPathBatch::Create(geometry); |
| 1022 } | 1020 } |
| 1023 | 1021 |
| 1024 #endif | 1022 #endif |
| OLD | NEW |