| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 */ | 70 */ |
| 71 | 71 |
| 72 class CircleEdgeEffect : public GrGeometryProcessor { | 72 class CircleEdgeEffect : public GrGeometryProcessor { |
| 73 public: | 73 public: |
| 74 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { | 74 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri
x& localMatrix) { |
| 75 return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix)); | 75 return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 const Attribute* inPosition() const { return fInPosition; } | 78 const Attribute* inPosition() const { return fInPosition; } |
| 79 const Attribute* inCircleEdge() const { return fInCircleEdge; } | 79 const Attribute* inCircleEdge() const { return fInCircleEdge; } |
| 80 GrColor color() const { return fColor; } |
| 80 virtual ~CircleEdgeEffect() {} | 81 virtual ~CircleEdgeEffect() {} |
| 81 | 82 |
| 82 const char* name() const override { return "CircleEdge"; } | 83 const char* name() const override { return "CircleEdge"; } |
| 83 | 84 |
| 84 inline bool isStroked() const { return fStroke; } | 85 inline bool isStroked() const { return fStroke; } |
| 85 | 86 |
| 86 class GLProcessor : public GrGLGeometryProcessor { | 87 class GLProcessor : public GrGLGeometryProcessor { |
| 87 public: | 88 public: |
| 88 GLProcessor(const GrGeometryProcessor&, | 89 GLProcessor(const GrGeometryProcessor&, |
| 89 const GrBatchTracker&) | 90 const GrBatchTracker&) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 170 } |
| 170 | 171 |
| 171 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 172 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 172 BatchTracker* local = bt->cast<BatchTracker>(); | 173 BatchTracker* local = bt->cast<BatchTracker>(); |
| 173 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 174 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 174 local->fUsesLocalCoords = init.fUsesLocalCoords; | 175 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 175 } | 176 } |
| 176 | 177 |
| 177 private: | 178 private: |
| 178 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 179 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
| 179 : INHERITED(color, SkMatrix::I(), localMatrix) { | 180 : INHERITED(SkMatrix::I(), localMatrix) |
| 181 , fColor(color) { |
| 180 this->initClassID<CircleEdgeEffect>(); | 182 this->initClassID<CircleEdgeEffect>(); |
| 181 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 183 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
| 182 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", | 184 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", |
| 183 kVec4f_GrVertexAttrib
Type)); | 185 kVec4f_GrVertexAttrib
Type)); |
| 184 fStroke = stroke; | 186 fStroke = stroke; |
| 185 } | 187 } |
| 186 | 188 |
| 187 struct BatchTracker { | 189 struct BatchTracker { |
| 188 GrGPInput fInputColorType; | 190 GrGPInput fInputColorType; |
| 189 GrColor fColor; | 191 GrColor fColor; |
| 190 bool fUsesLocalCoords; | 192 bool fUsesLocalCoords; |
| 191 }; | 193 }; |
| 192 | 194 |
| 195 GrColor fColor; |
| 193 const Attribute* fInPosition; | 196 const Attribute* fInPosition; |
| 194 const Attribute* fInCircleEdge; | 197 const Attribute* fInCircleEdge; |
| 195 bool fStroke; | 198 bool fStroke; |
| 196 | 199 |
| 197 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 200 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 198 | 201 |
| 199 typedef GrGeometryProcessor INHERITED; | 202 typedef GrGeometryProcessor INHERITED; |
| 200 }; | 203 }; |
| 201 | 204 |
| 202 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect); | 205 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 226 return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix)); | 229 return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix)); |
| 227 } | 230 } |
| 228 | 231 |
| 229 virtual ~EllipseEdgeEffect() {} | 232 virtual ~EllipseEdgeEffect() {} |
| 230 | 233 |
| 231 const char* name() const override { return "EllipseEdge"; } | 234 const char* name() const override { return "EllipseEdge"; } |
| 232 | 235 |
| 233 const Attribute* inPosition() const { return fInPosition; } | 236 const Attribute* inPosition() const { return fInPosition; } |
| 234 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } | 237 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } |
| 235 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } | 238 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } |
| 239 GrColor color() const { return fColor; } |
| 236 | 240 |
| 237 inline bool isStroked() const { return fStroke; } | 241 inline bool isStroked() const { return fStroke; } |
| 238 | 242 |
| 239 class GLProcessor : public GrGLGeometryProcessor { | 243 class GLProcessor : public GrGLGeometryProcessor { |
| 240 public: | 244 public: |
| 241 GLProcessor(const GrGeometryProcessor&, | 245 GLProcessor(const GrGeometryProcessor&, |
| 242 const GrBatchTracker&) | 246 const GrBatchTracker&) |
| 243 : fColor(GrColor_ILLEGAL) {} | 247 : fColor(GrColor_ILLEGAL) {} |
| 244 | 248 |
| 245 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 249 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 348 } |
| 345 | 349 |
| 346 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 350 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 347 BatchTracker* local = bt->cast<BatchTracker>(); | 351 BatchTracker* local = bt->cast<BatchTracker>(); |
| 348 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 352 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 349 local->fUsesLocalCoords = init.fUsesLocalCoords; | 353 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 350 } | 354 } |
| 351 | 355 |
| 352 private: | 356 private: |
| 353 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) | 357 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix) |
| 354 : INHERITED(color, SkMatrix::I(), localMatrix) { | 358 : INHERITED(SkMatrix::I(), localMatrix) |
| 359 , fColor(color) { |
| 355 this->initClassID<EllipseEdgeEffect>(); | 360 this->initClassID<EllipseEdgeEffect>(); |
| 356 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 361 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
| 357 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", | 362 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", |
| 358 kVec2f_GrVertexAtt
ribType)); | 363 kVec2f_GrVertexAtt
ribType)); |
| 359 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", | 364 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", |
| 360 kVec4f_GrVertexAttr
ibType)); | 365 kVec4f_GrVertexAttr
ibType)); |
| 361 fStroke = stroke; | 366 fStroke = stroke; |
| 362 } | 367 } |
| 363 | 368 |
| 364 struct BatchTracker { | 369 struct BatchTracker { |
| 365 GrGPInput fInputColorType; | 370 GrGPInput fInputColorType; |
| 366 GrColor fColor; | 371 GrColor fColor; |
| 367 bool fUsesLocalCoords; | 372 bool fUsesLocalCoords; |
| 368 }; | 373 }; |
| 369 | 374 |
| 370 const Attribute* fInPosition; | 375 const Attribute* fInPosition; |
| 371 const Attribute* fInEllipseOffset; | 376 const Attribute* fInEllipseOffset; |
| 372 const Attribute* fInEllipseRadii; | 377 const Attribute* fInEllipseRadii; |
| 378 GrColor fColor; |
| 373 bool fStroke; | 379 bool fStroke; |
| 374 | 380 |
| 375 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 381 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 376 | 382 |
| 377 typedef GrGeometryProcessor INHERITED; | 383 typedef GrGeometryProcessor INHERITED; |
| 378 }; | 384 }; |
| 379 | 385 |
| 380 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect); | 386 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect); |
| 381 | 387 |
| 382 GrGeometryProcessor* EllipseEdgeEffect::TestCreate(SkRandom* random, | 388 GrGeometryProcessor* EllipseEdgeEffect::TestCreate(SkRandom* random, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 407 return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode)); | 413 return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode)); |
| 408 } | 414 } |
| 409 | 415 |
| 410 virtual ~DIEllipseEdgeEffect() {} | 416 virtual ~DIEllipseEdgeEffect() {} |
| 411 | 417 |
| 412 const char* name() const override { return "DIEllipseEdge"; } | 418 const char* name() const override { return "DIEllipseEdge"; } |
| 413 | 419 |
| 414 const Attribute* inPosition() const { return fInPosition; } | 420 const Attribute* inPosition() const { return fInPosition; } |
| 415 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } | 421 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } |
| 416 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } | 422 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } |
| 423 GrColor color() const { return fColor; } |
| 417 | 424 |
| 418 inline Mode getMode() const { return fMode; } | 425 inline Mode getMode() const { return fMode; } |
| 419 | 426 |
| 420 class GLProcessor : public GrGLGeometryProcessor { | 427 class GLProcessor : public GrGLGeometryProcessor { |
| 421 public: | 428 public: |
| 422 GLProcessor(const GrGeometryProcessor&, | 429 GLProcessor(const GrGeometryProcessor&, |
| 423 const GrBatchTracker&) | 430 const GrBatchTracker&) |
| 424 : fColor(GrColor_ILLEGAL) {} | 431 : fColor(GrColor_ILLEGAL) {} |
| 425 | 432 |
| 426 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 433 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 546 } |
| 540 | 547 |
| 541 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 548 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 542 BatchTracker* local = bt->cast<BatchTracker>(); | 549 BatchTracker* local = bt->cast<BatchTracker>(); |
| 543 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 550 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 544 local->fUsesLocalCoords = init.fUsesLocalCoords; | 551 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 545 } | 552 } |
| 546 | 553 |
| 547 private: | 554 private: |
| 548 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) | 555 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode) |
| 549 : INHERITED(color, viewMatrix) { | 556 : INHERITED(viewMatrix) |
| 557 , fColor(color) { |
| 550 this->initClassID<DIEllipseEdgeEffect>(); | 558 this->initClassID<DIEllipseEdgeEffect>(); |
| 551 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 559 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
| 552 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", | 560 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", |
| 553 kVec2f_GrVertexA
ttribType)); | 561 kVec2f_GrVertexA
ttribType)); |
| 554 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", | 562 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", |
| 555 kVec2f_GrVertexA
ttribType)); | 563 kVec2f_GrVertexA
ttribType)); |
| 556 fMode = mode; | 564 fMode = mode; |
| 557 } | 565 } |
| 558 | 566 |
| 559 struct BatchTracker { | 567 struct BatchTracker { |
| 560 GrGPInput fInputColorType; | 568 GrGPInput fInputColorType; |
| 561 GrColor fColor; | 569 GrColor fColor; |
| 562 bool fUsesLocalCoords; | 570 bool fUsesLocalCoords; |
| 563 }; | 571 }; |
| 564 | 572 |
| 565 const Attribute* fInPosition; | 573 const Attribute* fInPosition; |
| 566 const Attribute* fInEllipseOffsets0; | 574 const Attribute* fInEllipseOffsets0; |
| 567 const Attribute* fInEllipseOffsets1; | 575 const Attribute* fInEllipseOffsets1; |
| 576 GrColor fColor; |
| 568 Mode fMode; | 577 Mode fMode; |
| 569 | 578 |
| 570 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 579 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 571 | 580 |
| 572 typedef GrGeometryProcessor INHERITED; | 581 typedef GrGeometryProcessor INHERITED; |
| 573 }; | 582 }; |
| 574 | 583 |
| 575 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect); | 584 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect); |
| 576 | 585 |
| 577 GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(SkRandom* random, | 586 GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(SkRandom* random, |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 } | 2067 } |
| 2059 | 2068 |
| 2060 BATCH_TEST_DEFINE(RRectBatch) { | 2069 BATCH_TEST_DEFINE(RRectBatch) { |
| 2061 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2070 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
| 2062 GrColor color = GrRandomColor(random); | 2071 GrColor color = GrRandomColor(random); |
| 2063 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2072 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
| 2064 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2073 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
| 2065 } | 2074 } |
| 2066 | 2075 |
| 2067 #endif | 2076 #endif |
| OLD | NEW |