| 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.fFPCoordTransformHandler); | 580 args.fTransformsIn, |
| 581 args.fTransformsOut); |
| 581 | 582 |
| 582 SkAssertResult(fragBuilder->enableFeature( | 583 SkAssertResult(fragBuilder->enableFeature( |
| 583 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); | 584 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
| 584 fragBuilder->codeAppendf("float edgeAlpha;"); | 585 fragBuilder->codeAppendf("float edgeAlpha;"); |
| 585 | 586 |
| 586 // keep the derivative instructions outside the conditional | 587 // keep the derivative instructions outside the conditional |
| 587 fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 588 fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| 588 fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 589 fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
| 589 fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn()
, v.fsIn()); | 590 fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn()
, v.fsIn()); |
| 590 // today we know z and w are in device space. We could use derivativ
es | 591 // today we know z and w are in device space. We could use derivativ
es |
| (...skipping 15 matching lines...) Expand all Loading... |
| 606 const GrGLSLCaps&, | 607 const GrGLSLCaps&, |
| 607 GrProcessorKeyBuilder* b) { | 608 GrProcessorKeyBuilder* b) { |
| 608 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); | 609 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); |
| 609 uint32_t key = 0; | 610 uint32_t key = 0; |
| 610 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ?
0x1 : 0x0; | 611 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ?
0x1 : 0x0; |
| 611 key |= qee.colorIgnored() ? 0x2 : 0x0; | 612 key |= qee.colorIgnored() ? 0x2 : 0x0; |
| 612 b->add32(key); | 613 b->add32(key); |
| 613 } | 614 } |
| 614 | 615 |
| 615 void setData(const GrGLSLProgramDataManager& pdman, | 616 void setData(const GrGLSLProgramDataManager& pdman, |
| 616 const GrPrimitiveProcessor& gp, | 617 const GrPrimitiveProcessor& gp) override { |
| 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 this->setTransformDataHelper(qe.fLocalMatrix, pdman, &transformIter)
; | 625 } |
| 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); |
| 626 } | 633 } |
| 627 | 634 |
| 628 private: | 635 private: |
| 629 GrColor fColor; | 636 GrColor fColor; |
| 630 UniformHandle fColorUniform; | 637 UniformHandle fColorUniform; |
| 631 | 638 |
| 632 typedef GrGLSLGeometryProcessor INHERITED; | 639 typedef GrGLSLGeometryProcessor INHERITED; |
| 633 }; | 640 }; |
| 634 | 641 |
| 635 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 642 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 | 1017 |
| 1011 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1018 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
| 1012 GrColor color = GrRandomColor(random); | 1019 GrColor color = GrRandomColor(random); |
| 1013 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 1020 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 1014 SkPath path = GrTest::TestPathConvex(random); | 1021 SkPath path = GrTest::TestPathConvex(random); |
| 1015 | 1022 |
| 1016 return new AAConvexPathBatch(color, viewMatrix, path); | 1023 return new AAConvexPathBatch(color, viewMatrix, path); |
| 1017 } | 1024 } |
| 1018 | 1025 |
| 1019 #endif | 1026 #endif |
| OLD | NEW |