OLD | NEW |
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 Loading... |
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 | |
36 struct Geometry : public GrTestBatch::Geometry { | 35 struct Geometry : public GrTestBatch::Geometry { |
37 SkRect fBounds; | 36 SkRect fBounds; |
38 }; | 37 }; |
39 | 38 |
40 const char* name() const override { return "BezierCubicOrConicTestBatch"; } | 39 const char* name() const override { return "BezierCubicOrConicTestBatch"; } |
41 | 40 |
42 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge
o, | 41 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge
o, |
43 const SkScalar klmEqs[9], SkScalar sign) { | 42 const SkScalar klmEqs[9], SkScalar sign) { |
44 return new BezierCubicOrConicTestBatch(gp, geo, klmEqs, sign); | 43 return new BezierCubicOrConicTestBatch(gp, geo, klmEqs, sign); |
45 } | 44 } |
46 | 45 |
47 private: | 46 private: |
48 BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& g
eo, | 47 BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& g
eo, |
49 const SkScalar klmEqs[9], SkScalar sign) | 48 const SkScalar klmEqs[9], SkScalar sign) |
50 : INHERITED(ClassID(), gp, geo.fBounds) { | 49 : INHERITED(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 Loading... |
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 | |
436 struct Geometry : public GrTestBatch::Geometry { | 435 struct Geometry : public GrTestBatch::Geometry { |
437 SkRect fBounds; | 436 SkRect fBounds; |
438 }; | 437 }; |
439 | 438 |
440 const char* name() const override { return "BezierQuadTestBatch"; } | 439 const char* name() const override { return "BezierQuadTestBatch"; } |
441 | 440 |
442 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge
o, | 441 static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& ge
o, |
443 const GrPathUtils::QuadUVMatrix& devToUV) { | 442 const GrPathUtils::QuadUVMatrix& devToUV) { |
444 return new BezierQuadTestBatch(gp, geo, devToUV); | 443 return new BezierQuadTestBatch(gp, geo, devToUV); |
445 } | 444 } |
446 | 445 |
447 private: | 446 private: |
448 BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo, | 447 BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo, |
449 const GrPathUtils::QuadUVMatrix& devToUV) | 448 const GrPathUtils::QuadUVMatrix& devToUV) |
450 : INHERITED(ClassID(), gp, geo.fBounds) | 449 : INHERITED(gp, geo.fBounds) |
451 , fGeometry(geo) | 450 , fGeometry(geo) |
452 , fDevToUV(devToUV) { | 451 , 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 Loading... |
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 |
OLD | NEW |