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

Side by Side Diff: src/gpu/batches/GrNinePatch.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/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNonAAFillRectBatch.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 * 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 "GrNinePatch.h" 8 #include "GrNinePatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 fGeoData[i].fCenter.fLeft, fGeoData[i].fCenter.fTop, 67 fGeoData[i].fCenter.fLeft, fGeoData[i].fCenter.fTop,
68 fGeoData[i].fCenter.fRight, fGeoData[i].fCenter.fBottom, 68 fGeoData[i].fCenter.fRight, fGeoData[i].fCenter.fBottom,
69 fGeoData[i].fDst.fLeft, fGeoData[i].fDst.fTop, 69 fGeoData[i].fDst.fLeft, fGeoData[i].fDst.fTop,
70 fGeoData[i].fDst.fRight, fGeoData[i].fDst.fBottom); 70 fGeoData[i].fDst.fRight, fGeoData[i].fDst.fBottom);
71 } 71 }
72 72
73 str.append(INHERITED::dumpInfo()); 73 str.append(INHERITED::dumpInfo());
74 return str; 74 return str;
75 } 75 }
76 76
77 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 77 void computePipelineOptimizations(GrInitInvariantOutput* color,
78 out->setUnknownFourComponents(); 78 GrInitInvariantOutput* coverage,
79 } 79 GrBatchToXPOverrides* overrides) const ove rride {
80 80 color->setUnknownFourComponents();
81 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 81 coverage->setKnownSingleComponent(0xff);
82 out->setKnownSingleComponent(0xff); 82 overrides->fUsePLSDstRead = false;
83 } 83 }
84 84
85 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 85 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
86 86
87 private: 87 private:
88 void onPrepareDraws(Target* target) override { 88 void onPrepareDraws(Target* target) override {
89 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOpts.readsCoverage ())); 89 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov erage()));
90 if (!gp) { 90 if (!gp) {
91 SkDebugf("Couldn't create GrGeometryProcessor\n"); 91 SkDebugf("Couldn't create GrGeometryProcessor\n");
92 return; 92 return;
93 } 93 }
94 94
95 target->initDraw(gp, this->pipeline()); 95 target->initDraw(gp, this->pipeline());
96 96
97 size_t vertexStride = gp->getVertexStride(); 97 size_t vertexStride = gp->getVertexStride();
98 int instanceCount = fGeoData.count(); 98 int instanceCount = fGeoData.count();
99 99
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 for (int j = 0; j < 4; ++j) { 135 for (int j = 0; j < 4; ++j) {
136 *vertColor = geo.fColor; 136 *vertColor = geo.fColor;
137 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ; 137 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ;
138 } 138 }
139 verts += kVertsPerRect * vertexStride; 139 verts += kVertsPerRect * vertexStride;
140 } 140 }
141 } 141 }
142 helper.recordDraw(target); 142 helper.recordDraw(target);
143 } 143 }
144 144
145 void initBatchTracker(const GrPipelineOptimizations& opt) override { 145 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
146 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 146 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
147 fOpts = opt; 147 fOverrides = overrides;
148 } 148 }
149 149
150 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 150 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
151 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>(); 151 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>();
152 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 152 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
153 that->bounds(), caps)) { 153 that->bounds(), caps)) {
154 return false; 154 return false;
155 } 155 }
156 156
157 SkASSERT(this->fImageWidth == that->fImageWidth && 157 SkASSERT(this->fImageWidth == that->fImageWidth &&
158 this->fImageHeight == that->fImageHeight); 158 this->fImageHeight == that->fImageHeight);
159 159
160 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to 160 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to
161 // not tweaking 161 // not tweaking
162 if (fOpts.canTweakAlphaForCoverage() && !that->fOpts.canTweakAlphaForCov erage()) { 162 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakA lphaForCoverage()) {
163 fOpts = that->fOpts; 163 fOverrides = that->fOverrides;
164 } 164 }
165 165
166 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; 166 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ;
167 this->joinBounds(that->bounds()); 167 this->joinBounds(that->bounds());
168 return true; 168 return true;
169 } 169 }
170 170
171 GrPipelineOptimizations fOpts; 171 GrXPOverridesForBatch fOverrides;
172 int fImageWidth; 172 int fImageWidth;
173 int fImageHeight; 173 int fImageHeight;
174 SkSTArray<1, Geometry, true> fGeoData; 174 SkSTArray<1, Geometry, true> fGeoData;
175 175
176 typedef GrVertexBatch INHERITED; 176 typedef GrVertexBatch INHERITED;
177 }; 177 };
178 178
179 namespace GrNinePatch { 179 namespace GrNinePatch {
180 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight, 180 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight,
181 const SkIRect& center, const SkRect& dst) { 181 const SkIRect& center, const SkRect& dst) {
182 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst); 182 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst);
183 } 183 }
184 }; 184 };
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNonAAFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698