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

Side by Side Diff: src/gpu/GrAALinearizingConvexPathRenderer.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/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAALinearizingConvexPathRenderer.h" 9 #include "GrAALinearizingConvexPathRenderer.h"
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 tess.coverage(i); 86 tess.coverage(i);
87 } 87 }
88 } 88 }
89 89
90 for (int i = 0; i < tess.numIndices(); ++i) { 90 for (int i = 0; i < tess.numIndices(); ++i) {
91 idxs[i] = tess.index(i) + firstIndex; 91 idxs[i] = tess.index(i) + firstIndex;
92 } 92 }
93 } 93 }
94 94
95 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, 95 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
96 const SkMatrix& localMatrix, 96 const SkMatrix& viewMatrix,
97 bool usesLocalCoords, 97 bool usesLocalCoords,
98 bool coverageIgnored) { 98 bool coverageIgnored) {
99 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; 99 using namespace GrDefaultGeoProcFactory;
100 if (!tweakAlphaForCoverage) { 100
101 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; 101 Color color(Color::kAttribute_Type);
102 Coverage::Type coverageType;
103 // TODO remove coverage if coverage is ignored
104 /*if (coverageIgnored) {
105 coverageType = Coverage::kNone_Type;
106 } else*/ if (tweakAlphaForCoverage) {
107 coverageType = Coverage::kSolid_Type;
108 } else {
109 coverageType = Coverage::kAttribute_Type;
102 } 110 }
103 111 Coverage coverage(coverageType);
104 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored, 112 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
105 SkMatrix::I(), localMatrix); 113 LocalCoords::kUnused_Type);
114 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
106 } 115 }
107 116
108 class AAFlatteningConvexPathBatch : public GrBatch { 117 class AAFlatteningConvexPathBatch : public GrBatch {
109 public: 118 public:
110 struct Geometry { 119 struct Geometry {
111 GrColor fColor; 120 GrColor fColor;
112 SkMatrix fViewMatrix; 121 SkMatrix fViewMatrix;
113 SkPath fPath; 122 SkPath fPath;
114 SkScalar fStrokeWidth; 123 SkScalar fStrokeWidth;
115 SkPaint::Join fJoin; 124 SkPaint::Join fJoin;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 180 }
172 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); 181 memcpy(idxs, indices, indexCount * sizeof(uint16_t));
173 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, 182 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex,
174 firstIndex, vertexCount, indexCount); 183 firstIndex, vertexCount, indexCount);
175 batchTarget->draw(info); 184 batchTarget->draw(info);
176 } 185 }
177 186
178 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 187 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
179 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 188 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
180 189
181 SkMatrix invert; 190 // Setup GrGeometryProcessor
182 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 191 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage,
183 SkDebugf("Could not invert viewmatrix\n"); 192 this->viewMatr ix(),
193 this->usesLoca lCoords(),
194 this->coverage Ignored()));
195 if (!gp) {
196 SkDebugf("Couldn't create a GrGeometryProcessor\n");
184 return; 197 return;
185 } 198 }
186 199
187 // Setup GrGeometryProcessor
188 SkAutoTUnref<const GrGeometryProcessor> gp(
189 create_fill_gp(canTweakAlphaForC overage, invert,
190 this->usesLocalCo ords(),
191 this->coverageIgn ored()));
192
193 batchTarget->initDraw(gp, pipeline); 200 batchTarget->initDraw(gp, pipeline);
194 201
195 size_t vertexStride = gp->getVertexStride(); 202 size_t vertexStride = gp->getVertexStride();
196 203
197 SkASSERT(canTweakAlphaForCoverage ? 204 SkASSERT(canTweakAlphaForCoverage ?
198 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 205 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
199 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 206 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
200 207
201 int instanceCount = fGeoData.count(); 208 int instanceCount = fGeoData.count();
202 209
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 332 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
326 AAFlatteningConvexPathBatch::Geometry geometry; 333 AAFlatteningConvexPathBatch::Geometry geometry;
327 geometry.fColor = GrRandomColor(random); 334 geometry.fColor = GrRandomColor(random);
328 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 335 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
329 geometry.fPath = GrTest::TestPathConvex(random); 336 geometry.fPath = GrTest::TestPathConvex(random);
330 337
331 return AAFlatteningConvexPathBatch::Create(geometry); 338 return AAFlatteningConvexPathBatch::Create(geometry);
332 } 339 }
333 340
334 #endif 341 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698