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

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 1301663002: Privatize GrBatch subclass overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@drawsonvb
Patch Set: more 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/batches/GrStrokeRectBatch.h ('k') | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const char* name() const override { return "DashBatch"; } 265 const char* name() const override { return "DashBatch"; }
266 266
267 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 267 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
268 // When this is called on a batch, there is only one geometry bundle 268 // When this is called on a batch, there is only one geometry bundle
269 out->setKnownFourComponents(fGeoData[0].fColor); 269 out->setKnownFourComponents(fGeoData[0].fColor);
270 } 270 }
271 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 271 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
272 out->setUnknownSingleComponent(); 272 out->setUnknownSingleComponent();
273 } 273 }
274 274
275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
276
277 private:
278 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) {
279 this->initClassID<DashBatch>();
280 fGeoData.push_back(geometry);
281
282 fBatch.fAAMode = aaMode;
283 fBatch.fCap = cap;
284 fBatch.fFullDash = fullDash;
285
286 // compute bounds
287 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
288 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth;
289 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]);
290 fBounds.outset(xBloat, halfStrokeWidth);
291
292 // Note, we actually create the combined matrix here, and save the work
293 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv;
294 combinedMatrix.postConcat(geometry.fViewMatrix);
295 combinedMatrix.mapRect(&fBounds);
296 }
297
275 void initBatchTracker(const GrPipelineOptimizations& opt) override { 298 void initBatchTracker(const GrPipelineOptimizations& opt) override {
276 // Handle any color overrides 299 // Handle any color overrides
277 if (!opt.readsColor()) { 300 if (!opt.readsColor()) {
278 fGeoData[0].fColor = GrColor_ILLEGAL; 301 fGeoData[0].fColor = GrColor_ILLEGAL;
279 } 302 }
280 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 303 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
281 304
282 // setup batch properties 305 // setup batch properties
283 fBatch.fColorIgnored = !opt.readsColor(); 306 fBatch.fColorIgnored = !opt.readsColor();
284 fBatch.fColor = fGeoData[0].fColor; 307 fBatch.fColor = fGeoData[0].fColor;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRo tInv, verts); 610 setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRo tInv, verts);
588 } 611 }
589 curVIdx += 4; 612 curVIdx += 4;
590 } 613 }
591 rectIndex++; 614 rectIndex++;
592 } 615 }
593 SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount); 616 SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
594 helper.recordDraw(target); 617 helper.recordDraw(target);
595 } 618 }
596 619
597 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
598
599 private:
600 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) {
601 this->initClassID<DashBatch>();
602 fGeoData.push_back(geometry);
603
604 fBatch.fAAMode = aaMode;
605 fBatch.fCap = cap;
606 fBatch.fFullDash = fullDash;
607
608 // compute bounds
609 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
610 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth;
611 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]);
612 fBounds.outset(xBloat, halfStrokeWidth);
613
614 // Note, we actually create the combined matrix here, and save the work
615 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv;
616 combinedMatrix.postConcat(geometry.fViewMatrix);
617 combinedMatrix.mapRect(&fBounds);
618 }
619
620 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 620 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
621 DashBatch* that = t->cast<DashBatch>(); 621 DashBatch* that = t->cast<DashBatch>();
622 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 622 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
623 that->bounds(), caps)) { 623 that->bounds(), caps)) {
624 return false; 624 return false;
625 } 625 }
626 626
627 if (this->aaMode() != that->aaMode()) { 627 if (this->aaMode() != that->aaMode()) {
628 return false; 628 return false;
629 } 629 }
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 info.fIntervals = intervals; 1297 info.fIntervals = intervals;
1298 info.fCount = 2; 1298 info.fCount = 2;
1299 info.fPhase = phase; 1299 info.fPhase = phase;
1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1301 SkASSERT(success); 1301 SkASSERT(success);
1302 1302
1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1304 } 1304 }
1305 1305
1306 #endif 1306 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrStrokeRectBatch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698