OSDN Git Service

drm_hwcomposer: fix logic error in premult blending
authorHaixia Shi <hshi@chromium.org>
Wed, 14 Oct 2015 01:27:10 +0000 (18:27 -0700)
committerHaixia Shi <hshi@chromium.org>
Wed, 14 Oct 2015 01:27:10 +0000 (18:27 -0700)
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

glworker.cpp

index ffb4182..118b397 100644 (file)
@@ -214,9 +214,9 @@ static int GenerateShaders(std::vector<AutoGLProgram> *blend_programs) {
 "  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"