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

Side by Side Diff: gm/beziereffects.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 | « no previous file | gm/convexpolyeffect.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
(...skipping 14 matching lines...) Expand all
25 #include "effects/GrBezierEffect.h" 25 #include "effects/GrBezierEffect.h"
26 26
27 static inline SkScalar eval_line(const SkPoint& p, const SkScalar lineEq[3], SkS calar sign) { 27 static inline SkScalar eval_line(const SkPoint& p, const SkScalar lineEq[3], SkS calar sign) {
28 return sign * (lineEq[0] * p.fX + lineEq[1] * p.fY + lineEq[2]); 28 return sign * (lineEq[0] * p.fX + lineEq[1] * p.fY + lineEq[2]);
29 } 29 }
30 30
31 namespace skiagm { 31 namespace skiagm {
32 32
33 class BezierCubicOrConicTestBatch : public GrTestBatch { 33 class BezierCubicOrConicTestBatch : public GrTestBatch {
34 public: 34 public:
35 DEFINE_BATCH_CLASS_ID
35 struct Geometry : public GrTestBatch::Geometry { 36 struct Geometry : public GrTestBatch::Geometry {
36 SkRect fBounds; 37 SkRect fBounds;
37 }; 38 };
38 39
39 const char* name() const override { return "BezierCubicOrConicTestBatch"; } 40 const char* name() const override { return "BezierCubicOrConicTestBatch"; }
40 41
41 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge o, 42 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge o,
42 const SkScalar klmEqs[9], SkScalar sign) { 43 const SkScalar klmEqs[9], SkScalar sign) {
43 return new BezierCubicOrConicTestBatch(gp, geo, klmEqs, sign); 44 return new BezierCubicOrConicTestBatch(gp, geo, klmEqs, sign);
44 } 45 }
45 46
46 private: 47 private:
47 BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& g eo, 48 BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& g eo,
48 const SkScalar klmEqs[9], SkScalar sign) 49 const SkScalar klmEqs[9], SkScalar sign)
49 : INHERITED(gp, geo.fBounds) { 50 : INHERITED(ClassID(), gp, geo.fBounds) {
50 this->initClassID<BezierCubicOrConicTestBatch>();
51 for (int i = 0; i < 9; i++) { 51 for (int i = 0; i < 9; i++) {
52 fKlmEqs[i] = klmEqs[i]; 52 fKlmEqs[i] = klmEqs[i];
53 } 53 }
54 54
55 fGeometry = geo; 55 fGeometry = geo;
56 fSign = sign; 56 fSign = sign;
57 } 57 }
58 58
59 struct Vertex { 59 struct Vertex {
60 SkPoint fPosition; 60 SkPoint fPosition;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 return conicCnt; 425 return conicCnt;
426 } 426 }
427 427
428 typedef GM INHERITED; 428 typedef GM INHERITED;
429 }; 429 };
430 430
431 ////////////////////////////////////////////////////////////////////////////// 431 //////////////////////////////////////////////////////////////////////////////
432 432
433 class BezierQuadTestBatch : public GrTestBatch { 433 class BezierQuadTestBatch : public GrTestBatch {
434 public: 434 public:
435 DEFINE_BATCH_CLASS_ID
435 struct Geometry : public GrTestBatch::Geometry { 436 struct Geometry : public GrTestBatch::Geometry {
436 SkRect fBounds; 437 SkRect fBounds;
437 }; 438 };
438 439
439 const char* name() const override { return "BezierQuadTestBatch"; } 440 const char* name() const override { return "BezierQuadTestBatch"; }
440 441
441 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge o, 442 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge o,
442 const GrPathUtils::QuadUVMatrix& devToUV) { 443 const GrPathUtils::QuadUVMatrix& devToUV) {
443 return new BezierQuadTestBatch(gp, geo, devToUV); 444 return new BezierQuadTestBatch(gp, geo, devToUV);
444 } 445 }
445 446
446 private: 447 private:
447 BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo, 448 BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
448 const GrPathUtils::QuadUVMatrix& devToUV) 449 const GrPathUtils::QuadUVMatrix& devToUV)
449 : INHERITED(gp, geo.fBounds) 450 : INHERITED(ClassID(), gp, geo.fBounds)
450 , fGeometry(geo) 451 , fGeometry(geo)
451 , fDevToUV(devToUV) { 452 , fDevToUV(devToUV) {
452 this->initClassID<BezierQuadTestBatch>();
453 } 453 }
454 454
455 struct Vertex { 455 struct Vertex {
456 SkPoint fPosition; 456 SkPoint fPosition;
457 float fKLM[4]; // The last value is ignored. The effect expects a vec4 f. 457 float fKLM[4]; // The last value is ignored. The effect expects a vec4 f.
458 }; 458 };
459 459
460 Geometry* geoData(int index) override { 460 Geometry* geoData(int index) override {
461 SkASSERT(0 == index); 461 SkASSERT(0 == index);
462 return &fGeometry; 462 return &fGeometry;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 private: 630 private:
631 typedef GM INHERITED; 631 typedef GM INHERITED;
632 }; 632 };
633 633
634 DEF_GM(return new BezierCubicEffects;) 634 DEF_GM(return new BezierCubicEffects;)
635 DEF_GM(return new BezierConicEffects;) 635 DEF_GM(return new BezierConicEffects;)
636 DEF_GM(return new BezierQuadEffects;) 636 DEF_GM(return new BezierQuadEffects;)
637 } 637 }
638 638
639 #endif 639 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/convexpolyeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698