2011-01-30 Simon Fraser <simon.fraser@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
parent d395a38d
2011-01-30 Simon Fraser <simon.fraser@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@apple.com>
Reviewed by Dan Bernstein.
......@@ -4,11 +4,11 @@
<style type="text/css" media="screen">
.wrapper {
outline: 1px solid silver;
width: 300px;
height: 300px;
width: 280px;
height: 280px;
-webkit-box-sizing: border-box;
padding: 100px;
margin: 20px;
padding: 90px;
margin: 4px;
display: inline-block;
}
......@@ -28,7 +28,7 @@
</head>
<body>
<p>The extent of the shadow should approximately match the pale green boxes.</p>
<!-- 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>
......@@ -38,6 +38,7 @@
<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>
......@@ -45,8 +46,8 @@
</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 class="indicator box" style="outline-width: 90px"></div>
<div class="box" style="box-shadow: 0 0 90px black"></div>
</div>
</body>
......
<!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>
23ba60c65cf48e0e012e476b94b38317
\ No newline at end of file
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
9f46077840f2deeaaedcdab100aa4111
\ No newline at end of file
a02bddc40047df063cd94e3fdb056947
\ No newline at end of file
5f1790bd3fcdc71480b77004f2d447db
\ No newline at end of file
d37116ba08bde4654f9f6fd5d2875e89
\ No newline at end of file
f9f719f2c8fdd561074ab854ebd1cf76
\ No newline at end of file
34ad81d5148350aeaa78c6d7df8b364a
\ No newline at end of file
5b06904ddcbf5693596efe7e04da8a2b
\ No newline at end of file
7359066b6905fc19895deb90eaea750e
\ No newline at end of file
c13c803bbc81cc5d5c0698cae4d1150b
\ No newline at end of file
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
e3e66b612e728e6ffcf252e4a5820098
\ No newline at end of file
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
63f40b74de385bdc2412ee687bf1464f
\ No newline at end of file
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
76c6e041c849e3a746babf586b924f8e
\ No newline at end of file
97eea6389112a0a5017a5414ce64e2bb
\ No newline at end of file
0c496b7b8a3fd1a6e4c0de9f84462194
\ No newline at end of file
695b3c8ded16f5c7fa7b1e05591e9e9c
\ No newline at end of file
5bef70ebbf27224182d3ced6840a51d3
\ No newline at end of file
b11a95e290a528cbc9bdef444d14a7c4
\ No newline at end of file
5bef70ebbf27224182d3ced6840a51d3
\ No newline at end of file
b11a95e290a528cbc9bdef444d14a7c4
\ No newline at end of file
0d68e506d6e464a086fdbfdd5a9d7eea
\ No newline at end of file
981d7ca2da1322ce6da7a4f8c811f27a
\ No newline at end of file
0d68e506d6e464a086fdbfdd5a9d7eea
\ No newline at end of file
981d7ca2da1322ce6da7a4f8c811f27a
\ No newline at end of file
2a37b65c230bcb71bb1ecfb4c884942d
\ No newline at end of file
a0e5ee11bcb74515d7f3014db0cc6910
\ No newline at end of file
65d65ba9cd1b25005fb0d8f248a4b8ff
\ No newline at end of file
77b385e496342af6033ce4655eba3762
\ No newline at end of file
2011-01-30 Simon Fraser <simon.fraser@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@apple.com>
Try to fix Qt build (again).
......@@ -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)
......
......@@ -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();
......
......@@ -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();
......
......@@ -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);