Modified: trunk/Source/WebKit2/ChangeLog (103009 => 103010)
--- trunk/Source/WebKit2/ChangeLog 2011-12-16 02:15:22 UTC (rev 103009)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-16 02:32:08 UTC (rev 103010)
@@ -1,3 +1,23 @@
+2011-12-15 Anders Carlsson <[email protected]>
+
+ Add support for accelerated compositing to the tiled Core Animation drawing area
+ https://bugs.webkit.org/show_bug.cgi?id=74675
+
+ Reviewed by Andreas Kling.
+
+ Add a layer flush scheduler and get rid of the content layer since WebCore will manage that for us.
+
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+ (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+ (WebKit::TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea):
+ (WebKit::TiledCoreAnimationDrawingArea::setNeedsDisplay):
+ (WebKit::TiledCoreAnimationDrawingArea::scroll):
+ (WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
+ (WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerSync):
+ (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
+ (WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
+
2011-12-15 Sheriff Bot <[email protected]>
Unreviewed, rolling out r102652 and r102717.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (103009 => 103010)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2011-12-16 02:15:22 UTC (rev 103009)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2011-12-16 02:32:08 UTC (rev 103010)
@@ -27,6 +27,8 @@
#define TiledCoreAnimationDrawingArea_h
#include "DrawingArea.h"
+#include <WebCore/LayerFlushScheduler.h>
+#include <WebCore/LayerFlushSchedulerClient.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
@@ -36,7 +38,7 @@
namespace WebKit {
-class TiledCoreAnimationDrawingArea : public DrawingArea {
+class TiledCoreAnimationDrawingArea : public DrawingArea, private WebCore::LayerFlushSchedulerClient {
public:
static PassOwnPtr<TiledCoreAnimationDrawingArea> create(WebPage*, const WebPageCreationParameters&);
virtual ~TiledCoreAnimationDrawingArea();
@@ -51,14 +53,16 @@
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE;
virtual void scheduleCompositingLayerSync() OVERRIDE;
+ // WebCore::LayerFlushSchedulerClient
+ virtual bool flushLayers() OVERRIDE;
+
// Message handlers.
virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
+ WebCore::LayerFlushScheduler m_layerFlushScheduler;
RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
RetainPtr<CALayer> m_rootLayer;
-
- RetainPtr<WKContentLayer> m_contentLayer;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (103009 => 103010)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2011-12-16 02:15:22 UTC (rev 103009)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2011-12-16 02:32:08 UTC (rev 103010)
@@ -31,7 +31,12 @@
#import "WebPage.h"
#import "WebProcess.h"
#import <QuartzCore/QuartzCore.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameView.h>
#import <WebCore/GraphicsContext.h>
+#import <WebCore/Page.h>
+#import <WebCore/ScrollingCoordinator.h>
+#import <WebCore/Settings.h>
#import <WebKitSystemInterface.h>
@interface CATransaction (Details)
@@ -40,37 +45,6 @@
using namespace WebCore;
-@interface WKContentLayer : CALayer {
- WebKit::WebPage *_webPage;
-}
-
-- (id)initWithWebPage:(WebKit::WebPage *)webPage;
-
-@end
-
-@implementation WKContentLayer
-
-- (id)initWithWebPage:(WebKit::WebPage *)webPage
-{
- self = [super init];
- if (self)
- self->_webPage = webPage;
-
- return self;
-}
-
-- (void)drawInContext:(CGContextRef)context
-{
- _webPage->layoutIfNeeded();
-
- CGRect clipRect = CGContextGetClipBoundingBox(context);
-
- GraphicsContext graphicsContext(context);
- _webPage->drawRect(graphicsContext, enclosingIntRect(NSRectFromCGRect(clipRect)));
-}
-
-@end
-
namespace WebKit {
PassOwnPtr<TiledCoreAnimationDrawingArea> TiledCoreAnimationDrawingArea::create(WebPage* webPage, const WebPageCreationParameters& parameters)
@@ -80,7 +54,11 @@
TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, const WebPageCreationParameters& parameters)
: DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage)
+ , m_layerFlushScheduler(this)
{
+ // FIXME: It's weird that we're mucking around with the settings here.
+ webPage->corePage()->settings()->setForceCompositingMode(true);
+
m_rootLayer = [CALayer layer];
CGRect rootLayerFrame = m_webPage->bounds();
@@ -91,11 +69,6 @@
// Give the root layer a background color so it's visible on screen.
m_rootLayer.get().backgroundColor = CGColorCreateGenericRGB(1, 0, 0, 1);
- m_contentLayer.adoptNS([[WKContentLayer alloc] initWithWebPage:webPage]);
- m_contentLayer.get().frame = m_rootLayer.get().frame;
-
- [m_rootLayer.get() addSublayer:m_contentLayer.get()];
-
mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort();
m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort);
WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer.get());
@@ -107,28 +80,45 @@
TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
{
+ m_layerFlushScheduler.invalidate();
}
void TiledCoreAnimationDrawingArea::setNeedsDisplay(const IntRect& rect)
{
- [m_contentLayer.get() setNeedsDisplayInRect:rect];
}
void TiledCoreAnimationDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
{
- [m_contentLayer.get() setNeedsDisplayInRect:scrollRect];
}
-void TiledCoreAnimationDrawingArea::setRootCompositingLayer(GraphicsLayer*)
+void TiledCoreAnimationDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
{
- // FIXME: Implement.
+ if (!graphicsLayer) {
+ m_rootLayer.get().sublayers = nil;
+ return;
+ }
+
+ m_rootLayer.get().sublayers = [NSArray arrayWithObject:graphicsLayer->platformLayer()];
}
void TiledCoreAnimationDrawingArea::scheduleCompositingLayerSync()
{
+ m_layerFlushScheduler.schedule();
// FIXME: Implement
}
+bool TiledCoreAnimationDrawingArea::flushLayers()
+{
+ // This gets called outside of the normal event loop so wrap in an autorelease pool
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ bool returnValue = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
+
+ [pool drain];
+ return returnValue;
+}
+
+
void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize)
{
m_webPage->setSize(viewSize);
@@ -138,7 +128,6 @@
[CATransaction setDisableActions:YES];
m_rootLayer.get().frame = CGRectMake(0, 0, viewSize.width(), viewSize.height());
- m_contentLayer.get().frame = CGRectMake(0, 0, viewSize.width(), viewSize.height());
[CATransaction commit];