OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "GrAAConvexPathRenderer.h" | 8 #include "GrAAConvexPathRenderer.h" |
10 | 9 |
11 #include "GrAAConvexTessellator.h" | 10 #include "GrAAConvexTessellator.h" |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // Make 'verts' point to the colors | 702 // Make 'verts' point to the colors |
704 verts += sizeof(SkPoint); | 703 verts += sizeof(SkPoint); |
705 for (int i = 0; i < tess.numPts(); ++i) { | 704 for (int i = 0; i < tess.numPts(); ++i) { |
706 if (tweakAlphaForCoverage) { | 705 if (tweakAlphaForCoverage) { |
707 SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255); | 706 SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255); |
708 unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i)); | 707 unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i)); |
709 GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, s
cale); | 708 GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, s
cale); |
710 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; | 709 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; |
711 } else { | 710 } else { |
712 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; | 711 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; |
713 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = | 712 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = |
714 tess.coverage(i); | 713 tess.coverage(i); |
715 } | 714 } |
716 } | 715 } |
717 | 716 |
718 for (int i = 0; i < tess.numIndices(); ++i) { | 717 for (int i = 0; i < tess.numIndices(); ++i) { |
719 idxs[i] = tess.index(i); | 718 idxs[i] = tess.index(i); |
720 } | 719 } |
721 } | 720 } |
722 | 721 |
723 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, | 722 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, |
(...skipping 24 matching lines...) Expand all Loading... |
748 struct Geometry { | 747 struct Geometry { |
749 GrColor fColor; | 748 GrColor fColor; |
750 SkMatrix fViewMatrix; | 749 SkMatrix fViewMatrix; |
751 SkPath fPath; | 750 SkPath fPath; |
752 }; | 751 }; |
753 | 752 |
754 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa
thBatch(geometry); } | 753 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa
thBatch(geometry); } |
755 | 754 |
756 const char* name() const override { return "AAConvexBatch"; } | 755 const char* name() const override { return "AAConvexBatch"; } |
757 | 756 |
758 void computePipelineOptimizations(GrInitInvariantOutput* color, | 757 void computePipelineOptimizations(GrInitInvariantOutput* color, |
759 GrInitInvariantOutput* coverage, | 758 GrInitInvariantOutput* coverage, |
760 GrBatchToXPOverrides* overrides) const ove
rride { | 759 GrBatchToXPOverrides* overrides) const ove
rride { |
761 // When this is called on a batch, there is only one geometry bundle | 760 // When this is called on a batch, there is only one geometry bundle |
762 color->setKnownFourComponents(fGeoData[0].fColor); | 761 color->setKnownFourComponents(fGeoData[0].fColor); |
763 coverage->setUnknownSingleComponent(); | 762 coverage->setUnknownSingleComponent(); |
764 } | 763 } |
765 | 764 |
766 private: | 765 private: |
767 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 766 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
768 // Handle any color overrides | 767 // Handle any color overrides |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1024 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1026 AAConvexPathBatch::Geometry geometry; | 1025 AAConvexPathBatch::Geometry geometry; |
1027 geometry.fColor = GrRandomColor(random); | 1026 geometry.fColor = GrRandomColor(random); |
1028 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1027 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1029 geometry.fPath = GrTest::TestPathConvex(random); | 1028 geometry.fPath = GrTest::TestPathConvex(random); |
1030 | 1029 |
1031 return AAConvexPathBatch::Create(geometry); | 1030 return AAConvexPathBatch::Create(geometry); |
1032 } | 1031 } |
1033 | 1032 |
1034 #endif | 1033 #endif |
OLD | NEW |