RESOLVED FIXED 46918
ContextShadow should not use the blur radius as kernel size of the box blurs
https://bugs.webkit.org/show_bug.cgi?id=46918
Summary ContextShadow should not use the blur radius as kernel size of the box blurs
Alejandro G. Castro
Reported 2010-09-30 10:29:07 PDT
Currently we are using the blur radius in ContextShadow directly as the kernel size when blurring, this is causing a bigger blurring effect than expected. We should calculate the kernel size required to get a blur effect which size is like the blur radius. We were using before 2/3 of the blur radius, because we are adding kernel_size/2 pixels with each box blur, therefore with 3 box blurs we get 3*kernel_size/2 more pixels, which should be the blur radius. Firefox is applying a similar solution.
Attachments
Proposed patch (3.18 KB, patch)
2010-09-30 10:33 PDT, Alejandro G. Castro
no flags
Proposed patch (3.92 KB, patch)
2010-10-01 04:43 PDT, Alejandro G. Castro
no flags
Proposed patch (4.77 KB, patch)
2010-10-04 04:34 PDT, Alejandro G. Castro
no flags
Proposed patch (4.77 KB, patch)
2010-10-04 04:49 PDT, Alejandro G. Castro
krit: review-
Proposed patch (9.65 KB, patch)
2010-10-06 08:11 PDT, Alejandro G. Castro
krit: review+
Alejandro G. Castro
Comment 1 2010-09-30 10:33:45 PDT
Created attachment 69347 [details] Proposed patch This is an option without supporting fractional kernel sizes which would be probably the one with the best results, mostly for the small radii. It is basically what we are currently doing in FEGaussianBlur.
Martin Robinson
Comment 2 2010-09-30 10:45:18 PDT
Comment on attachment 69347 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=69347&action=review > WebCore/platform/graphics/ContextShadow.cpp:158 > + // We expand the area by the blur radius to give extra space for the blur transition. > + m_layerRect.inflate((m_type == BlurShadow) ? ceil(m_blurRadius) : 0); We probably want to change the name m_blurRadius to m_blurWidth to clear up any confusion about what this value means.
Alejandro G. Castro
Comment 3 2010-09-30 11:32:30 PDT
(In reply to comment #2) > > [...] > > We probably want to change the name m_blurRadius to m_blurWidth to clear up any confusion about what this value means. I agree, I've checked the CSS spec and it is call blur distance we can use that: http://www.w3.org/TR/css3-background/#box-shadow
Jarred Nicholls
Comment 4 2010-09-30 19:57:27 PDT
Alejandro, I would update this patch to conform to the landed patch in r68824 (https://bugs.webkit.org/show_bug.cgi?id=46931), which removes the unnecessary calls to ceil (which happen to break MSVC builds since 9/23 when the Qt blur was forked for Cairo). Just FYI.
Alejandro G. Castro
Comment 5 2010-09-30 23:56:58 PDT
(In reply to comment #4) > Alejandro, I would update this patch to conform to the landed patch in r68824 (https://bugs.webkit.org/show_bug.cgi?id=46931), which removes the unnecessary calls to ceil (which happen to break MSVC builds since 9/23 when the Qt blur was forked for Cairo). Just FYI. Thanks for information, I'll do it.
Alejandro G. Castro
Comment 6 2010-10-01 04:43:51 PDT
Created attachment 69450 [details] Proposed patch Addressed the recomendations, I've used blurDistance (from the css spec) and d (from the svg spec). Rebased over Jarred patch.
Early Warning System Bot
Comment 7 2010-10-01 05:02:25 PDT
Jarred Nicholls
Comment 8 2010-10-01 05:31:32 PDT
See r68145, Mark changed several files in Cairo and Qt to use m_blurRadius that will also need refactoring for the name change to m_blurDistance, e.g. qt/FontQt.cpp.
Jarred Nicholls
Comment 9 2010-10-01 08:56:36 PDT
(In reply to comment #8) > See r68145, Mark changed several files in Cairo and Qt to use m_blurRadius that will also need refactoring for the name change to m_blurDistance, e.g. qt/FontQt.cpp. First off, I meant to type Martin and for some reason typed Mark. My apologies Martin! Second, it's actually just the qt/FontQt.cpp after doing a search. Hope that saves you some time.
Alejandro G. Castro
Comment 10 2010-10-01 09:11:09 PDT
(In reply to comment #9) > (In reply to comment #8) > > See r68145, Mark changed several files in Cairo and Qt to use m_blurRadius that will also need refactoring for the name change to m_blurDistance, e.g. qt/FontQt.cpp. > > First off, I meant to type Martin and for some reason typed Mark. My apologies Martin! > > Second, it's actually just the qt/FontQt.cpp after doing a search. Hope that saves you some time. Yeah, thanks very much Jarred, preparing the patch.
Alejandro G. Castro
Comment 11 2010-10-04 04:34:01 PDT
Created attachment 69615 [details] Proposed patch I've modified the m_blurRadius in FontQt, is there any reason not to declare those members as private and add a funtion to get them? In that case we could open other bug to do that.
Early Warning System Bot
Comment 12 2010-10-04 04:40:43 PDT
Alejandro G. Castro
Comment 13 2010-10-04 04:49:50 PDT
Created attachment 69617 [details] Proposed patch
Dirk Schulze
Comment 14 2010-10-06 05:03:48 PDT
Comment on attachment 69617 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=69617&action=review Please fix the issues and I'm fine with it. r- because of the issues. > WebCore/platform/graphics/ContextShadow.cpp:88 > + unsigned d = max(2.f, (2 / 3.f) * m_blurDistance); d is unsigned, you can't use unsigned d = max(2.f use unsigned d = max<unsigned>(2, floorf(2 / 3.f * m_blurDistance)); instead. > WebCore/platform/graphics/ContextShadow.cpp:158 > + m_layerRect.inflate((m_type == BlurShadow) ? m_blurDistance : 0); remove the braces arround m_type == BlurShadow > WebCore/platform/graphics/ContextShadow.cpp:171 > + m_layerRect.inflate((m_type == BlurShadow) ? m_blurDistance : 0); Ditto.
Dirk Schulze
Comment 15 2010-10-06 05:04:43 PDT
(In reply to comment #14) > (From update of attachment 69617 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=69617&action=review > d is unsigned, you can't use unsigned d = max(2.f > use > unsigned d = max<unsigned>(2, floorf(2 / 3.f * m_blurDistance)); instead. > you still need a static_cast<unsigned> for floorf, sorry.
Alejandro G. Castro
Comment 16 2010-10-06 08:09:05 PDT
(In reply to comment #15) > (In reply to comment #14) > > (From update of attachment 69617 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=69617&action=review > > d is unsigned, you can't use unsigned d = max(2.f > > use > > unsigned d = max<unsigned>(2, floorf(2 / 3.f * m_blurDistance)); instead. > > > you still need a static_cast<unsigned> for floorf, sorry. Thanks for the review, I'm going to use int the distance is limited to 128 so it is not a problem, something like: + int d = max(2, static_cast<int>(floorf((2 / 3.f) * m_blurDistance)));
Alejandro G. Castro
Comment 17 2010-10-06 08:11:30 PDT
Created attachment 69942 [details] Proposed patch Fixed the issues pointed out in the comments.
Dirk Schulze
Comment 18 2010-10-06 10:15:03 PDT
Comment on attachment 69942 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=69942&action=review LGTM. Please use a better phrasing in the ChangeLog. > WebCore/ChangeLog:10 > + Calculate the size of the kernel in the blur algorihtm using the > + radius instead of using directly. Change the name of the variables using directly something is missing here. What don't you want to use directly?
Alejandro G. Castro
Comment 19 2010-10-06 10:35:07 PDT
(In reply to comment #18) > (From update of attachment 69942 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=69942&action=review > > LGTM. Please use a better phrasing in the ChangeLog. > > > WebCore/ChangeLog:10 > > + Calculate the size of the kernel in the blur algorihtm using the > > + radius instead of using directly. Change the name of the variables > > using directly > something is missing here. What don't you want to use directly? Yep, ... instead of using directly the blur distance as the kernel size. Thanks, I'm going to commit it.
Martin Robinson
Comment 20 2010-10-06 12:38:09 PDT
Note You need to log in before you can comment on or make changes to this bug.