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

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

Issue 1345393003: Revert of add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
250 struct Geometry { 248 struct Geometry {
249 GrColor fColor;
251 SkMatrix fViewMatrix; 250 SkMatrix fViewMatrix;
252 SkMatrix fSrcRotInv; 251 SkMatrix fSrcRotInv;
253 SkPoint fPtsRot[2]; 252 SkPoint fPtsRot[2];
254 SkScalar fSrcStrokeWidth; 253 SkScalar fSrcStrokeWidth;
255 SkScalar fPhase; 254 SkScalar fPhase;
256 SkScalar fIntervals[2]; 255 SkScalar fIntervals[2];
257 SkScalar fParallelScale; 256 SkScalar fParallelScale;
258 SkScalar fPerpendicularScale; 257 SkScalar fPerpendicularScale;
259 GrColor fColor;
260 }; 258 };
261 259
262 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA AMode aaMode, 260 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA AMode aaMode,
263 bool fullDash) { 261 bool fullDash) {
264 return new DashBatch(geometry, cap, aaMode, fullDash); 262 return new DashBatch(geometry, cap, aaMode, fullDash);
265 } 263 }
266 264
267 const char* name() const override { return "DashBatch"; } 265 const char* name() const override { return "DashBatch"; }
268 266
269 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 267 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
270 // 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
271 out->setKnownFourComponents(fGeoData[0].fColor); 269 out->setKnownFourComponents(fGeoData[0].fColor);
272 } 270 }
273 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 271 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
274 out->setUnknownSingleComponent(); 272 out->setUnknownSingleComponent();
275 } 273 }
276 274
277 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
278 276
279 private: 277 private:
280 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) 278 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) {
281 : INHERITED(ClassID()) { 279 this->initClassID<DashBatch>();
282 fGeoData.push_back(geometry); 280 fGeoData.push_back(geometry);
283 281
284 fBatch.fAAMode = aaMode; 282 fBatch.fAAMode = aaMode;
285 fBatch.fCap = cap; 283 fBatch.fCap = cap;
286 fBatch.fFullDash = fullDash; 284 fBatch.fFullDash = fullDash;
287 285
288 // compute bounds 286 // compute bounds
289 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; 287 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
290 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; 288 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth;
291 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); 289 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 SkPaint::Cap fCap; 667 SkPaint::Cap fCap;
670 DashAAMode fAAMode; 668 DashAAMode fAAMode;
671 bool fFullDash; 669 bool fFullDash;
672 }; 670 };
673 671
674 static const int kVertsPerDash = 4; 672 static const int kVertsPerDash = 4;
675 static const int kIndicesPerDash = 6; 673 static const int kIndicesPerDash = 6;
676 674
677 BatchTracker fBatch; 675 BatchTracker fBatch;
678 SkSTArray<1, Geometry, true> fGeoData; 676 SkSTArray<1, Geometry, true> fGeoData;
679
680 typedef GrVertexBatch INHERITED;
681 }; 677 };
682 678
683 static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons t SkPoint pts[2], 679 static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons t SkPoint pts[2],
684 bool useAA, const GrStrokeInfo& strokeInfo, boo l msaaRT) { 680 bool useAA, const GrStrokeInfo& strokeInfo, boo l msaaRT) {
685 const SkScalar* intervals = strokeInfo.getDashIntervals(); 681 const SkScalar* intervals = strokeInfo.getDashIntervals();
686 SkScalar phase = strokeInfo.getDashPhase(); 682 SkScalar phase = strokeInfo.getDashPhase();
687 683
688 SkPaint::Cap cap = strokeInfo.getCap(); 684 SkPaint::Cap cap = strokeInfo.getCap();
689 685
690 DashBatch::Geometry geometry; 686 DashBatch::Geometry geometry;
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 info.fIntervals = intervals; 1274 info.fIntervals = intervals;
1279 info.fCount = 2; 1275 info.fCount = 2;
1280 info.fPhase = phase; 1276 info.fPhase = phase;
1281 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1277 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1282 SkASSERT(success); 1278 SkASSERT(success);
1283 1279
1284 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1280 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1285 } 1281 }
1286 1282
1287 #endif 1283 #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