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

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

Issue 1265763002: Args structs to GrPathRenderer functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 4 months 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
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.h ('k') | src/gpu/GrTest.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 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 "GrTessellatingPathRenderer.h" 8 #include "GrTessellatingPathRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 } 1335 }
1336 1336
1337 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport( 1337 GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport(
1338 const GrDrawTarget*, 1338 const GrDrawTarget*,
1339 const GrPipelineBuil der*, 1339 const GrPipelineBuil der*,
1340 const SkPath&, 1340 const SkPath&,
1341 const GrStrokeInfo&) const { 1341 const GrStrokeInfo&) const {
1342 return GrPathRenderer::kNoSupport_StencilSupport; 1342 return GrPathRenderer::kNoSupport_StencilSupport;
1343 } 1343 }
1344 1344
1345 bool GrTessellatingPathRenderer::canDrawPath(const GrDrawTarget* target, 1345 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons t {
1346 const GrPipelineBuilder* pipelineBu ilder,
1347 const SkMatrix& viewMatrix,
1348 const SkPath& path,
1349 const GrStrokeInfo& stroke,
1350 bool antiAlias) const {
1351 // This path renderer can draw all fill styles, but does not do antialiasing . It can do convex 1346 // This path renderer can draw all fill styles, but does not do antialiasing . It can do convex
1352 // and concave paths, but we'll leave the convex ones to simpler algorithms. 1347 // and concave paths, but we'll leave the convex ones to simpler algorithms.
1353 return stroke.isFillStyle() && !antiAlias && !path.isConvex(); 1348 return args.fStroke->isFillStyle() && !args.fAntiAlias && !args.fPath->isCon vex();
1354 } 1349 }
1355 1350
1356 class TessellatingPathBatch : public GrBatch { 1351 class TessellatingPathBatch : public GrBatch {
1357 public: 1352 public:
1358 1353
1359 static GrBatch* Create(const GrColor& color, 1354 static GrBatch* Create(const GrColor& color,
1360 const SkPath& path, 1355 const SkPath& path,
1361 const SkMatrix& viewMatrix, 1356 const SkMatrix& viewMatrix,
1362 SkRect clipBounds) { 1357 SkRect clipBounds) {
1363 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB ounds)); 1358 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB ounds));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 viewMatrix.mapRect(&fBounds); 1477 viewMatrix.mapRect(&fBounds);
1483 } 1478 }
1484 1479
1485 GrColor fColor; 1480 GrColor fColor;
1486 SkPath fPath; 1481 SkPath fPath;
1487 SkMatrix fViewMatrix; 1482 SkMatrix fViewMatrix;
1488 SkRect fClipBounds; // in source space 1483 SkRect fClipBounds; // in source space
1489 GrPipelineInfo fPipelineInfo; 1484 GrPipelineInfo fPipelineInfo;
1490 }; 1485 };
1491 1486
1492 bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, 1487 bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
1493 GrPipelineBuilder* pipelineBuilder, 1488 SkASSERT(!args.fAntiAlias);
1494 GrColor color, 1489 const GrRenderTarget* rt = args.fPipelineBuilder->getRenderTarget();
1495 const SkMatrix& viewM,
1496 const SkPath& path,
1497 const GrStrokeInfo&,
1498 bool antiAlias) {
1499 SkASSERT(!antiAlias);
1500 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
1501 if (NULL == rt) { 1490 if (NULL == rt) {
1502 return false; 1491 return false;
1503 } 1492 }
1504 1493
1505 SkIRect clipBoundsI; 1494 SkIRect clipBoundsI;
1506 pipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); 1495 args.fPipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI);
1507 SkRect clipBounds = SkRect::Make(clipBoundsI); 1496 SkRect clipBounds = SkRect::Make(clipBoundsI);
1508 SkMatrix vmi; 1497 SkMatrix vmi;
1509 if (!viewM.invert(&vmi)) { 1498 if (!args.fViewMatrix->invert(&vmi)) {
1510 return false; 1499 return false;
1511 } 1500 }
1512 vmi.mapRect(&clipBounds); 1501 vmi.mapRect(&clipBounds);
1513 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM , clipBounds)); 1502 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(args.fColor, *args .fPath,
1514 target->drawBatch(*pipelineBuilder, batch); 1503 *args.fViewMatrix, clipBounds));
1504 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
1515 1505
1516 return true; 1506 return true;
1517 } 1507 }
1518 1508
1519 //////////////////////////////////////////////////////////////////////////////// /////////////////// 1509 //////////////////////////////////////////////////////////////////////////////// ///////////////////
1520 1510
1521 #ifdef GR_TEST_UTILS 1511 #ifdef GR_TEST_UTILS
1522 1512
1523 BATCH_TEST_DEFINE(TesselatingPathBatch) { 1513 BATCH_TEST_DEFINE(TesselatingPathBatch) {
1524 GrColor color = GrRandomColor(random); 1514 GrColor color = GrRandomColor(random);
1525 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 1515 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
1526 SkPath path = GrTest::TestPath(random); 1516 SkPath path = GrTest::TestPath(random);
1527 SkRect clipBounds = GrTest::TestRect(random); 1517 SkRect clipBounds = GrTest::TestRect(random);
1528 SkMatrix vmi; 1518 SkMatrix vmi;
1529 bool result = viewMatrix.invert(&vmi); 1519 bool result = viewMatrix.invert(&vmi);
1530 if (!result) { 1520 if (!result) {
1531 SkFAIL("Cannot invert matrix\n"); 1521 SkFAIL("Cannot invert matrix\n");
1532 } 1522 }
1533 vmi.mapRect(&clipBounds); 1523 vmi.mapRect(&clipBounds);
1534 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds); 1524 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds);
1535 } 1525 }
1536 1526
1537 #endif 1527 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.h ('k') | src/gpu/GrTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698