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

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

Issue 1261083003: Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: tweaks 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/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.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 2012 Google Inc. 2 * Copyright 2012 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 "GrAARectRenderer.h" 8 #include "GrAARectRenderer.h"
9 #include "GrBatch.h" 9 #include "GrBatch.h"
10 #include "GrBatchTarget.h" 10 #include "GrBatchTarget.h"
(...skipping 14 matching lines...) Expand all
25 25
26 /////////////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////////////
27 27
28 static void set_inset_fan(SkPoint* pts, size_t stride, 28 static void set_inset_fan(SkPoint* pts, size_t stride,
29 const SkRect& r, SkScalar dx, SkScalar dy) { 29 const SkRect& r, SkScalar dx, SkScalar dy) {
30 pts->setRectFan(r.fLeft + dx, r.fTop + dy, 30 pts->setRectFan(r.fLeft + dx, r.fTop + dy,
31 r.fRight - dx, r.fBottom - dy, stride); 31 r.fRight - dx, r.fBottom - dy, stride);
32 } 32 }
33 33
34 static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage , 34 static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage ,
35 const SkMatrix& localMatri x, 35 const SkMatrix& viewMatrix ,
36 bool usesLocalCoords, 36 bool usesLocalCoords,
37 bool coverageIgnored) { 37 bool coverageIgnored) {
38 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; 38 using namespace GrDefaultGeoProcFactory;
39 const GrGeometryProcessor* gp; 39
40 if (tweakAlphaForCoverage) { 40 Color color(Color::kAttribute_Type);
41 gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoor ds, coverageIgnored, 41 Coverage::Type coverageType;
42 SkMatrix::I(), localMatrix); 42 // TODO remove coverage if coverage is ignored
43 /*if (coverageIgnored) {
44 coverageType = Coverage::kNone_Type;
45 } else*/ if (tweakAlphaForCoverage) {
46 coverageType = Coverage::kSolid_Type;
43 } else { 47 } else {
44 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; 48 coverageType = Coverage::kAttribute_Type;
45 gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoor ds, coverageIgnored,
46 SkMatrix::I(), localMatrix);
47 } 49 }
48 return gp; 50 Coverage coverage(coverageType);
51 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
52 LocalCoords::kUnused_Type);
53 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
49 } 54 }
50 55
51 GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); 56 GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
52 57
53 class AAFillRectBatch : public GrBatch { 58 class AAFillRectBatch : public GrBatch {
54 public: 59 public:
55 struct Geometry { 60 struct Geometry {
56 GrColor fColor; 61 GrColor fColor;
57 SkMatrix fViewMatrix; 62 SkMatrix fViewMatrix;
58 SkRect fRect; 63 SkRect fRect;
(...skipping 26 matching lines...) Expand all
85 fBatch.fColorIgnored = !init.readsColor(); 90 fBatch.fColorIgnored = !init.readsColor();
86 fBatch.fColor = fGeoData[0].fColor; 91 fBatch.fColor = fGeoData[0].fColor;
87 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 92 fBatch.fUsesLocalCoords = init.readsLocalCoords();
88 fBatch.fCoverageIgnored = !init.readsCoverage(); 93 fBatch.fCoverageIgnored = !init.readsCoverage();
89 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); 94 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
90 } 95 }
91 96
92 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 97 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
93 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 98 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
94 99
95 SkMatrix localMatrix; 100 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA lphaForCoverage,
96 if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { 101 this->vie wMatrix(),
97 SkDebugf("Cannot invert\n"); 102 this->use sLocalCoords(),
103 this->cov erageIgnored()));
104 if (!gp) {
105 SkDebugf("Couldn't create GrGeometryProcessor\n");
98 return; 106 return;
99 } 107 }
100 108
101 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA lphaForCoverage,
102 localMatr ix,
103 this->use sLocalCoords(),
104 this->cov erageIgnored()));
105
106 batchTarget->initDraw(gp, pipeline); 109 batchTarget->initDraw(gp, pipeline);
107 110
108 size_t vertexStride = gp->getVertexStride(); 111 size_t vertexStride = gp->getVertexStride();
109 SkASSERT(canTweakAlphaForCoverage ? 112 SkASSERT(canTweakAlphaForCoverage ?
110 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 113 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
111 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 114 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
112 int instanceCount = fGeoData.count(); 115 int instanceCount = fGeoData.count();
113 116
114 SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer( 117 SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer(
115 batchTarget->resourceProvider())); 118 batchTarget->resourceProvider()));
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 fBatch.fColor = fGeoData[0].fColor; 440 fBatch.fColor = fGeoData[0].fColor;
438 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 441 fBatch.fUsesLocalCoords = init.readsLocalCoords();
439 fBatch.fCoverageIgnored = !init.readsCoverage(); 442 fBatch.fCoverageIgnored = !init.readsCoverage();
440 fBatch.fMiterStroke = fGeoData[0].fMiterStroke; 443 fBatch.fMiterStroke = fGeoData[0].fMiterStroke;
441 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); 444 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
442 } 445 }
443 446
444 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 447 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
445 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 448 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
446 449
447 // Local matrix is ignored if we don't have local coords. If we have lo calcoords we only 450 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA lphaForCoverage,
448 // batch with identical view matrices 451 this->vie wMatrix(),
449 SkMatrix localMatrix; 452 this->use sLocalCoords(),
450 if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { 453 this->cov erageIgnored()));
451 SkDebugf("Cannot invert\n"); 454 if (!gp) {
455 SkDebugf("Couldn't create GrGeometryProcessor\n");
452 return; 456 return;
453 } 457 }
454 458
455 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakA lphaForCoverage,
456 localMatr ix,
457 this->use sLocalCoords(),
458 this->cov erageIgnored()));
459
460 batchTarget->initDraw(gp, pipeline); 459 batchTarget->initDraw(gp, pipeline);
461 460
462 size_t vertexStride = gp->getVertexStride(); 461 size_t vertexStride = gp->getVertexStride();
463 462
464 SkASSERT(canTweakAlphaForCoverage ? 463 SkASSERT(canTweakAlphaForCoverage ?
465 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 464 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
466 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 465 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
467 int innerVertexNum = 4; 466 int innerVertexNum = 4;
468 int outerVertexNum = this->miterStroke() ? 4 : 8; 467 int outerVertexNum = this->miterStroke() ? 4 : 8;
469 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; 468 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 geo.fColor = GrRandomColor(random); 848 geo.fColor = GrRandomColor(random);
850 geo.fDevOutside = outside; 849 geo.fDevOutside = outside;
851 geo.fDevOutsideAssist = outsideAssist; 850 geo.fDevOutsideAssist = outsideAssist;
852 geo.fDevInside = inside; 851 geo.fDevInside = inside;
853 geo.fMiterStroke = miterStroke; 852 geo.fMiterStroke = miterStroke;
854 853
855 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); 854 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random));
856 } 855 }
857 856
858 #endif 857 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698