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/GrGLSLUniformHandler.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()) << 1) | |
| 26 (SkToInt(pathProc.viewMatrix().hasPerspective()) << 2)); |
26 } | 27 } |
27 | 28 |
28 void emitCode(EmitArgs& args) override { | 29 void emitCode(EmitArgs& args) override { |
29 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 30 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
30 const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>(); | 31 const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>(); |
31 | 32 |
| 33 if (!pathProc.viewMatrix().hasPerspective()) { |
| 34 args.fVaryingHandler->setNoPerspective(); |
| 35 } |
| 36 |
32 // emit transforms | 37 // emit transforms |
33 this->emitTransforms(args.fVaryingHandler, args.fTransformsIn, args.fTra
nsformsOut); | 38 this->emitTransforms(args.fVaryingHandler, args.fTransformsIn, args.fTra
nsformsOut); |
34 | 39 |
35 // Setup uniform color | 40 // Setup uniform color |
36 if (pathProc.overrides().readsColor()) { | 41 if (pathProc.overrides().readsColor()) { |
37 const char* stagedLocalVarName; | 42 const char* stagedLocalVarName; |
38 fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderF
lag, | 43 fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderF
lag, |
39 kVec4f_GrSLType, | 44 kVec4f_GrSLType, |
40 kDefault_GrSLPrecis
ion, | 45 kDefault_GrSLPrecis
ion, |
41 "Color", | 46 "Color", |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 135 |
131 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, | 136 void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, |
132 GrProcessorKeyBuilder* b) const { | 137 GrProcessorKeyBuilder* b) const { |
133 GrGLPathProcessor::GenKey(*this, caps, b); | 138 GrGLPathProcessor::GenKey(*this, caps, b); |
134 } | 139 } |
135 | 140 |
136 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps&
caps) const { | 141 GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps&
caps) const { |
137 SkASSERT(caps.pathRenderingSupport()); | 142 SkASSERT(caps.pathRenderingSupport()); |
138 return new GrGLPathProcessor(); | 143 return new GrGLPathProcessor(); |
139 } | 144 } |
OLD | NEW |