Changeset 170841 in webkit


Ignore:
Timestamp:
Jul 7, 2014 12:16:04 AM (10 years ago)
Author:
Ion Rosca
Message:

[CSS Blending]The background images set on the root element will blend on an initial white backdrop.
https://bugs.webkit.org/show_bug.cgi?id=134342

Reviewed by Dean Jackson.

Source/WebCore:
Tests: css3/blending/background-blend-mode-body-image.html

css3/blending/background-blend-mode-body-transparent-color-and-image.html
css3/blending/background-blend-mode-body-transparent-image.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintFillLayers):
If the background layers have blend modes, we paint the base background color first,
before starting a new transparency layer. After creating the transparency layer,
the base background will be skipped, and the background layers will blend on top of
a transparent backdrop.
(WebCore::RenderBox::paintFillLayer):

  • rendering/RenderBox.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):
This method is able to paint only the base background color (BaseBackgroundColorOnly),
skipping the background-color and background-images. This option is available only
on bottom layer of the root renderer and only if the background color is not opaque,
otherwise the method will return early.
Another option is to paint the root background without using the base background color
(BaseBackgroundColorSkip).

  • rendering/RenderBoxModelObject.h:

Adding the BaseBackgroundColorUsage enum.

LayoutTests:

  • css3/blending/background-blend-mode-body-image-expected.html: Added.
  • css3/blending/background-blend-mode-body-image.html: Added.
  • css3/blending/background-blend-mode-body-transparent-color-and-image-expected.html: Added.
  • css3/blending/background-blend-mode-body-transparent-color-and-image.html: Added.
  • css3/blending/background-blend-mode-body-transparent-image-expected.html: Added.
  • css3/blending/background-blend-mode-body-transparent-image.html: Added.
Location:
trunk
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r170837 r170841  
     12014-07-07  Ion Rosca  <rosca@adobe.com>
     2
     3        [CSS Blending]The background images set on the root element will blend on an initial white backdrop.
     4        https://bugs.webkit.org/show_bug.cgi?id=134342
     5
     6        Reviewed by Dean Jackson.
     7
     8        * css3/blending/background-blend-mode-body-image-expected.html: Added.
     9        * css3/blending/background-blend-mode-body-image.html: Added.
     10        * css3/blending/background-blend-mode-body-transparent-color-and-image-expected.html: Added.
     11        * css3/blending/background-blend-mode-body-transparent-color-and-image.html: Added.
     12        * css3/blending/background-blend-mode-body-transparent-image-expected.html: Added.
     13        * css3/blending/background-blend-mode-body-transparent-image.html: Added.
     14
    1152014-07-06  Yoav Weiss  <yoav@yoav.ws>
    216
  • trunk/Source/WebCore/ChangeLog

    r170837 r170841  
     12014-07-07  Ion Rosca  <rosca@adobe.com>
     2
     3        [CSS Blending]The background images set on the root element will blend on an initial white backdrop.
     4        https://bugs.webkit.org/show_bug.cgi?id=134342
     5
     6        Reviewed by Dean Jackson.
     7
     8        Tests: css3/blending/background-blend-mode-body-image.html
     9               css3/blending/background-blend-mode-body-transparent-color-and-image.html
     10               css3/blending/background-blend-mode-body-transparent-image.html
     11
     12        * rendering/RenderBox.cpp:
     13        (WebCore::RenderBox::paintFillLayers):
     14        If the background layers have blend modes, we paint the base background color first,
     15        before starting a new transparency layer. After creating the transparency layer,
     16        the base background will be skipped, and the background layers will blend on top of
     17        a transparent backdrop.
     18        (WebCore::RenderBox::paintFillLayer):
     19        * rendering/RenderBox.h:
     20        * rendering/RenderBoxModelObject.cpp:
     21        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     22        This method is able to paint only the base background color (BaseBackgroundColorOnly),
     23        skipping the background-color and background-images. This option is available only
     24        on bottom layer of the root renderer and only if the background color is not opaque,
     25        otherwise the method will return early.
     26        Another option is to paint the root background without using the base background color
     27        (BaseBackgroundColorSkip).
     28        * rendering/RenderBoxModelObject.h:
     29        Adding the BaseBackgroundColorUsage enum.
     30
    1312014-07-06  Yoav Weiss  <yoav@yoav.ws>
    232
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r170817 r170841  
    15661566    if (!context)
    15671567        shouldDrawBackgroundInSeparateBuffer = false;
    1568     if (shouldDrawBackgroundInSeparateBuffer)
     1568
     1569    BaseBackgroundColorUsage baseBgColorUsage = BaseBackgroundColorUse;
     1570
     1571    if (shouldDrawBackgroundInSeparateBuffer) {
     1572        paintFillLayer(paintInfo, c, *layers.rbegin(), rect, bleedAvoidance, op, backgroundObject, BaseBackgroundColorOnly);
     1573        baseBgColorUsage = BaseBackgroundColorSkip;
    15691574        context->beginTransparencyLayer(1);
     1575    }
    15701576
    15711577    Vector<const FillLayer*>::const_reverse_iterator topLayer = layers.rend();
    15721578    for (Vector<const FillLayer*>::const_reverse_iterator it = layers.rbegin(); it != topLayer; ++it)
    1573         paintFillLayer(paintInfo, c, *it, rect, bleedAvoidance, op, backgroundObject);
     1579        paintFillLayer(paintInfo, c, *it, rect, bleedAvoidance, op, backgroundObject, baseBgColorUsage);
    15741580
    15751581    if (shouldDrawBackgroundInSeparateBuffer)
     
    15781584
    15791585void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const LayoutRect& rect,
    1580     BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderElement* backgroundObject)
    1581 {
    1582     paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, LayoutSize(), op, backgroundObject);
     1586    BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)
     1587{
     1588    paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, LayoutSize(), op, backgroundObject, baseBgColorUsage);
    15831589}
    15841590
  • trunk/Source/WebCore/rendering/RenderBox.h

    r169407 r170841  
    634634    void paintBackground(const PaintInfo&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone);
    635635   
    636     void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, CompositeOperator, RenderElement* backgroundObject);
     636    void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, CompositeOperator, RenderElement* backgroundObject, BaseBackgroundColorUsage = BaseBackgroundColorUse);
    637637    void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = nullptr);
    638638
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r170774 r170841  
    619619
    620620void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer* bgLayer, const LayoutRect& rect,
    621     BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSize& boxSize, CompositeOperator op, RenderElement* backgroundObject)
     621    BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSize& boxSize, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)
    622622{
    623623    GraphicsContext* context = paintInfo.context;
     
    660660        }
    661661    }
     662
     663    bool baseBgColorOnly = (baseBgColorUsage == BaseBackgroundColorOnly);
     664    if (baseBgColorOnly && (!isRoot || bgLayer->next() || (bgColor.isValid() && !bgColor.hasAlpha())))
     665        return;
    662666
    663667    bool colorVisible = bgColor.isValid() && bgColor.alpha();
     
    802806            Color baseColor;
    803807            bool shouldClearBackground = false;
    804             if (isOpaqueRoot) {
     808            if ((baseBgColorUsage != BaseBackgroundColorSkip) && isOpaqueRoot) {
    805809                baseColor = view().frameView().baseBackgroundColor();
    806810                if (!baseColor.alpha())
     
    814818            FloatRect backgroundRectForPainting = pixelSnappedForPainting(backgroundRect, deviceScaleFactor);
    815819            if (baseColor.alpha()) {
    816                 if (bgColor.alpha())
     820                if (!baseBgColorOnly && bgColor.alpha())
    817821                    baseColor = baseColor.blend(bgColor);
    818822
    819823                context->fillRect(backgroundRectForPainting, baseColor, style().colorSpace(), CompositeCopy);
    820             } else if (bgColor.alpha()) {
     824            } else if (!baseBgColorOnly && bgColor.alpha()) {
    821825                CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
    822826                context->fillRect(backgroundRectForPainting, bgColor, style().colorSpace(), operation);
     
    827831
    828832    // no progressive loading of the background image
    829     if (shouldPaintBackgroundImage) {
     833    if (!baseBgColorOnly && shouldPaintBackgroundImage) {
    830834        BackgroundImageGeometry geometry;
    831835        calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, scrolledPaintRect, geometry, backgroundObject);
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r169408 r170841  
    4242};
    4343
     44enum BaseBackgroundColorUsage {
     45    BaseBackgroundColorUse,
     46    BaseBackgroundColorOnly,
     47    BaseBackgroundColorSkip
     48};
     49
    4450enum ContentChangeType {
    4551    ImageChanged,
     
    171177    bool paintNinePieceImage(GraphicsContext*, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
    172178    void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle&, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    173     void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = 0);
     179    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = 0, BaseBackgroundColorUsage = BaseBackgroundColorUse);
    174180
    175181    virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox* = 0) const;
Note: See TracChangeset for help on using the changeset viewer.