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

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

Issue 38573007: Do not apply hairline optimization for paths if nv_path_rendering is used (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address problems Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrDrawState.h" 11 #include "GrDrawState.h"
12 #include "GrPathUtils.h" 12 #include "GrPathUtils.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "SkStrokeRec.h" 14 #include "SkStrokeRec.h"
15 #include "SkTLazy.h"
15 #include "SkTrace.h" 16 #include "SkTrace.h"
16 17
17 18
18 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, 19 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport,
19 bool stencilWrapOpsSupport) 20 bool stencilWrapOpsSupport)
20 : fSeparateStencil(separateStencilSupport) 21 : fSeparateStencil(separateStencilSupport)
21 , fStencilWrapOps(stencilWrapOpsSupport) { 22 , fStencilWrapOps(stencilWrapOpsSupport) {
22 } 23 }
23 24
24 25
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 SkASSERT((idx - idxBase) <= maxIdxs); 319 SkASSERT((idx - idxBase) <= maxIdxs);
319 320
320 *vertexCnt = static_cast<int>(vert - base); 321 *vertexCnt = static_cast<int>(vert - base);
321 *indexCnt = static_cast<int>(idx - idxBase); 322 *indexCnt = static_cast<int>(idx - idxBase);
322 323
323 } 324 }
324 return true; 325 return true;
325 } 326 }
326 327
327 bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path, 328 bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
328 const SkStrokeRec& stroke, 329 const SkStrokeRec& origStroke,
329 GrDrawTarget* target, 330 GrDrawTarget* target,
330 bool stencilOnly) { 331 bool stencilOnly) {
331 332
332 SkMatrix viewM = target->getDrawState().getViewMatrix(); 333 SkMatrix viewM = target->getDrawState().getViewMatrix();
334 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke);
335
336 SkScalar hairlineCoverage;
337 if (IsStrokeHairlineOrEquivalent(*stroke, target->getDrawState().getViewMatr ix(),
338 &hairlineCoverage)) {
339 uint8_t newCoverage = SkScalarRoundToInt(hairlineCoverage *
340 target->getDrawState().getCover age());
341 target->drawState()->setCoverage(newCoverage);
342
343 if (!stroke->isHairlineStyle()) {
344 stroke.writable()->setHairlineStyle();
345 }
346 }
347
333 SkScalar tol = SK_Scalar1; 348 SkScalar tol = SK_Scalar1;
334 tol = GrPathUtils::scaleToleranceToSrc(tol, viewM, path.getBounds()); 349 tol = GrPathUtils::scaleToleranceToSrc(tol, viewM, path.getBounds());
335 350
336 int vertexCnt; 351 int vertexCnt;
337 int indexCnt; 352 int indexCnt;
338 GrPrimitiveType primType; 353 GrPrimitiveType primType;
339 GrDrawTarget::AutoReleaseGeometry arg; 354 GrDrawTarget::AutoReleaseGeometry arg;
340 if (!this->createGeom(path, 355 if (!this->createGeom(path,
341 stroke, 356 *stroke,
342 tol, 357 tol,
343 target, 358 target,
344 &primType, 359 &primType,
345 &vertexCnt, 360 &vertexCnt,
346 &indexCnt, 361 &indexCnt,
347 &arg)) { 362 &arg)) {
348 return false; 363 return false;
349 } 364 }
350 365
351 SkASSERT(NULL != target); 366 SkASSERT(NULL != target);
352 GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit); 367 GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit);
353 GrDrawState* drawState = target->drawState(); 368 GrDrawState* drawState = target->drawState();
354 bool colorWritesWereDisabled = drawState->isColorWriteDisabled(); 369 bool colorWritesWereDisabled = drawState->isColorWriteDisabled();
355 // face culling doesn't make sense here 370 // face culling doesn't make sense here
356 SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace()); 371 SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace());
357 372
358 int passCount = 0; 373 int passCount = 0;
359 const GrStencilSettings* passes[3]; 374 const GrStencilSettings* passes[3];
360 GrDrawState::DrawFace drawFace[3]; 375 GrDrawState::DrawFace drawFace[3];
361 bool reverse = false; 376 bool reverse = false;
362 bool lastPassIsBounds; 377 bool lastPassIsBounds;
363 378
364 if (stroke.isHairlineStyle()) { 379 if (stroke->isHairlineStyle()) {
365 passCount = 1; 380 passCount = 1;
366 if (stencilOnly) { 381 if (stencilOnly) {
367 passes[0] = &gDirectToStencil; 382 passes[0] = &gDirectToStencil;
368 } else { 383 } else {
369 passes[0] = NULL; 384 passes[0] = NULL;
370 } 385 }
371 lastPassIsBounds = false; 386 lastPassIsBounds = false;
372 drawFace[0] = GrDrawState::kBoth_DrawFace; 387 drawFace[0] = GrDrawState::kBoth_DrawFace;
373 } else { 388 } else {
374 if (single_pass_path(path, stroke)) { 389 if (single_pass_path(path, *stroke)) {
375 passCount = 1; 390 passCount = 1;
376 if (stencilOnly) { 391 if (stencilOnly) {
377 passes[0] = &gDirectToStencil; 392 passes[0] = &gDirectToStencil;
378 } else { 393 } else {
379 passes[0] = NULL; 394 passes[0] = NULL;
380 } 395 }
381 drawFace[0] = GrDrawState::kBoth_DrawFace; 396 drawFace[0] = GrDrawState::kBoth_DrawFace;
382 lastPassIsBounds = false; 397 lastPassIsBounds = false;
383 } else { 398 } else {
384 switch (path.getFillType()) { 399 switch (path.getFillType()) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 507 }
493 } 508 }
494 return true; 509 return true;
495 } 510 }
496 511
497 bool GrDefaultPathRenderer::canDrawPath(const SkPath& path, 512 bool GrDefaultPathRenderer::canDrawPath(const SkPath& path,
498 const SkStrokeRec& stroke, 513 const SkStrokeRec& stroke,
499 const GrDrawTarget* target, 514 const GrDrawTarget* target,
500 bool antiAlias) const { 515 bool antiAlias) const {
501 // this class can draw any path with any fill but doesn't do any anti-aliasi ng. 516 // this class can draw any path with any fill but doesn't do any anti-aliasi ng.
502 return (stroke.isFillStyle() || stroke.isHairlineStyle()) && !antiAlias; 517
518 return !antiAlias &&
519 (stroke.isFillStyle() ||
520 IsStrokeHairlineOrEquivalent(stroke, target->getDrawState().getViewMatr ix(), NULL));
503 } 521 }
504 522
505 bool GrDefaultPathRenderer::onDrawPath(const SkPath& path, 523 bool GrDefaultPathRenderer::onDrawPath(const SkPath& path,
506 const SkStrokeRec& stroke, 524 const SkStrokeRec& stroke,
507 GrDrawTarget* target, 525 GrDrawTarget* target,
508 bool antiAlias) { 526 bool antiAlias) {
509 return this->internalDrawPath(path, 527 return this->internalDrawPath(path,
510 stroke, 528 stroke,
511 target, 529 target,
512 false); 530 false);
513 } 531 }
514 532
515 void GrDefaultPathRenderer::onStencilPath(const SkPath& path, 533 void GrDefaultPathRenderer::onStencilPath(const SkPath& path,
516 const SkStrokeRec& stroke, 534 const SkStrokeRec& stroke,
517 GrDrawTarget* target) { 535 GrDrawTarget* target) {
518 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); 536 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType());
519 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); 537 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType());
520 this->internalDrawPath(path, stroke, target, true); 538 this->internalDrawPath(path, stroke, target, true);
521 } 539 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698