| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrPathProcessor.h" | 8 #include "GrPathProcessor.h" | 
| 9 | 9 | 
| 10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" | 
| 11 #include "glsl/GrGLSLCaps.h" | 11 #include "glsl/GrGLSLCaps.h" | 
| 12 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 12 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 
| 13 #include "glsl/GrGLSLProcessorTypes.h" | 13 #include "glsl/GrGLSLProcessorTypes.h" | 
| 14 #include "glsl/GrGLSLProgramBuilder.h" | 14 #include "glsl/GrGLSLUniformHandler.h" | 
| 15 #include "glsl/GrGLSLVarying.h" | 15 #include "glsl/GrGLSLVarying.h" | 
| 16 | 16 | 
| 17 class GrGLPathProcessor : public GrGLSLPrimitiveProcessor { | 17 class GrGLPathProcessor : public GrGLSLPrimitiveProcessor { | 
| 18 public: | 18 public: | 
| 19     GrGLPathProcessor() : fColor(GrColor_ILLEGAL) {} | 19     GrGLPathProcessor() : fColor(GrColor_ILLEGAL) {} | 
| 20 | 20 | 
| 21     static void GenKey(const GrPathProcessor& pathProc, | 21     static void GenKey(const GrPathProcessor& pathProc, | 
| 22                        const GrGLSLCaps&, | 22                        const GrGLSLCaps&, | 
| 23                        GrProcessorKeyBuilder* b) { | 23                        GrProcessorKeyBuilder* b) { | 
| 24         b->add32(SkToInt(pathProc.overrides().readsColor()) | | 24         b->add32(SkToInt(pathProc.overrides().readsColor()) | | 
| 25                  SkToInt(pathProc.overrides().readsCoverage()) << 16); | 25                  SkToInt(pathProc.overrides().readsCoverage()) << 16); | 
| 26     } | 26     } | 
| 27 | 27 | 
| 28     void emitCode(EmitArgs& args) override { | 28     void emitCode(EmitArgs& args) override { | 
| 29         GrGLSLGPBuilder* pb = args.fPB; |  | 
| 30         GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 29         GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 
| 31         const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>(); | 30         const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>(); | 
| 32 | 31 | 
| 33         // emit transforms | 32         // emit transforms | 
| 34         this->emitTransforms(args.fVaryingHandler, args.fTransformsIn, args.fTra
     nsformsOut); | 33         this->emitTransforms(args.fVaryingHandler, args.fTransformsIn, args.fTra
     nsformsOut); | 
| 35 | 34 | 
| 36         // Setup uniform color | 35         // Setup uniform color | 
| 37         if (pathProc.overrides().readsColor()) { | 36         if (pathProc.overrides().readsColor()) { | 
| 38             const char* stagedLocalVarName; | 37             const char* stagedLocalVarName; | 
| 39             fColorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visib
     ility, | 38             fColorUniform = args.fUniformHandler->addUniform( | 
| 40                                            kVec4f_GrSLType, | 39                                                          GrGLSLUniformHandler::k
     Fragment_Visibility, | 
| 41                                            kDefault_GrSLPrecision, | 40                                                          kVec4f_GrSLType, | 
| 42                                            "Color", | 41                                                          kDefault_GrSLPrecision, | 
| 43                                            &stagedLocalVarName); | 42                                                          "Color", | 
|  | 43                                                          &stagedLocalVarName); | 
| 44             fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalV
     arName); | 44             fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalV
     arName); | 
| 45         } | 45         } | 
| 46 | 46 | 
| 47         // setup constant solid coverage | 47         // setup constant solid coverage | 
| 48         if (pathProc.overrides().readsCoverage()) { | 48         if (pathProc.overrides().readsCoverage()) { | 
| 49             fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); | 49             fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); | 
| 50         } | 50         } | 
| 51     } | 51     } | 
| 52 | 52 | 
| 53     void emitTransforms(GrGLSLVaryingHandler* varyingHandler, | 53     void emitTransforms(GrGLSLVaryingHandler* varyingHandler, | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 133 | 133 | 
| 134 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, | 134 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, | 
| 135                                           GrProcessorKeyBuilder* b) const { | 135                                           GrProcessorKeyBuilder* b) const { | 
| 136     GrGLPathProcessor::GenKey(*this, caps, b); | 136     GrGLPathProcessor::GenKey(*this, caps, b); | 
| 137 } | 137 } | 
| 138 | 138 | 
| 139 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps& 
     caps) const { | 139 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps& 
     caps) const { | 
| 140     SkASSERT(caps.pathRenderingSupport()); | 140     SkASSERT(caps.pathRenderingSupport()); | 
| 141     return new GrGLPathProcessor(); | 141     return new GrGLPathProcessor(); | 
| 142 } | 142 } | 
| OLD | NEW | 
|---|