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

Side by Side Diff: src/gpu/batches/GrNonAAStrokeRectBatch.cpp

Issue 1467553002: New API for computing optimization invariants. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/batches/GrNonAAFillRectBatch.cpp ('k') | src/gpu/batches/GrTInstanceBatch.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 "GrNonAAStrokeRectBatch.h" 8 #include "GrNonAAStrokeRectBatch.h"
9 9
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 SkScalar fStrokeWidth; 47 SkScalar fStrokeWidth;
48 GrColor fColor; 48 GrColor fColor;
49 }; 49 };
50 50
51 static NonAAStrokeRectBatch* Create() { 51 static NonAAStrokeRectBatch* Create() {
52 return new NonAAStrokeRectBatch; 52 return new NonAAStrokeRectBatch;
53 } 53 }
54 54
55 const char* name() const override { return "GrStrokeRectBatch"; } 55 const char* name() const override { return "GrStrokeRectBatch"; }
56 56
57 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 57 void computePipelineOptimizations(GrInitInvariantOutput* color,
58 GrInitInvariantOutput* coverage,
59 GrBatchToXPOverrides* overrides) const ove rride {
58 // When this is called on a batch, there is only one geometry bundle 60 // When this is called on a batch, there is only one geometry bundle
59 out->setKnownFourComponents(fGeoData[0].fColor); 61 color->setKnownFourComponents(fGeoData[0].fColor);
60 } 62 coverage->setKnownSingleComponent(0xff);
61 63 overrides->fUsePLSDstRead = false;
62 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
63 out->setKnownSingleComponent(0xff);
64 } 64 }
65 65
66 void append(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect, 66 void append(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
67 SkScalar strokeWidth) { 67 SkScalar strokeWidth) {
68 Geometry& geometry = fGeoData.push_back(); 68 Geometry& geometry = fGeoData.push_back();
69 geometry.fViewMatrix = viewMatrix; 69 geometry.fViewMatrix = viewMatrix;
70 geometry.fRect = rect; 70 geometry.fRect = rect;
71 geometry.fStrokeWidth = strokeWidth; 71 geometry.fStrokeWidth = strokeWidth;
72 geometry.fColor = color; 72 geometry.fColor = color;
73 } 73 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); 155 vertex[2].set(args.fRect.fRight, args.fRect.fBottom);
156 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); 156 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom);
157 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); 157 vertex[4].set(args.fRect.fLeft, args.fRect.fTop);
158 } 158 }
159 159
160 GrVertices vertices; 160 GrVertices vertices;
161 vertices.init(primType, vertexBuffer, firstVertex, vertexCount); 161 vertices.init(primType, vertexBuffer, firstVertex, vertexCount);
162 target->draw(vertices); 162 target->draw(vertices);
163 } 163 }
164 164
165 void initBatchTracker(const GrPipelineOptimizations& opt) override { 165 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
166 // Handle any color overrides 166 // Handle any color overrides
167 if (!opt.readsColor()) { 167 if (!overrides.readsColor()) {
168 fGeoData[0].fColor = GrColor_ILLEGAL; 168 fGeoData[0].fColor = GrColor_ILLEGAL;
169 } 169 }
170 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 170 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
171 171
172 // setup batch properties 172 // setup batch properties
173 fBatch.fColorIgnored = !opt.readsColor(); 173 fBatch.fColorIgnored = !overrides.readsColor();
174 fBatch.fColor = fGeoData[0].fColor; 174 fBatch.fColor = fGeoData[0].fColor;
175 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 175 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
176 fBatch.fCoverageIgnored = !opt.readsCoverage(); 176 fBatch.fCoverageIgnored = !overrides.readsCoverage();
177 } 177 }
178 178
179 NonAAStrokeRectBatch() : INHERITED(ClassID()) {} 179 NonAAStrokeRectBatch() : INHERITED(ClassID()) {}
180 180
181 GrColor color() const { return fBatch.fColor; } 181 GrColor color() const { return fBatch.fColor; }
182 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } 182 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
183 bool colorIgnored() const { return fBatch.fColorIgnored; } 183 bool colorIgnored() const { return fBatch.fColorIgnored; }
184 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } 184 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
185 bool hairline() const { return fBatch.fHairline; } 185 bool hairline() const { return fBatch.fHairline; }
186 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } 186 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { 244 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
245 SkMatrix viewMatrix = GrTest::TestMatrix(random); 245 SkMatrix viewMatrix = GrTest::TestMatrix(random);
246 GrColor color = GrRandomColor(random); 246 GrColor color = GrRandomColor(random);
247 SkRect rect = GrTest::TestRect(random); 247 SkRect rect = GrTest::TestRect(random);
248 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; 248 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f;
249 249
250 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool()); 250 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool());
251 } 251 }
252 252
253 #endif 253 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAFillRectBatch.cpp ('k') | src/gpu/batches/GrTInstanceBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698