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

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

Issue 1352813003: add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 3 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/GrVertexBatch.cpp ('k') | tests/GrPorterDuffTest.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 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 * position relative to the dashed line. 238 * position relative to the dashed line.
239 */ 239 */
240 static GrGeometryProcessor* create_dash_gp(GrColor, 240 static GrGeometryProcessor* create_dash_gp(GrColor,
241 DashAAMode aaMode, 241 DashAAMode aaMode,
242 DashCap cap, 242 DashCap cap,
243 const SkMatrix& localMatrix, 243 const SkMatrix& localMatrix,
244 bool usesLocalCoords); 244 bool usesLocalCoords);
245 245
246 class DashBatch : public GrVertexBatch { 246 class DashBatch : public GrVertexBatch {
247 public: 247 public:
248 DEFINE_BATCH_CLASS_ID
249
248 struct Geometry { 250 struct Geometry {
249 GrColor fColor;
250 SkMatrix fViewMatrix; 251 SkMatrix fViewMatrix;
251 SkMatrix fSrcRotInv; 252 SkMatrix fSrcRotInv;
252 SkPoint fPtsRot[2]; 253 SkPoint fPtsRot[2];
253 SkScalar fSrcStrokeWidth; 254 SkScalar fSrcStrokeWidth;
254 SkScalar fPhase; 255 SkScalar fPhase;
255 SkScalar fIntervals[2]; 256 SkScalar fIntervals[2];
256 SkScalar fParallelScale; 257 SkScalar fParallelScale;
257 SkScalar fPerpendicularScale; 258 SkScalar fPerpendicularScale;
259 GrColor fColor;
258 }; 260 };
259 261
260 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA AMode aaMode, 262 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA AMode aaMode,
261 bool fullDash) { 263 bool fullDash) {
262 return new DashBatch(geometry, cap, aaMode, fullDash); 264 return new DashBatch(geometry, cap, aaMode, fullDash);
263 } 265 }
264 266
265 const char* name() const override { return "DashBatch"; } 267 const char* name() const override { return "DashBatch"; }
266 268
267 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 269 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
268 // When this is called on a batch, there is only one geometry bundle 270 // When this is called on a batch, there is only one geometry bundle
269 out->setKnownFourComponents(fGeoData[0].fColor); 271 out->setKnownFourComponents(fGeoData[0].fColor);
270 } 272 }
271 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 273 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
272 out->setUnknownSingleComponent(); 274 out->setUnknownSingleComponent();
273 } 275 }
274 276
275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 277 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
276 278
277 private: 279 private:
278 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) { 280 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash)
279 this->initClassID<DashBatch>(); 281 : INHERITED(ClassID()) {
280 fGeoData.push_back(geometry); 282 fGeoData.push_back(geometry);
281 283
282 fBatch.fAAMode = aaMode; 284 fBatch.fAAMode = aaMode;
283 fBatch.fCap = cap; 285 fBatch.fCap = cap;
284 fBatch.fFullDash = fullDash; 286 fBatch.fFullDash = fullDash;
285 287
286 // compute bounds 288 // compute bounds
287 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; 289 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
288 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; 290 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth;
289 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); 291 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 SkPaint::Cap fCap; 669 SkPaint::Cap fCap;
668 DashAAMode fAAMode; 670 DashAAMode fAAMode;
669 bool fFullDash; 671 bool fFullDash;
670 }; 672 };
671 673
672 static const int kVertsPerDash = 4; 674 static const int kVertsPerDash = 4;
673 static const int kIndicesPerDash = 6; 675 static const int kIndicesPerDash = 6;
674 676
675 BatchTracker fBatch; 677 BatchTracker fBatch;
676 SkSTArray<1, Geometry, true> fGeoData; 678 SkSTArray<1, Geometry, true> fGeoData;
679
680 typedef GrVertexBatch INHERITED;
677 }; 681 };
678 682
679 static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons t SkPoint pts[2], 683 static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons t SkPoint pts[2],
680 bool useAA, const GrStrokeInfo& strokeInfo, boo l msaaRT) { 684 bool useAA, const GrStrokeInfo& strokeInfo, boo l msaaRT) {
681 const SkScalar* intervals = strokeInfo.getDashIntervals(); 685 const SkScalar* intervals = strokeInfo.getDashIntervals();
682 SkScalar phase = strokeInfo.getDashPhase(); 686 SkScalar phase = strokeInfo.getDashPhase();
683 687
684 SkPaint::Cap cap = strokeInfo.getCap(); 688 SkPaint::Cap cap = strokeInfo.getCap();
685 689
686 DashBatch::Geometry geometry; 690 DashBatch::Geometry geometry;
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 info.fIntervals = intervals; 1278 info.fIntervals = intervals;
1275 info.fCount = 2; 1279 info.fCount = 2;
1276 info.fPhase = phase; 1280 info.fPhase = phase;
1277 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1281 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1278 SkASSERT(success); 1282 SkASSERT(success);
1279 1283
1280 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1284 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1281 } 1285 }
1282 1286
1283 #endif 1287 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrVertexBatch.cpp ('k') | tests/GrPorterDuffTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698