Bug 68899 - [CG] Both ShadowBlur and CG Shadow are applied to the rect in GraphicsContext::fillRect()
Summary: [CG] Both ShadowBlur and CG Shadow are applied to the rect in GraphicsContext...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-27 06:41 PDT by Renata Hodovan
Modified: 2022-07-15 14:58 PDT (History)
8 users (show)

See Also:


Attachments
with_contextShadow.png (7.63 KB, image/png)
2011-09-27 06:41 PDT, Renata Hodovan
no flags Details
without_contextShadow.png (5.60 KB, image/png)
2011-09-27 06:42 PDT, Renata Hodovan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Renata Hodovan 2011-09-27 06:41:02 PDT
Original code:

    bool drawOwnShadow = !isAcceleratedContext() && 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(context, CGSizeZero, 0, 0);

        ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
        contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
    }

    CGContextFillRect(context, rect);


After some debugging it seems that the shadow applied twice both with ShadowBlur and CGShadow.
We halved the rectangle to emphasize this effect:

    // Was CGContextFillRect(context, rect);
    FloatRect tmp2 = FloatRect(rect.x() + rect.width() / 4, rect.y() + rect.height() / 4, rect.width() / 2, rect.height() / 2);
    CGContextFillRect(context, tmp2);

We attached two pics. In without_contextShadow.png the drawRectShadow was commented out while it was enabled on with_contextShadow.png.
The strange thing was the shadow is still drawn when the drawRectShadow was commented out.
Any idea?
Comment 1 Renata Hodovan 2011-09-27 06:41:48 PDT
Created attachment 108840 [details]
with_contextShadow.png
Comment 2 Renata Hodovan 2011-09-27 06:42:32 PDT
Created attachment 108841 [details]
without_contextShadow.png
Comment 3 Tim Horton 2011-09-27 15:33:25 PDT
I'm a bit confused. Where's the testcase; how can I reproduce this? Or is this in code you're currently working on?

Anyway, how are you applying the shadow? -webkit-svg-shadow? If it's -webkit-svg-shadow, that gets applied via a transparency layer that gets created (in SVGRenderSupport::prepareToRenderSVGContent) whenever you first hit the -webkit-svg-shadow'd element, so each element has no need to draw its own shadow.
Comment 4 Renata Hodovan 2011-09-29 07:16:52 PDT
(In reply to comment #3)
> I'm a bit confused. Where's the testcase; how can I reproduce this? Or is this in code you're currently working on?

> Anyway, how are you applying the shadow? -webkit-svg-shadow? If it's -webkit-svg-shadow, that gets applied via a transparency layer that gets created (in SVGRenderSupport::prepareToRenderSVGContent) whenever you first hit the -webkit-svg-shadow'd element, so each element has no need to draw its own shadow.

The test case was a reduced version of svg/css/group-with-shadow.svg. It uses -webkit-svg-shadow property. I faced this problem while I was working on a new renderer for SVGElements which painted with the shape's own painter without path's one. So if I tried to fill a rectangle with the platform dependent fillRect() it applied both of the shadows.
Comment 5 Simon Fraser (smfr) 2011-09-30 10:25:30 PDT
Why is SVG different from CSS here? CSS doesn't have this issue.
Comment 6 Renata Hodovan 2011-09-30 11:03:09 PDT
(In reply to comment #5)
> Why is SVG different from CSS here? CSS doesn't have this issue.

I don't know exactly the reason but it seems that doesn't matter if I turn out the shadow drawing it still will be painted. I guess it maybe related to context redirections...
Comment 7 Dirk Schulze 2014-05-12 06:42:09 PDT
rene, could you upload a test case please? Is this still the case?
Comment 8 Simon Fraser (smfr) 2015-12-04 21:24:48 PST
Still need a testcase.
Comment 9 Brent Fulgham 2022-07-15 14:58:40 PDT
It's difficult to confirm this bug without a test case. We don't believe there is an ongoing issue here. If you do feel there is a problem, please REOPEN this bug and include a test case illustrating the issue.