Bug 44091 - [Qt] Reduce the size of the shadow buffer to the clip region
Summary: [Qt] Reduce the size of the shadow buffer to the clip region
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Ariya Hidayat
URL:
Keywords: HTML5, Qt, QtTriaged
Depends on:
Blocks: 34479
  Show dependency treegraph
 
Reported: 2010-08-16 21:59 PDT by Ariya Hidayat
Modified: 2010-08-17 01:33 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.78 KB, patch)
2010-08-16 22:12 PDT, Ariya Hidayat
no flags Details | Formatted Diff | Diff
Patch (3.13 KB, patch)
2010-08-17 00:36 PDT, Ariya Hidayat
no flags Details | Formatted Diff | Diff
Patch (3.13 KB, patch)
2010-08-17 01:12 PDT, Ariya Hidayat
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ariya Hidayat 2010-08-16 21:59:43 PDT
http://trac.webkit.org/changeset/65425 (from https://bugs.webkit.org/show_bug.cgi?id=44025) adds blur support to the shadow. The buffer image for the shadow is however slightly larger than the rectangle that casts the shadow. This becomes a problem if the rectangle is e.g. a very big <div> in a web page. Technically the shadow buffer needs to be as large as the viewport or the current clipping region only.
Comment 1 Ariya Hidayat 2010-08-16 22:12:07 PDT
Created attachment 64551 [details]
Patch
Comment 2 Dirk Schulze 2010-08-16 22:24:36 PDT
I wounder if the clipping should be applied before adjusting the shadow rect. Doesn't your shadow have some blurring on the sides of the screen, if the shadowed rect is bigger than the current viewport?
Comment 3 Ariya Hidayat 2010-08-16 22:49:03 PDT
(In reply to comment #2)
> I wounder if the clipping should be applied before adjusting the shadow rect. 

In that case, we might miss the case where the clip is adjacent to the shadow rect, and the shadow has a large blur radius.

But I see your point. I guess when the clip region can not fully contain the enlarged shadow rect (thus, they are intersecting or reverse contained), we need to expand the resulting rect once again.

I'll update the patch to reflect this situation.
Comment 4 Ariya Hidayat 2010-08-17 00:36:34 PDT
Created attachment 64556 [details]
Patch
Comment 5 Kenneth Rohde Christiansen 2010-08-17 01:04:01 PDT
Comment on attachment 64556 [details]
Patch

Is there any performance difference with this?WebCore/platform/graphics/qt/ContextShadow.cpp:212
 +  
why a new line here?
Comment 6 Ariya Hidayat 2010-08-17 01:07:39 PDT
(In reply to comment #5)
> (From update of attachment 64556 [details])
> Is there any performance difference with this?

Definitely. Some sites, e.g. http://sueddeutsche.de/ has superlarge div, several thousand pixels height, with drop shadow and blur. Without this patch, we keep using QImage as large as that while a much smaller one will do the job just fine.

> WebCore/platform/graphics/qt/ContextShadow.cpp:212
>  +  
> why a new line here?

Not necessary.
Comment 7 Kenneth Rohde Christiansen 2010-08-17 01:11:10 PDT
Can this be slower in some cases as well? or is that neglectable?
Comment 8 Ariya Hidayat 2010-08-17 01:12:59 PDT
Created attachment 64564 [details]
Patch
Comment 9 Dirk Schulze 2010-08-17 01:16:01 PDT
Not sure how this is called. But doesn't Qt store the current drawing of the page? So that the page doesn't need to draw on scrolling? That would mean, you just need to calculate the shadow once, and not over and over again?
Comment 10 Ariya Hidayat 2010-08-17 01:18:51 PDT
(In reply to comment #7)
> Can this be slower in some cases as well? or is that neglectable?

The shadow blur area is guaranteed to be the same or smaller with this patch, vs without this patch.

The only possible slowdown is the clipRegion().boundingRect() calculation. But this is really nothing (=negligible) compared to the blur operations itself (the most expensive part!), thus the extra cost is really worth the benefit.
Comment 11 Ariya Hidayat 2010-08-17 01:20:35 PDT
(In reply to comment #9)
> Not sure how this is called. But doesn't Qt store the current drawing of the page? So that the page doesn't need to draw on scrolling? That would mean, you just need to calculate the shadow once, and not over and over again?

Do you mean the tiled backing store? It's just an optimization to reduce the painting operations, but the shadow (as with other primitives) still needs be drawn once.
Comment 12 Dirk Schulze 2010-08-17 01:23:27 PDT
(In reply to comment #11)
> Do you mean the tiled backing store? It's just an optimization to reduce the painting operations, but the shadow (as with other primitives) still needs be drawn once.

Yes I mean tiled backing store. But what do you mean with "still needs be drawn once.", this wouldn't affect scrolling right? Means you just have a longer calculation of the effect once? (I'm just curious)
Comment 13 Ariya Hidayat 2010-08-17 01:30:33 PDT
> Yes I mean tiled backing store. But what do you mean with "still needs be drawn once.", this wouldn't affect scrolling right? Means you just have a longer calculation of the effect once? (I'm just curious)

It's just caching the page onto a set of pixmaps (=tiles) with the coverage slightly larger than the viewport. When you scroll a bit and the tiles still cover the new viewport entirely, only bitmap blit is necessary. When you scroll farther and the newly exposed area in the viewport are not covered by any of the tiles, then new tiles are generated (this is where the page is drawn, to the tiles).
Comment 14 Ariya Hidayat 2010-08-17 01:33:10 PDT
Comment on attachment 64564 [details]
Patch

Clearing flags on attachment: 64564

Committed r65488: <http://trac.webkit.org/changeset/65488>
Comment 15 Ariya Hidayat 2010-08-17 01:33:25 PDT
All reviewed patches have been landed.  Closing bug.