| 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 |
| 11 #include "GrContext.h" | 11 #include "GrContext.h" |
| 12 #include "GrDrawState.h" | 12 #include "GrDrawState.h" |
| 13 #include "GrDrawTargetCaps.h" | 13 #include "GrDrawTargetCaps.h" |
| 14 #include "GrGeometryProcessor.h" |
| 14 #include "GrInvariantOutput.h" | 15 #include "GrInvariantOutput.h" |
| 15 #include "GrProcessor.h" | 16 #include "GrProcessor.h" |
| 16 #include "GrPathUtils.h" | 17 #include "GrPathUtils.h" |
| 17 #include "GrTBackendProcessorFactory.h" | |
| 18 #include "SkString.h" | 18 #include "SkString.h" |
| 19 #include "SkStrokeRec.h" | 19 #include "SkStrokeRec.h" |
| 20 #include "SkTraceEvent.h" | 20 #include "SkTraceEvent.h" |
| 21 | |
| 22 #include "gl/builders/GrGLProgramBuilder.h" | |
| 23 #include "gl/GrGLProcessor.h" | 21 #include "gl/GrGLProcessor.h" |
| 24 #include "gl/GrGLSL.h" | 22 #include "gl/GrGLSL.h" |
| 25 #include "gl/GrGLGeometryProcessor.h" | 23 #include "gl/GrGLGeometryProcessor.h" |
| 26 | 24 #include "gl/builders/GrGLProgramBuilder.h" |
| 27 #include "GrGeometryProcessor.h" | |
| 28 | 25 |
| 29 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { | 26 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { |
| 30 } | 27 } |
| 31 | 28 |
| 32 struct Segment { | 29 struct Segment { |
| 33 enum { | 30 enum { |
| 34 // These enum values are assumed in member functions below. | 31 // These enum values are assumed in member functions below. |
| 35 kLine = 0, | 32 kLine = 0, |
| 36 kQuad = 1, | 33 kQuad = 1, |
| 37 } fType; | 34 } fType; |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 public: | 506 public: |
| 510 | 507 |
| 511 static GrGeometryProcessor* Create() { | 508 static GrGeometryProcessor* Create() { |
| 512 GR_CREATE_STATIC_PROCESSOR(gQuadEdgeEffect, QuadEdgeEffect, ()); | 509 GR_CREATE_STATIC_PROCESSOR(gQuadEdgeEffect, QuadEdgeEffect, ()); |
| 513 gQuadEdgeEffect->ref(); | 510 gQuadEdgeEffect->ref(); |
| 514 return gQuadEdgeEffect; | 511 return gQuadEdgeEffect; |
| 515 } | 512 } |
| 516 | 513 |
| 517 virtual ~QuadEdgeEffect() {} | 514 virtual ~QuadEdgeEffect() {} |
| 518 | 515 |
| 519 static const char* Name() { return "QuadEdge"; } | 516 virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; } |
| 520 | 517 |
| 521 const GrAttribute* inPosition() const { return fInPosition; } | 518 const GrAttribute* inPosition() const { return fInPosition; } |
| 522 const GrAttribute* inQuadEdge() const { return fInQuadEdge; } | 519 const GrAttribute* inQuadEdge() const { return fInQuadEdge; } |
| 523 | 520 |
| 524 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | |
| 525 return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance()
; | |
| 526 } | |
| 527 | |
| 528 class GLProcessor : public GrGLGeometryProcessor { | 521 class GLProcessor : public GrGLGeometryProcessor { |
| 529 public: | 522 public: |
| 530 GLProcessor(const GrBackendProcessorFactory& factory, | 523 GLProcessor(const GrGeometryProcessor&, |
| 531 const GrGeometryProcessor&, | 524 const GrBatchTracker&) {} |
| 532 const GrBatchTracker&) | |
| 533 : INHERITED (factory) {} | |
| 534 | 525 |
| 535 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 526 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { |
| 536 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); | 527 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); |
| 537 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 528 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 538 | 529 |
| 539 GrGLVertToFrag v(kVec4f_GrSLType); | 530 GrGLVertToFrag v(kVec4f_GrSLType); |
| 540 args.fPB->addVarying("QuadEdge", &v); | 531 args.fPB->addVarying("QuadEdge", &v); |
| 541 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 532 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
| 542 | 533 |
| 543 // setup coord outputs | 534 // setup coord outputs |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 GrProcessorKeyBuilder*) {} | 570 GrProcessorKeyBuilder*) {} |
| 580 | 571 |
| 581 virtual void setData(const GrGLProgramDataManager&, | 572 virtual void setData(const GrGLProgramDataManager&, |
| 582 const GrGeometryProcessor&, | 573 const GrGeometryProcessor&, |
| 583 const GrBatchTracker&) SK_OVERRIDE {} | 574 const GrBatchTracker&) SK_OVERRIDE {} |
| 584 | 575 |
| 585 private: | 576 private: |
| 586 typedef GrGLGeometryProcessor INHERITED; | 577 typedef GrGLGeometryProcessor INHERITED; |
| 587 }; | 578 }; |
| 588 | 579 |
| 580 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 581 const GrGLCaps& caps, |
| 582 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 583 GLProcessor::GenKey(*this, bt, caps, b); |
| 584 } |
| 585 |
| 586 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { |
| 587 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 588 } |
| 589 |
| 589 private: | 590 private: |
| 590 QuadEdgeEffect() { | 591 QuadEdgeEffect() { |
| 592 this->initClassID<QuadEdgeEffect>(); |
| 591 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 593 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
| 592 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); | 594 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); |
| 593 } | 595 } |
| 594 | 596 |
| 595 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 597 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 596 return true; | 598 return true; |
| 597 } | 599 } |
| 598 | 600 |
| 599 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { | 601 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
| 600 inout->mulByUnknownAlpha(); | 602 inout->mulByUnknownAlpha(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 vOffset, // start vertex | 714 vOffset, // start vertex |
| 713 0, // start index | 715 0, // start index |
| 714 draw.fVertexCnt, | 716 draw.fVertexCnt, |
| 715 draw.fIndexCnt, | 717 draw.fIndexCnt, |
| 716 &devBounds); | 718 &devBounds); |
| 717 vOffset += draw.fVertexCnt; | 719 vOffset += draw.fVertexCnt; |
| 718 } | 720 } |
| 719 | 721 |
| 720 return true; | 722 return true; |
| 721 } | 723 } |
| OLD | NEW |