[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
simon.fraser at apple.com
simon.fraser at apple.com
Mon Feb 21 00:24:30 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit 9d92cc2a236f8a7ce841a21b45198d29efd7636f
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 31 03:36:03 2011 +0000
2011-01-30 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
-webkit-box-shadow causes awful scroll/resize/redraw performance
https://bugs.webkit.org/show_bug.cgi?id=22102
Use ShadowBlur for CG, whe rendering shadows on rects and
rounded rects outside of canvas.
CG shadows with a radius of more than 8px do not render
correctly. We preserve this incorrect rendering by compensating
for it when rending -webkit-box-shadow. Calls that should use
this deprecated radius behavior now use setLegacyShadow().
Test: fast/box-shadow/box-shadow-transformed.html
* html/canvas/CanvasRenderingContext2D.cpp: Use setLegacyShadow()
for canvas, to indicate that it should use the deprecated radius
behavior.
(WebCore::CanvasRenderingContext2D::setAllAttributesToDefault): Ditto.
(WebCore::CanvasRenderingContext2D::setShadow): Ditto.
(WebCore::CanvasRenderingContext2D::applyShadow): Ditto.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::setLegacyShadow): Set the m_state.shadowsUseLegacyRadius bit.
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContextState::GraphicsContextState): Add a
shadowsUseLegacyRadius bit to the state.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::radiusToLegacyRadius): Map from the actual radius to one
that approximates CG behavior.
(WebCore::hasBlurredShadow): Helper that returns true if we have a shadow
with a non-zero blur radius.
(WebCore::GraphicsContext::fillRect): Use ShadowBlur if not canvas.
(WebCore::GraphicsContext::fillRoundedRect): Ditto.
(WebCore::GraphicsContext::setPlatformShadow): Comment.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBoxShadow): Call setLegacyShadow()
for -webkit-box-shadow.
* platform/graphics/ShadowBlur.cpp:
(WebCore::ShadowBlur::calculateLayerBoundingRect): Fix some pixel crack issues
by rounding up the blur radius.
(WebCore::ShadowBlur::drawRectShadow): Ditto
(WebCore::ShadowBlur::drawRectShadowWithTiling): Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77101 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a824f6b..7621fb0 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,51 @@
+2011-01-30 Simon Fraser <simon.fraser at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ -webkit-box-shadow causes awful scroll/resize/redraw performance
+ https://bugs.webkit.org/show_bug.cgi?id=22102
+
+ Update pixel results for slightly different shadow rendering, and change
+ in appearane of shadows on transformed elements.
+
+ * fast/box-shadow/box-shadow-transformed.html: Added.
+ * platform/gtk/fast/css/box-shadow-expected.checksum: Removed.
+ * platform/gtk/fast/css/box-shadow-expected.png: Removed.
+ * platform/gtk/fast/css/box-shadow-expected.txt: Removed.
+ * platform/mac/compositing/shadows/shadow-drawing-expected.checksum:
+ * platform/mac/compositing/shadows/shadow-drawing-expected.png:
+ * platform/mac/fast/borders/border-image-rotate-transform-expected.checksum:
+ * platform/mac/fast/borders/border-image-rotate-transform-expected.png:
+ * platform/mac/fast/borders/border-radius-split-inline-expected.checksum:
+ * platform/mac/fast/borders/border-radius-split-inline-expected.png:
+ * platform/mac/fast/box-shadow/basic-shadows-expected.checksum:
+ * platform/mac/fast/box-shadow/basic-shadows-expected.png:
+ * platform/mac/fast/box-shadow/box-shadow-radius-expected.checksum: Added.
+ * platform/mac/fast/box-shadow/box-shadow-radius-expected.png: Added.
+ * platform/mac/fast/box-shadow/box-shadow-radius-expected.txt: Added.
+ * platform/mac/fast/box-shadow/box-shadow-transformed-expected.checksum: Added.
+ * platform/mac/fast/box-shadow/box-shadow-transformed-expected.png: Added.
+ * platform/mac/fast/box-shadow/box-shadow-transformed-expected.txt: Added.
+ * platform/mac/fast/css/box-shadow-expected.checksum: Removed.
+ * platform/mac/fast/css/box-shadow-expected.png: Removed.
+ * platform/mac/fast/css/box-shadow-expected.txt: Removed.
+ * platform/mac/fast/repaint/box-shadow-h-expected.checksum:
+ * platform/mac/fast/repaint/box-shadow-h-expected.png:
+ * platform/mac/fast/repaint/box-shadow-v-expected.checksum:
+ * platform/mac/fast/repaint/box-shadow-v-expected.png:
+ * platform/mac/fast/repaint/shadow-multiple-horizontal-expected.checksum:
+ * platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png:
+ * platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.checksum:
+ * platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png:
+ * platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.checksum:
+ * platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png:
+ * platform/mac/fast/repaint/shadow-multiple-vertical-expected.checksum:
+ * platform/mac/fast/repaint/shadow-multiple-vertical-expected.png:
+ * platform/mac/fast/repaint/transform-replaced-shadows-expected.checksum:
+ * platform/mac/fast/repaint/transform-replaced-shadows-expected.png:
+ * platform/mac/fast/transforms/shadows-expected.checksum:
+ * platform/mac/fast/transforms/shadows-expected.png:
+
2011-01-29 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
diff --git a/LayoutTests/fast/box-shadow/box-shadow-radius.html b/LayoutTests/fast/box-shadow/box-shadow-radius.html
new file mode 100644
index 0000000..a5bc08d
--- /dev/null
+++ b/LayoutTests/fast/box-shadow/box-shadow-radius.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style type="text/css" media="screen">
+ .wrapper {
+ outline: 1px solid silver;
+ width: 280px;
+ height: 280px;
+ -webkit-box-sizing: border-box;
+ padding: 90px;
+ margin: 4px;
+ display: inline-block;
+ }
+
+ .box {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ display: inline-block;
+ }
+
+ .indicator {
+ position: absolute;
+ outline: 0 solid rgba(0, 255, 0, 0.05);
+ }
+
+ </style>
+</head>
+<body>
+
+ <!-- The extent of the shadow should approximately match the pale green boxes. -->
+ <div class="wrapper">
+ <div class="indicator box" style="outline-width: 10px"></div>
+ <div class="box" style="box-shadow: 0 0 10px black"></div>
+ </div>
+
+ <div class="wrapper">
+ <div class="indicator box" style="outline-width: 20px"></div>
+ <div class="box" style="box-shadow: 0 0 20px black"></div>
+ </div>
+ <br>
+
+ <div class="wrapper">
+ <div class="indicator box" style="outline-width: 50px"></div>
+ <div class="box" style="box-shadow: 0 0 50px black"></div>
+ </div>
+
+ <div class="wrapper">
+ <div class="indicator box" style="outline-width: 90px"></div>
+ <div class="box" style="box-shadow: 0 0 90px black"></div>
+ </div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/box-shadow/box-shadow-transformed.html b/LayoutTests/fast/box-shadow/box-shadow-transformed.html
new file mode 100644
index 0000000..77022ac
--- /dev/null
+++ b/LayoutTests/fast/box-shadow/box-shadow-transformed.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style type="text/css" media="screen">
+ .wrapper {
+ width: 300px;
+ height: 300px;
+ -webkit-box-sizing: border-box;
+ padding: 100px;
+ margin: 20px;
+ display: inline-block;
+ }
+
+ .top {
+ height: 150px;
+ padding: 25px 100px;
+ }
+
+
+ .box {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ display: inline-block;
+ }
+
+ </style>
+</head>
+<body>
+
+ <p>The shadow should look identical relative to the box in each case.</p>
+ <div class="top wrapper">
+ <div class="box" style="box-shadow: 0 10px 20px black; -webkit-transform: scale(2, 1)"></div>
+ </div>
+
+ <div class="top wrapper">
+ <div class="box" style="box-shadow: 0 10px 20px black; -webkit-transform: rotate(45deg)"></div>
+ </div>
+
+ <div class="wrapper">
+ <div class="box" style="box-shadow: 0 10px 20px black; -webkit-transform: rotate(45deg) scale(1.7)"></div>
+ </div>
+
+ <div class="wrapper">
+ <div class="box" style="box-shadow: 0 10px 20px black; -webkit-transform: rotate(45deg) scale(0.8)"></div>
+ </div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css/box-shadow.html b/LayoutTests/fast/css/box-shadow.html
deleted file mode 100644
index 50f16cf..0000000
--- a/LayoutTests/fast/css/box-shadow.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <style type="text/css" media="screen">
- .wrapper {
- outline: 1px solid silver;
- width: 300px;
- height: 300px;
- -webkit-box-sizing: border-box;
- padding: 100px;
- margin: 20px;
- display: inline-block;
- }
-
- .box {
- position: relative;
- width: 100px;
- height: 100px;
- display: inline-block;
- }
-
- .indicator {
- position: absolute;
- outline: 0 solid rgba(0, 255, 0, 0.05);
- }
-
- </style>
-</head>
-<body>
-
- <p>The extent of the shadow should approximately match the pale green boxes.</p>
- <div class="wrapper">
- <div class="indicator box" style="outline-width: 10px"></div>
- <div class="box" style="box-shadow: 0 0 10px black"></div>
- </div>
-
- <div class="wrapper">
- <div class="indicator box" style="outline-width: 20px"></div>
- <div class="box" style="box-shadow: 0 0 20px black"></div>
- </div>
-
- <div class="wrapper">
- <div class="indicator box" style="outline-width: 50px"></div>
- <div class="box" style="box-shadow: 0 0 50px black"></div>
- </div>
-
- <div class="wrapper">
- <div class="indicator box" style="outline-width: 100px"></div>
- <div class="box" style="box-shadow: 0 0 100px black"></div>
- </div>
-
-</body>
-</html>
diff --git a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.checksum b/LayoutTests/platform/gtk/fast/css/box-shadow-expected.checksum
deleted file mode 100644
index 364a4da..0000000
--- a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.checksum
+++ /dev/null
@@ -1 +0,0 @@
-23ba60c65cf48e0e012e476b94b38317
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.png b/LayoutTests/platform/gtk/fast/css/box-shadow-expected.png
deleted file mode 100644
index 9392587..0000000
Binary files a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.txt b/LayoutTests/platform/gtk/fast/css/box-shadow-expected.txt
deleted file mode 100644
index 99fea7b..0000000
--- a/LayoutTests/platform/gtk/fast/css/box-shadow-expected.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-layer at (0,0) size 781x739
- RenderView at (0,0) size 781x600
-layer at (0,0) size 781x739
- RenderBlock {HTML} at (0,0) size 781x739
- RenderBody {BODY} at (8,16) size 765x715
- RenderBlock {P} at (0,0) size 765x19
- RenderText {#text} at (0,0) size 479x19
- text run at (0,0) width 479: "The extent of the shadow should approximately match the pale green boxes."
- RenderBlock (anonymous) at (0,35) size 765x680
- RenderBlock {DIV} at (20,20) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (340,205) size 4x19
- text run at (340,205) width 4: " "
- RenderBlock {DIV} at (364,20) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
- RenderBlock {DIV} at (20,360) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (340,545) size 4x19
- text run at (340,545) width 4: " "
- RenderBlock {DIV} at (364,360) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
-layer at (128,171) size 100x100
- RenderBlock (positioned) {DIV} at (128,171) size 100x100
-layer at (128,171) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (472,171) size 100x100
- RenderBlock (positioned) {DIV} at (472,171) size 100x100
-layer at (472,171) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (128,511) size 100x100
- RenderBlock (positioned) {DIV} at (128,511) size 100x100
-layer at (128,511) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (472,511) size 100x100
- RenderBlock (positioned) {DIV} at (472,511) size 100x100
-layer at (472,511) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.checksum b/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.checksum
index 928ef7b..256fbe8 100644
--- a/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.checksum
+++ b/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.checksum
@@ -1 +1 @@
-9f46077840f2deeaaedcdab100aa4111
\ No newline at end of file
+a02bddc40047df063cd94e3fdb056947
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.png b/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.png
index 3a804eb..1ed89b3 100644
Binary files a/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.png and b/LayoutTests/platform/mac/compositing/shadows/shadow-drawing-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.checksum b/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.checksum
index 947a146..ca59504 100644
--- a/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.checksum
+++ b/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.checksum
@@ -1 +1 @@
-5f1790bd3fcdc71480b77004f2d447db
\ No newline at end of file
+d37116ba08bde4654f9f6fd5d2875e89
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.png b/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.png
index acaf7d1..5f7aa9e 100644
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.checksum b/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.checksum
index 4119c37..3630637 100644
--- a/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.checksum
+++ b/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.checksum
@@ -1 +1 @@
-f9f719f2c8fdd561074ab854ebd1cf76
\ No newline at end of file
+34ad81d5148350aeaa78c6d7df8b364a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.png b/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.png
index d2dc9b8..6397be1 100644
Binary files a/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.png and b/LayoutTests/platform/mac/fast/borders/border-radius-split-inline-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.checksum b/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.checksum
index b5b570b..d8e2483 100644
--- a/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.checksum
+++ b/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.checksum
@@ -1 +1 @@
-5b06904ddcbf5693596efe7e04da8a2b
\ No newline at end of file
+7359066b6905fc19895deb90eaea750e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.png b/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.png
index be94c56..4021542 100644
Binary files a/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.png and b/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.checksum b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.checksum
new file mode 100644
index 0000000..ec0f579
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.checksum
@@ -0,0 +1 @@
+c13c803bbc81cc5d5c0698cae4d1150b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.png b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.png
new file mode 100644
index 0000000..ddd65ec
Binary files /dev/null and b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.txt b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.txt
new file mode 100644
index 0000000..ad35278
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-radius-expected.txt
@@ -0,0 +1,37 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x592
+ RenderBlock {HTML} at (0,0) size 800x592
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {DIV} at (4,4) size 280x280
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (288,180) size 4x18
+ text run at (288,180) width 4: " "
+ RenderBlock {DIV} at (296,4) size 280x280
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (580,180) size 4x18
+ text run at (580,180) width 4: " "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderBlock {DIV} at (4,292) size 280x280
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (288,468) size 4x18
+ text run at (288,468) width 4: " "
+ RenderBlock {DIV} at (296,292) size 280x280
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (102,102) size 100x100
+ RenderBlock (positioned) {DIV} at (102,102) size 100x100
+layer at (102,102) size 100x100
+ RenderBlock (relative positioned) {DIV} at (90,90) size 100x100
+layer at (394,102) size 100x100
+ RenderBlock (positioned) {DIV} at (394,102) size 100x100
+layer at (394,102) size 100x100
+ RenderBlock (relative positioned) {DIV} at (90,90) size 100x100
+layer at (102,390) size 100x100
+ RenderBlock (positioned) {DIV} at (102,390) size 100x100
+layer at (102,390) size 100x100
+ RenderBlock (relative positioned) {DIV} at (90,90) size 100x100
+layer at (394,390) size 100x100
+ RenderBlock (positioned) {DIV} at (394,390) size 100x100
+layer at (394,390) size 100x100
+ RenderBlock (relative positioned) {DIV} at (90,90) size 100x100
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.checksum b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.checksum
new file mode 100644
index 0000000..bd5e884
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.checksum
@@ -0,0 +1 @@
+e3e66b612e728e6ffcf252e4a5820098
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png
new file mode 100644
index 0000000..e55f3d1
Binary files /dev/null and b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.txt b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.txt
new file mode 100644
index 0000000..6e57fb7
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.txt
@@ -0,0 +1,31 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x588
+ RenderBlock {HTML} at (0,0) size 800x588
+ RenderBody {BODY} at (8,16) size 784x564
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 414x18
+ text run at (0,0) width 414: "The shadow should look identical relative to the box in each case."
+ RenderBlock (anonymous) at (0,34) size 784x530
+ RenderBlock {DIV} at (20,20) size 300x150
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (340,131) size 4x18
+ text run at (340,131) width 4: " "
+ RenderBlock {DIV} at (364,20) size 300x150
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+ RenderBlock {DIV} at (20,210) size 300x300
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (340,396) size 4x18
+ text run at (340,396) width 4: " "
+ RenderBlock {DIV} at (364,210) size 300x300
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (128,95) size 100x100
+ RenderBlock (relative positioned) {DIV} at (100,25) size 100x100
+layer at (472,95) size 100x100
+ RenderBlock (relative positioned) {DIV} at (100,25) size 100x100
+layer at (128,360) size 100x100
+ RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
+layer at (472,360) size 100x100
+ RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/fast/css/box-shadow-expected.checksum b/LayoutTests/platform/mac/fast/css/box-shadow-expected.checksum
deleted file mode 100644
index b07e4b9..0000000
--- a/LayoutTests/platform/mac/fast/css/box-shadow-expected.checksum
+++ /dev/null
@@ -1 +0,0 @@
-63f40b74de385bdc2412ee687bf1464f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/box-shadow-expected.png b/LayoutTests/platform/mac/fast/css/box-shadow-expected.png
deleted file mode 100644
index f951cbb..0000000
Binary files a/LayoutTests/platform/mac/fast/css/box-shadow-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/mac/fast/css/box-shadow-expected.txt b/LayoutTests/platform/mac/fast/css/box-shadow-expected.txt
deleted file mode 100644
index 250b267..0000000
--- a/LayoutTests/platform/mac/fast/css/box-shadow-expected.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-layer at (0,0) size 785x738
- RenderView at (0,0) size 785x600
-layer at (0,0) size 785x738
- RenderBlock {HTML} at (0,0) size 785x738
- RenderBody {BODY} at (8,16) size 769x714
- RenderBlock {P} at (0,0) size 769x18
- RenderText {#text} at (0,0) size 479x18
- text run at (0,0) width 479: "The extent of the shadow should approximately match the pale green boxes."
- RenderBlock (anonymous) at (0,34) size 769x680
- RenderBlock {DIV} at (20,20) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (340,206) size 4x18
- text run at (340,206) width 4: " "
- RenderBlock {DIV} at (364,20) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
- RenderBlock {DIV} at (20,360) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (340,546) size 4x18
- text run at (340,546) width 4: " "
- RenderBlock {DIV} at (364,360) size 300x300
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
-layer at (128,170) size 100x100
- RenderBlock (positioned) {DIV} at (128,170) size 100x100
-layer at (128,170) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (472,170) size 100x100
- RenderBlock (positioned) {DIV} at (472,170) size 100x100
-layer at (472,170) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (128,510) size 100x100
- RenderBlock (positioned) {DIV} at (128,510) size 100x100
-layer at (128,510) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
-layer at (472,510) size 100x100
- RenderBlock (positioned) {DIV} at (472,510) size 100x100
-layer at (472,510) size 100x100
- RenderBlock (relative positioned) {DIV} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.checksum b/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.checksum
index bf3160c..1359abe 100644
--- a/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.checksum
@@ -1 +1 @@
-76c6e041c849e3a746babf586b924f8e
\ No newline at end of file
+97eea6389112a0a5017a5414ce64e2bb
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.png b/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.png
index fdab1c1..db3f7be 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.png and b/LayoutTests/platform/mac/fast/repaint/box-shadow-h-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.checksum b/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.checksum
index a3d8b17..dbbb48f 100644
--- a/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.checksum
@@ -1 +1 @@
-0c496b7b8a3fd1a6e4c0de9f84462194
\ No newline at end of file
+695b3c8ded16f5c7fa7b1e05591e9e9c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.png b/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.png
index 4fd0693..d4223aa 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.png and b/LayoutTests/platform/mac/fast/repaint/box-shadow-v-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.checksum b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.checksum
index fa2a570..b2b0887 100644
--- a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.checksum
@@ -1 +1 @@
-5bef70ebbf27224182d3ced6840a51d3
\ No newline at end of file
+b11a95e290a528cbc9bdef444d14a7c4
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png
index 7c85eff..0d3cc4d 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png and b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.checksum b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.checksum
index fa2a570..b2b0887 100644
--- a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.checksum
@@ -1 +1 @@
-5bef70ebbf27224182d3ced6840a51d3
\ No newline at end of file
+b11a95e290a528cbc9bdef444d14a7c4
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png
index 7c85eff..0d3cc4d 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png and b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.checksum b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.checksum
index 5249657..e09a51f 100644
--- a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.checksum
@@ -1 +1 @@
-0d68e506d6e464a086fdbfdd5a9d7eea
\ No newline at end of file
+981d7ca2da1322ce6da7a4f8c811f27a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png
index 1ddf551..34477a2 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png and b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.checksum b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.checksum
index 5249657..e09a51f 100644
--- a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.checksum
@@ -1 +1 @@
-0d68e506d6e464a086fdbfdd5a9d7eea
\ No newline at end of file
+981d7ca2da1322ce6da7a4f8c811f27a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.png b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.png
index 1ddf551..34477a2 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.png and b/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.checksum b/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.checksum
index ea058e0..b4d79f2 100644
--- a/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.checksum
+++ b/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.checksum
@@ -1 +1 @@
-2a37b65c230bcb71bb1ecfb4c884942d
\ No newline at end of file
+a0e5ee11bcb74515d7f3014db0cc6910
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.png b/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.png
index 8ed6ad7..0e14438 100644
Binary files a/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.png and b/LayoutTests/platform/mac/fast/repaint/transform-replaced-shadows-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/transforms/shadows-expected.checksum b/LayoutTests/platform/mac/fast/transforms/shadows-expected.checksum
index 54878c3..0c72cb8 100644
--- a/LayoutTests/platform/mac/fast/transforms/shadows-expected.checksum
+++ b/LayoutTests/platform/mac/fast/transforms/shadows-expected.checksum
@@ -1 +1 @@
-65d65ba9cd1b25005fb0d8f248a4b8ff
\ No newline at end of file
+77b385e496342af6033ce4655eba3762
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/transforms/shadows-expected.png b/LayoutTests/platform/mac/fast/transforms/shadows-expected.png
index a7eb99a..63e1d42 100644
Binary files a/LayoutTests/platform/mac/fast/transforms/shadows-expected.png and b/LayoutTests/platform/mac/fast/transforms/shadows-expected.png differ
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index cded821..8404bd9 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,53 @@
+2011-01-30 Simon Fraser <simon.fraser at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ -webkit-box-shadow causes awful scroll/resize/redraw performance
+ https://bugs.webkit.org/show_bug.cgi?id=22102
+
+ Use ShadowBlur for CG, whe rendering shadows on rects and
+ rounded rects outside of canvas.
+
+ CG shadows with a radius of more than 8px do not render
+ correctly. We preserve this incorrect rendering by compensating
+ for it when rending -webkit-box-shadow. Calls that should use
+ this deprecated radius behavior now use setLegacyShadow().
+
+ Test: fast/box-shadow/box-shadow-transformed.html
+
+ * html/canvas/CanvasRenderingContext2D.cpp: Use setLegacyShadow()
+ for canvas, to indicate that it should use the deprecated radius
+ behavior.
+ (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault): Ditto.
+ (WebCore::CanvasRenderingContext2D::setShadow): Ditto.
+ (WebCore::CanvasRenderingContext2D::applyShadow): Ditto.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::setLegacyShadow): Set the m_state.shadowsUseLegacyRadius bit.
+
+ * platform/graphics/GraphicsContext.h:
+ (WebCore::GraphicsContextState::GraphicsContextState): Add a
+ shadowsUseLegacyRadius bit to the state.
+
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::radiusToLegacyRadius): Map from the actual radius to one
+ that approximates CG behavior.
+ (WebCore::hasBlurredShadow): Helper that returns true if we have a shadow
+ with a non-zero blur radius.
+ (WebCore::GraphicsContext::fillRect): Use ShadowBlur if not canvas.
+ (WebCore::GraphicsContext::fillRoundedRect): Ditto.
+ (WebCore::GraphicsContext::setPlatformShadow): Comment.
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintBoxShadow): Call setLegacyShadow()
+ for -webkit-box-shadow.
+
+ * platform/graphics/ShadowBlur.cpp:
+ (WebCore::ShadowBlur::calculateLayerBoundingRect): Fix some pixel crack issues
+ by rounding up the blur radius.
+ (WebCore::ShadowBlur::drawRectShadow): Ditto
+ (WebCore::ShadowBlur::drawRectShadowWithTiling): Ditto.
+
2011-01-30 Oliver Hunt <oliver at apple.com>
Try to fix Qt build (again).
diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index e5bf352..3078d08 100644
--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -234,7 +234,7 @@ void CanvasRenderingContext2D::setAllAttributesToDefault()
if (!context)
return;
- context->setShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
+ context->setLegacyShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
context->setAlpha(1);
context->setCompositeOperation(CompositeSourceOver);
}
@@ -1000,7 +1000,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
if (!c)
return;
- c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
}
void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, float alpha)
@@ -1018,7 +1018,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
if (!c)
return;
- c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
}
void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel, float alpha)
@@ -1031,7 +1031,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
if (!c)
return;
- c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
}
void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float r, float g, float b, float a)
@@ -1044,7 +1044,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
if (!c)
return;
- c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
}
void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float c, float m, float y, float k, float a)
@@ -1064,7 +1064,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
CGContextSetShadowWithColor(dc->platformContext(), adjustedShadowSize(width, -height), blur, shadowColor);
CGColorRelease(shadowColor);
#else
- dc->setShadow(IntSize(width, -height), blur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ dc->setLegacyShadow(FloatSize(width, -height), blur, state().m_shadowColor, ColorSpaceDeviceRGB);
#endif
}
@@ -1084,7 +1084,7 @@ void CanvasRenderingContext2D::applyShadow()
float width = state().m_shadowOffset.width();
float height = state().m_shadowOffset.height();
- c->setShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+ c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
}
static IntSize size(HTMLImageElement* image)
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp
index 5b00e25..400cba0 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp
@@ -142,6 +142,18 @@ void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
setPlatformShadow(offset, blur, color, colorSpace);
}
+void GraphicsContext::setLegacyShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace)
+{
+ m_state.shadowOffset = offset;
+ m_state.shadowBlur = blur;
+ m_state.shadowColor = color;
+ m_state.shadowColorSpace = colorSpace;
+#if PLATFORM(CG)
+ m_state.shadowsUseLegacyRadius = true;
+#endif
+ setPlatformShadow(offset, blur, color, colorSpace);
+}
+
void GraphicsContext::clearShadow()
{
m_state.shadowOffset = FloatSize();
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
index c018d67..47d1aa3 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext.h
@@ -168,6 +168,11 @@ namespace WebCore {
, shouldSmoothFonts(true)
, paintingDisabled(false)
, shadowsIgnoreTransforms(false)
+#if PLATFORM(CG)
+ // Core Graphics incorrectly renders shadows with radius > 8px (<rdar://problem/8103442>),
+ // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
+ , shadowsUseLegacyRadius(false)
+#endif
{
}
@@ -204,6 +209,9 @@ namespace WebCore {
bool shouldSmoothFonts : 1;
bool paintingDisabled : 1;
bool shadowsIgnoreTransforms : 1;
+#if PLATFORM(CG)
+ bool shadowsUseLegacyRadius : 1;
+#endif
};
class GraphicsContext {
@@ -352,6 +360,10 @@ namespace WebCore {
bool hasShadow() const;
void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
+ // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
+ // It has different treatment of radii > 8px.
+ void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
+
bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
void clearShadow();
diff --git a/Source/WebCore/platform/graphics/ShadowBlur.cpp b/Source/WebCore/platform/graphics/ShadowBlur.cpp
index 238d774..c6033d9 100644
--- a/Source/WebCore/platform/graphics/ShadowBlur.cpp
+++ b/Source/WebCore/platform/graphics/ShadowBlur.cpp
@@ -256,6 +256,8 @@ void ShadowBlur::adjustBlurDistance(GraphicsContext* context)
IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const FloatRect& shadowedRect, const IntRect& clipRect)
{
+ const float roundedRadius = ceilf(m_blurRadius);
+
// Calculate the destination of the blurred and/or transformed layer.
FloatRect layerFloatRect;
float inflation = 0;
@@ -272,8 +274,8 @@ IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const F
// We expand the area by the blur radius to give extra space for the blur transition.
if (m_type == BlurShadow) {
- layerFloatRect.inflate(m_blurRadius);
- inflation += m_blurRadius;
+ layerFloatRect.inflate(roundedRadius);
+ inflation += roundedRadius;
}
FloatRect unclippedLayerRect = layerFloatRect;
@@ -287,13 +289,13 @@ IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const F
// Pixels at the edges can be affected by pixels outside the buffer,
// so intersect with the clip inflated by the blur.
if (m_type == BlurShadow)
- inflatedClip.inflate(m_blurRadius);
+ inflatedClip.inflate(roundedRadius);
layerFloatRect.intersect(inflatedClip);
}
const int frameSize = inflation * 2;
- m_sourceRect = IntRect(0, 0, shadowedRect.width() + frameSize, shadowedRect.height() + frameSize);
+ m_sourceRect = FloatRect(0, 0, shadowedRect.width() + frameSize, shadowedRect.height() + frameSize);
m_layerOrigin = FloatPoint(layerFloatRect.x(), layerFloatRect.y());
m_layerSize = layerFloatRect.size();
@@ -370,8 +372,10 @@ void ShadowBlur::drawRectShadow(GraphicsContext* graphicsContext, const FloatRec
return;
}
- int templateSideLength = 1;
- float twiceRadius = m_blurRadius * 2;
+ const float roundedRadius = ceilf(m_blurRadius);
+ const float twiceRadius = roundedRadius * 2;
+
+ const int templateSideLength = 1;
// Find the extra space needed from the curve of the corners.
int extraWidthFromCornerRadii = twiceRadius + max(radii.topLeft().width(), radii.bottomLeft().width()) + twiceRadius + max(radii.topRight().width(), radii.bottomRight().width());
@@ -388,7 +392,7 @@ void ShadowBlur::drawRectShadow(GraphicsContext* graphicsContext, const FloatRec
// Determine dimensions of shadow rect.
FloatRect shadowRect = shadowedRect;
- shadowRect.inflate(m_blurRadius); // FIXME: duplicating code with calculateLayerBoundingRect.
+ shadowRect.inflate(roundedRadius); // FIXME: duplicating code with calculateLayerBoundingRect.
// Reduce the size of what we have to draw with the clip area.
calculateLayerBoundingRect(graphicsContext, shadowedRect, graphicsContext->clipBounds());
@@ -453,13 +457,14 @@ void ShadowBlur::drawRectShadowWithoutTiling(GraphicsContext* graphicsContext, c
void ShadowBlur::drawRectShadowWithTiling(GraphicsContext* graphicsContext, const FloatRect& shadowedRect, const RoundedIntRect::Radii& radii, float alpha, const IntSize& shadowTemplateSize)
{
- float twiceRadius = m_blurRadius * 2;
+ const float roundedRadius = ceilf(m_blurRadius);
+ const float twiceRadius = roundedRadius * 2;
// Size of the tiling side.
- int templateSideLength = 1;
+ const int templateSideLength = 1;
FloatRect shadowRect = shadowedRect;
- shadowRect.inflate(m_blurRadius); // FIXME: duplicating code with calculateLayerBoundingRect.
+ shadowRect.inflate(roundedRadius); // FIXME: duplicating code with calculateLayerBoundingRect.
shadowRect.move(m_offset.width(), m_offset.height());
@@ -472,7 +477,7 @@ void ShadowBlur::drawRectShadowWithTiling(GraphicsContext* graphicsContext, cons
shadowContext->clearRect(FloatRect(0, 0, shadowTemplateSize.width(), shadowTemplateSize.height()));
// Draw the rectangle.
- IntRect templateRect = IntRect(m_blurRadius, m_blurRadius, shadowTemplateSize.width() - twiceRadius, shadowTemplateSize.height() - twiceRadius);
+ FloatRect templateRect = FloatRect(roundedRadius, roundedRadius, shadowTemplateSize.width() - twiceRadius, shadowTemplateSize.height() - twiceRadius);
Path path;
path.addRoundedRect(templateRect, radii.topLeft(), radii.topRight(), radii.bottomLeft(), radii.bottomRight());
@@ -516,28 +521,28 @@ void ShadowBlur::drawRectShadowWithTiling(GraphicsContext* graphicsContext, cons
FloatRect tileRect = FloatRect(twiceRadius + radii.topLeft().width(), 0, templateSideLength, twiceRadius);
FloatRect destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y());
- destRect.setWidth(shadowRect.width() - radii.topLeft().width() - radii.topRight().width() - m_blurRadius * 4);
+ destRect.setWidth(shadowRect.width() - radii.topLeft().width() - radii.topRight().width() - roundedRadius * 4);
graphicsContext->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, destRect, tileRect);
// Draw the bottom side.
tileRect = FloatRect(twiceRadius + radii.bottomLeft().width(), shadowTemplateSize.height() - twiceRadius, templateSideLength, twiceRadius);
destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y() + twiceRadius + shadowedRect.height() - shadowTemplateSize.height());
- destRect.setWidth(shadowRect.width() - radii.bottomLeft().width() - radii.bottomRight().width() - m_blurRadius * 4);
+ destRect.setWidth(shadowRect.width() - radii.bottomLeft().width() - radii.bottomRight().width() - roundedRadius * 4);
graphicsContext->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, destRect, tileRect);
// Draw the right side.
tileRect = FloatRect(shadowTemplateSize.width() - twiceRadius, twiceRadius + radii.topRight().height(), twiceRadius, templateSideLength);
destRect = tileRect;
destRect.move(shadowRect.x() + twiceRadius + shadowedRect.width() - shadowTemplateSize.width(), shadowRect.y());
- destRect.setHeight(shadowRect.height() - radii.topRight().height() - radii.bottomRight().height() - m_blurRadius * 4);
+ destRect.setHeight(shadowRect.height() - radii.topRight().height() - radii.bottomRight().height() - roundedRadius * 4);
graphicsContext->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, destRect, tileRect);
// Draw the left side.
tileRect = FloatRect(0, twiceRadius + radii.topLeft().height(), twiceRadius, templateSideLength);
destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y());
- destRect.setHeight(shadowRect.height() - radii.topLeft().height() - radii.bottomLeft().height() - m_blurRadius * 4);
+ destRect.setHeight(shadowRect.height() - radii.topLeft().height() - radii.bottomLeft().height() - roundedRadius * 4);
graphicsContext->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, destRect, tileRect);
// Draw the top left corner.
diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index 60356b6..cbf467d 100644
--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -35,6 +35,7 @@
#include "KURL.h"
#include "Path.h"
#include "Pattern.h"
+#include "ShadowBlur.h"
#include <CoreGraphics/CoreGraphics.h>
#include <wtf/MathExtras.h>
@@ -616,6 +617,16 @@ void GraphicsContext::strokePath(const Path& path)
CGContextStrokePath(context);
}
+static float radiusToLegacyRadius(float radius)
+{
+ return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
+}
+
+static bool hasBlurredShadow(const GraphicsContextState& state)
+{
+ return state.shadowColor.isValid() && state.shadowColor.alpha() && state.shadowBlur;
+}
+
void GraphicsContext::fillRect(const FloatRect& rect)
{
if (paintingDisabled())
@@ -648,7 +659,22 @@ void GraphicsContext::fillRect(const FloatRect& rect)
if (m_state.fillPattern)
applyFillPattern();
+
+ bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ if (drawOwnShadow) {
+ float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
+ // Turn off CG shadows.
+ CGContextSaveGState(context);
+ CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
+
+ ShadowBlur contextShadow(shadowBlur, m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ contextShadow.drawRectShadow(this, rect, RoundedIntRect::Radii());
+ }
+
CGContextFillRect(context, rect);
+
+ if (drawOwnShadow)
+ CGContextRestoreGState(context);
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
@@ -663,7 +689,21 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
+ bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ if (drawOwnShadow) {
+ float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
+ // Turn off CG shadows.
+ CGContextSaveGState(context);
+ CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
+
+ ShadowBlur contextShadow(shadowBlur, m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ contextShadow.drawRectShadow(this, rect, RoundedIntRect::Radii());
+ }
+
CGContextFillRect(context, rect);
+
+ if (drawOwnShadow)
+ CGContextRestoreGState(context);
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, oldFillColor, oldColorSpace);
@@ -683,8 +723,24 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
Path path;
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
+
+ bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ if (drawOwnShadow) {
+ float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
+
+ // Turn off CG shadows.
+ CGContextSaveGState(context);
+ CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
+
+ ShadowBlur contextShadow(shadowBlur, m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ contextShadow.drawRectShadow(this, rect, RoundedIntRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
+ }
+
fillPath(path);
+ if (drawOwnShadow)
+ CGContextRestoreGState(context);
+
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, oldFillColor, oldColorSpace);
}
@@ -776,6 +832,9 @@ void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, con
{
if (paintingDisabled())
return;
+
+ // FIXME: we could avoid the shadow setup cost when we know we'll render the shadow ourselves.
+
CGFloat xOffset = offset.width();
CGFloat yOffset = offset.height();
CGFloat blurRadius = blur;
diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp
index 40acd03..61fc4ad 100644
--- a/Source/WebCore/rendering/RenderBoxModelObject.cpp
+++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp
@@ -1625,7 +1625,11 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
shadowOffset -= extraOffset;
fillRect.move(extraOffset);
- context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+ if (shadow->isWebkitBoxShadow())
+ context->setLegacyShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+ else
+ context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+
if (hasBorderRadius) {
RoundedIntRect rectToClipOut = border;
@@ -1641,6 +1645,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
if (shadowSpread < 0)
fillRect.expandRadii(shadowSpread);
+
context->fillRoundedRect(fillRect, Color::black, s->colorSpace());
} else {
IntRect rectToClipOut = border.rect();
@@ -1722,7 +1727,12 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
context->setFillRule(RULE_EVENODD);
context->setFillColor(fillColor, s->colorSpace());
- context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+
+ if (shadow->isWebkitBoxShadow())
+ context->setLegacyShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+ else
+ context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
+
context->fillPath(path);
context->restore();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list