Title: [139674] trunk
Revision
139674
Author
commit-qu...@webkit.org
Date
2013-01-14 15:11:04 -0800 (Mon, 14 Jan 2013)

Log Message

[TexMap] Use a premuliplied color in TextureMapperGL.
https://bugs.webkit.org/show_bug.cgi?id=105786

Patch by Huang Dongsung <luxte...@company100.net> on 2013-01-14
Reviewed by Noam Rosenthal.

Source/WebCore:

TextureMapperGL always uses a premultiplied color, so we must convert
an unmultiplied color to a premultiplied color before setting the uniform value of
colorLocation.

Test: compositing/background-color/background-color-alpha-with-opacity.html

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawBorder):
(WebCore::TextureMapperGL::drawSolidColor):
(WebCore::prepareFilterProgram):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::blendWithOpacity):
(WebCore):
(WebCore::TextureMapperLayer::paintSelf):
    TextureMapperLayer must not convert solidColor to premultiplied
    color, because TextureMapperImageBuffer expects unmultiplied color.

LayoutTests:

Created new tests for composited background colors with fractional
number opacity. This test is similar to background-color-alpha.html

* compositing/background-color/background-color-alpha-with-opacity-expected.html: Added.
* compositing/background-color/background-color-alpha-with-opacity.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139673 => 139674)


--- trunk/LayoutTests/ChangeLog	2013-01-14 23:02:19 UTC (rev 139673)
+++ trunk/LayoutTests/ChangeLog	2013-01-14 23:11:04 UTC (rev 139674)
@@ -1,3 +1,16 @@
+2013-01-14  Huang Dongsung  <luxte...@company100.net>
+
+        [TexMap] Use a premuliplied color in TextureMapperGL.
+        https://bugs.webkit.org/show_bug.cgi?id=105786
+
+        Reviewed by Noam Rosenthal.
+
+        Created new tests for composited background colors with fractional
+        number opacity. This test is similar to background-color-alpha.html
+
+        * compositing/background-color/background-color-alpha-with-opacity-expected.html: Added.
+        * compositing/background-color/background-color-alpha-with-opacity.html: Added.
+
 2013-01-14  Arko Saha  <a...@motorola.com>
 
         Microdata: REGRESSION(r138725): Causes crash in chromium port

Added: trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity-expected.html (0 => 139674)


--- trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity-expected.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity-expected.html	2013-01-14 23:11:04 UTC (rev 139674)
@@ -0,0 +1,31 @@
+<html>
+    <head>
+        <style type="text/css">
+            .green {
+                width: 100px;
+                height: 100px;
+                background-color: rgba(0, 128, 0, 128);
+                opacity: 0.5;
+                display: block;
+            }
+            .blue {
+                width: 100px;
+                height: 100px;
+                background-color: rgba(0, 0, 128, 128);
+                opacity: 0.5;
+                display: block;
+                -webkit-transform: translate(50px, 50px);
+            }
+
+            .composited {
+                -webkit-transform-style: preserve-3d;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="green">
+            <div class="blue">
+            </div>
+        </div>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity.html (0 => 139674)


--- trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/background-color/background-color-alpha-with-opacity.html	2013-01-14 23:11:04 UTC (rev 139674)
@@ -0,0 +1,31 @@
+<html>
+    <head>
+        <style type="text/css">
+            .green {
+                width: 100px;
+                height: 100px;
+                background-color: rgba(0, 128, 0, 128);
+                opacity: 0.5;
+                display: block;
+            }
+            .blue {
+                width: 100px;
+                height: 100px;
+                background-color: rgba(0, 0, 128, 128);
+                opacity: 0.5;
+                display: block;
+                -webkit-transform: translate(50px, 50px);
+            }
+
+            .composited {
+                -webkit-transform-style: preserve-3d;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="green composited">
+            <div class="blue composited">
+            </div>
+        </div>
+    </body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (139673 => 139674)


--- trunk/Source/WebCore/ChangeLog	2013-01-14 23:02:19 UTC (rev 139673)
+++ trunk/Source/WebCore/ChangeLog	2013-01-14 23:11:04 UTC (rev 139674)
@@ -1,3 +1,27 @@
+2013-01-14  Huang Dongsung  <luxte...@company100.net>
+
+        [TexMap] Use a premuliplied color in TextureMapperGL.
+        https://bugs.webkit.org/show_bug.cgi?id=105786
+
+        Reviewed by Noam Rosenthal.
+
+        TextureMapperGL always uses a premultiplied color, so we must convert
+        an unmultiplied color to a premultiplied color before setting the uniform value of
+        colorLocation.
+
+        Test: compositing/background-color/background-color-alpha-with-opacity.html
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawBorder):
+        (WebCore::TextureMapperGL::drawSolidColor):
+        (WebCore::prepareFilterProgram):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::blendWithOpacity):
+        (WebCore):
+        (WebCore::TextureMapperLayer::paintSelf):
+            TextureMapperLayer must not convert solidColor to premultiplied
+            color, because TextureMapperImageBuffer expects unmultiplied color.
+
 2013-01-14  Arko Saha  <a...@motorola.com>
 
         Microdata: REGRESSION(r138725): Causes crash in chromium port

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (139673 => 139674)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2013-01-14 23:02:19 UTC (rev 139673)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2013-01-14 23:11:04 UTC (rev 139674)
@@ -302,7 +302,7 @@
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
-    color.getRGBA(r, g, b, a);
+    Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
     m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
     m_context3D->lineWidth(width);
 
@@ -431,7 +431,7 @@
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
-    color.getRGBA(r, g, b, a);
+    Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
     m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
     if (a < 1)
         flags |= ShouldBlend;
@@ -824,7 +824,7 @@
         case 1:
             // Second pass: we need the shadow color and the content texture for compositing.
             float r, g, b, a;
-            shadow.color().getRGBA(r, g, b, a);
+            Color(premultipliedARGBFromColor(shadow.color())).getRGBA(r, g, b, a);
             context->uniform4f(program->colorLocation(), r, g, b, a);
             context->uniform2f(program->blurRadiusLocation(), 0, shadow.stdDeviation() / float(size.height()));
             context->uniform2f(program->shadowOffsetLocation(), 0, 0);

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (139673 => 139674)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2013-01-14 23:02:19 UTC (rev 139673)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2013-01-14 23:11:04 UTC (rev 139674)
@@ -104,6 +104,15 @@
     paintRecursive(options);
 }
 
+static Color blendWithOpacity(const Color& color, float opacity)
+{
+    RGBA32 rgba = color.rgb();
+    // See Color::getRGBA() to know how to extract alpha from color.
+    float alpha = alphaChannel(rgba) / 255.;
+    float effectiveAlpha = alpha * opacity;
+    return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
+}
+
 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
 {
     if (!m_state.visible || !m_state.contentsVisible)
@@ -119,14 +128,7 @@
     RefPtr<BitmapTexture> mask = options.mask;
 
     if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
-        if (!m_state.solidColor.alpha())
-            return;
-
-        Color color = m_state.solidColor;
-        float r, g, b, a;
-        color.getRGBA(r, g, b, a);
-        color = Color(r * opacity, g * opacity, b * opacity, a * opacity);
-        options.textureMapper->drawSolidColor(m_state.contentsRect, transform, color);
+        options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, opacity));
         return;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to