drm_hwcomposer: fix logic error in premult blending
In case of premult blending, the tex.rgb is premultiplied with tex.a,
but it still needs to be multiplied by the plane alpha.
BUG=24914993
TEST=verify the blending artifacts are fixed
Change-Id: I9135f91d52b2d256a71895e13caf2158286de992
diff --git a/glworker.cpp b/glworker.cpp
index ffb4182..118b397 100644
--- a/glworker.cpp
+++ b/glworker.cpp
@@ -214,9 +214,9 @@
" float alphaCover = 1.0; \n"
" for (int i = 0; i < LAYER_COUNT; i++) { \n"
" vec4 texSample = texture2D(uLayerTextures[i], fTexCoords[i]); \n"
-" float a = texSample.a * uLayerAlpha[i]; \n"
-" color += max(a, uLayerPremult[i]) * alphaCover * texSample.rgb; \n"
-" alphaCover *= 1.0 - a; \n"
+" vec3 multRgb = texSample.rgb * max(texSample.a, uLayerPremult[i]); \n"
+" color += multRgb * uLayerAlpha[i] * alphaCover; \n"
+" alphaCover *= 1.0 - texSample.a * uLayerAlpha[i]; \n"
" if (alphaCover <= 0.5/255.0) \n"
" break; \n"
" } \n"