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 "GrAAConvexTessellator.h" | 11 #include "GrAAConvexTessellator.h" |
12 #include "GrBatchFlushState.h" | 12 #include "GrBatchFlushState.h" |
13 #include "GrBatchTest.h" | 13 #include "GrBatchTest.h" |
14 #include "GrCaps.h" | 14 #include "GrCaps.h" |
15 #include "GrContext.h" | 15 #include "GrContext.h" |
16 #include "GrDefaultGeoProcFactory.h" | 16 #include "GrDefaultGeoProcFactory.h" |
17 #include "GrGeometryProcessor.h" | 17 #include "GrGeometryProcessor.h" |
18 #include "GrInvariantOutput.h" | 18 #include "GrInvariantOutput.h" |
19 #include "GrPathUtils.h" | 19 #include "GrPathUtils.h" |
20 #include "GrProcessor.h" | 20 #include "GrProcessor.h" |
21 #include "GrPipelineBuilder.h" | 21 #include "GrPipelineBuilder.h" |
22 #include "GrStrokeInfo.h" | 22 #include "GrStrokeInfo.h" |
23 #include "SkGeometry.h" | 23 #include "SkGeometry.h" |
24 #include "SkPathPriv.h" | 24 #include "SkPathPriv.h" |
25 #include "SkString.h" | 25 #include "SkString.h" |
26 #include "SkTraceEvent.h" | 26 #include "SkTraceEvent.h" |
27 #include "batches/GrVertexBatch.h" | 27 #include "batches/GrVertexBatch.h" |
28 #include "gl/GrGLGeometryProcessor.h" | 28 #include "gl/GrGLGeometryProcessor.h" |
29 #include "gl/builders/GrGLProgramBuilder.h" | 29 #include "glsl/GrGLSLProgramBuilder.h" |
30 #include "glsl/GrGLSLProgramDataManager.h" | 30 #include "glsl/GrGLSLProgramDataManager.h" |
31 | 31 |
32 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { | 32 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { |
33 } | 33 } |
34 | 34 |
35 struct Segment { | 35 struct Segment { |
36 enum { | 36 enum { |
37 // These enum values are assumed in member functions below. | 37 // These enum values are assumed in member functions below. |
38 kLine = 0, | 38 kLine = 0, |
39 kQuad = 1, | 39 kQuad = 1, |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 bool usesLocalCoords() const { return fUsesLocalCoords; } | 542 bool usesLocalCoords() const { return fUsesLocalCoords; } |
543 | 543 |
544 class GLProcessor : public GrGLGeometryProcessor { | 544 class GLProcessor : public GrGLGeometryProcessor { |
545 public: | 545 public: |
546 GLProcessor() | 546 GLProcessor() |
547 : fColor(GrColor_ILLEGAL) {} | 547 : fColor(GrColor_ILLEGAL) {} |
548 | 548 |
549 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 549 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
550 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); | 550 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); |
551 GrGLSLGPBuilder* pb = args.fPB; | 551 GrGLSLGPBuilder* pb = args.fPB; |
552 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 552 GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
553 | 553 |
554 // emit attributes | 554 // emit attributes |
555 vsBuilder->emitAttributes(qe); | 555 vsBuilder->emitAttributes(qe); |
556 | 556 |
557 GrGLSLVertToFrag v(kVec4f_GrSLType); | 557 GrGLSLVertToFrag v(kVec4f_GrSLType); |
558 args.fPB->addVarying("QuadEdge", &v); | 558 args.fPB->addVarying("QuadEdge", &v); |
559 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 559 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
560 | 560 |
561 // Setup pass through color | 561 // Setup pass through color |
562 if (!qe.colorIgnored()) { | 562 if (!qe.colorIgnored()) { |
563 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); | 563 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
564 } | 564 } |
565 | 565 |
566 // Setup position | 566 // Setup position |
567 this->setupPosition(pb, gpArgs, qe.inPosition()->fName); | 567 this->setupPosition(pb, gpArgs, qe.inPosition()->fName); |
568 | 568 |
569 // emit transforms | 569 // emit transforms |
570 this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()
->fName, | 570 this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()
->fName, |
571 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); | 571 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); |
572 | 572 |
573 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(
); | 573 GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde
r(); |
574 | 574 |
575 SkAssertResult(fsBuilder->enableFeature( | 575 SkAssertResult(fsBuilder->enableFeature( |
576 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 576 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
577 fsBuilder->codeAppendf("float edgeAlpha;"); | 577 fsBuilder->codeAppendf("float edgeAlpha;"); |
578 | 578 |
579 // keep the derivative instructions outside the conditional | 579 // keep the derivative instructions outside the conditional |
580 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 580 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
581 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 581 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
582 fsBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(),
v.fsIn()); | 582 fsBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(),
v.fsIn()); |
583 // today we know z and w are in device space. We could use derivativ
es | 583 // today we know z and w are in device space. We could use derivativ
es |
584 fsBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);
", v.fsIn(), | 584 fsBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);
", v.fsIn(), |
585 v.fsIn()); | 585 v.fsIn()); |
586 fsBuilder->codeAppendf ("} else {"); | 586 fsBuilder->codeAppendf ("} else {"); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1007 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1008 AAConvexPathBatch::Geometry geometry; | 1008 AAConvexPathBatch::Geometry geometry; |
1009 geometry.fColor = GrRandomColor(random); | 1009 geometry.fColor = GrRandomColor(random); |
1010 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1010 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1011 geometry.fPath = GrTest::TestPathConvex(random); | 1011 geometry.fPath = GrTest::TestPathConvex(random); |
1012 | 1012 |
1013 return AAConvexPathBatch::Create(geometry); | 1013 return AAConvexPathBatch::Create(geometry); |
1014 } | 1014 } |
1015 | 1015 |
1016 #endif | 1016 #endif |
OLD | NEW |