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

Side by Side Diff: src/gpu/batches/GrAAStrokeRectBatch.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
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 "GrAAStrokeRectBatch.h" 8 #include "GrAAStrokeRectBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 GrColor fColor; 55 GrColor fColor;
56 bool fDegenerate; 56 bool fDegenerate;
57 }; 57 };
58 58
59 static AAStrokeRectBatch* Create(const SkMatrix& viewMatrix, bool miterStrok e) { 59 static AAStrokeRectBatch* Create(const SkMatrix& viewMatrix, bool miterStrok e) {
60 return new AAStrokeRectBatch(viewMatrix, miterStroke); 60 return new AAStrokeRectBatch(viewMatrix, miterStroke);
61 } 61 }
62 62
63 const char* name() const override { return "AAStrokeRect"; } 63 const char* name() const override { return "AAStrokeRect"; }
64 64
65 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 65 void computePipelineOptimizations(GrInitInvariantOutput* color,
66 GrInitInvariantOutput* coverage,
67 GrBatchToXPOverrides* overrides) const ove rride {
66 // When this is called on a batch, there is only one geometry bundle 68 // When this is called on a batch, there is only one geometry bundle
67 out->setKnownFourComponents(fGeoData[0].fColor); 69 color->setKnownFourComponents(fGeoData[0].fColor);
68 } 70 coverage->setUnknownSingleComponent();
69 71 overrides->fUsePLSDstRead = false;
70 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
71 out->setUnknownSingleComponent();
72 } 72 }
73 73
74 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 74 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
75 75
76 bool canAppend(const SkMatrix& viewMatrix, bool miterStroke) { 76 bool canAppend(const SkMatrix& viewMatrix, bool miterStroke) {
77 return fViewMatrix.cheapEqualTo(viewMatrix) && fMiterStroke == miterStro ke; 77 return fViewMatrix.cheapEqualTo(viewMatrix) && fMiterStroke == miterStro ke;
78 } 78 }
79 79
80 void append(GrColor color, const SkRect& devOutside, const SkRect& devOutsid eAssist, 80 void append(GrColor color, const SkRect& devOutside, const SkRect& devOutsid eAssist,
81 const SkRect& devInside, bool degenerate) { 81 const SkRect& devInside, bool degenerate) {
(...skipping 19 matching lines...) Expand all
101 101
102 private: 102 private:
103 void updateBounds(SkRect* bounds, const Geometry& geo) { 103 void updateBounds(SkRect* bounds, const Geometry& geo) {
104 // If we have miterstroke then we inset devOutside and outset devOutside Assist, so we need 104 // If we have miterstroke then we inset devOutside and outset devOutside Assist, so we need
105 // the join for proper bounds 105 // the join for proper bounds
106 *bounds = geo.fDevOutside; 106 *bounds = geo.fDevOutside;
107 bounds->join(geo.fDevOutsideAssist); 107 bounds->join(geo.fDevOutsideAssist);
108 } 108 }
109 109
110 void onPrepareDraws(Target*) override; 110 void onPrepareDraws(Target*) override;
111 void initBatchTracker(const GrPipelineOptimizations&) override; 111 void initBatchTracker(const GrXPOverridesForBatch&) override;
112 112
113 AAStrokeRectBatch(const SkMatrix& viewMatrix,bool miterStroke) 113 AAStrokeRectBatch(const SkMatrix& viewMatrix,bool miterStroke)
114 : INHERITED(ClassID()) { 114 : INHERITED(ClassID()) {
115 fViewMatrix = viewMatrix; 115 fViewMatrix = viewMatrix;
116 fMiterStroke = miterStroke; 116 fMiterStroke = miterStroke;
117 } 117 }
118 118
119 static const int kMiterIndexCnt = 3 * 24; 119 static const int kMiterIndexCnt = 3 * 24;
120 static const int kMiterVertexCnt = 16; 120 static const int kMiterVertexCnt = 16;
121 static const int kNumMiterRectsInIndexBuffer = 256; 121 static const int kNumMiterRectsInIndexBuffer = 256;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 }; 160 };
161 161
162 BatchTracker fBatch; 162 BatchTracker fBatch;
163 SkSTArray<1, Geometry, true> fGeoData; 163 SkSTArray<1, Geometry, true> fGeoData;
164 SkMatrix fViewMatrix; 164 SkMatrix fViewMatrix;
165 bool fMiterStroke; 165 bool fMiterStroke;
166 166
167 typedef GrVertexBatch INHERITED; 167 typedef GrVertexBatch INHERITED;
168 }; 168 };
169 169
170 void AAStrokeRectBatch::initBatchTracker(const GrPipelineOptimizations& opt) { 170 void AAStrokeRectBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) {
171 // Handle any color overrides 171 // Handle any color overrides
172 if (!opt.readsColor()) { 172 if (!overrides.readsColor()) {
173 fGeoData[0].fColor = GrColor_ILLEGAL; 173 fGeoData[0].fColor = GrColor_ILLEGAL;
174 } 174 }
175 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 175 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
176 176
177 // setup batch properties 177 // setup batch properties
178 fBatch.fColorIgnored = !opt.readsColor(); 178 fBatch.fColorIgnored = !overrides.readsColor();
179 fBatch.fColor = fGeoData[0].fColor; 179 fBatch.fColor = fGeoData[0].fColor;
180 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 180 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
181 fBatch.fCoverageIgnored = !opt.readsCoverage(); 181 fBatch.fCoverageIgnored = !overrides.readsCoverage();
182 fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage(); 182 fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage();
183 } 183 }
184 184
185 void AAStrokeRectBatch::onPrepareDraws(Target* target) { 185 void AAStrokeRectBatch::onPrepareDraws(Target* target) {
186 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 186 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
187 187
188 SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlp haForCoverage, 188 SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlp haForCoverage,
189 this->viewM atrix(), 189 this->viewM atrix(),
190 this->usesL ocalCoords(), 190 this->usesL ocalCoords(),
191 this->cover ageIgnored())); 191 this->cover ageIgnored()));
192 if (!gp) { 192 if (!gp) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 SkRect inside = outside; 656 SkRect inside = outside;
657 inside.inset(strokeWidth, strokeWidth); 657 inside.inset(strokeWidth, strokeWidth);
658 658
659 GrColor color = GrRandomColor(random); 659 GrColor color = GrRandomColor(random);
660 660
661 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist, 661 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist,
662 inside, miterStroke, inside.isFinite() && inside.isEmpty()); 662 inside, miterStroke, inside.isFinite() && inside.isEmpty());
663 } 663 }
664 664
665 #endif 665 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAtlasTextBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698