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

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

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch 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/GrTargetCommands.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.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 "GrBatchTarget.h" 10 #include "GrBatchTarget.h"
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 } // namespace 1377 } // namespace
1378 1378
1379 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons t { 1379 bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons t {
1380 // This path renderer can draw all fill styles, all stroke styles except hai rlines, but does 1380 // This path renderer can draw all fill styles, all stroke styles except hai rlines, but does
1381 // not do antialiasing. It can do convex and concave paths, but we'll leave the convex ones to 1381 // not do antialiasing. It can do convex and concave paths, but we'll leave the convex ones to
1382 // simpler algorithms. 1382 // simpler algorithms.
1383 return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, NULL) && 1383 return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, NULL) &&
1384 !args.fAntiAlias && !args.fPath->isConvex(); 1384 !args.fAntiAlias && !args.fPath->isConvex();
1385 } 1385 }
1386 1386
1387 class TessellatingPathBatch : public GrBatch { 1387 class TessellatingPathBatch : public GrVertexBatch {
1388 public: 1388 public:
1389 1389
1390 static GrBatch* Create(const GrColor& color, 1390 static GrDrawBatch* Create(const GrColor& color,
1391 const SkPath& path, 1391 const SkPath& path,
1392 const GrStrokeInfo& stroke, 1392 const GrStrokeInfo& stroke,
1393 const SkMatrix& viewMatrix, 1393 const SkMatrix& viewMatrix,
1394 SkRect clipBounds) { 1394 SkRect clipBounds) {
1395 return SkNEW_ARGS(TessellatingPathBatch, (color, path, stroke, viewMatri x, clipBounds)); 1395 return SkNEW_ARGS(TessellatingPathBatch, (color, path, stroke, viewMatri x, clipBounds));
1396 } 1396 }
1397 1397
1398 const char* name() const override { return "TessellatingPathBatch"; } 1398 const char* name() const override { return "TessellatingPathBatch"; }
1399 1399
1400 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1400 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1401 out->setKnownFourComponents(fColor); 1401 out->setKnownFourComponents(fColor);
1402 } 1402 }
1403 1403
1404 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1404 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 } 1613 }
1614 1614
1615 SkIRect clipBoundsI; 1615 SkIRect clipBoundsI;
1616 args.fPipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI); 1616 args.fPipelineBuilder->clip().getConservativeBounds(rt, &clipBoundsI);
1617 SkRect clipBounds = SkRect::Make(clipBoundsI); 1617 SkRect clipBounds = SkRect::Make(clipBoundsI);
1618 SkMatrix vmi; 1618 SkMatrix vmi;
1619 if (!args.fViewMatrix->invert(&vmi)) { 1619 if (!args.fViewMatrix->invert(&vmi)) {
1620 return false; 1620 return false;
1621 } 1621 }
1622 vmi.mapRect(&clipBounds); 1622 vmi.mapRect(&clipBounds);
1623 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(args.fColor, *args .fPath, 1623 SkAutoTUnref<GrDrawBatch> batch(TessellatingPathBatch::Create(args.fColor, * args.fPath,
1624 *args.fStroke, *ar gs.fViewMatrix, 1624 *args.fStroke, *args.fViewMatrix,
1625 clipBounds)); 1625 clipBounds));
1626 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); 1626 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
1627 1627
1628 return true; 1628 return true;
1629 } 1629 }
1630 1630
1631 //////////////////////////////////////////////////////////////////////////////// /////////////////// 1631 //////////////////////////////////////////////////////////////////////////////// ///////////////////
1632 1632
1633 #ifdef GR_TEST_UTILS 1633 #ifdef GR_TEST_UTILS
1634 1634
1635 BATCH_TEST_DEFINE(TesselatingPathBatch) { 1635 DRAW_BATCH_TEST_DEFINE(TesselatingPathBatch) {
1636 GrColor color = GrRandomColor(random); 1636 GrColor color = GrRandomColor(random);
1637 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 1637 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
1638 SkPath path = GrTest::TestPath(random); 1638 SkPath path = GrTest::TestPath(random);
1639 SkRect clipBounds = GrTest::TestRect(random); 1639 SkRect clipBounds = GrTest::TestRect(random);
1640 SkMatrix vmi; 1640 SkMatrix vmi;
1641 bool result = viewMatrix.invert(&vmi); 1641 bool result = viewMatrix.invert(&vmi);
1642 if (!result) { 1642 if (!result) {
1643 SkFAIL("Cannot invert matrix\n"); 1643 SkFAIL("Cannot invert matrix\n");
1644 } 1644 }
1645 vmi.mapRect(&clipBounds); 1645 vmi.mapRect(&clipBounds);
1646 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); 1646 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random);
1647 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds); 1647 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl ipBounds);
1648 } 1648 }
1649 1649
1650 #endif 1650 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698