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 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 18 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 19 |
| 20 // We don't think any shaders actually output negative coverage, but jus
t as a safety check |
| 21 // for floating point precision errors we compare with <= here |
| 22 fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {" |
| 23 " discard;" |
| 24 "}", args.fInputCoverage); |
19 const char* dstColor = fsBuilder->dstColor(); | 25 const char* dstColor = fsBuilder->dstColor(); |
20 | 26 |
21 const char* dstCopyTopLeftName; | 27 const char* dstCopyTopLeftName; |
22 const char* dstCopyCoordScaleName; | 28 const char* dstCopyCoordScaleName; |
23 | 29 |
24 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, | 30 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, |
25 kVec2f_GrSLType, | 31 kVec2f_GrSLType, |
26 kDefault_GrSLPrecision, | 32 kDefault_GrSLPrecision, |
27 "DstCopyUpperLeft", | 33 "DstCopyUpperLeft", |
28 &dstCopyTopLeftName); | 34 &dstCopyTopLeftName); |
(...skipping 30 matching lines...) Expand all Loading... |
59 } else { | 65 } else { |
60 SkASSERT(!fDstCopyScaleUni.isValid()); | 66 SkASSERT(!fDstCopyScaleUni.isValid()); |
61 } | 67 } |
62 } else { | 68 } else { |
63 SkASSERT(!fDstCopyTopLeftUni.isValid()); | 69 SkASSERT(!fDstCopyTopLeftUni.isValid()); |
64 SkASSERT(!fDstCopyScaleUni.isValid()); | 70 SkASSERT(!fDstCopyScaleUni.isValid()); |
65 } | 71 } |
66 this->onSetData(pdm, xp); | 72 this->onSetData(pdm, xp); |
67 } | 73 } |
68 | 74 |
OLD | NEW |