Changeset 139674 in webkit


Ignore:
Timestamp:
Jan 14, 2013 3:11:04 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Huang Dongsung <luxtella@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.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139673 r139674  
     12013-01-14  Huang Dongsung  <luxtella@company100.net>
     2
     3        [TexMap] Use a premuliplied color in TextureMapperGL.
     4        https://bugs.webkit.org/show_bug.cgi?id=105786
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Created new tests for composited background colors with fractional
     9        number opacity. This test is similar to background-color-alpha.html
     10
     11        * compositing/background-color/background-color-alpha-with-opacity-expected.html: Added.
     12        * compositing/background-color/background-color-alpha-with-opacity.html: Added.
     13
    1142013-01-14  Arko Saha  <arko@motorola.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r139673 r139674  
     12013-01-14  Huang Dongsung  <luxtella@company100.net>
     2
     3        [TexMap] Use a premuliplied color in TextureMapperGL.
     4        https://bugs.webkit.org/show_bug.cgi?id=105786
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        TextureMapperGL always uses a premultiplied color, so we must convert
     9        an unmultiplied color to a premultiplied color before setting the uniform value of
     10        colorLocation.
     11
     12        Test: compositing/background-color/background-color-alpha-with-opacity.html
     13
     14        * platform/graphics/texmap/TextureMapperGL.cpp:
     15        (WebCore::TextureMapperGL::drawBorder):
     16        (WebCore::TextureMapperGL::drawSolidColor):
     17        (WebCore::prepareFilterProgram):
     18        * platform/graphics/texmap/TextureMapperLayer.cpp:
     19        (WebCore::blendWithOpacity):
     20        (WebCore):
     21        (WebCore::TextureMapperLayer::paintSelf):
     22            TextureMapperLayer must not convert solidColor to premultiplied
     23            color, because TextureMapperImageBuffer expects unmultiplied color.
     24
    1252013-01-14  Arko Saha  <arko@motorola.com>
    226
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r138891 r139674  
    303303
    304304    float r, g, b, a;
    305     color.getRGBA(r, g, b, a);
     305    Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
    306306    m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
    307307    m_context3D->lineWidth(width);
     
    432432
    433433    float r, g, b, a;
    434     color.getRGBA(r, g, b, a);
     434    Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
    435435    m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
    436436    if (a < 1)
     
    825825            // Second pass: we need the shadow color and the content texture for compositing.
    826826            float r, g, b, a;
    827             shadow.color().getRGBA(r, g, b, a);
     827            Color(premultipliedARGBFromColor(shadow.color())).getRGBA(r, g, b, a);
    828828            context->uniform4f(program->colorLocation(), r, g, b, a);
    829829            context->uniform2f(program->blurRadiusLocation(), 0, shadow.stdDeviation() / float(size.height()));
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r139526 r139674  
    105105}
    106106
     107static Color blendWithOpacity(const Color& color, float opacity)
     108{
     109    RGBA32 rgba = color.rgb();
     110    // See Color::getRGBA() to know how to extract alpha from color.
     111    float alpha = alphaChannel(rgba) / 255.;
     112    float effectiveAlpha = alpha * opacity;
     113    return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
     114}
     115
    107116void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
    108117{
     
    120129
    121130    if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
    122         if (!m_state.solidColor.alpha())
    123             return;
    124 
    125         Color color = m_state.solidColor;
    126         float r, g, b, a;
    127         color.getRGBA(r, g, b, a);
    128         color = Color(r * opacity, g * opacity, b * opacity, a * opacity);
    129         options.textureMapper->drawSolidColor(m_state.contentsRect, transform, color);
     131        options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, opacity));
    130132        return;
    131133    }
Note: See TracChangeset for help on using the changeset viewer.