OSDN Git Service

Simplify handling of opaque layers in shader generation
authorMathias Agopian <mathias@google.com>
Wed, 14 Aug 2013 23:33:27 +0000 (16:33 -0700)
committerMathias Agopian <mathias@google.com>
Thu, 15 Aug 2013 22:11:01 +0000 (15:11 -0700)
just ensure the alpha value is 1.0 in the opaque case
when reading the color from the texture or the
global color.

Bug: 8679321

Change-Id: Ia38b30e97c3bce5a2d534a40c0d66e0bfc3ea40d

services/surfaceflinger/RenderEngine/ProgramCache.cpp

index f378713..1f2eb9d 100644 (file)
@@ -140,28 +140,16 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
     } else {
         fs << "gl_FragColor = color;";
     }
+    if (needs.isOpaque()) {
+        fs << "gl_FragColor.a = 1.0;";
+    }
     if (needs.hasPlaneAlpha()) {
         // modulate the alpha value with planeAlpha
         if (needs.isPremultiplied()) {
             // ... and the color too if we're premultiplied
-            if (needs.isOpaque()) {
-                // ... we're opaque, only premultiply the color component
-                fs << "gl_FragColor.rgb *= alphaPlane;"
-                   << "gl_FragColor.a = alphaPlane;";
-            } else {
-                fs << "gl_FragColor *= alphaPlane;";
-            }
+            fs << "gl_FragColor *= alphaPlane;";
         } else {
-            // not premultiplied
-            if (needs.isOpaque()) {
-                fs << "gl_FragColor.a = alphaPlane;";
-            } else {
-                fs << "gl_FragColor.a *= alphaPlane;";
-            }
-        }
-    } else {
-        if (needs.isOpaque()) {
-            fs << "gl_FragColor.a = 1.0;";
+            fs << "gl_FragColor.a *= alphaPlane;";
         }
     }
     fs << dedent << "}";