<https://webkit.org/b/120476> [CSS Masking] Implement luminance masking
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Sep 2013 13:53:08 +0000 (13:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Sep 2013 13:53:08 +0000 (13:53 +0000)
Source/WebCore:

Added implementation for luminance masking. A luminance mask is applied by transforming its RGB values into
an alpha value, using luminance-to-alpha coefficients. Because this conversion is already implemented in
the ImageBuffer class, we used it in our implementation.

Patch by Andrei Parvu <parvu@adobe.com> on 2013-09-25
Reviewed by Dirk Schulze.

Tests: css3/masking/mask-luminance-gradient.html
       css3/masking/mask-luminance-png.html
       css3/masking/mask-luminance-svg.html

* platform/graphics/BitmapImage.cpp: Add a drawPattern method, in which an ImageBuffer is created and converted from alpha to luminance, if there is a luminance mask.
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::drawPattern):
* platform/graphics/BitmapImage.h:
* platform/graphics/GeneratorGeneratedImage.cpp: Convert the ImageBuffer to luminance, if necessary.
(WebCore::GeneratorGeneratedImage::drawPattern):
* platform/graphics/GraphicsContext.cpp: Add methods which set and check if a luminance mask is drawn.
(WebCore::GraphicsContext::setDrawLuminanceMask):
(WebCore::GraphicsContext::drawLuminanceMask):
* platform/graphics/GraphicsContext.h: Add property to ContextState for luminance drawing.
(WebCore::GraphicsContextState::GraphicsContextState):
* rendering/RenderBoxModelObject.cpp: Set the luminance property of the mask, if the layer has a mask source type of luminance.
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* svg/graphics/SVGImage.cpp: Convert the ImageBuffer to luminance, if necessary.
(WebCore::SVGImage::drawPatternForContainer):
* svg/graphics/SVGImageForContainer.cpp: Pass the luminance property to the SVG image.
(WebCore::SVGImageForContainer::drawPattern):

LayoutTests:

Added tests to verify the implementation of luminance masking.

Patch by Andrei Parvu <parvu@adobe.com> on 2013-09-25
Reviewed by Dirk Schulze.

* css3/masking/mask-luminance-gradient-expected.html: Added.
* css3/masking/mask-luminance-gradient.html: Added.
* css3/masking/mask-luminance-png.html: Added.
* css3/masking/mask-luminance-svg-expected.html: Added.
* css3/masking/mask-luminance-svg.html: Added.
* css3/masking/resources/circle-alpha.svg: Added.
* css3/masking/resources/circle2.svg: Added.
* css3/masking/resources/dice.png: Added.
* platform/mac/css3/masking/mask-luminance-png-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156391 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/masking/mask-luminance-gradient-expected.html [new file with mode: 0644]
LayoutTests/css3/masking/mask-luminance-gradient.html [new file with mode: 0644]
LayoutTests/css3/masking/mask-luminance-png.html [new file with mode: 0644]
LayoutTests/css3/masking/mask-luminance-svg-expected.html [new file with mode: 0644]
LayoutTests/css3/masking/mask-luminance-svg.html [new file with mode: 0644]
LayoutTests/css3/masking/resources/circle-alpha.svg [new file with mode: 0644]
LayoutTests/css3/masking/resources/circle2.svg [new file with mode: 0644]
LayoutTests/css3/masking/resources/dice.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/masking/mask-luminance-png-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/GradientImage.cpp
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/svg/graphics/SVGImage.cpp

index 7ca68e6f909457fca289d51f16d74878bfda6adb..fbf924aa2bc8fc7115a7eac6af1f41086581a3f6 100644 (file)
@@ -1,3 +1,21 @@
+2013-09-25  Andrei Parvu  <parvu@adobe.com>
+
+        <https://webkit.org/b/120476> [CSS Masking] Implement luminance masking
+
+        Added tests to verify the implementation of luminance masking.
+
+        Reviewed by Dirk Schulze.
+
+        * css3/masking/mask-luminance-gradient-expected.html: Added.
+        * css3/masking/mask-luminance-gradient.html: Added.
+        * css3/masking/mask-luminance-png.html: Added.
+        * css3/masking/mask-luminance-svg-expected.html: Added.
+        * css3/masking/mask-luminance-svg.html: Added.
+        * css3/masking/resources/circle-alpha.svg: Added.
+        * css3/masking/resources/circle2.svg: Added.
+        * css3/masking/resources/dice.png: Added.
+        * platform/mac/css3/masking/mask-luminance-png-expected.txt: Added.
+
 2013-09-25  Krzysztof Czech  <k.czech@samsung.com>
 
         [EFL] Updated accessibility expectations after r154781 and r155599
 2013-09-25  Krzysztof Czech  <k.czech@samsung.com>
 
         [EFL] Updated accessibility expectations after r154781 and r155599
diff --git a/LayoutTests/css3/masking/mask-luminance-gradient-expected.html b/LayoutTests/css3/masking/mask-luminance-gradient-expected.html
new file mode 100644 (file)
index 0000000..c3a9862
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <style>
+            #back {
+                width: 1000px;
+                height: 600px;
+                background-color: green;
+            }
+            #front {
+                width: 800px;
+                height: 400px;
+                background-color: red;
+                border: 50px solid blue;
+                padding: 50px;
+                -webkit-mask-image: linear-gradient(45deg, black, transparent 100%);
+                -webkit-mask-source-type: alpha;
+                -webkit-mask-size: 200px auto;
+                -webkit-mask-repeat: repeat;
+                -webkit-mask-origin: border-box;
+                -webkit-mask-clip: border-box;
+            }
+        </style>
+    </head>
+
+    <body>
+        <div id="back">
+            <div id="front" />
+        </div>
+            </body>
+</html>
+
diff --git a/LayoutTests/css3/masking/mask-luminance-gradient.html b/LayoutTests/css3/masking/mask-luminance-gradient.html
new file mode 100644 (file)
index 0000000..3a2e951
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <style>
+            #back {
+                width: 1000px;
+                height: 600px;
+                background-color: green;
+            }
+            #front {
+                width: 800px;
+                height: 400px;
+                background-color: red;
+                border: 50px solid blue;
+                padding: 50px;
+                -webkit-mask-image: linear-gradient(45deg, white, black);
+                -webkit-mask-source-type: luminance;
+                -webkit-mask-size: 200px auto;
+                -webkit-mask-repeat: repeat;
+                -webkit-mask-origin: border-box;
+                -webkit-mask-clip: border-box;
+            }
+        </style>
+    </head>
+
+    <body>
+        <div id="back">
+            <div id="front" />
+        </div>
+            </body>
+</html>
+
diff --git a/LayoutTests/css3/masking/mask-luminance-png.html b/LayoutTests/css3/masking/mask-luminance-png.html
new file mode 100644 (file)
index 0000000..6d92a65
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <style>
+            #back {
+                width: 1000px;
+                height: 600px;
+                background-color: green;
+            }
+            #front {
+                width: 800px;
+                height: 400px;
+                background-color: red;
+                border: 50px solid blue;
+                padding: 50px;
+                -webkit-mask-image: url(resources/dice.png);
+                -webkit-mask-source-type: luminance;
+                -webkit-mask-size: 200px auto;
+                -webkit-mask-repeat: repeat;
+                -webkit-mask-origin: border-box;
+                -webkit-mask-clip: border-box;
+            }
+        </style>
+    </head>
+
+    <body>
+        <div id="back">
+            <div id="front" />
+        </div>
+            </body>
+</html>
+
diff --git a/LayoutTests/css3/masking/mask-luminance-svg-expected.html b/LayoutTests/css3/masking/mask-luminance-svg-expected.html
new file mode 100644 (file)
index 0000000..561315e
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <style>
+            #back {
+                width: 1000px;
+                height: 600px;
+                background-color: green;
+            }
+            #front {
+                width: 800px;
+                height: 400px;
+                background-color: red;
+                border: 50px solid blue;
+                padding: 50px;
+                -webkit-mask-image: url(resources/circle-alpha.svg);
+                -webkit-mask-source-type: alpha;
+                -webkit-mask-size: 200px auto;
+                -webkit-mask-repeat: repeat;
+                -webkit-mask-origin: border-box;
+                -webkit-mask-clip: border-box;
+            }
+        </style>
+    </head>
+
+    <body>
+        <div id="back">
+            <div id="front" />
+        </div>
+            </body>
+</html>
+
diff --git a/LayoutTests/css3/masking/mask-luminance-svg.html b/LayoutTests/css3/masking/mask-luminance-svg.html
new file mode 100644 (file)
index 0000000..684f4f0
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <style>
+            #back {
+                width: 1000px;
+                height: 600px;
+                background-color: green;
+            }
+            #front {
+                width: 800px;
+                height: 400px;
+                background-color: red;
+                border: 50px solid blue;
+                padding: 50px;
+                -webkit-mask-image: url(resources/circle2.svg);
+                -webkit-mask-source-type: luminance;
+                -webkit-mask-size: 200px auto;
+                -webkit-mask-repeat: repeat;
+                -webkit-mask-origin: border-box;
+                -webkit-mask-clip: border-box;
+            }
+        </style>
+    </head>
+
+    <body>
+        <div id="back">
+            <div id="front" />
+        </div>
+            </body>
+</html>
+
diff --git a/LayoutTests/css3/masking/resources/circle-alpha.svg b/LayoutTests/css3/masking/resources/circle-alpha.svg
new file mode 100644 (file)
index 0000000..b317147
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="360" height="288">
+    <circle cx="180" cy="144" r="80" style="fill:rgb(0,0,0)" />
+</svg>
diff --git a/LayoutTests/css3/masking/resources/circle2.svg b/LayoutTests/css3/masking/resources/circle2.svg
new file mode 100644 (file)
index 0000000..aabab3d
--- /dev/null
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="360" height="288">
+    <rect width="360" height="288" style="fill:rgb(0,0,0)" />
+    <circle cx="180" cy="144" r="80" style="fill:rgb(255,255,255)" />
+</svg>
+
diff --git a/LayoutTests/css3/masking/resources/dice.png b/LayoutTests/css3/masking/resources/dice.png
new file mode 100644 (file)
index 0000000..f18b814
Binary files /dev/null and b/LayoutTests/css3/masking/resources/dice.png differ
diff --git a/LayoutTests/platform/mac/css3/masking/mask-luminance-png-expected.txt b/LayoutTests/platform/mac/css3/masking/mask-luminance-png-expected.txt
new file mode 100644 (file)
index 0000000..360d299
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 1008x616
+  RenderView at (0,0) size 785x585
+layer at (0,0) size 785x616
+  RenderBlock {HTML} at (0,0) size 785x616
+    RenderBody {BODY} at (8,8) size 769x600
+      RenderBlock {DIV} at (0,0) size 1000x600 [bgcolor=#008000]
+layer at (8,8) size 1000x600
+  RenderBlock {DIV} at (0,0) size 1000x600 [bgcolor=#FF0000] [border: (50px solid #0000FF)]
index bf8c425311923c4cdef548a0ea35c29dde3d1e68..69717cf62055a56d7f32a4b04240094e2fef8b53 100644 (file)
@@ -1,3 +1,35 @@
+2013-09-25  Andrei Parvu  <parvu@adobe.com>
+
+        <https://webkit.org/b/120476> [CSS Masking] Implement luminance masking
+
+        Added implementation for luminance masking. A luminance mask is applied by transforming its RGB values into
+        an alpha value, using luminance-to-alpha coefficients. Because this conversion is already implemented in
+        the ImageBuffer class, we used it in our implementation.
+
+        Reviewed by Dirk Schulze.
+
+        Tests: css3/masking/mask-luminance-gradient.html
+               css3/masking/mask-luminance-png.html
+               css3/masking/mask-luminance-svg.html
+
+        * platform/graphics/BitmapImage.cpp: Add a drawPattern method, in which an ImageBuffer is created and converted from alpha to luminance, if there is a luminance mask.
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::drawPattern):
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/GeneratorGeneratedImage.cpp: Convert the ImageBuffer to luminance, if necessary.
+        (WebCore::GeneratorGeneratedImage::drawPattern):
+        * platform/graphics/GraphicsContext.cpp: Add methods which set and check if a luminance mask is drawn.
+        (WebCore::GraphicsContext::setDrawLuminanceMask):
+        (WebCore::GraphicsContext::drawLuminanceMask):
+        * platform/graphics/GraphicsContext.h: Add property to ContextState for luminance drawing.
+        (WebCore::GraphicsContextState::GraphicsContextState):
+        * rendering/RenderBoxModelObject.cpp: Set the luminance property of the mask, if the layer has a mask source type of luminance.
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * svg/graphics/SVGImage.cpp: Convert the ImageBuffer to luminance, if necessary.
+        (WebCore::SVGImage::drawPatternForContainer):
+        * svg/graphics/SVGImageForContainer.cpp: Pass the luminance property to the SVG image.
+        (WebCore::SVGImageForContainer::drawPattern):
+
 2013-09-25  Andreas Kling  <akling@apple.com>
 
         Remove EventPathWalker.
 2013-09-25  Andreas Kling  <akling@apple.com>
 
         Remove EventPathWalker.
index a0ee0dd80309bda738c7cac6af774d3d1d53c9a4..5395af358435f25e2fc9ac28f31b9674498ee88f 100644 (file)
@@ -28,6 +28,7 @@
 #include "BitmapImage.h"
 
 #include "FloatRect.h"
 #include "BitmapImage.h"
 
 #include "FloatRect.h"
+#include "ImageBuffer.h"
 #include "ImageObserver.h"
 #include "IntRect.h"
 #include "MIMETypeRegistry.h"
 #include "ImageObserver.h"
 #include "IntRect.h"
 #include "MIMETypeRegistry.h"
@@ -58,6 +59,7 @@ BitmapImage::BitmapImage(ImageObserver* observer)
     , m_sizeAvailable(false)
     , m_hasUniformFrameSize(true)
     , m_haveFrameCount(false)
     , m_sizeAvailable(false)
     , m_hasUniformFrameSize(true)
     , m_haveFrameCount(false)
+    , m_cachedImage(0)
 {
 }
 
 {
 }
 
@@ -492,6 +494,40 @@ unsigned BitmapImage::decodedSize() const
     return m_decodedSize;
 }
 
     return m_decodedSize;
 }
 
+void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& transform,
+    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
+{
+    if (tileRect.isEmpty())
+        return;
+
+    if (!ctxt->drawLuminanceMask()) {
+        Image::drawPattern(ctxt, tileRect, transform, phase, styleColorSpace, op, destRect, blendMode);
+        return;
+    }
+    if (!m_cachedImage) {
+        OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(tileRect.size()));
+        ASSERT(buffer.get() > 0);
+
+        ImageObserver* observer = imageObserver();
+        ASSERT(observer);
+
+        // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout.
+        setImageObserver(0);
+
+        draw(buffer->context(), tileRect, tileRect, styleColorSpace, op, blendMode);
+
+        setImageObserver(observer);
+        buffer->convertToLuminanceMask();
+
+        m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled);
+        m_cachedImage->setSpaceSize(spaceSize());
+
+        setImageObserver(observer);
+    }
+
+    ctxt->setDrawLuminanceMask(false);
+    m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, styleColorSpace, op, destRect, blendMode);
+}
 
 
 void BitmapImage::advanceAnimation(Timer<BitmapImage>*)
 
 
 void BitmapImage::advanceAnimation(Timer<BitmapImage>*)
index 20fe46e766d2c64c3be305b8b65512f550c84a86..7e6abac7bb8657262a66eebe1f41e2890b43c2bd 100644 (file)
@@ -136,6 +136,9 @@ public:
 
     virtual unsigned decodedSize() const OVERRIDE;
 
 
     virtual unsigned decodedSize() const OVERRIDE;
 
+    virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
+        const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal) OVERRIDE;
+
 #if PLATFORM(MAC)
     // Accessors for native image formats.
     virtual NSImage* getNSImage() OVERRIDE;
 #if PLATFORM(MAC)
     // Accessors for native image formats.
     virtual NSImage* getNSImage() OVERRIDE;
@@ -296,6 +299,8 @@ private:
     bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
     mutable bool m_hasUniformFrameSize : 1;
     mutable bool m_haveFrameCount : 1;
     bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
     mutable bool m_hasUniformFrameSize : 1;
     mutable bool m_haveFrameCount : 1;
+
+    RefPtr<Image> m_cachedImage;
 };
 
 }
 };
 
 }
index f28916d98e7d0ff8c57fdd5cbb7e5d16ed2593b9..9b2d15ccf602434c3f7b3779f6035f192cb9083c 100644 (file)
@@ -72,9 +72,14 @@ void GradientImage::drawPattern(GraphicsContext* destContext, const FloatRect& s
 
         m_cachedGeneratorHash = generatorHash;
         m_cachedAdjustedSize = adjustedSize;
 
         m_cachedGeneratorHash = generatorHash;
         m_cachedAdjustedSize = adjustedSize;
+
+        if (destContext->drawLuminanceMask())
+            m_cachedImageBuffer->convertToLuminanceMask();
     }
 
     m_cachedImageBuffer->setSpaceSize(spaceSize());
     }
 
     m_cachedImageBuffer->setSpaceSize(spaceSize());
+    destContext->setDrawLuminanceMask(false);
+
     // Tile the image buffer into the context.
     m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
 }
     // Tile the image buffer into the context.
     m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
 }
index 2d572d3f4fb5d9596866f9aab8e5350756822c25..8c5b5c3f3126a53134fd1a60e7bf371ee2940841 100644 (file)
@@ -738,6 +738,16 @@ BlendMode GraphicsContext::blendModeOperation() const
     return m_state.blendMode;
 }
 
     return m_state.blendMode;
 }
 
+void GraphicsContext::setDrawLuminanceMask(bool drawLuminanceMask)
+{
+    m_state.drawLuminanceMask = drawLuminanceMask;
+}
+
+bool GraphicsContext::drawLuminanceMask() const
+{
+    return m_state.drawLuminanceMask;
+}
+
 #if !USE(CG)
 // Implement this if you want to go ahead and push the drawing mode into your native context
 // immediately.
 #if !USE(CG)
 // Implement this if you want to go ahead and push the drawing mode into your native context
 // immediately.
index 8ec2c5930e17219b8ea4d6ebe14848dded5aa9f2..0eb51363cdeb64900bb77a317e4bed4f7b935e95 100644 (file)
@@ -150,6 +150,7 @@ namespace WebCore {
             // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
             , shadowsUseLegacyRadius(false)
 #endif
             // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
             , shadowsUseLegacyRadius(false)
 #endif
+            , drawLuminanceMask(false)
         {
         }
 
         {
         }
 
@@ -188,6 +189,7 @@ namespace WebCore {
 #if USE(CG)
         bool shadowsUseLegacyRadius : 1;
 #endif
 #if USE(CG)
         bool shadowsUseLegacyRadius : 1;
 #endif
+        bool drawLuminanceMask : 1;
     };
 
     class GraphicsContext {
     };
 
     class GraphicsContext {
@@ -382,6 +384,9 @@ namespace WebCore {
         CompositeOperator compositeOperation() const;
         BlendMode blendModeOperation() const;
 
         CompositeOperator compositeOperation() const;
         BlendMode blendModeOperation() const;
 
+        void setDrawLuminanceMask(bool);
+        bool drawLuminanceMask() const;
+
         void clip(const Path&, WindRule = RULE_EVENODD);
 
         // This clip function is used only by <canvas> code. It allows
         void clip(const Path&, WindRule = RULE_EVENODD);
 
         // This clip function is used only by <canvas> code. It allows
index 8b6efc365759f8d8d0576233f568e5c8d3308b91..0abe883ec4275da8b3ee532c7d248842fa48f97f 100644 (file)
@@ -120,7 +120,7 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const Fl
     oneTileRect.setSize(scaledTileSize);
     
     // Check and see if a single draw of the image can cover the entire area we are supposed to tile.    
     oneTileRect.setSize(scaledTileSize);
     
     // Check and see if a single draw of the image can cover the entire area we are supposed to tile.    
-    if (oneTileRect.contains(destRect)) {
+    if (oneTileRect.contains(destRect) && !ctxt->drawLuminanceMask()) {
         FloatRect visibleSrcRect;
         visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
         visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
         FloatRect visibleSrcRect;
         visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
         visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
index caa7b2e39ea6ab5fe803a9b95af728ed470161ac..8c06781f7c40f9f8a3f97011a808890acd481d3d 100644 (file)
@@ -797,6 +797,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
             CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
             RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this;
             RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geometry.tileSize());
             CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
             RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this;
             RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geometry.tileSize());
+            context->setDrawLuminanceMask(bgLayer->maskSourceType() == MaskLuminance);
             bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.get(), bgLayer, geometry.tileSize());
             if (image.get())
                 image->setSpaceSize(geometry.spaceSize());
             bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.get(), bgLayer, geometry.tileSize());
             if (image.get())
                 image->setSpaceSize(geometry.spaceSize());
index 5b2e01c51cbf7f079319f7fb046c82de4ce51867..75e12bdecd5ad96d91c1adad543b6db540089ea1 100644 (file)
@@ -201,6 +201,9 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
     if (!buffer) // Failed to allocate buffer.
         return;
     drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal);
     if (!buffer) // Failed to allocate buffer.
         return;
     drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal);
+    if (context->drawLuminanceMask())
+        buffer->convertToLuminanceMask();
+
     RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
     image->setSpaceSize(spaceSize());
 
     RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
     image->setSpaceSize(spaceSize());
 
@@ -210,6 +213,7 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
     AffineTransform unscaledPatternTransform(patternTransform);
     unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height());
 
     AffineTransform unscaledPatternTransform(patternTransform);
     unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height());
 
+    context->setDrawLuminanceMask(false);
     image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect);
 }
 
     image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect);
 }