Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/gpu/GrDefaultPathRenderer.cpp

Issue 825443002: Add conic support to Default and AAConvex path redender. (Closed) Base URL: https://skia.googlesource.com/skia.git@conics
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" 8 #include "GrDefaultPathRenderer.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrDefaultGeoProcFactory.h" 11 #include "GrDefaultGeoProcFactory.h"
12 #include "GrDrawState.h" 12 #include "GrDrawState.h"
13 #include "GrPathUtils.h" 13 #include "GrPathUtils.h"
14 #include "SkGeometry.h"
14 #include "SkString.h" 15 #include "SkString.h"
15 #include "SkStrokeRec.h" 16 #include "SkStrokeRec.h"
16 #include "SkTLazy.h" 17 #include "SkTLazy.h"
17 #include "SkTraceEvent.h" 18 #include "SkTraceEvent.h"
18 19
19 20
20 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, 21 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport,
21 bool stencilWrapOpsSupport) 22 bool stencilWrapOpsSupport)
22 : fSeparateStencil(separateStencilSupport) 23 : fSeparateStencil(separateStencilSupport)
23 , fStencilWrapOps(stencilWrapOpsSupport) { 24 , fStencilWrapOps(stencilWrapOpsSupport) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 SkPoint pts[4]; 250 SkPoint pts[4];
250 251
251 bool first = true; 252 bool first = true;
252 int subpath = 0; 253 int subpath = 0;
253 254
254 SkPath::Iter iter(path, false); 255 SkPath::Iter iter(path, false);
255 256
256 for (;;) { 257 for (;;) {
257 SkPath::Verb verb = iter.next(pts); 258 SkPath::Verb verb = iter.next(pts);
258 switch (verb) { 259 switch (verb) {
259 case SkPath::kConic_Verb: 260 case SkPath::kConic_Verb: {
260 SkASSERT(0); 261 SkScalar weight = iter.conicWeight();
262 SkAutoConicToQuads converter;
263 const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.2 5f);
reed1 2014/12/22 20:04:09 // Converting in src-space, hence the finer tolera
egdaniel 2014/12/22 21:37:13 Done.
264 for (int i = 0; i < converter.countQuads(); ++i) {
265 int baseIdx = i*2;
266 uint16_t firstQPtIdx = (uint16_t)(vert - base) - 1;
reed1 2014/12/22 20:04:09 Separate from this CL: WHAT THE HECK IS UP WITH IN
egdaniel 2014/12/22 21:37:13 Brian do you have any insight on this?
bsalomon 2014/12/22 22:10:31 I dunno... the indices have to fit in shorts, but
267 uint16_t numPts = (uint16_t)
268 GrPathUtils::generateQuadraticPoints(
269 quadPts[baseIdx], quadPts[baseIdx + 1], quadPts[base Idx + 2],
270 srcSpaceTolSqd, &vert,
271 GrPathUtils::quadraticPointCount(quadPts + baseIdx, srcSpaceTol));
272 if (indexed) {
273 for (uint16_t i = 0; i < numPts; ++i) {
274 append_countour_edge_indices(isHairline, subpathIdxS tart,
275 firstQPtIdx + i, &idx);
276 }
277 }
278 }
261 break; 279 break;
280 }
262 case SkPath::kMove_Verb: 281 case SkPath::kMove_Verb:
263 if (!first) { 282 if (!first) {
264 uint16_t currIdx = (uint16_t) (vert - base); 283 uint16_t currIdx = (uint16_t) (vert - base);
265 subpathIdxStart = currIdx; 284 subpathIdxStart = currIdx;
266 ++subpath; 285 ++subpath;
267 } 286 }
268 *vert = pts[0]; 287 *vert = pts[0];
269 vert++; 288 vert++;
270 break; 289 break;
271 case SkPath::kLine_Verb: 290 case SkPath::kLine_Verb:
272 if (indexed) { 291 if (indexed) {
273 uint16_t prevIdx = (uint16_t)(vert - base) - 1; 292 uint16_t prevIdx = (uint16_t)(vert - base) - 1;
274 append_countour_edge_indices(isHairline, subpathIdxStart, 293 append_countour_edge_indices(isHairline, subpathIdxStart,
275 prevIdx, &idx); 294 prevIdx, &idx);
276 } 295 }
277 *(vert++) = pts[1]; 296 *(vert++) = pts[1];
278 break; 297 break;
279 case SkPath::kQuad_Verb: { 298 case SkPath::kQuad_Verb: {
280 // first pt of quad is the pt we ended on in previous step 299 // first pt of quad is the pt we ended on in previous step
281 uint16_t firstQPtIdx = (uint16_t)(vert - base) - 1; 300 uint16_t firstQPtIdx = (uint16_t)(vert - base) - 1;
reed1 2014/12/22 20:04:09 can we capture this in a helper function, so we do
egdaniel 2014/12/22 21:37:13 Done.
282 uint16_t numPts = (uint16_t) 301 uint16_t numPts = (uint16_t)
283 GrPathUtils::generateQuadraticPoints( 302 GrPathUtils::generateQuadraticPoints(
284 pts[0], pts[1], pts[2], 303 pts[0], pts[1], pts[2],
285 srcSpaceTolSqd, &vert, 304 srcSpaceTolSqd, &vert,
286 GrPathUtils::quadraticPointCount(pts, srcSpaceTol)); 305 GrPathUtils::quadraticPointCount(pts, srcSpaceTol));
287 if (indexed) { 306 if (indexed) {
288 for (uint16_t i = 0; i < numPts; ++i) { 307 for (uint16_t i = 0; i < numPts; ++i) {
289 append_countour_edge_indices(isHairline, subpathIdxStart , 308 append_countour_edge_indices(isHairline, subpathIdxStart ,
290 firstQPtIdx + i, &idx); 309 firstQPtIdx + i, &idx);
291 } 310 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 538 }
520 return true; 539 return true;
521 } 540 }
522 541
523 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, 542 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target,
524 const GrDrawState* drawState, 543 const GrDrawState* drawState,
525 const SkPath& path, 544 const SkPath& path,
526 const SkStrokeRec& stroke, 545 const SkStrokeRec& stroke,
527 bool antiAlias) const { 546 bool antiAlias) const {
528 // this class can draw any path with any fill but doesn't do any anti-aliasi ng. 547 // this class can draw any path with any fill but doesn't do any anti-aliasi ng.
529 548 return !antiAlias && (stroke.isFillStyle() ||
530 return !antiAlias && !(SkPath::kConic_SegmentMask & path.getSegmentMasks()) && 549 IsStrokeHairlineOrEquivalent(stroke, drawState->getVie wMatrix(), NULL));
531 (stroke.isFillStyle() ||
532 IsStrokeHairlineOrEquivalent(stroke, drawState->getViewMatrix(), NULL)) ;
533 } 550 }
534 551
535 bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target, 552 bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
536 GrDrawState* drawState, 553 GrDrawState* drawState,
537 GrColor color, 554 GrColor color,
538 const SkPath& path, 555 const SkPath& path,
539 const SkStrokeRec& stroke, 556 const SkStrokeRec& stroke,
540 bool antiAlias) { 557 bool antiAlias) {
541 return this->internalDrawPath(target, 558 return this->internalDrawPath(target,
542 drawState, 559 drawState,
543 color, 560 color,
544 path, 561 path,
545 stroke, 562 stroke,
546 false); 563 false);
547 } 564 }
548 565
549 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, 566 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target,
550 GrDrawState* drawState, 567 GrDrawState* drawState,
551 const SkPath& path, 568 const SkPath& path,
552 const SkStrokeRec& stroke) { 569 const SkStrokeRec& stroke) {
553 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); 570 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType());
554 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); 571 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType());
555 this->internalDrawPath(target, drawState, GrColor_WHITE, path, stroke, true) ; 572 this->internalDrawPath(target, drawState, GrColor_WHITE, path, stroke, true) ;
556 } 573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698