Bug 90082

Summary: [Qt] Add support for tiled shadow blur
Product: WebKit Reporter: Bruno Abinader (history only) <bruno.abinader>
Component: WebKit QtAssignee: Lamarque V. Souza <lamarque>
Status: RESOLVED FIXED    
Severity: Enhancement CC: allan.jensen, hausmann, helder.correia, igor.oliveira, kenneth, noam, webkit.review.bot
Priority: P2 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 45042, 90562, 111736    
Bug Blocks:    
Attachments:
Description Flags
Proposed patch for Qt's GC
none
Proposed patch (with fix for shadow rotation)
none
Proposed patch (v3)
none
Additional patch for GraphicsContext::fillRect(const FloatRect& rect) overloaded function
none
Patch for landing
none
Patch
none
Patch noam: review+

Description Bruno Abinader (history only) 2012-06-27 10:04:16 PDT
This change takes advantage of tiling (implemented on ShadowBlur::drawRectShadow) to improve drawing performance. However there are some issues to consider before finishing this change:

[1] Both Qt and Cairo does not support tiling drawing on rotated rectangles (see bug 45042) - basically the shadows are painted well, but with some graphical artifacts between tile edges and sides.
[2] However it works fine in Cairo, using drawRectShadow without tiling for rotated rectangles is currently broken on Qt (seems that shadow drawing does not respect rectangle rotation).
[3] When forcing usage of tiling drawing code inside drawRectShadow on Qt port, issue [2] ceases to exist, but issue [1] maintains, so it is imperative to fix tiling artifacts and Qt handling of drawRectShadow before anything else.

My plan is to let a provisional patch here for consideration, while working on the issues mentioned above. What do you guys think?
Comment 1 Igor Trindade Oliveira 2012-06-27 10:08:38 PDT
[1] Is a different bug. Should not be treated in this patch.

For [2] and [3] would be great!
Comment 2 Bruno Abinader (history only) 2012-06-27 10:09:20 PDT
Created attachment 149771 [details]
Proposed patch for Qt's GC

This is the proposed patch for Qt's GC implementation. I haven't touched on the "void GraphicsContext::fillRect(const FloatRect& rect)" overloaded function as I haven't found any layout test that actually triggers it yet.
Comment 3 Bruno Abinader (history only) 2012-06-27 11:04:52 PDT
Changing bug summary to a proper meaning - less cryptful, at least :D
Comment 4 Bruno Abinader (history only) 2012-06-27 13:59:38 PDT
Created attachment 149792 [details]
Proposed patch (with fix for shadow rotation)

Updated patch with fix for rotated shadows in Qt's GraphicsContext::pushTransparencyLayerInternal. A missing device transform was preventing the shadows from being properly drawn. This patch probably will need some layout tests rebaselines :)
Comment 5 Bruno Abinader (history only) 2012-06-28 06:03:32 PDT
Created attachment 149934 [details]
Proposed patch (v3)

Fixed an unnecessary cast to QRectF on GraphicsContext::fillRoundedRect.
Comment 6 WebKit Review Bot 2012-06-28 09:15:10 PDT
Comment on attachment 149934 [details]
Proposed patch (v3)

Clearing flags on attachment: 149934

Committed r121435: <http://trac.webkit.org/changeset/121435>
Comment 7 WebKit Review Bot 2012-06-28 09:15:16 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Bruno Abinader (history only) 2012-06-29 06:35:02 PDT
Created attachment 150165 [details]
Additional patch for GraphicsContext::fillRect(const FloatRect& rect) overloaded function

This is an additional patch for a certain case in the first fillRect() overload. Tested with canvas/philip/tests/2d.shadow.blur.high.html and canvas/philip/tests/2d.shadow.blur.low.html with same results.
Comment 9 Bruno Abinader (history only) 2012-06-29 06:37:39 PDT
Changing status to "reopened" while additional patch is pending review/commit-queue authorization.
Comment 10 WebKit Review Bot 2012-06-29 10:17:19 PDT
Comment on attachment 150165 [details]
Additional patch for GraphicsContext::fillRect(const FloatRect& rect) overloaded function

Clearing flags on attachment: 150165

Committed r121569: <http://trac.webkit.org/changeset/121569>
Comment 11 WebKit Review Bot 2012-06-29 10:17:26 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Noam Rosenthal 2012-06-29 16:19:48 PDT
I believe this broke the Qt Linux release bot. Mind taking a look?
Comment 13 Noam Rosenthal 2012-06-29 16:42:49 PDT
Reopening to attach new patch.
Comment 14 Noam Rosenthal 2012-06-29 16:43:12 PDT
Created attachment 150271 [details]
Patch for landing
Comment 15 Bruno Abinader (history only) 2012-06-29 19:45:03 PDT
Sure, sorry for the delay (just checked my mail - Manaus timezone is -04:00). I am running a second pass with and without the patch to see any changes on the test results.

(In reply to comment #12)
> I believe this broke the Qt Linux release bot. Mind taking a look?
Comment 16 WebKit Review Bot 2012-06-29 20:52:34 PDT
Comment on attachment 150271 [details]
Patch for landing

Clearing flags on attachment: 150271

Committed r121618: <http://trac.webkit.org/changeset/121618>
Comment 17 WebKit Review Bot 2012-06-29 20:52:40 PDT
All reviewed patches have been landed.  Closing bug.
Comment 18 Bruno Abinader (history only) 2012-06-30 00:20:22 PDT
Indeed, I detected 29 regressions with the additional patch. Sorry :/ I've only tested them with philip patches but forgot to do a full test run. Thanks for pointing it out, No'am.
Comment 19 Bruno Abinader (history only) 2012-06-30 00:28:44 PDT
Actually pardon again, but these 29 were actually tests with no expected results from the reverted patch test run, not the patched test run. The actual diff are these two tests:

fast/canvas/canvas-scale-fillRect-shadow.html
fast/canvas/canvas-transforms-fillRect-shadow.html

I'll have a look at these tomorrow.

(In reply to comment #18)
> Indeed, I detected 29 regressions with the additional patch. Sorry :/ I've only tested them with philip patches but forgot to do a full test run. Thanks for pointing it out, No'am.
Comment 20 Bruno Abinader (history only) 2012-07-04 08:57:51 PDT
Seems that ShadowBlur's current drawRectShadow() implementation does not take into consideration Qt's brush properties for some reason. I am going to issue that into another bug. With the first patch landed and sounding well on tests, I'd assume this bug is fixed.

(In reply to comment #19)
> Actually pardon again, but these 29 were actually tests with no expected results from the reverted patch test run, not the patched test run. The actual diff are these two tests:
> 
> fast/canvas/canvas-scale-fillRect-shadow.html
> fast/canvas/canvas-transforms-fillRect-shadow.html
> 
> I'll have a look at these tomorrow.
> 
> (In reply to comment #18)
> > Indeed, I detected 29 regressions with the additional patch. Sorry :/ I've only tested them with philip patches but forgot to do a full test run. Thanks for pointing it out, No'am.
Comment 21 Allan Sandfeld Jensen 2013-01-22 04:46:24 PST
The fix was rolled out, so the issue is still open.
Comment 22 Lamarque V. Souza 2013-02-11 11:28:54 PST
Created attachment 187626 [details]
Patch

Fix for patch 'Additional patch for GraphicsContext::fillRect(const FloatRect& rect) overloaded function' which was rolled out in comment #16.
Comment 23 Allan Sandfeld Jensen 2013-03-07 06:27:08 PST
Comment on attachment 187626 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=187626&action=review

> Source/WebCore/ChangeLog:9
> +        This overloaded fillRect implementation also supports this optimization in
> +        certain situations.

Could you instead explain what the issue was and what the patch changes in ShadowBlur?
Comment 24 Lamarque V. Souza 2013-03-07 15:34:54 PST
(In reply to comment #23)
> (From update of attachment 187626 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=187626&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        This overloaded fillRect implementation also supports this optimization in
> > +        certain situations.
> 
> Could you instead explain what the issue was and what the patch changes in ShadowBlur?

The main goal of this patch is improving performance according to what is written in comment #1. I am not 100% sure if the changes I made in the patch are correct, that is why I asked for reviewing. One thing I noticed during my tests is that using save()/restore() instead of GraphicsContextStateSaver in computeSliceSizesFromRadii() helps fixing the regressions mentioned in comment #19. The changes in ShadowBlur::drawShadowBuffer() and computeSliceSizesFromRadii() are basically to fix the regressions but I am not sure exactly how this code work.
Comment 25 Lamarque V. Souza 2013-03-08 11:35:59 PST
This patch is a working in progress. What I did was compare the sequence of function/method calls with and without the original patch (https://bugs.webkit.org/attachment.cgi?id=149934). My patch basically outlines the difference between the two sequence of calls. I still need to investigate further why the changes in ShadowBlur::drawShadowBuffer() makes the regressions mentioned in comment #19 go away. The main goal is to use ShadowBlur::drawRectShadow(), which according to the bug description, improves drawing performance by taking advantage of tiled shadow rendering.
Comment 26 Allan Sandfeld Jensen 2013-03-11 08:12:49 PDT
Created attachment 192473 [details]
Patch
Comment 27 Allan Sandfeld Jensen 2013-03-11 08:15:09 PDT
(In reply to comment #24)
> (In reply to comment #23)
> > (From update of attachment 187626 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=187626&action=review
> > 
> > > Source/WebCore/ChangeLog:9
> > > +        This overloaded fillRect implementation also supports this optimization in
> > > +        certain situations.
> > 
> > Could you instead explain what the issue was and what the patch changes in ShadowBlur?
> 
> The main goal of this patch is improving performance according to what is written in comment #1. I am not 100% sure if the changes I made in the patch are correct, that is why I asked for reviewing. One thing I noticed during my tests is that using save()/restore() instead of GraphicsContextStateSaver in computeSliceSizesFromRadii() helps fixing the regressions mentioned in comment #19. The changes in ShadowBlur::drawShadowBuffer() and computeSliceSizesFromRadii() are basically to fix the regressions but I am not sure exactly how this code work.

Your patch only worked on the transform test-case not the scale test-case, but it worked by avoiding clipToImageBuffer which produces scaling artifacts due to the way we transform alphaMaps.
Comment 28 Allan Sandfeld Jensen 2013-03-14 07:06:49 PDT
Committed r145810: <http://trac.webkit.org/changeset/145810>