OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gl/GrGLXferProcessor.h" | 8 #include "gl/GrGLXferProcessor.h" |
9 | 9 |
10 #include "GrXferProcessor.h" | 10 #include "GrXferProcessor.h" |
11 #include "gl/builders/GrGLFragmentShaderBuilder.h" | 11 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
12 #include "gl/builders/GrGLProgramBuilder.h" | 12 #include "gl/builders/GrGLProgramBuilder.h" |
13 | 13 |
14 void GrGLXferProcessor::emitCode(const EmitArgs& args) { | 14 void GrGLXferProcessor::emitCode(const EmitArgs& args) { |
15 if (args.fXP.getDstCopyTexture()) { | 15 if (args.fXP.getDstCopyTexture()) { |
16 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()-
>origin(); | 16 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()-
>origin(); |
17 | 17 |
18 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 18 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
19 | 19 |
20 // We don't think any shaders actually output negative coverage, but jus
t as a safety check | 20 if (args.fXP.readsCoverage()) { |
21 // for floating point precision errors we compare with <= here | 21 // We don't think any shaders actually output negative coverage, but
just as a safety |
22 fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {" | 22 // check for floating point precision errors we compare with <= here |
23 " discard;" | 23 fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {" |
24 "}", args.fInputCoverage); | 24 " discard;" |
| 25 "}", args.fInputCoverage); |
| 26 } |
| 27 |
25 const char* dstColor = fsBuilder->dstColor(); | 28 const char* dstColor = fsBuilder->dstColor(); |
26 | 29 |
27 const char* dstCopyTopLeftName; | 30 const char* dstCopyTopLeftName; |
28 const char* dstCopyCoordScaleName; | 31 const char* dstCopyCoordScaleName; |
29 | 32 |
30 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, | 33 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, |
31 kVec2f_GrSLType, | 34 kVec2f_GrSLType, |
32 kDefault_GrSLPrecision, | 35 kDefault_GrSLPrecision, |
33 "DstCopyUpperLeft", | 36 "DstCopyUpperLeft", |
34 &dstCopyTopLeftName); | 37 &dstCopyTopLeftName); |
(...skipping 30 matching lines...) Expand all Loading... |
65 } else { | 68 } else { |
66 SkASSERT(!fDstCopyScaleUni.isValid()); | 69 SkASSERT(!fDstCopyScaleUni.isValid()); |
67 } | 70 } |
68 } else { | 71 } else { |
69 SkASSERT(!fDstCopyTopLeftUni.isValid()); | 72 SkASSERT(!fDstCopyTopLeftUni.isValid()); |
70 SkASSERT(!fDstCopyScaleUni.isValid()); | 73 SkASSERT(!fDstCopyScaleUni.isValid()); |
71 } | 74 } |
72 this->onSetData(pdm, xp); | 75 this->onSetData(pdm, xp); |
73 } | 76 } |
74 | 77 |
OLD | NEW |