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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 fsBuilder->codeAppendf("vec4 %s = ", dstColor); | 57 fsBuilder->codeAppendf("vec4 %s = ", dstColor); |
58 fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f
_GrSLType); | 58 fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f
_GrSLType); |
59 fsBuilder->codeAppend(";"); | 59 fsBuilder->codeAppend(";"); |
60 } | 60 } |
61 | 61 |
62 this->emitBlendCodeForDstRead(args.fPB, args.fInputColor, dstColor, args.fOu
tputPrimary, | 62 this->emitBlendCodeForDstRead(args.fPB, args.fInputColor, dstColor, args.fOu
tputPrimary, |
63 args.fXP); | 63 args.fXP); |
64 | 64 |
65 // Apply coverage. | 65 // Apply coverage. |
66 if (args.fXP.readsCoverage()) { | 66 if (args.fXP.dstReadUsesMixedSamples()) { |
| 67 if (args.fXP.readsCoverage()) { |
| 68 fsBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInput
Coverage); |
| 69 fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fInpu
tCoverage); |
| 70 } else { |
| 71 fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary); |
| 72 } |
| 73 } else if (args.fXP.readsCoverage()) { |
67 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", | 74 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", |
68 args.fOutputPrimary, args.fInputCoverage, | 75 args.fOutputPrimary, args.fInputCoverage, |
69 args.fOutputPrimary, args.fInputCoverage, dstColo
r); | 76 args.fOutputPrimary, args.fInputCoverage, dstColo
r); |
70 } | 77 } |
71 } | 78 } |
72 | 79 |
73 void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferP
rocessor& xp) { | 80 void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferP
rocessor& xp) { |
74 if (xp.getDstTexture()) { | 81 if (xp.getDstTexture()) { |
75 if (fDstTopLeftUni.isValid()) { | 82 if (fDstTopLeftUni.isValid()) { |
76 pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset
().fX), | 83 pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset
().fX), |
77 static_cast<GrGLfloat>(xp.dstTextureOffset().fY)); | 84 static_cast<GrGLfloat>(xp.dstTextureOffset().fY)); |
78 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), | 85 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), |
79 1.f / xp.getDstTexture()->height()); | 86 1.f / xp.getDstTexture()->height()); |
80 } else { | 87 } else { |
81 SkASSERT(!fDstScaleUni.isValid()); | 88 SkASSERT(!fDstScaleUni.isValid()); |
82 } | 89 } |
83 } else { | 90 } else { |
84 SkASSERT(!fDstTopLeftUni.isValid()); | 91 SkASSERT(!fDstTopLeftUni.isValid()); |
85 SkASSERT(!fDstScaleUni.isValid()); | 92 SkASSERT(!fDstScaleUni.isValid()); |
86 } | 93 } |
87 this->onSetData(pdm, xp); | 94 this->onSetData(pdm, xp); |
88 } | 95 } |
89 | 96 |
OLD | NEW |