| Index: src/effects/SkLumaXfermode.cpp
|
| diff --git a/src/effects/SkLumaXfermode.cpp b/src/effects/SkLumaXfermode.cpp
|
| index aa3d780aa06ffa97ae8f3a4c85e7caf4cefc712c..d1e1ce9425015c9bd55f6a96ea12b4ae4515ea87 100644
|
| --- a/src/effects/SkLumaXfermode.cpp
|
| +++ b/src/effects/SkLumaXfermode.cpp
|
| @@ -39,14 +39,12 @@ SkPMColor SkLumaMaskXfermode::lumaProc(const SkPMColor a, const SkPMColor b) con
|
| }
|
|
|
| template <typename T>
|
| -static inline const T* lumaOpA(SkXfermode::Mode mode,
|
| - const T* src, const T* dst) {
|
| +static inline T lumaOpA(SkXfermode::Mode mode, T src, T dst) {
|
| return SkXfermode::kSrcIn_Mode == mode ? src : dst;
|
| }
|
|
|
| template <typename T>
|
| -static inline const T* lumaOpB(SkXfermode::Mode mode,
|
| - const T* src, const T* dst) {
|
| +static inline T lumaOpB(SkXfermode::Mode mode, T src, T dst) {
|
| return SkXfermode::kSrcIn_Mode == mode ? dst : src;
|
| }
|
|
|
| @@ -78,15 +76,15 @@ void SkLumaMaskXfermode::flatten(SkFlattenableWriteBuffer& buffer) const {
|
| }
|
|
|
| SkPMColor SkLumaMaskXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
|
| - const SkPMColor* a = lumaOpA<SkPMColor>(fMode, &src, &dst);
|
| - const SkPMColor* b = lumaOpB<SkPMColor>(fMode, &src, &dst);
|
| + const SkPMColor* a = lumaOpA<const SkPMColor*>(fMode, &src, &dst);
|
| + const SkPMColor* b = lumaOpB<const SkPMColor*>(fMode, &src, &dst);
|
| return this->lumaProc(*a, *b);
|
| }
|
|
|
| void SkLumaMaskXfermode::xfer32(SkPMColor dst[], const SkPMColor src[],
|
| int count, const SkAlpha aa[]) const {
|
| - const SkPMColor* a = lumaOpA<SkPMColor>(fMode, src, dst);
|
| - const SkPMColor* b = lumaOpB<SkPMColor>(fMode, src, dst);
|
| + const SkPMColor* a = lumaOpA<const SkPMColor*>(fMode, src, dst);
|
| + const SkPMColor* b = lumaOpB<const SkPMColor*>(fMode, src, dst);
|
|
|
| if (aa) {
|
| for (int i = 0; i < count; ++i) {
|
| @@ -157,7 +155,7 @@ public:
|
| const GrDrawEffect&,
|
| EffectKey,
|
| const char* outputColor,
|
| - const char* inputColor,
|
| + const GrGLSLExpr4& inputColor,
|
| const TransformedCoordsArray&,
|
| const TextureSamplerArray&) SK_OVERRIDE;
|
|
|
| @@ -206,30 +204,26 @@ void GrGLLumaMaskEffect::emitCode(GrGLShaderBuilder* builder,
|
| const GrDrawEffect& effect,
|
| EffectKey key,
|
| const char* outputColor,
|
| - const char* inputColor,
|
| + const GrGLSLExpr4& inputColor,
|
| const TransformedCoordsArray&,
|
| const TextureSamplerArray& samplers) {
|
|
|
| const GrLumaMaskEffect& lumaEffect = effect.castEffect<GrLumaMaskEffect>();
|
| - const char* dstColor = builder->dstColor();
|
| - SkASSERT(NULL != dstColor);
|
| - if (NULL == inputColor) {
|
| - inputColor = "vec4(1)";
|
| - }
|
| + GrGLSLExpr4 dstColor(builder->dstColor());
|
|
|
| - const char *opA = lumaOpA<char>(lumaEffect.getMode(), inputColor, dstColor);
|
| - const char *opB = lumaOpB<char>(lumaEffect.getMode(), inputColor, dstColor);
|
| + const GrGLSLExpr4& opA = lumaOpA(lumaEffect.getMode(), inputColor, dstColor);
|
| + const GrGLSLExpr4& opB = lumaOpB(lumaEffect.getMode(), inputColor, dstColor);
|
|
|
| builder->fsCodeAppendf("\t\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb); \n",
|
| SK_ITU_BT709_LUM_COEFF_R,
|
| SK_ITU_BT709_LUM_COEFF_G,
|
| SK_ITU_BT709_LUM_COEFF_B,
|
| - opB);
|
| + opB.c_str());
|
| if (SkXfermode::kSrcOver_Mode == lumaEffect.getMode()) {
|
| - builder->fsCodeAppendf("\t\tvec4 newB = %s;\n\t\tif (newB.a > 0.0) { newB *= luma / newB.a; }\n\t\tnewB.a = luma;\n", opB);
|
| - builder->fsCodeAppendf("\t\t%s = newB + %s * (1.0 - luma); \n", outputColor, opA);
|
| + builder->fsCodeAppendf("\t\tvec4 newB = %s;\n\t\tif (newB.a > 0.0) { newB *= luma / newB.a; }\n\t\tnewB.a = luma;\n", opB.c_str());
|
| + builder->fsCodeAppendf("\t\t%s = newB + %s * (1.0 - luma); \n", outputColor, opA.c_str());
|
| } else {
|
| - builder->fsCodeAppendf("\t\t%s = %s * luma;\n", outputColor, opA);
|
| + builder->fsCodeAppendf("\t\t%s = %s * luma;\n", outputColor, opA.c_str());
|
| }
|
| }
|
|
|
|
|