| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrPLSPathRenderer.h" | 8 #include "GrPLSPathRenderer.h" |
| 9 | 9 |
| 10 #include "SkChunkAlloc.h" | 10 #include "SkChunkAlloc.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance; | 138 SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance; |
| 139 SkScalar tol = GrPathUtils::scaleToleranceToSrc(screenSpaceTol, m, bounds); | 139 SkScalar tol = GrPathUtils::scaleToleranceToSrc(screenSpaceTol, m, bounds); |
| 140 int contourCnt; | 140 int contourCnt; |
| 141 int maxPts = GrPathUtils::worstCasePointCount(path, &contourCnt, tol); | 141 int maxPts = GrPathUtils::worstCasePointCount(path, &contourCnt, tol); |
| 142 if (maxPts <= 0) { | 142 if (maxPts <= 0) { |
| 143 return 0; | 143 return 0; |
| 144 } | 144 } |
| 145 SkPath linesOnlyPath; | 145 SkPath linesOnlyPath; |
| 146 linesOnlyPath.setFillType(path.getFillType()); | 146 linesOnlyPath.setFillType(path.getFillType()); |
| 147 SkSTArray<15, SkPoint, true> quadPoints; | 147 SkSTArray<15, SkPoint, true> quadPoints; |
| 148 SkPathPriv::FirstDirection dir = SkPathPriv::FirstDirection::kUnknown_FirstD
irection; | |
| 149 SkPath::Iter iter(path, true); | 148 SkPath::Iter iter(path, true); |
| 150 bool done = false; | 149 bool done = false; |
| 151 while (!done) { | 150 while (!done) { |
| 152 SkPoint pts[4]; | 151 SkPoint pts[4]; |
| 153 SkPath::Verb verb = iter.next(pts); | 152 SkPath::Verb verb = iter.next(pts); |
| 154 switch (verb) { | 153 switch (verb) { |
| 155 case SkPath::kMove_Verb: | 154 case SkPath::kMove_Verb: |
| 156 SkASSERT(quadPoints.count() % 3 == 0); | 155 SkASSERT(quadPoints.count() % 3 == 0); |
| 157 for (int i = 0; i < quadPoints.count(); i += 3) { | 156 for (int i = 0; i < quadPoints.count(); i += 3) { |
| 158 add_quad(&quadPoints[i], quadVertices); | 157 add_quad(&quadPoints[i], quadVertices); |
| 159 } | 158 } |
| 160 quadPoints.reset(); | 159 quadPoints.reset(); |
| 161 m.mapPoints(&pts[0], 1); | 160 m.mapPoints(&pts[0], 1); |
| 162 linesOnlyPath.moveTo(pts[0]); | 161 linesOnlyPath.moveTo(pts[0]); |
| 163 break; | 162 break; |
| 164 case SkPath::kLine_Verb: | 163 case SkPath::kLine_Verb: |
| 165 m.mapPoints(&pts[1], 1); | 164 m.mapPoints(&pts[1], 1); |
| 166 linesOnlyPath.lineTo(pts[1]); | 165 linesOnlyPath.lineTo(pts[1]); |
| 167 break; | 166 break; |
| 168 case SkPath::kQuad_Verb: | 167 case SkPath::kQuad_Verb: |
| 169 m.mapPoints(pts, 3); | 168 m.mapPoints(pts, 3); |
| 170 linesOnlyPath.lineTo(pts[2]); | 169 linesOnlyPath.lineTo(pts[2]); |
| 171 quadPoints.push_back(pts[0]); | 170 quadPoints.push_back(pts[0]); |
| 172 quadPoints.push_back(pts[1]); | 171 quadPoints.push_back(pts[1]); |
| 173 quadPoints.push_back(pts[2]); | 172 quadPoints.push_back(pts[2]); |
| 174 break; | 173 break; |
| 175 case SkPath::kCubic_Verb: { | 174 case SkPath::kCubic_Verb: { |
| 176 m.mapPoints(pts, 4); | 175 m.mapPoints(pts, 4); |
| 177 SkSTArray<15, SkPoint, true> quads; | 176 SkSTArray<15, SkPoint, true> quads; |
| 178 GrPathUtils::convertCubicToQuads(pts, kCubicTolerance, false, di
r, &quads); | 177 GrPathUtils::convertCubicToQuads(pts, kCubicTolerance, &quads); |
| 179 int count = quads.count(); | 178 int count = quads.count(); |
| 180 for (int q = 0; q < count; q += 3) { | 179 for (int q = 0; q < count; q += 3) { |
| 181 linesOnlyPath.lineTo(quads[q + 2]); | 180 linesOnlyPath.lineTo(quads[q + 2]); |
| 182 quadPoints.push_back(quads[q]); | 181 quadPoints.push_back(quads[q]); |
| 183 quadPoints.push_back(quads[q + 1]); | 182 quadPoints.push_back(quads[q + 1]); |
| 184 quadPoints.push_back(quads[q + 2]); | 183 quadPoints.push_back(quads[q + 2]); |
| 185 } | 184 } |
| 186 break; | 185 break; |
| 187 } | 186 } |
| 188 case SkPath::kConic_Verb: { | 187 case SkPath::kConic_Verb: { |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { | 1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { |
| 1004 PLSPathBatch::Geometry geometry; | 1003 PLSPathBatch::Geometry geometry; |
| 1005 geometry.fColor = GrRandomColor(random); | 1004 geometry.fColor = GrRandomColor(random); |
| 1006 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 1007 geometry.fPath = GrTest::TestPathConvex(random); | 1006 geometry.fPath = GrTest::TestPathConvex(random); |
| 1008 | 1007 |
| 1009 return PLSPathBatch::Create(geometry); | 1008 return PLSPathBatch::Create(geometry); |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1012 #endif | 1011 #endif |
| OLD | NEW |