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 "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrDrawState.h" | 12 #include "GrDrawState.h" |
13 #include "GrDrawTargetCaps.h" | 13 #include "GrDrawTargetCaps.h" |
14 #include "GrProcessor.h" | 14 #include "GrProcessor.h" |
15 #include "GrPathUtils.h" | 15 #include "GrPathUtils.h" |
16 #include "GrTBackendProcessorFactory.h" | 16 #include "GrTBackendProcessorFactory.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 #include "SkStrokeRec.h" | 18 #include "SkStrokeRec.h" |
19 #include "SkTraceEvent.h" | 19 #include "SkTraceEvent.h" |
20 | 20 |
21 #include "gl/builders/GrGLFullProgramBuilder.h" | 21 #include "gl/builders/GrGLProgramBuilder.h" |
22 #include "gl/GrGLProcessor.h" | 22 #include "gl/GrGLProcessor.h" |
23 #include "gl/GrGLSL.h" | 23 #include "gl/GrGLSL.h" |
24 #include "gl/GrGLGeometryProcessor.h" | 24 #include "gl/GrGLGeometryProcessor.h" |
25 | 25 |
26 #include "GrGeometryProcessor.h" | 26 #include "GrGeometryProcessor.h" |
27 | 27 |
28 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { | 28 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { |
29 } | 29 } |
30 | 30 |
31 struct Segment { | 31 struct Segment { |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 521 |
522 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 522 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
523 return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance()
; | 523 return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance()
; |
524 } | 524 } |
525 | 525 |
526 class GLProcessor : public GrGLGeometryProcessor { | 526 class GLProcessor : public GrGLGeometryProcessor { |
527 public: | 527 public: |
528 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) | 528 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) |
529 : INHERITED (factory) {} | 529 : INHERITED (factory) {} |
530 | 530 |
531 virtual void emitCode(GrGLFullProgramBuilder* builder, | 531 virtual void emitCode(GrGLGPBuilder* builder, |
532 const GrGeometryProcessor& geometryProcessor, | 532 const GrGeometryProcessor& geometryProcessor, |
533 const GrProcessorKey& key, | 533 const GrProcessorKey& key, |
534 const char* outputColor, | 534 const char* outputColor, |
535 const char* inputColor, | 535 const char* inputColor, |
536 const TransformedCoordsArray&, | 536 const TransformedCoordsArray&, |
537 const TextureSamplerArray& samplers) SK_OVERRIDE { | 537 const TextureSamplerArray& samplers) SK_OVERRIDE { |
538 const char *vsName, *fsName; | 538 const char *vsName, *fsName; |
539 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); | 539 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); |
540 | 540 |
541 GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragment
ShaderBuilder(); | 541 GrGLGPFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderB
uilder(); |
542 | 542 |
543 SkAssertResult(fsBuilder->enableFeature( | 543 SkAssertResult(fsBuilder->enableFeature( |
544 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 544 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
545 fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n"); | 545 fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n"); |
546 | 546 |
547 // keep the derivative instructions outside the conditional | 547 // keep the derivative instructions outside the conditional |
548 fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); | 548 fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); |
549 fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); | 549 fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); |
550 fsBuilder->codeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa
me, fsName); | 550 fsBuilder->codeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa
me, fsName); |
551 // today we know z and w are in device space. We could use derivativ
es | 551 // today we know z and w are in device space. We could use derivativ
es |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 vOffset, // start vertex | 713 vOffset, // start vertex |
714 0, // start index | 714 0, // start index |
715 draw.fVertexCnt, | 715 draw.fVertexCnt, |
716 draw.fIndexCnt, | 716 draw.fIndexCnt, |
717 &devBounds); | 717 &devBounds); |
718 vOffset += draw.fVertexCnt; | 718 vOffset += draw.fVertexCnt; |
719 } | 719 } |
720 | 720 |
721 return true; | 721 return true; |
722 } | 722 } |
OLD | NEW |