2011-02-01 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Feb 2011 01:09:34 +0000 (01:09 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Feb 2011 01:09:34 +0000 (01:09 +0000)
        Reviewed by Dan Bernstein.

        Add a layer backed NSView for accelerated content
        https://bugs.webkit.org/show_bug.cgi?id=53555

        Rename the current _layerHostingView to _oldLayerHostingView and
        add a new _layerHostingView to be used with the new drawing area.

        * UIProcess/API/mac/WKView.mm:
        (-[WKView hitTest:]):
        (-[WKView _startAcceleratedCompositing:]):
        (-[WKView _stopAcceleratedCompositing]):
        (-[WKView _enterAcceleratedCompositingMode:]):
        (-[WKView _exitAcceleratedCompositingMode]):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm

index f63069d..08b270b 100644 (file)
@@ -2,6 +2,23 @@
 
         Reviewed by Dan Bernstein.
 
 
         Reviewed by Dan Bernstein.
 
+        Add a layer backed NSView for accelerated content
+        https://bugs.webkit.org/show_bug.cgi?id=53555
+
+        Rename the current _layerHostingView to _oldLayerHostingView and
+        add a new _layerHostingView to be used with the new drawing area.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView hitTest:]):
+        (-[WKView _startAcceleratedCompositing:]):
+        (-[WKView _stopAcceleratedCompositing]):
+        (-[WKView _enterAcceleratedCompositingMode:]):
+        (-[WKView _exitAcceleratedCompositingMode]):
+
+2011-02-01  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
         Pass enter/exit accelerated compositing mode to the WKView
         https://bugs.webkit.org/show_bug.cgi?id=53552
 
         Pass enter/exit accelerated compositing mode to the WKView
         https://bugs.webkit.org/show_bug.cgi?id=53552
 
index 59b4ce5..991f405 100644 (file)
@@ -107,8 +107,11 @@ typedef HashMap<String, ValidationVector> ValidationMap;
     id _trackingRectOwner;
     void* _trackingRectUserData;
 
     id _trackingRectOwner;
     void* _trackingRectUserData;
 
+    RetainPtr<NSView> _layerHostingView;
+
+    // FIXME: Remove _oldLayerHostingView.
 #if USE(ACCELERATED_COMPOSITING)
 #if USE(ACCELERATED_COMPOSITING)
-    NSView *_layerHostingView;
+    NSView *_oldLayerHostingView;
 #endif
 
     RetainPtr<id> _remoteAccessibilityChild;
 #endif
 
     RetainPtr<id> _remoteAccessibilityChild;
@@ -1501,9 +1504,12 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 - (NSView *)hitTest:(NSPoint)point
 {
     NSView *hitView = [super hitTest:point];
 - (NSView *)hitTest:(NSPoint)point
 {
     NSView *hitView = [super hitTest:point];
-#if USE(ACCELERATED_COMPOSITING)
     if (hitView && _data && hitView == _data->_layerHostingView)
         hitView = self;
     if (hitView && _data && hitView == _data->_layerHostingView)
         hitView = self;
+
+#if USE(ACCELERATED_COMPOSITING)
+    if (hitView && _data && hitView == _data->_oldLayerHostingView)
+        hitView = self;
 #endif
     return hitView;
 }
 #endif
     return hitView;
 }
@@ -1767,7 +1773,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 #if USE(ACCELERATED_COMPOSITING)
 - (void)_startAcceleratedCompositing:(CALayer *)rootLayer
 {
 #if USE(ACCELERATED_COMPOSITING)
 - (void)_startAcceleratedCompositing:(CALayer *)rootLayer
 {
-    if (!_data->_layerHostingView) {
+    if (!_data->_oldLayerHostingView) {
         NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]];
 #if !defined(BUILDING_ON_LEOPARD)
         [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
         NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]];
 #if !defined(BUILDING_ON_LEOPARD)
         [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
@@ -1775,7 +1781,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
         
         [self addSubview:hostingView];
         [hostingView release];
         
         [self addSubview:hostingView];
         [hostingView release];
-        _data->_layerHostingView = hostingView;
+        _data->_oldLayerHostingView = hostingView;
     }
 
     // Make a container layer, which will get sized/positioned by AppKit and CA.
     }
 
     // Make a container layer, which will get sized/positioned by AppKit and CA.
@@ -1809,8 +1815,8 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
 #endif
 
     [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
 #endif
 
-    [_data->_layerHostingView setLayer:viewLayer];
-    [_data->_layerHostingView setWantsLayer:YES];
+    [_data->_oldLayerHostingView setLayer:viewLayer];
+    [_data->_oldLayerHostingView setWantsLayer:YES];
     
     // Parent our root layer in the container layer
     [viewLayer addSublayer:rootLayer];
     
     // Parent our root layer in the container layer
     [viewLayer addSublayer:rootLayer];
@@ -1818,11 +1824,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 
 - (void)_stopAcceleratedCompositing
 {
 
 - (void)_stopAcceleratedCompositing
 {
-    if (_data->_layerHostingView) {
-        [_data->_layerHostingView setLayer:nil];
-        [_data->_layerHostingView setWantsLayer:NO];
-        [_data->_layerHostingView removeFromSuperview];
-        _data->_layerHostingView = nil;
+    if (_data->_oldLayerHostingView) {
+        [_data->_oldLayerHostingView setLayer:nil];
+        [_data->_oldLayerHostingView setWantsLayer:NO];
+        [_data->_oldLayerHostingView removeFromSuperview];
+        _data->_oldLayerHostingView = nil;
     }
 }
 
     }
 }
 
@@ -1855,12 +1861,32 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 
 - (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext
 {
 
 - (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext
 {
-    // FIXME: Implement.
+    ASSERT(!_data->_layerHostingView);
+
+    // Create an NSView that will host our layer tree.
+    _data->_layerHostingView.adoptNS([[NSView alloc] initWithFrame:[self bounds]]);
+    [_data->_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+    [self addSubview:_data->_layerHostingView.get()];
+
+    // Create a root layer that will back the NSView.
+    CALayer *rootLayer = [CALayer layer];
+#ifndef NDEBUG
+    [rootLayer setName:@"Hosting root layer"];
+#endif
+
+    [_data->_layerHostingView.get() setLayer:rootLayer];
+    [_data->_layerHostingView.get() setWantsLayer:YES];
 }
 
 - (void)_exitAcceleratedCompositingMode
 {
 }
 
 - (void)_exitAcceleratedCompositingMode
 {
-    // FIXME: Implement.
+    ASSERT(_data->_layerHostingView);
+
+    [_data->_layerHostingView.get() setLayer:nil];
+    [_data->_layerHostingView.get() setWantsLayer:NO];
+    [_data->_layerHostingView.get() removeFromSuperview];
+    
+    _data->_layerHostingView = nullptr;
 }
 
 - (void)_pageDidEnterAcceleratedCompositing
 }
 
 - (void)_pageDidEnterAcceleratedCompositing