Bug 127438

Summary: WebKit2 View Gestures (Swipe): Add a simple cache of view snapshots
Product: WebKit Reporter: Tim Horton <thorton>
Component: WebKit2Assignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, sam, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 127363    
Attachments:
Description Flags
patch
none
patch disabled by default
none
patch sam: review+

Description Tim Horton 2014-01-22 11:49:58 PST
This is a cache of bitmap snapshots of the WKView, for use in the forthcoming fluid swipe implementation. For now, it just stores all snapshots forever.

https://bugs.webkit.org/show_bug.cgi?id=127389 and https://bugs.webkit.org/show_bug.cgi?id=127390 track improvements.
Comment 1 Tim Horton 2014-01-22 12:06:53 PST
Created attachment 221887 [details]
patch
Comment 2 Tim Horton 2014-01-22 12:20:58 PST
Errm, I need a way to make us not take snapshots if swiping isn't enabled.
Comment 3 Tim Horton 2014-01-22 13:04:09 PST
Created attachment 221897 [details]
patch disabled by default
Comment 4 Sam Weinig 2014-01-22 21:10:16 PST
Comment on attachment 221897 [details]
patch disabled by default

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

> Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h:48
> +    CGImageRef getSnapshotAndRenderTreeSize(WebBackForwardListItem*, uint64_t& renderTreeSize);

This should return a std::pair<RetainPtr<CGImageRef>, uint64_t>

> Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm:76
> +    WKView *wkView = webPageProxy.wkView();

This class should not know about WKView! Instead, takeSnapshot() should really do all its work through the PageClient interface.  Is there a WebCore image type we could use for this kind of thing instead of CGImageRef directly?
Comment 5 Tim Horton 2014-01-23 01:26:17 PST
(In reply to comment #4)
> (From update of attachment 221897 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=221897&action=review
> 
> > Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h:48
> > +    CGImageRef getSnapshotAndRenderTreeSize(WebBackForwardListItem*, uint64_t& renderTreeSize);
> 
> This should return a std::pair<RetainPtr<CGImageRef>, uint64_t>

So much better.

> > Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm:76
> > +    WKView *wkView = webPageProxy.wkView();
> 
> This class should not know about WKView! Instead, takeSnapshot() should really do all its work through the PageClient interface.

OK.

> Is there a WebCore image type we could use for this kind of thing instead of CGImageRef directly?

I didn't want to get too locked into something like that until we figure out the purgeability story.
Comment 6 Sam Weinig 2014-01-23 11:27:30 PST
> > Is there a WebCore image type we could use for this kind of thing instead of CGImageRef directly?
> 
> I didn't want to get too locked into something like that until we figure out the purgeability story.

Ok.
Comment 7 Anders Carlsson 2014-01-23 11:29:14 PST
(In reply to comment #5)
> > 
> > This class should not know about WKView! Instead, takeSnapshot() should really do all its work through the PageClient interface.
> 

For classes that are Mac only I see no problem exposing the view directly. Maybe this is not a Mac only class though.
Comment 8 Sam Weinig 2014-01-23 11:35:57 PST
(In reply to comment #7)
> (In reply to comment #5)
> > > 
> > > This class should not know about WKView! Instead, takeSnapshot() should really do all its work through the PageClient interface.
> > 
> 
> For classes that are Mac only I see no problem exposing the view directly. Maybe this is not a Mac only class though.

I have been trying to keep a division still.  If something wants to know about the WKView, it should be in UIProcess/API/Cocoa or UIProcess/API/Mac.
Comment 9 Anders Carlsson 2014-01-23 12:03:05 PST
(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #5)
> > > > 
> > > > This class should not know about WKView! Instead, takeSnapshot() should really do all its work through the PageClient interface.
> > > 
> > 
> > For classes that are Mac only I see no problem exposing the view directly. Maybe this is not a Mac only class though.
> 
> I have been trying to keep a division still.  If something wants to know about the WKView, it should be in UIProcess/API/Cocoa or UIProcess/API/Mac.

And that's why PageClient is a clusterfuck of random unrelated functions...
Comment 10 Tim Horton 2014-01-23 18:00:13 PST
Created attachment 222054 [details]
patch
Comment 11 Tim Horton 2014-01-24 10:52:17 PST
http://trac.webkit.org/changeset/162710