Changeset 149010 in webkit


Ignore:
Timestamp:
Apr 23, 2013 5:53:42 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Add platform support for -webkit-background-blend-mode to CG context with background color
https://bugs.webkit.org/show_bug.cgi?id=114412

Patch by Mihai Tica <mitica@adobe.com> on 2013-04-23
Reviewed by Darin Adler.

Source/WebCore:

Tests: css3/compositing/effect-background-blend-mode-color.html, css3/compositing/effect-background-blend-mode-color2.html

This patch adds support for blending on background colors to the Core Graphics port of WebKit.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):

  • platform/graphics/GraphicsContext.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):

LayoutTests:

Adding pixel tests for -webkit-background-blend-mode with bg-color
effect-background-blend-mode-color.html uses accelerated compositing
effect-background-blend-mode-color2.html uses software rendering

  • css3/compositing/effect-background-blend-mode-color-expected.txt: Added.
  • css3/compositing/effect-background-blend-mode-color.html: Added.
  • platform/mac/css3/compositing/effect-background-blend-mode-color-expected.png: Added.
  • css3/compositing/effect-background-blend-mode-color2-expected.txt: Added.
  • css3/compositing/effect-background-blend-mode-color2.html: Added.
  • platform/mac/css3/compositing/effect-background-blend-mode-color2-expected.png: Added.
Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r149001 r149010  
     12013-04-23  Mihai Tica  <mitica@adobe.com>
     2
     3        Add platform support for -webkit-background-blend-mode to CG context with background color
     4        https://bugs.webkit.org/show_bug.cgi?id=114412
     5
     6        Reviewed by Darin Adler.
     7
     8        Adding pixel tests for -webkit-background-blend-mode with bg-color
     9        effect-background-blend-mode-color.html uses accelerated compositing
     10        effect-background-blend-mode-color2.html uses software rendering
     11
     12        * css3/compositing/effect-background-blend-mode-color-expected.txt: Added.
     13        * css3/compositing/effect-background-blend-mode-color.html: Added.
     14        * platform/mac/css3/compositing/effect-background-blend-mode-color-expected.png: Added.
     15        * css3/compositing/effect-background-blend-mode-color2-expected.txt: Added.
     16        * css3/compositing/effect-background-blend-mode-color2.html: Added.
     17        * platform/mac/css3/compositing/effect-background-blend-mode-color2-expected.png: Added.
     18
    1192013-04-23  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    220
  • trunk/Source/WebCore/ChangeLog

    r149009 r149010  
     12013-04-23  Mihai Tica  <mitica@adobe.com>
     2
     3        Add platform support for -webkit-background-blend-mode to CG context with background color
     4        https://bugs.webkit.org/show_bug.cgi?id=114412
     5
     6        Reviewed by Darin Adler.
     7
     8        Tests: css3/compositing/effect-background-blend-mode-color.html, css3/compositing/effect-background-blend-mode-color2.html
     9
     10        This patch adds support for blending on background colors to the Core Graphics port of WebKit.
     11
     12        * platform/graphics/GraphicsContext.cpp:
     13        (WebCore::GraphicsContext::fillRect):
     14        (WebCore::GraphicsContext::fillRoundedRect):
     15        * platform/graphics/GraphicsContext.h:
     16        * rendering/RenderBoxModelObject.cpp:
     17        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     18
    1192013-04-23  Ryosuke Niwa  <rniwa@webkit.org>
    220
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r148757 r149010  
    674674}
    675675
    676 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op)
     676void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
    677677{
    678678    if (paintingDisabled())
     
    680680
    681681    CompositeOperator previousOperator = compositeOperation();
    682     setCompositeOperation(op);
     682    setCompositeOperation(op, blendMode);
    683683    fillRect(rect, color, styleColorSpace);
    684684    setCompositeOperation(previousOperator);
    685685}
    686686
    687 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace)
    688 {
    689     if (rect.isRounded())
     687void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace, BlendMode blendMode)
     688{
     689
     690    if (rect.isRounded()) {
     691        setCompositeOperation(compositeOperation(), blendMode);
    690692        fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
    691     else
    692         fillRect(rect.rect(), color, colorSpace);
     693        setCompositeOperation(compositeOperation());
     694    } else
     695        fillRect(rect.rect(), color, colorSpace, compositeOperation(), blendMode);
    693696}
    694697
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r148757 r149010  
    302302        void fillRect(const FloatRect&, const Color&, ColorSpace);
    303303        void fillRect(const FloatRect&, Generator&);
    304         void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator);
     304        void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
    305305        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
    306         void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace);
     306        void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
    307307        void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleRect, const Color&, ColorSpace);
    308308
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r148949 r149010  
    788788            RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge);
    789789            if (border.isRenderable())
    790                 context->fillRoundedRect(border, bgColor, style()->colorSpace());
     790                context->fillRoundedRect(border, bgColor, style()->colorSpace(), bgLayer->blendMode());
    791791            else {
    792792                context->save();
    793793                clipRoundedInnerRect(context, rect, border);
    794                 context->fillRect(border.rect(), bgColor, style()->colorSpace());
     794                context->fillRect(border.rect(), bgColor, style()->colorSpace(), context->compositeOperation(), bgLayer->blendMode());
    795795                context->restore();
    796796            }
    797797        } else
    798             context->fillRect(pixelSnappedIntRect(rect), bgColor, style()->colorSpace());
    799        
     798            context->fillRect(pixelSnappedIntRect(rect), bgColor, style()->colorSpace(), context->compositeOperation(), bgLayer->blendMode());
     799
    800800        return;
    801801    }
     
    941941                    baseColor = baseColor.blend(bgColor);
    942942
    943                 context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
     943                context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy, bgLayer->blendMode());
    944944            } else if (bgColor.alpha()) {
    945945                CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
    946                 context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
     946                context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation, bgLayer->blendMode());
    947947            } else if (shouldClearBackground)
    948948                context->clearRect(backgroundRect);
Note: See TracChangeset for help on using the changeset viewer.