WebKit2 snapshots should contain accelerated content
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 01:39:28 +0000 (01:39 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 01:39:28 +0000 (01:39 +0000)
<rdar://problem/8807393>
https://bugs.webkit.org/show_bug.cgi?id=51660

Reviewed by Anders Carlsson.

When creating a snapshot, flatten the layer tree for painting so that
accelerated content is included in the snapshot.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::snapshotInViewCoordinates):
(WebKit::WebPage::snapshotInDocumentCoordinates):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74704 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/WebProcess/WebPage/WebPage.cpp

index 6886d293ebee853c88d3ce7acf0b420eef307a92..2dfb09f9434135cd66930094ec06d4d0dc0f6ca6 100644 (file)
@@ -1,3 +1,18 @@
+2010-12-27  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2 snapshots should contain accelerated content
+        <rdar://problem/8807393>
+        https://bugs.webkit.org/show_bug.cgi?id=51660
+
+        When creating a snapshot, flatten the layer tree for painting so that
+        accelerated content is included in the snapshot.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::snapshotInViewCoordinates):
+        (WebKit::WebPage::snapshotInDocumentCoordinates):
+
 2010-12-27  Daniel Bates  <dbates@rim.com>
 
         Attempt to fix the WebKit2 Windows build after changeset 74698
index 571321c1f9fb99e8931ee0d210313eee7b1e1d1b..96b701df6856c3886e8c2c0f51bcf0d92642d8ec 100644 (file)
@@ -596,6 +596,9 @@ PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, Ima
 
     frameView->updateLayoutAndStyleIfNeededRecursive();
 
+    PaintBehavior oldBehavior = frameView->paintBehavior();
+    frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
+
     RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
     OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext();
 
@@ -604,6 +607,8 @@ PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, Ima
     frameView->paint(graphicsContext.get(), rect);
     graphicsContext->restore();
 
+    frameView->setPaintBehavior(oldBehavior);
+
     return snapshot.release();
 }
 
@@ -615,6 +620,9 @@ PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect,
 
     frameView->updateLayoutAndStyleIfNeededRecursive();
 
+    PaintBehavior oldBehavior = frameView->paintBehavior();
+    frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
+
     RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
     OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext();
 
@@ -623,6 +631,8 @@ PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect,
     frameView->paintContents(graphicsContext.get(), rect);
     graphicsContext->restore();
 
+    frameView->setPaintBehavior(oldBehavior);
+
     return snapshot.release();
 }