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

Side by Side Diff: src/gpu/GrAAConvexPathRenderer.cpp

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix Created 6 years 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/GrAAConvexPathRenderer.h ('k') | src/gpu/GrAADistanceFieldPathRenderer.h » ('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 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 * distance with negative being inside, positive outside. The edge is specified in 498 * distance with negative being inside, positive outside. The edge is specified in
499 * window space (y-down). If either the third or fourth component of the interpo lated 499 * window space (y-down). If either the third or fourth component of the interpo lated
500 * vertex coord is > 0 then the pixel is considered outside the edge. This is us ed to 500 * vertex coord is > 0 then the pixel is considered outside the edge. This is us ed to
501 * attempt to trim to a portion of the infinite quad. 501 * attempt to trim to a portion of the infinite quad.
502 * Requires shader derivative instruction support. 502 * Requires shader derivative instruction support.
503 */ 503 */
504 504
505 class QuadEdgeEffect : public GrGeometryProcessor { 505 class QuadEdgeEffect : public GrGeometryProcessor {
506 public: 506 public:
507 507
508 static GrGeometryProcessor* Create() { 508 static GrGeometryProcessor* Create(GrColor color) {
509 return SkNEW(QuadEdgeEffect); 509 return SkNEW_ARGS(QuadEdgeEffect, (color));
510 } 510 }
511 511
512 virtual ~QuadEdgeEffect() {} 512 virtual ~QuadEdgeEffect() {}
513 513
514 virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; } 514 virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; }
515 515
516 const GrAttribute* inPosition() const { return fInPosition; } 516 const GrAttribute* inPosition() const { return fInPosition; }
517 const GrAttribute* inQuadEdge() const { return fInQuadEdge; } 517 const GrAttribute* inQuadEdge() const { return fInQuadEdge; }
518 518
519 class GLProcessor : public GrGLGeometryProcessor { 519 class GLProcessor : public GrGLGeometryProcessor {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 const GrGLCaps& caps, 579 const GrGLCaps& caps,
580 GrProcessorKeyBuilder* b) const SK_OVERRIDE { 580 GrProcessorKeyBuilder* b) const SK_OVERRIDE {
581 GLProcessor::GenKey(*this, bt, caps, b); 581 GLProcessor::GenKey(*this, bt, caps, b);
582 } 582 }
583 583
584 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE { 584 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE {
585 return SkNEW_ARGS(GLProcessor, (*this, bt)); 585 return SkNEW_ARGS(GLProcessor, (*this, bt));
586 } 586 }
587 587
588 private: 588 private:
589 QuadEdgeEffect() { 589 QuadEdgeEffect(GrColor color) : INHERITED(color) {
590 this->initClassID<QuadEdgeEffect>(); 590 this->initClassID<QuadEdgeEffect>();
591 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr VertexAttribType)); 591 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr VertexAttribType));
592 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr VertexAttribType)); 592 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr VertexAttribType));
593 } 593 }
594 594
595 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 595 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE {
596 return true; 596 return true;
597 } 597 }
598 598
599 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE { 599 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE {
600 inout->mulByUnknownAlpha(); 600 inout->mulByUnknownAlpha();
601 } 601 }
602 602
603 const GrAttribute* fInPosition; 603 const GrAttribute* fInPosition;
604 const GrAttribute* fInQuadEdge; 604 const GrAttribute* fInQuadEdge;
605 605
606 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 606 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
607 607
608 typedef GrFragmentProcessor INHERITED; 608 typedef GrGeometryProcessor INHERITED;
609 }; 609 };
610 610
611 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect); 611 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
612 612
613 GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random, 613 GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random,
614 GrContext*, 614 GrContext*,
615 const GrDrawTargetCaps& caps, 615 const GrDrawTargetCaps& caps,
616 GrTexture*[]) { 616 GrTexture*[]) {
617 // Doesn't work without derivative instructions. 617 // Doesn't work without derivative instructions.
618 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL; 618 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create(GrRandomColor (random)) : NULL;
619 } 619 }
620 620
621 /////////////////////////////////////////////////////////////////////////////// 621 ///////////////////////////////////////////////////////////////////////////////
622 622
623 bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target, 623 bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target,
624 const GrDrawState*, 624 const GrDrawState*,
625 const SkPath& path, 625 const SkPath& path,
626 const SkStrokeRec& stroke, 626 const SkStrokeRec& stroke,
627 bool antiAlias) const { 627 bool antiAlias) const {
628 return (target->caps()->shaderDerivativeSupport() && antiAlias && 628 return (target->caps()->shaderDerivativeSupport() && antiAlias &&
629 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex() ); 629 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex() );
630 } 630 }
631 631
632 bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target, 632 bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
633 GrDrawState* drawState, 633 GrDrawState* drawState,
634 GrColor color,
634 const SkPath& origPath, 635 const SkPath& origPath,
635 const SkStrokeRec&, 636 const SkStrokeRec&,
636 bool antiAlias) { 637 bool antiAlias) {
637 638
638 const SkPath* path = &origPath; 639 const SkPath* path = &origPath;
639 if (path->isEmpty()) { 640 if (path->isEmpty()) {
640 return true; 641 return true;
641 } 642 }
642 643
643 SkMatrix viewMatrix = drawState->getViewMatrix(); 644 SkMatrix viewMatrix = drawState->getViewMatrix();
(...skipping 27 matching lines...) Expand all
671 // We can't simply use the path bounds because we may degenerate cubics to q uads which produces 672 // We can't simply use the path bounds because we may degenerate cubics to q uads which produces
672 // new control points outside the original convex hull. 673 // new control points outside the original convex hull.
673 SkRect devBounds; 674 SkRect devBounds;
674 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d evBounds)) { 675 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d evBounds)) {
675 return false; 676 return false;
676 } 677 }
677 678
678 // Our computed verts should all be within one pixel of the segment control points. 679 // Our computed verts should all be within one pixel of the segment control points.
679 devBounds.outset(SK_Scalar1, SK_Scalar1); 680 devBounds.outset(SK_Scalar1, SK_Scalar1);
680 681
681 GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create(); 682 GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create(color);
682 drawState->setGeometryProcessor(quadProcessor)->unref(); 683 drawState->setGeometryProcessor(quadProcessor)->unref();
683 684
684 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert exStride(), iCount); 685 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert exStride(), iCount);
685 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex)); 686 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex));
686 if (!arg.succeeded()) { 687 if (!arg.succeeded()) {
687 return false; 688 return false;
688 } 689 }
689 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); 690 verts = reinterpret_cast<QuadVertex*>(arg.vertices());
690 idxs = reinterpret_cast<uint16_t*>(arg.indices()); 691 idxs = reinterpret_cast<uint16_t*>(arg.indices());
691 692
(...skipping 20 matching lines...) Expand all
712 vOffset, // start vertex 713 vOffset, // start vertex
713 0, // start index 714 0, // start index
714 draw.fVertexCnt, 715 draw.fVertexCnt,
715 draw.fIndexCnt, 716 draw.fIndexCnt,
716 &devBounds); 717 &devBounds);
717 vOffset += draw.fVertexCnt; 718 vOffset += draw.fVertexCnt;
718 } 719 }
719 720
720 return true; 721 return true;
721 } 722 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.h ('k') | src/gpu/GrAADistanceFieldPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698