Bug 98581

Summary: [BlackBerry] Fetch blit rects from a viewport accessor
Product: WebKit Reporter: Jakob Petsovits <jpetsovits>
Component: WebKit BlackBerryAssignee: Jakob Petsovits <jpetsovits>
Status: RESOLVED FIXED    
Severity: Normal CC: anilsson, anlo, dbates, gyuyoung.kim, manyoso, mifenton, rakuco, rwlbuis, staikos, tonikitoo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch, same but with internal reviewer line
none
Patch none

Jakob Petsovits
Reported 2012-10-05 19:39:34 PDT
The long-standing userInterfaceBlittedVisibleContentsRect() method in WebPageClient has long been the bane of my existence, as it returns the source rect for WebKit contents, but in backingstore pixel coordinates. This makes it not only unwieldy but also terribly fragile; when the backingstore changes its zoom factor then the result of this method has to change as well, synchronously, even though many things happen on the user interface thread these days. BlackBerry::Platform now exposes a ViewportAccessor interface, which can be used to get the same rectangle in document coordinates or target pixel coordinates, both being a better choice for being passed as an argument as they make the backingstore scale an implementation detail. I started out on a smaller patch that would add a setScale() to BackingStoreGeometry and the single tiles. Not only does this provide safety against blitting a buffer with wrong scale, but it also lays the foundation for blitting multiple states at different scales, if we want that. (There is certainly a need for having both a low-res preview tile with wide coverage underlying the current tiles, or maybe rendering some tiles in a different resolution while we pinch-zoom.) The disadvantage of my first approach was that it used the scale in the current BackingStoreGeometry (a.k.a. tile layout) even if we're operating without tiles. That made it necessary to access the front and back state BackingStoreGeometry objects in places where we wouldn't usually care about or update any BackingStoreGeometry at all, and where it's not threadsafe to do so. (Hat tip to Arvid for calling me out on this.) The solution turned out to be a lot nicer, but also more wide-ranging in scope. The relevant backState()->setScale() calls are still in the patch, but I removed the bad ones. In turn, I modified blitVisibleContents() so that it doesn't use backingstore tile pixel measures at all except in the block where it actually blits from the tiles. Other code in blitVisibleContents(), including the WebPageCompositor part, now only refers to either document (WebCore) or user-visible pixel coordinates. In order to achieve this, I had to change paintDefaultBackground() so that it doesn't take a backingstore-to-UI-pixel differential transformation. It's very easy to calculate those same areas with ViewportAccessor methods. However, that in turn broke the DEBUG_VISUALIZE blocks (which were slightly broken before); in order to fix this mode it seemed like a good solution to supply a different ViewportAccessor instead. The paintDefaultBackground() call in renderDirectToWindow() seemed to be broken too as it didn't take scroll information into account, and it happens on the WebKit thread so I can't use the UI thread ViewportAccessor there. In the end, the patch introduced two new ViewportAccessors. The plan for the WebKitThreadViewportAccessor is to use it in lots more places and also replace the unloved transformed/untransformed nomenclature with the more intuitive pixel/document naming provided by ViewportAccessor. == tl;dr == Never worry anymore about the resolution of backingstore tiles when asking for scaled blits. Internally tracked as RIM PR 173292. Patch below.
Attachments
Patch (51.67 KB, patch)
2012-10-05 20:21 PDT, Jakob Petsovits
no flags
Patch, same but with internal reviewer line (51.76 KB, patch)
2012-10-06 17:51 PDT, Jakob Petsovits
no flags
Patch (52.64 KB, patch)
2012-10-12 14:18 PDT, Jakob Petsovits
no flags
Jakob Petsovits
Comment 1 2012-10-05 20:21:36 PDT
Arvid Nilsson
Comment 2 2012-10-06 01:41:51 PDT
(In reply to comment #1) > Created an attachment (id=167437) [details] > Patch Looks very good to me! Great stuff!
Jakob Petsovits
Comment 3 2012-10-06 17:51:36 PDT
Created attachment 167466 [details] Patch, same but with internal reviewer line I take Arvid's comment as a positive internal review, as he did the previous round already and is probably the most knowledgeable person about this code right now. Still needs an upstream review, thanks!
Jakob Petsovits
Comment 4 2012-10-12 14:18:48 PDT
Created attachment 168480 [details] Patch Adam suggested that the scale tracking in geometry and tiles was poorly explained by the commit message. Here's an attempt at making it better.
George Staikos
Comment 5 2012-10-13 06:10:43 PDT
Comment on attachment 168480 [details] Patch Good to go!
WebKit Review Bot
Comment 6 2012-10-13 06:20:08 PDT
Comment on attachment 168480 [details] Patch Clearing flags on attachment: 168480 Committed r131257: <http://trac.webkit.org/changeset/131257>
WebKit Review Bot
Comment 7 2012-10-13 06:20:12 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.