Title: [149010] trunk
Revision
149010
Author
[email protected]
Date
2013-04-23 17:53:42 -0700 (Tue, 23 Apr 2013)

Log 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 <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149009 => 149010)


--- trunk/LayoutTests/ChangeLog	2013-04-24 00:33:19 UTC (rev 149009)
+++ trunk/LayoutTests/ChangeLog	2013-04-24 00:53:42 UTC (rev 149010)
@@ -1,3 +1,21 @@
+2013-04-23  Mihai Tica  <[email protected]>
+
+        Add platform support for -webkit-background-blend-mode to CG context with background color
+        https://bugs.webkit.org/show_bug.cgi?id=114412
+
+        Reviewed by Darin Adler.
+
+        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.
+
 2013-04-23  Christophe Dumez  <[email protected]>
 
         Global constructors should be configurable and not enumerable

Added: trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color-expected.txt (0 => 149010)


--- trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color-expected.txt	2013-04-24 00:53:42 UTC (rev 149010)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color.html (0 => 149010)


--- trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color.html	                        (rev 0)
+++ trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color.html	2013-04-24 00:53:42 UTC (rev 149010)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<script>
+  if (window.testRunner)
+    window.testRunner.overridePreference("WebKitAcceleratedCompositingEnabled", "1");
+
+  if (window.testRunner)
+    window.testRunner.dumpAsText(true);
+</script>
+<style>
+
+li
+{
+  margin: 5px;
+  width: 130px;
+  height: 130px;
+  background: yellow;
+  display: block;
+  float: left;
+}
+
+</style>
+<body style="background-color: green">
+  <ul>
+    <li style="-webkit-background-blend-mode: normal"></li>
+    <li style="-webkit-background-blend-mode: multiply"></li>
+    <li style="-webkit-background-blend-mode: screen"></li>
+    <li style="-webkit-background-blend-mode: overlay"></li>
+    <li style="-webkit-background-blend-mode: darken"></li>
+    <li style="-webkit-background-blend-mode: lighten"></li>
+    <li style="-webkit-background-blend-mode: color-dodge"></li>
+    <li style="-webkit-background-blend-mode: color-burn"></li>
+    <li style="-webkit-background-blend-mode: hard-light"></li>
+    <li style="-webkit-background-blend-mode: soft-light"></li>
+    <li style="-webkit-background-blend-mode: difference"></li>
+    <li style="-webkit-background-blend-mode: exclusion"></li>
+    <li style="-webkit-background-blend-mode: hue"></li>
+    <li style="-webkit-background-blend-mode: saturation"></li>
+    <li style="-webkit-background-blend-mode: color"></li>
+    <li style="-webkit-background-blend-mode: luminosity"></li>
+  </ul>
+</body>

Added: trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2-expected.txt (0 => 149010)


--- trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2-expected.txt	2013-04-24 00:53:42 UTC (rev 149010)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2.html (0 => 149010)


--- trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2.html	                        (rev 0)
+++ trunk/LayoutTests/css3/compositing/effect-background-blend-mode-color2.html	2013-04-24 00:53:42 UTC (rev 149010)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<script>
+  if (window.testRunner)
+    window.testRunner.overridePreference("WebKitAcceleratedCompositingEnabled", "0");
+
+  if (window.testRunner)
+    window.testRunner.dumpAsText(true);
+</script>
+<style>
+
+li
+{
+  margin: 5px;
+  width: 130px;
+  height: 130px;
+  background: yellow;
+  display: block;
+  float: left;
+}
+
+</style>
+<body style="background-color: green">
+  <ul>
+    <li style="-webkit-background-blend-mode: normal"></li>
+    <li style="-webkit-background-blend-mode: multiply"></li>
+    <li style="-webkit-background-blend-mode: screen"></li>
+    <li style="-webkit-background-blend-mode: overlay"></li>
+    <li style="-webkit-background-blend-mode: darken"></li>
+    <li style="-webkit-background-blend-mode: lighten"></li>
+    <li style="-webkit-background-blend-mode: color-dodge"></li>
+    <li style="-webkit-background-blend-mode: color-burn"></li>
+    <li style="-webkit-background-blend-mode: hard-light"></li>
+    <li style="-webkit-background-blend-mode: soft-light"></li>
+    <li style="-webkit-background-blend-mode: difference"></li>
+    <li style="-webkit-background-blend-mode: exclusion"></li>
+    <li style="-webkit-background-blend-mode: hue"></li>
+    <li style="-webkit-background-blend-mode: saturation"></li>
+    <li style="-webkit-background-blend-mode: color"></li>
+    <li style="-webkit-background-blend-mode: luminosity"></li>
+  </ul>
+</body>

Added: trunk/LayoutTests/platform/mac/css3/compositing/effect-background-blend-mode-color-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/compositing/effect-background-blend-mode-color-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/compositing/effect-background-blend-mode-color2-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/compositing/effect-background-blend-mode-color2-expected.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (149009 => 149010)


--- trunk/Source/WebCore/ChangeLog	2013-04-24 00:33:19 UTC (rev 149009)
+++ trunk/Source/WebCore/ChangeLog	2013-04-24 00:53:42 UTC (rev 149010)
@@ -1,3 +1,21 @@
+2013-04-23  Mihai Tica  <[email protected]>
+
+        Add platform support for -webkit-background-blend-mode to CG context with background color
+        https://bugs.webkit.org/show_bug.cgi?id=114412
+
+        Reviewed by Darin Adler.
+
+        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):
+
 2013-04-23  Ryosuke Niwa  <[email protected]>
 
         Remove an unused member variable erroneously added in r149007.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (149009 => 149010)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-04-24 00:33:19 UTC (rev 149009)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-04-24 00:53:42 UTC (rev 149010)
@@ -673,23 +673,26 @@
     generator.fill(this, rect);
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
 {
     if (paintingDisabled())
         return;
 
     CompositeOperator previousOperator = compositeOperation();
-    setCompositeOperation(op);
+    setCompositeOperation(op, blendMode);
     fillRect(rect, color, styleColorSpace);
     setCompositeOperation(previousOperator);
 }
 
-void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace)
+void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace, BlendMode blendMode)
 {
-    if (rect.isRounded())
+
+    if (rect.isRounded()) {
+        setCompositeOperation(compositeOperation(), blendMode);
         fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
-    else
-        fillRect(rect.rect(), color, colorSpace);
+        setCompositeOperation(compositeOperation());
+    } else
+        fillRect(rect.rect(), color, colorSpace, compositeOperation(), blendMode);
 }
 
 #if !USE(CG) && !PLATFORM(QT)

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (149009 => 149010)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2013-04-24 00:33:19 UTC (rev 149009)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2013-04-24 00:53:42 UTC (rev 149010)
@@ -301,9 +301,9 @@
         void fillRect(const FloatRect&);
         void fillRect(const FloatRect&, const Color&, ColorSpace);
         void fillRect(const FloatRect&, Generator&);
-        void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator);
+        void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
         void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
-        void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace);
+        void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
         void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleRect, const Color&, ColorSpace);
 
         void clearRect(const FloatRect&);

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (149009 => 149010)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-04-24 00:33:19 UTC (rev 149009)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-04-24 00:53:42 UTC (rev 149010)
@@ -787,16 +787,16 @@
         if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) {
             RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge);
             if (border.isRenderable())
-                context->fillRoundedRect(border, bgColor, style()->colorSpace());
+                context->fillRoundedRect(border, bgColor, style()->colorSpace(), bgLayer->blendMode());
             else {
                 context->save();
                 clipRoundedInnerRect(context, rect, border);
-                context->fillRect(border.rect(), bgColor, style()->colorSpace());
+                context->fillRect(border.rect(), bgColor, style()->colorSpace(), context->compositeOperation(), bgLayer->blendMode());
                 context->restore();
             }
         } else
-            context->fillRect(pixelSnappedIntRect(rect), bgColor, style()->colorSpace());
-        
+            context->fillRect(pixelSnappedIntRect(rect), bgColor, style()->colorSpace(), context->compositeOperation(), bgLayer->blendMode());
+
         return;
     }
 
@@ -940,10 +940,10 @@
                 if (bgColor.alpha())
                     baseColor = baseColor.blend(bgColor);
 
-                context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
+                context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy, bgLayer->blendMode());
             } else if (bgColor.alpha()) {
                 CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
-                context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
+                context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation, bgLayer->blendMode());
             } else if (shouldClearBackground)
                 context->clearRect(backgroundRect);
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to