| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 bool tweakAlphaForCoverage) { | 700 bool tweakAlphaForCoverage) { |
| 701 intptr_t verts = reinterpret_cast<intptr_t>(vertices); | 701 intptr_t verts = reinterpret_cast<intptr_t>(vertices); |
| 702 | 702 |
| 703 for (int i = 0; i < tess.numPts(); ++i) { | 703 for (int i = 0; i < tess.numPts(); ++i) { |
| 704 *((SkPoint*)((intptr_t)verts + i * vertexStride)) = tess.point(i); | 704 *((SkPoint*)((intptr_t)verts + i * vertexStride)) = tess.point(i); |
| 705 } | 705 } |
| 706 | 706 |
| 707 // Make 'verts' point to the colors | 707 // Make 'verts' point to the colors |
| 708 verts += sizeof(SkPoint); | 708 verts += sizeof(SkPoint); |
| 709 for (int i = 0; i < tess.numPts(); ++i) { | 709 for (int i = 0; i < tess.numPts(); ++i) { |
| 710 SkASSERT(tess.depth(i) >= -0.5f && tess.depth(i) <= 0.5f); |
| 710 if (tweakAlphaForCoverage) { | 711 if (tweakAlphaForCoverage) { |
| 711 SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255); | 712 SkASSERT(SkScalarRoundToInt(255.0f * (tess.depth(i) + 0.5f)) <= 255)
; |
| 712 unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i)); | 713 unsigned scale = SkScalarRoundToInt(255.0f * (tess.depth(i) + 0.5f))
; |
| 713 GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, s
cale); | 714 GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, s
cale); |
| 714 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; | 715 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; |
| 715 } else { | 716 } else { |
| 716 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; | 717 *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; |
| 717 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = | 718 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = |
| 718 tess.coverage(i); | 719 tess.depth(i
) + 0.5f; |
| 719 } | 720 } |
| 720 } | 721 } |
| 721 | 722 |
| 722 for (int i = 0; i < tess.numIndices(); ++i) { | 723 for (int i = 0; i < tess.numIndices(); ++i) { |
| 723 idxs[i] = tess.index(i); | 724 idxs[i] = tess.index(i); |
| 724 } | 725 } |
| 725 } | 726 } |
| 726 | 727 |
| 727 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, | 728 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, |
| 728 const SkMatrix& localMatrix, | 729 const SkMatrix& localMatrix, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1019 BATCH_TEST_DEFINE(AAConvexPathBatch) { |
| 1019 AAConvexPathBatch::Geometry geometry; | 1020 AAConvexPathBatch::Geometry geometry; |
| 1020 geometry.fColor = GrRandomColor(random); | 1021 geometry.fColor = GrRandomColor(random); |
| 1021 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1022 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 1022 geometry.fPath = GrTest::TestPathConvex(random); | 1023 geometry.fPath = GrTest::TestPathConvex(random); |
| 1023 | 1024 |
| 1024 return AAConvexPathBatch::Create(geometry); | 1025 return AAConvexPathBatch::Create(geometry); |
| 1025 } | 1026 } |
| 1026 | 1027 |
| 1027 #endif | 1028 #endif |
| OLD | NEW |