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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 args.fPB->addVarying("QuadEdge", &v); | 555 args.fPB->addVarying("QuadEdge", &v); |
556 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 556 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
557 | 557 |
558 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 558 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
559 | 559 |
560 // Setup pass through color | 560 // Setup pass through color |
561 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, | 561 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, |
562 &fColorUniform); | 562 &fColorUniform); |
563 | 563 |
564 // Setup position | 564 // Setup position |
565 this->setupPosition(pb, gpArgs, qe.inPosition()->fName, qe.viewMatri
x()); | 565 this->setupPosition(pb, gpArgs, qe.inPosition()->fName); |
566 | 566 |
567 // emit transforms | 567 // emit transforms |
568 this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()
->fName, | 568 this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()
->fName, |
569 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); | 569 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); |
570 | 570 |
571 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(
); | 571 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(
); |
572 | 572 |
573 SkAssertResult(fsBuilder->enableFeature( | 573 SkAssertResult(fsBuilder->enableFeature( |
574 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 574 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
575 fsBuilder->codeAppendf("float edgeAlpha;"); | 575 fsBuilder->codeAppendf("float edgeAlpha;"); |
(...skipping 17 matching lines...) Expand all Loading... |
593 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 593 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
594 } | 594 } |
595 | 595 |
596 static inline void GenKey(const GrGeometryProcessor& gp, | 596 static inline void GenKey(const GrGeometryProcessor& gp, |
597 const GrBatchTracker& bt, | 597 const GrBatchTracker& bt, |
598 const GrGLSLCaps&, | 598 const GrGLSLCaps&, |
599 GrProcessorKeyBuilder* b) { | 599 GrProcessorKeyBuilder* b) { |
600 const BatchTracker& local = bt.cast<BatchTracker>(); | 600 const BatchTracker& local = bt.cast<BatchTracker>(); |
601 uint32_t key = local.fInputColorType << 16; | 601 uint32_t key = local.fInputColorType << 16; |
602 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 : 0x0; | 602 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 : 0x0; |
603 key |= ComputePosKey(gp.viewMatrix()) << 1; | |
604 b->add32(key); | 603 b->add32(key); |
605 } | 604 } |
606 | 605 |
607 virtual void setData(const GrGLProgramDataManager& pdman, | 606 virtual void setData(const GrGLProgramDataManager& pdman, |
608 const GrPrimitiveProcessor& gp, | 607 const GrPrimitiveProcessor& gp, |
609 const GrBatchTracker& bt) override { | 608 const GrBatchTracker& bt) override { |
610 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | |
611 | |
612 const BatchTracker& local = bt.cast<BatchTracker>(); | 609 const BatchTracker& local = bt.cast<BatchTracker>(); |
613 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { | 610 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { |
614 GrGLfloat c[4]; | 611 GrGLfloat c[4]; |
615 GrColorToRGBAFloat(local.fColor, c); | 612 GrColorToRGBAFloat(local.fColor, c); |
616 pdman.set4fv(fColorUniform, 1, c); | 613 pdman.set4fv(fColorUniform, 1, c); |
617 fColor = local.fColor; | 614 fColor = local.fColor; |
618 } | 615 } |
619 } | 616 } |
620 | 617 |
621 private: | 618 private: |
(...skipping 15 matching lines...) Expand all Loading... |
637 } | 634 } |
638 | 635 |
639 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 636 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
640 BatchTracker* local = bt->cast<BatchTracker>(); | 637 BatchTracker* local = bt->cast<BatchTracker>(); |
641 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 638 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
642 local->fUsesLocalCoords = init.fUsesLocalCoords; | 639 local->fUsesLocalCoords = init.fUsesLocalCoords; |
643 } | 640 } |
644 | 641 |
645 private: | 642 private: |
646 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) | 643 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) |
647 : INHERITED(SkMatrix::I(), localMatrix) | 644 : INHERITED(localMatrix) |
648 , fColor(color) { | 645 , fColor(color) { |
649 this->initClassID<QuadEdgeEffect>(); | 646 this->initClassID<QuadEdgeEffect>(); |
650 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 647 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
651 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); | 648 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); |
652 } | 649 } |
653 | 650 |
654 struct BatchTracker { | 651 struct BatchTracker { |
655 GrGPInput fInputColorType; | 652 GrGPInput fInputColorType; |
656 GrColor fColor; | 653 GrColor fColor; |
657 bool fUsesLocalCoords; | 654 bool fUsesLocalCoords; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 BATCH_TEST_DEFINE(AAConvexPath) { | 1025 BATCH_TEST_DEFINE(AAConvexPath) { |
1029 AAConvexPathBatch::Geometry geometry; | 1026 AAConvexPathBatch::Geometry geometry; |
1030 geometry.fColor = GrRandomColor(random); | 1027 geometry.fColor = GrRandomColor(random); |
1031 geometry.fViewMatrix = GrTest::TestMatrix(random); | 1028 geometry.fViewMatrix = GrTest::TestMatrix(random); |
1032 geometry.fPath = GrTest::TestPathConvex(random); | 1029 geometry.fPath = GrTest::TestPathConvex(random); |
1033 | 1030 |
1034 return AAConvexPathBatch::Create(geometry); | 1031 return AAConvexPathBatch::Create(geometry); |
1035 } | 1032 } |
1036 | 1033 |
1037 #endif | 1034 #endif |
OLD | NEW |