2011-01-30 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Ariya Hidayat.

        Enhance ShadowBlur to render inset box shadows; Part 1.
        https://bugs.webkit.org/show_bug.cgi?id=51567

        Add a new method to GraphicsContext to render a rect with a rounded hole,
        for use by inset box-shadow code. Knowledge that we're rendering a rounded
        hole will enable ShadowBlur to be used here in future.

        * platform/graphics/GraphicsContext.cpp:
        (WebCore::GraphicsContext::fillRectWithRoundedHole):
        * platform/graphics/GraphicsContext.h:
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::paintBoxShadow):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77106 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2d33a85b
2011-01-30 Simon Fraser <simon.fraser@apple.com>
Reviewed by Ariya Hidayat.
Enhance ShadowBlur to render inset box shadows; Part 1.
https://bugs.webkit.org/show_bug.cgi?id=51567
Add a new method to GraphicsContext to render a rect with a rounded hole,
for use by inset box-shadow code. Knowledge that we're rendering a rounded
hole will enable ShadowBlur to be used here in future.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::fillRectWithRoundedHole):
* platform/graphics/GraphicsContext.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBoxShadow):
2011-01-23 MORITA Hajime <morrita@google.com>
Reviewed by Eric Seidel.
......@@ -610,6 +610,32 @@ void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& c
fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
}
void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedIntRect& roundedHoleRect, const Color& color, ColorSpace colorSpace)
{
if (paintingDisabled())
return;
Path path;
path.addRect(rect);
if (!roundedHoleRect.radii().isZero())
path.addRoundedRect(roundedHoleRect.rect(), roundedHoleRect.radii().topLeft(), roundedHoleRect.radii().topRight(), roundedHoleRect.radii().bottomLeft(), roundedHoleRect.radii().bottomRight());
else
path.addRect(roundedHoleRect.rect());
WindRule oldFillRule = fillRule();
Color oldFillColor = fillColor();
ColorSpace oldFillColorSpace = fillColorSpace();
setFillRule(RULE_EVENODD);
setFillColor(color, colorSpace);
fillPath(path);
setFillRule(oldFillRule);
setFillColor(oldFillColor, oldFillColorSpace);
}
void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation)
{
m_state.compositeOperator = compositeOperation;
......
......@@ -293,6 +293,7 @@ namespace WebCore {
void fillRect(const FloatRect&, Generator&);
void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
void fillRectWithRoundedHole(const IntRect&, const RoundedIntRect& roundedHoleRect, const Color&, ColorSpace);
void clearRect(const FloatRect&);
......
......@@ -1707,9 +1707,9 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
Path path;
if (hasBorderRadius) {
Path path;
path.addRoundedRect(border.rect(), border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight());
context->clip(path);
path.clear();
} else
context->clip(border.rect());
......@@ -1717,24 +1717,16 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
context->translate(extraOffset.width(), extraOffset.height());
shadowOffset -= extraOffset;
path.addRect(outerRect);
if (hasBorderRadius) {
if (shadowSpread > 0)
border.shrinkRadii(shadowSpread);
path.addRoundedRect(holeRect, border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight());
} else
path.addRect(holeRect);
context->setFillRule(RULE_EVENODD);
context->setFillColor(fillColor, s->colorSpace());
if (hasBorderRadius && shadowSpread > 0)
border.shrinkRadii(shadowSpread);
if (shadow->isWebkitBoxShadow())
context->setLegacyShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
else
context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
context->fillPath(path);
RoundedIntRect roundedHole(holeRect, border.radii());
context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace());
context->restore();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment