Diff
Modified: trunk/Source/WebKit2/ChangeLog (99614 => 99615)
--- trunk/Source/WebKit2/ChangeLog 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-08 22:01:16 UTC (rev 99615)
@@ -1,3 +1,57 @@
+2011-11-08 Anders Carlsson <ander...@apple.com>
+
+ Add a basic layer hierarchy to the Core Animation drawing area
+ https://bugs.webkit.org/show_bug.cgi?id=71838
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView drawRect:]):
+ Return early if we're using a tiled drawing area.
+
+ (-[WKView initWithFrame:contextRef:pageGroupRef:]):
+ If we're using a tiled drawing area, make the WKView layer backed and set its layer
+ to a simple CALayer with a white background and set the view's content redraw policy
+ to never to avoid ever calling drawRect.
+
+ * UIProcess/DrawingAreaProxy.h:
+ (WebKit::DrawingAreaProxy::didUpdateGeometry):
+ * UIProcess/DrawingAreaProxy.messages.in:
+ Add a new didUpdateGeometry message.
+
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::TiledCoreAnimationDrawingAreaProxy):
+ Initialize m_isWaitingForDidUpdateGeometry.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::sizeDidChange):
+ Send an UpdateGeometry message to the web process and wait for a reply.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::enterAcceleratedCompositingMode):
+ Tell the web page proxy to enter accelerated compositing mode.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::exitAcceleratedCompositingMode):
+ Assert that this function is never called.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry):
+ Send another UpdateGeometry message if needed.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::sendUpdateGeometry):
+ Add helper function to actually send the UpdateGeometry message.
+
+ * WebProcess/WebPage/DrawingArea.h:
+ (WebKit::DrawingArea::updateGeometry):
+ * WebProcess/WebPage/DrawingArea.messages.in:
+ Add UpdateGeometry message.
+
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+ (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+ Create a red root layer and a remote layer client that hosts it.
+
+ (WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
+ Resize the root layer and tell the UI process that we've updated the geometry.
+
2011-11-08 Dan Bernstein <m...@apple.com>
<rdar://problem/10262225> Allow RenderView to have columns
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (99614 => 99615)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2011-11-08 22:01:16 UTC (rev 99615)
@@ -122,6 +122,7 @@
- (void)_setDrawingAreaSize:(NSSize)size;
- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState;
- (void)_disableComplexTextInputIfNecessary;
+- (BOOL)_shouldUseTiledDrawingArea;
@end
@interface WKViewData : NSObject {
@@ -1910,6 +1911,12 @@
{
LOG(View, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
_data->_page->endPrinting();
+
+ if ([self _shouldUseTiledDrawingArea]) {
+ // Nothing to do here.
+ return;
+ }
+
CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
@@ -2053,15 +2060,15 @@
_data->_resizeScrollOffset = NSZeroSize;
}
-@end
-
-@implementation WKView (Internal)
-
- (BOOL)_shouldUseTiledDrawingArea
{
return NO;
}
+@end
+
+@implementation WKView (Internal)
+
- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy
{
if ([self _shouldUseTiledDrawingArea])
@@ -2629,6 +2636,15 @@
[self _registerDraggedTypes];
+ if ([self _shouldUseTiledDrawingArea]) {
+ CALayer *layer = [CALayer layer];
+ layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
+ self.layer = layer;
+
+ self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever;
+ self.wantsLayer = YES;
+ }
+
WebContext::statistics().wkViewCount++;
return self;
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (99614 => 99615)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2011-11-08 22:01:16 UTC (rev 99615)
@@ -122,6 +122,9 @@
virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) { }
#endif
+#if PLATFORM(MAC)
+ virtual void didUpdateGeometry() { }
+#endif
#if USE(TILED_BACKING_STORE)
virtual void snapshotTaken(const UpdateInfo&) { }
virtual void createTile(int tileID, const UpdateInfo& updateInfo) { }
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in (99614 => 99615)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in 2011-11-08 22:01:16 UTC (rev 99615)
@@ -27,6 +27,12 @@
EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
#endif
+
+#if PLATFORM(MAC)
+ // Used by TiledCoreAnimationDrawingAreaProxy.
+ DidUpdateGeometry()
+#endif
+
#if USE(TILED_BACKING_STORE)
CreateTile(int tileID, WebKit::UpdateInfo updateInfo)
UpdateTile(int tileID, WebKit::UpdateInfo updateInfo)
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h (99614 => 99615)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2011-11-08 22:01:16 UTC (rev 99615)
@@ -42,6 +42,19 @@
// DrawingAreaProxy
virtual void deviceScaleFactorDidChange() OVERRIDE;
virtual void sizeDidChange() OVERRIDE;
+ virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) OVERRIDE;
+ virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) OVERRIDE;
+
+ // Message handlers.
+ virtual void didUpdateGeometry() OVERRIDE;
+
+ void sendUpdateGeometry();
+
+ // Whether we're waiting for a DidUpdateGeometry message from the web process.
+ bool m_isWaitingForDidUpdateGeometry;
+
+ // The last size we sent to the web process.
+ WebCore::IntSize m_lastSentSize;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (99614 => 99615)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2011-11-08 22:01:16 UTC (rev 99615)
@@ -23,9 +23,17 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "TiledCoreAnimationDrawingAreaProxy.h"
+#import "config.h"
+#import "TiledCoreAnimationDrawingAreaProxy.h"
+#import "DrawingAreaMessages.h"
+#import "DrawingAreaProxyMessages.h"
+#import "LayerTreeContext.h"
+#import "WebPageProxy.h"
+#import "WebProcessProxy.h"
+
+using namespace WebCore;
+
namespace WebKit {
PassOwnPtr<TiledCoreAnimationDrawingAreaProxy> TiledCoreAnimationDrawingAreaProxy::create(WebPageProxy* webPageProxy)
@@ -35,6 +43,7 @@
TiledCoreAnimationDrawingAreaProxy::TiledCoreAnimationDrawingAreaProxy(WebPageProxy* webPageProxy)
: DrawingAreaProxy(DrawingAreaTypeTiledCoreAnimation, webPageProxy)
+ , m_isWaitingForDidUpdateGeometry(false)
{
}
@@ -49,7 +58,54 @@
void TiledCoreAnimationDrawingAreaProxy::sizeDidChange()
{
- // FIXME: Implement.
+ if (!m_webPageProxy->isValid())
+ return;
+
+ // We only want one UpdateGeometry message in flight at once, so if we've already sent one but
+ // haven't yet received the reply we'll just return early here.
+ if (m_isWaitingForDidUpdateGeometry)
+ return;
+
+ sendUpdateGeometry();
+
+ if (m_webPageProxy->process()->isLaunching())
+ return;
+
+ // The timeout, in seconds, we use when waiting for a DidUpdateGeometry message.
+ static const double didUpdateBackingStoreStateTimeout = 0.5;
+ m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), didUpdateBackingStoreStateTimeout);
}
+void TiledCoreAnimationDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+{
+ m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext);
+}
+
+void TiledCoreAnimationDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&)
+{
+ // This should never be called.
+ ASSERT_NOT_REACHED();
+}
+
+void TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry()
+{
+ ASSERT(m_isWaitingForDidUpdateGeometry);
+
+ m_isWaitingForDidUpdateGeometry = false;
+
+ // If the WKView was resized while we were waiting for a DidUpdateGeometry reply from the web process,
+ // we need to resend the new size here.
+ if (m_lastSentSize != m_size)
+ sendUpdateGeometry();
+}
+
+void TiledCoreAnimationDrawingAreaProxy::sendUpdateGeometry()
+{
+ ASSERT(!m_isWaitingForDidUpdateGeometry);
+
+ m_lastSentSize = m_size;
+ m_webPageProxy->process()->send(Messages::DrawingArea::UpdateGeometry(m_size), m_webPageProxy->pageID());
+ m_isWaitingForDidUpdateGeometry = true;
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (99614 => 99615)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2011-11-08 22:01:16 UTC (rev 99615)
@@ -102,6 +102,11 @@
virtual void suspendPainting() { }
virtual void resumePainting() { }
+#if PLATFORM(MAC)
+ // Used by TiledCoreAnimationDrawingArea.
+ virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
+#endif
+
#if USE(TILED_BACKING_STORE)
virtual void setSize(const WebCore::IntSize& viewSize) { }
virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float) { }
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in (99614 => 99615)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2011-11-08 22:01:16 UTC (rev 99615)
@@ -26,6 +26,11 @@
SuspendPainting()
ResumePainting()
+#if PLATFORM(MAC)
+ // Used by TiledCoreAnimationDrawingArea.
+ UpdateGeometry(WebCore::IntSize viewSize)
+#endif
+
#if USE(TILED_BACKING_STORE)
SetSize(WebCore::IntSize viewSize)
SetVisibleContentRectAndScale(WebCore::IntRect visibleContentRect, float scale)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (99614 => 99615)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2011-11-08 22:01:16 UTC (rev 99615)
@@ -27,7 +27,12 @@
#define TiledCoreAnimationDrawingArea_h
#include "DrawingArea.h"
+#include <wtf/RetainPtr.h>
+OBJC_CLASS CALayer;
+
+typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef;
+
namespace WebKit {
class TiledCoreAnimationDrawingArea : public DrawingArea {
@@ -45,6 +50,12 @@
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE;
virtual void scheduleCompositingLayerSync() OVERRIDE;
+ // Message handlers.
+ virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
+
+ RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
+
+ RetainPtr<CALayer> m_rootLayer;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (99614 => 99615)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2011-11-08 21:57:16 UTC (rev 99614)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2011-11-08 22:01:16 UTC (rev 99615)
@@ -23,9 +23,20 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "TiledCoreAnimationDrawingArea.h"
+#import "config.h"
+#import "TiledCoreAnimationDrawingArea.h"
+#import "DrawingAreaProxyMessages.h"
+#import "LayerTreeContext.h"
+#import "WebPage.h"
+#import "WebProcess.h"
+#import <QuartzCore/QuartzCore.h>
+#import <WebKitSystemInterface.h>
+
+@interface CATransaction (Details)
++ (void)synchronize;
+@end
+
using namespace WebCore;
namespace WebKit {
@@ -38,6 +49,21 @@
TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, const WebPageCreationParameters& parameters)
: DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage)
{
+ m_rootLayer = [CALayer layer];
+
+ m_rootLayer.get().frame = m_webPage->bounds();
+ m_rootLayer.get().opaque = YES;
+
+ // Give the root layer a background color so it's visible on screen.
+ m_rootLayer.get().backgroundColor = CGColorCreateGenericRGB(1, 0, 0, 1);
+
+ mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort();
+ m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort);
+ WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer.get());
+
+ LayerTreeContext layerTreeContext;
+ layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get());
+ m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext));
}
TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
@@ -64,4 +90,17 @@
// FIXME: Implement
}
+void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize)
+{
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [m_rootLayer.get() setFrame:CGRectMake(0, 0, viewSize.width(), viewSize.height())];
+ [CATransaction commit];
+
+ [CATransaction flush];
+ [CATransaction synchronize];
+
+ m_webPage->send(Messages::DrawingAreaProxy::DidUpdateGeometry());
+}
+
} // namespace WebKit