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 "glsl/GrGLSLFragmentShaderBuilder.h" |
28 #include "glsl/GrGLSLGeometryProcessor.h" | 29 #include "glsl/GrGLSLGeometryProcessor.h" |
29 #include "glsl/GrGLSLProgramBuilder.h" | |
30 #include "glsl/GrGLSLProgramDataManager.h" | 30 #include "glsl/GrGLSLProgramDataManager.h" |
| 31 #include "glsl/GrGLSLUniformHandler.h" |
31 #include "glsl/GrGLSLVarying.h" | 32 #include "glsl/GrGLSLVarying.h" |
| 33 #include "glsl/GrGLSLVertexShaderBuilder.h" |
32 | 34 |
33 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { | 35 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { |
34 } | 36 } |
35 | 37 |
36 struct Segment { | 38 struct Segment { |
37 enum { | 39 enum { |
38 // These enum values are assumed in member functions below. | 40 // These enum values are assumed in member functions below. |
39 kLine = 0, | 41 kLine = 0, |
40 kQuad = 1, | 42 kQuad = 1, |
41 } fType; | 43 } fType; |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 544 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
543 bool usesLocalCoords() const { return fUsesLocalCoords; } | 545 bool usesLocalCoords() const { return fUsesLocalCoords; } |
544 | 546 |
545 class GLSLProcessor : public GrGLSLGeometryProcessor { | 547 class GLSLProcessor : public GrGLSLGeometryProcessor { |
546 public: | 548 public: |
547 GLSLProcessor() | 549 GLSLProcessor() |
548 : fColor(GrColor_ILLEGAL) {} | 550 : fColor(GrColor_ILLEGAL) {} |
549 | 551 |
550 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 552 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
551 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); | 553 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); |
552 GrGLSLGPBuilder* pb = args.fPB; | |
553 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; | 554 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; |
554 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; | 555 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; |
| 556 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
555 | 557 |
556 // emit attributes | 558 // emit attributes |
557 varyingHandler->emitAttributes(qe); | 559 varyingHandler->emitAttributes(qe); |
558 | 560 |
559 GrGLSLVertToFrag v(kVec4f_GrSLType); | 561 GrGLSLVertToFrag v(kVec4f_GrSLType); |
560 varyingHandler->addVarying("QuadEdge", &v); | 562 varyingHandler->addVarying("QuadEdge", &v); |
561 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fNa
me); | 563 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fNa
me); |
562 | 564 |
563 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 565 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
564 // Setup pass through color | 566 // Setup pass through color |
565 if (!qe.colorIgnored()) { | 567 if (!qe.colorIgnored()) { |
566 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fCo
lorUniform); | 568 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu
tColor, |
| 569 &fColorUniform); |
567 } | 570 } |
568 | 571 |
569 // Setup position | 572 // Setup position |
570 this->setupPosition(pb, vertBuilder, gpArgs, qe.inPosition()->fName)
; | 573 this->setupPosition(vertBuilder, gpArgs, qe.inPosition()->fName); |
571 | 574 |
572 // emit transforms | 575 // emit transforms |
573 this->emitTransforms(args.fPB, | 576 this->emitTransforms(vertBuilder, |
574 vertBuilder, | |
575 varyingHandler, | 577 varyingHandler, |
| 578 uniformHandler, |
576 gpArgs->fPositionVar, | 579 gpArgs->fPositionVar, |
577 qe.inPosition()->fName, | 580 qe.inPosition()->fName, |
578 qe.localMatrix(), | 581 qe.localMatrix(), |
579 args.fTransformsIn, | 582 args.fTransformsIn, |
580 args.fTransformsOut); | 583 args.fTransformsOut); |
581 | 584 |
582 SkAssertResult(fragBuilder->enableFeature( | 585 SkAssertResult(fragBuilder->enableFeature( |
583 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); | 586 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
584 fragBuilder->codeAppendf("float edgeAlpha;"); | 587 fragBuilder->codeAppendf("float edgeAlpha;"); |
585 | 588 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1025 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1023 AAConvexPathBatch::Geometry geometry; | 1026 AAConvexPathBatch::Geometry geometry; |
1024 geometry.fColor = GrRandomColor(random); | 1027 geometry.fColor = GrRandomColor(random); |
1025 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1028 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1026 geometry.fPath = GrTest::TestPathConvex(random); | 1029 geometry.fPath = GrTest::TestPathConvex(random); |
1027 | 1030 |
1028 return AAConvexPathBatch::Create(geometry); | 1031 return AAConvexPathBatch::Create(geometry); |
1029 } | 1032 } |
1030 | 1033 |
1031 #endif | 1034 #endif |
OLD | NEW |