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

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

Issue 1264283004: Revert of Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: 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& viewMatrix, 96 const SkMatrix& localMatrix,
97 bool usesLocalCoords, 97 bool usesLocalCoords,
98 bool coverageIgnored) { 98 bool coverageIgnored) {
99 using namespace GrDefaultGeoProcFactory; 99 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
100 if (!tweakAlphaForCoverage) {
101 flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
102 }
100 103
101 Color color(Color::kAttribute_Type); 104 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored,
102 Coverage::Type coverageType; 105 SkMatrix::I(), localMatrix);
103 if (coverageIgnored) {
104 coverageType = Coverage::kNone_Type;
105 } else if (tweakAlphaForCoverage) {
106 coverageType = Coverage::kSolid_Type;
107 } else {
108 coverageType = Coverage::kAttribute_Type;
109 }
110 Coverage coverage(coverageType);
111 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
112 LocalCoords::kUnused_Type);
113 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
114 } 106 }
115 107
116 class AAFlatteningConvexPathBatch : public GrBatch { 108 class AAFlatteningConvexPathBatch : public GrBatch {
117 public: 109 public:
118 struct Geometry { 110 struct Geometry {
119 GrColor fColor; 111 GrColor fColor;
120 SkMatrix fViewMatrix; 112 SkMatrix fViewMatrix;
121 SkPath fPath; 113 SkPath fPath;
122 SkScalar fStrokeWidth; 114 SkScalar fStrokeWidth;
123 SkPaint::Join fJoin; 115 SkPaint::Join fJoin;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 171 }
180 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); 172 memcpy(idxs, indices, indexCount * sizeof(uint16_t));
181 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, 173 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex,
182 firstIndex, vertexCount, indexCount); 174 firstIndex, vertexCount, indexCount);
183 batchTarget->draw(info); 175 batchTarget->draw(info);
184 } 176 }
185 177
186 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 178 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
187 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 179 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
188 180
189 // Setup GrGeometryProcessor 181 SkMatrix invert;
190 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage, 182 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
191 this->viewMatr ix(), 183 SkDebugf("Could not invert viewmatrix\n");
192 this->usesLoca lCoords(),
193 this->coverage Ignored()));
194 if (!gp) {
195 SkDebugf("Couldn't create a GrGeometryProcessor\n");
196 return; 184 return;
197 } 185 }
198 186
187 // Setup GrGeometryProcessor
188 SkAutoTUnref<const GrGeometryProcessor> gp(
189 create_fill_gp(canTweakAlphaForC overage, invert,
190 this->usesLocalCo ords(),
191 this->coverageIgn ored()));
192
199 batchTarget->initDraw(gp, pipeline); 193 batchTarget->initDraw(gp, pipeline);
200 194
201 size_t vertexStride = gp->getVertexStride(); 195 size_t vertexStride = gp->getVertexStride();
202 196
203 SkASSERT(canTweakAlphaForCoverage ? 197 SkASSERT(canTweakAlphaForCoverage ?
204 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 198 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
205 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 199 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
206 200
207 int instanceCount = fGeoData.count(); 201 int instanceCount = fGeoData.count();
208 202
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 325 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
332 AAFlatteningConvexPathBatch::Geometry geometry; 326 AAFlatteningConvexPathBatch::Geometry geometry;
333 geometry.fColor = GrRandomColor(random); 327 geometry.fColor = GrRandomColor(random);
334 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 328 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
335 geometry.fPath = GrTest::TestPathConvex(random); 329 geometry.fPath = GrTest::TestPathConvex(random);
336 330
337 return AAFlatteningConvexPathBatch::Create(geometry); 331 return AAFlatteningConvexPathBatch::Create(geometry);
338 } 332 }
339 333
340 #endif 334 #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