[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

andersca at apple.com andersca at apple.com
Sun Feb 20 23:12:45 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 9c57db9514e35d39e5199174e3c830431b1e635f
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 19 00:15:22 2011 +0000

    2011-01-18  Anders Carlsson  <andersca at apple.com>
    
            Reviewed by Darin Adler.
    
            Use a CGLayer for the backing store when possible
            https://bugs.webkit.org/show_bug.cgi?id=52679
    
            * UIProcess/mac/BackingStoreMac.mm:
            (WebKit::BackingStore::paint):
            If there is a layer, paint it into the given context.
    
            (WebKit::BackingStore::backingStoreContext):
            If we can get the containing window graphics context, use it to create a
            CGLayer that we'll use for the backing store.
    
            (WebKit::BackingStore::scroll):
            Paint the layer into itself.
    
            * UIProcess/mac/WebPageProxyMac.mm:
            (WebKit::WebPageProxy::containingWindowGraphicsContext):
            Call the page client.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76080 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 4ba5f2a..9fa3397 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,5 +1,27 @@
 2011-01-18  Anders Carlsson  <andersca at apple.com>
 
+        Reviewed by Darin Adler.
+
+        Use a CGLayer for the backing store when possible
+        https://bugs.webkit.org/show_bug.cgi?id=52679
+
+        * UIProcess/mac/BackingStoreMac.mm:
+        (WebKit::BackingStore::paint):
+        If there is a layer, paint it into the given context.
+
+        (WebKit::BackingStore::backingStoreContext):
+        If we can get the containing window graphics context, use it to create a 
+        CGLayer that we'll use for the backing store.
+
+        (WebKit::BackingStore::scroll):
+        Paint the layer into itself.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::containingWindowGraphicsContext):
+        Call the page client.
+
+2011-01-18  Anders Carlsson  <andersca at apple.com>
+
         Reviewed by Dan Bernstein.
 
         Pass the web page proxy to BackingStore::create
diff --git a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
index ffaefd7..7db8bb1 100644
--- a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
+++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
@@ -28,6 +28,7 @@
 #include "CGUtilities.h"
 #include "ShareableBitmap.h"
 #include "UpdateInfo.h"
+#include "WebPageProxy.h"
 #include <WebCore/GraphicsContext.h>
 
 using namespace WebCore;
@@ -36,13 +37,46 @@ namespace WebKit {
 
 void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect)
 {
-    ASSERT(m_bitmapContext);
+    if (m_cgLayer) {
+        CGContextSaveGState(context);
+        CGContextClipToRect(context, rect);
+
+        CGContextScaleCTM(context, 1, -1);
+        CGContextDrawLayerAtPoint(context, CGPointMake(0, -m_size.height()), m_cgLayer.get());
+
+        CGContextRestoreGState(context);
+        return;
+    }
 
+    ASSERT(m_bitmapContext);
     paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect);
 }
 
 CGContextRef BackingStore::backingStoreContext()
 {
+    if (m_cgLayer)
+        return CGLayerGetContext(m_cgLayer.get());
+
+    // Try to create a layer.
+    if (CGContextRef containingWindowContext = m_webPageProxy->containingWindowGraphicsContext()) {
+        m_cgLayer.adoptCF(CGLayerCreateWithContext(containingWindowContext, NSSizeToCGSize(m_size), 0));
+        CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get());
+        
+        CGContextSetBlendMode(layerContext, kCGBlendModeCopy);
+
+        // We want the origin to be in the top left corner so flip the backing store context.
+        CGContextTranslateCTM(layerContext, 0, m_size.height());
+        CGContextScaleCTM(layerContext, 1, -1);
+
+        if (m_bitmapContext) {
+            // Paint the contents of the bitmap into the layer context.
+            paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()));
+            m_bitmapContext = nullptr;
+        }
+
+        return layerContext;
+    }
+
     if (!m_bitmapContext) {
         RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
         
@@ -89,15 +123,25 @@ void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset
     if (scrollOffset.isZero())
         return;
 
+    if (m_cgLayer) {
+        CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get());
+
+        // Scroll the layer by painting it into itself with the given offset.
+        CGContextSaveGState(layerContext);
+        CGContextClipToRect(layerContext, scrollRect);
+        CGContextScaleCTM(layerContext, 1, -1);
+        CGContextDrawLayerAtPoint(layerContext, CGPointMake(scrollOffset.width(), -m_size.height() - scrollOffset.height()), m_cgLayer.get());
+        CGContextRestoreGState(layerContext);
+
+        return;
+    }
+
     ASSERT(m_bitmapContext);
 
     CGContextSaveGState(m_bitmapContext.get());
-
     CGContextClipToRect(m_bitmapContext.get(), scrollRect);
-
     CGPoint destination = CGPointMake(scrollRect.x() + scrollOffset.width(), scrollRect.y() + scrollOffset.height());
     paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect);
-
     CGContextRestoreGState(m_bitmapContext.get());
 }
 
diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
index 36905fb..cd3e6f1 100644
--- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
+++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
@@ -25,6 +25,7 @@
 
 #include "WebPageProxy.h"
 
+#include "PageClient.h"
 #include <WebCore/Language.h>
 #include <wtf/text/StringConcatenate.h>
 
@@ -110,4 +111,9 @@ void WebPageProxy::stopSpeaking()
     [NSApp stopSpeaking:nil];
 }
 
+CGContextRef WebPageProxy::containingWindowGraphicsContext()
+{
+    return m_pageClient->containingWindowGraphicsContext();
+}
+
 } // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list