OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAAConvexPathRenderer.h" | 8 #include "GrAAConvexPathRenderer.h" |
9 | 9 |
10 #include "GrAAConvexTessellator.h" | 10 #include "GrAAConvexTessellator.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // Setup position | 570 // Setup position |
571 this->setupPosition(vertBuilder, gpArgs, qe.inPosition()->fName); | 571 this->setupPosition(vertBuilder, gpArgs, qe.inPosition()->fName); |
572 | 572 |
573 // emit transforms | 573 // emit transforms |
574 this->emitTransforms(vertBuilder, | 574 this->emitTransforms(vertBuilder, |
575 varyingHandler, | 575 varyingHandler, |
576 uniformHandler, | 576 uniformHandler, |
577 gpArgs->fPositionVar, | 577 gpArgs->fPositionVar, |
578 qe.inPosition()->fName, | 578 qe.inPosition()->fName, |
579 qe.localMatrix(), | 579 qe.localMatrix(), |
580 args.fTransformsIn, | 580 args.fFPCoordTransformHandler); |
581 args.fTransformsOut); | |
582 | 581 |
583 SkAssertResult(fragBuilder->enableFeature( | 582 SkAssertResult(fragBuilder->enableFeature( |
584 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); | 583 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
585 fragBuilder->codeAppendf("float edgeAlpha;"); | 584 fragBuilder->codeAppendf("float edgeAlpha;"); |
586 | 585 |
587 // keep the derivative instructions outside the conditional | 586 // keep the derivative instructions outside the conditional |
588 fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 587 fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
589 fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 588 fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
590 fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn()
, v.fsIn()); | 589 fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn()
, v.fsIn()); |
591 // today we know z and w are in device space. We could use derivativ
es | 590 // today we know z and w are in device space. We could use derivativ
es |
(...skipping 15 matching lines...) Expand all Loading... |
607 const GrGLSLCaps&, | 606 const GrGLSLCaps&, |
608 GrProcessorKeyBuilder* b) { | 607 GrProcessorKeyBuilder* b) { |
609 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); | 608 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); |
610 uint32_t key = 0; | 609 uint32_t key = 0; |
611 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ?
0x1 : 0x0; | 610 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ?
0x1 : 0x0; |
612 key |= qee.colorIgnored() ? 0x2 : 0x0; | 611 key |= qee.colorIgnored() ? 0x2 : 0x0; |
613 b->add32(key); | 612 b->add32(key); |
614 } | 613 } |
615 | 614 |
616 void setData(const GrGLSLProgramDataManager& pdman, | 615 void setData(const GrGLSLProgramDataManager& pdman, |
617 const GrPrimitiveProcessor& gp) override { | 616 const GrPrimitiveProcessor& gp, |
| 617 FPCoordTransformIter&& transformIter) override { |
618 const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>(); | 618 const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>(); |
619 if (qe.color() != fColor) { | 619 if (qe.color() != fColor) { |
620 float c[4]; | 620 float c[4]; |
621 GrColorToRGBAFloat(qe.color(), c); | 621 GrColorToRGBAFloat(qe.color(), c); |
622 pdman.set4fv(fColorUniform, 1, c); | 622 pdman.set4fv(fColorUniform, 1, c); |
623 fColor = qe.color(); | 623 fColor = qe.color(); |
624 } | 624 } |
625 } | 625 this->setTransformDataHelper(qe.fLocalMatrix, pdman, &transformIter)
; |
626 | |
627 void setTransformData(const GrPrimitiveProcessor& primProc, | |
628 const GrGLSLProgramDataManager& pdman, | |
629 int index, | |
630 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | |
631 this->setTransformDataHelper(primProc.cast<QuadEdgeEffect>().fLocalM
atrix, pdman, index, | |
632 transforms); | |
633 } | 626 } |
634 | 627 |
635 private: | 628 private: |
636 GrColor fColor; | 629 GrColor fColor; |
637 UniformHandle fColorUniform; | 630 UniformHandle fColorUniform; |
638 | 631 |
639 typedef GrGLSLGeometryProcessor INHERITED; | 632 typedef GrGLSLGeometryProcessor INHERITED; |
640 }; | 633 }; |
641 | 634 |
642 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 635 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 1010 |
1018 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1011 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1019 GrColor color = GrRandomColor(random); | 1012 GrColor color = GrRandomColor(random); |
1020 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 1013 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
1021 SkPath path = GrTest::TestPathConvex(random); | 1014 SkPath path = GrTest::TestPathConvex(random); |
1022 | 1015 |
1023 return new AAConvexPathBatch(color, viewMatrix, path); | 1016 return new AAConvexPathBatch(color, viewMatrix, path); |
1024 } | 1017 } |
1025 | 1018 |
1026 #endif | 1019 #endif |
OLD | NEW |