| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
| 10 | 10 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 * distance with negative being inside, positive outside. The edge is specified
in | 499 * distance with negative being inside, positive outside. The edge is specified
in |
| 500 * window space (y-down). If either the third or fourth component of the interpo
lated | 500 * window space (y-down). If either the third or fourth component of the interpo
lated |
| 501 * vertex coord is > 0 then the pixel is considered outside the edge. This is us
ed to | 501 * vertex coord is > 0 then the pixel is considered outside the edge. This is us
ed to |
| 502 * attempt to trim to a portion of the infinite quad. | 502 * attempt to trim to a portion of the infinite quad. |
| 503 * Requires shader derivative instruction support. | 503 * Requires shader derivative instruction support. |
| 504 */ | 504 */ |
| 505 | 505 |
| 506 class QuadEdgeEffect : public GrVertexEffect { | 506 class QuadEdgeEffect : public GrVertexEffect { |
| 507 public: | 507 public: |
| 508 | 508 |
| 509 static GrEffectRef* Create() { | 509 static GrEffect* Create() { |
| 510 GR_CREATE_STATIC_EFFECT(gQuadEdgeEffect, QuadEdgeEffect, ()); | 510 GR_CREATE_STATIC_EFFECT(gQuadEdgeEffect, QuadEdgeEffect, ()); |
| 511 gQuadEdgeEffect->ref(); | 511 gQuadEdgeEffect->ref(); |
| 512 return gQuadEdgeEffect; | 512 return gQuadEdgeEffect; |
| 513 } | 513 } |
| 514 | 514 |
| 515 virtual ~QuadEdgeEffect() {} | 515 virtual ~QuadEdgeEffect() {} |
| 516 | 516 |
| 517 static const char* Name() { return "QuadEdge"; } | 517 static const char* Name() { return "QuadEdge"; } |
| 518 | 518 |
| 519 virtual void getConstantColorComponents(GrColor* color, | 519 virtual void getConstantColorComponents(GrColor* color, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 return true; | 588 return true; |
| 589 } | 589 } |
| 590 | 590 |
| 591 GR_DECLARE_EFFECT_TEST; | 591 GR_DECLARE_EFFECT_TEST; |
| 592 | 592 |
| 593 typedef GrVertexEffect INHERITED; | 593 typedef GrVertexEffect INHERITED; |
| 594 }; | 594 }; |
| 595 | 595 |
| 596 GR_DEFINE_EFFECT_TEST(QuadEdgeEffect); | 596 GR_DEFINE_EFFECT_TEST(QuadEdgeEffect); |
| 597 | 597 |
| 598 GrEffectRef* QuadEdgeEffect::TestCreate(SkRandom* random, | 598 GrEffect* QuadEdgeEffect::TestCreate(SkRandom* random, |
| 599 GrContext*, | 599 GrContext*, |
| 600 const GrDrawTargetCaps& caps, | 600 const GrDrawTargetCaps& caps, |
| 601 GrTexture*[]) { | 601 GrTexture*[]) { |
| 602 // Doesn't work without derivative instructions. | 602 // Doesn't work without derivative instructions. |
| 603 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL; | 603 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL; |
| 604 } | 604 } |
| 605 | 605 |
| 606 /////////////////////////////////////////////////////////////////////////////// | 606 /////////////////////////////////////////////////////////////////////////////// |
| 607 | 607 |
| 608 bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path, | 608 bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path, |
| 609 const SkStrokeRec& stroke, | 609 const SkStrokeRec& stroke, |
| 610 const GrDrawTarget* target, | 610 const GrDrawTarget* target, |
| 611 bool antiAlias) const { | 611 bool antiAlias) const { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { | 668 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { |
| 669 return false; | 669 return false; |
| 670 } | 670 } |
| 671 | 671 |
| 672 // Our computed verts should all be within one pixel of the segment control
points. | 672 // Our computed verts should all be within one pixel of the segment control
points. |
| 673 devBounds.outset(SK_Scalar1, SK_Scalar1); | 673 devBounds.outset(SK_Scalar1, SK_Scalar1); |
| 674 | 674 |
| 675 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs)); | 675 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs)); |
| 676 | 676 |
| 677 static const int kEdgeAttrIndex = 1; | 677 static const int kEdgeAttrIndex = 1; |
| 678 GrEffectRef* quadEffect = QuadEdgeEffect::Create(); | 678 GrEffect* quadEffect = QuadEdgeEffect::Create(); |
| 679 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref(); | 679 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref(); |
| 680 | 680 |
| 681 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); | 681 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); |
| 682 if (!arg.succeeded()) { | 682 if (!arg.succeeded()) { |
| 683 return false; | 683 return false; |
| 684 } | 684 } |
| 685 SkASSERT(sizeof(QuadVertex) == drawState->getVertexSize()); | 685 SkASSERT(sizeof(QuadVertex) == drawState->getVertexSize()); |
| 686 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 686 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
| 687 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 687 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
| 688 | 688 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 708 vOffset, // start vertex | 708 vOffset, // start vertex |
| 709 0, // start index | 709 0, // start index |
| 710 draw.fVertexCnt, | 710 draw.fVertexCnt, |
| 711 draw.fIndexCnt, | 711 draw.fIndexCnt, |
| 712 &devBounds); | 712 &devBounds); |
| 713 vOffset += draw.fVertexCnt; | 713 vOffset += draw.fVertexCnt; |
| 714 } | 714 } |
| 715 | 715 |
| 716 return true; | 716 return true; |
| 717 } | 717 } |
| OLD | NEW |