2009-02-03 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2009 20:14:37 +0000 (20:14 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2009 20:14:37 +0000 (20:14 +0000)
        Reviewed by Dave Hyatt

        https://bugs.webkit.org/show_bug.cgi?id=23365

        Hook up accelerated compositing layers the native
        view system on Mac.

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

19 files changed:
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/page/ChromeClient.h
WebCore/page/FrameView.cpp
WebCore/page/FrameView.h
WebCore/page/Page.cpp
WebCore/page/Page.h
WebCore/rendering/RenderLayerCompositor.cpp
WebCore/rendering/RenderLayerCompositor.h
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebChromeClient.h
WebKit/mac/WebCoreSupport/WebChromeClient.mm
WebKit/mac/WebView/WebHTMLView.mm
WebKit/mac/WebView/WebHTMLViewInternal.h
WebKit/mac/WebView/WebHTMLViewPrivate.h
WebKit/mac/WebView/WebView.mm
WebKit/mac/WebView/WebViewInternal.h

index a3168ed..1f98df5 100644 (file)
@@ -1,3 +1,59 @@
+2009-02-03  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dave Hyatt
+
+        https://bugs.webkit.org/show_bug.cgi?id=23365
+        
+        Hook up accelerated compositing layers the native
+        view system on Mac.
+
+        * WebCore.base.exp:
+        Export new Page methods.
+
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::attachRootGraphicsLayer):
+        (WebCore::ChromeClient::setNeedsOneShotDrawingSynchronization):
+        New methods for attaching/detaching the root GraphicsLayer, and
+        synchronizing layer changes with window drawing.
+
+        * page/FrameView.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateCompositingLayers):
+        (WebCore::FrameView::setNeedsOneShotDrawingSynchronization):
+        (WebCore::FrameView::didMoveOnscreen):
+        (WebCore::FrameView::willMoveOffscreen):
+        New methods to update the compositing layer hierarchy,
+        and pass-throughs to the RenderLayerCompositor.
+
+        (WebCore::FrameView::layout):
+        Update compositing layers after layout() and updateLayerPositions().
+
+        * page/Page.cpp:
+        (WebCore::Page::didMoveOnscreen):
+        (WebCore::Page::willMoveOffscreen):
+        * page/Page.h:
+        New methods to allow the native view system to tell the Page when it 
+        starts to be presented on-screen, and when it will be hidden.
+
+        * rendering/RenderLayerCompositor.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateLayerCompositingState):
+        (WebCore::RenderLayerCompositor::didMoveOnscreen):
+        (WebCore::RenderLayerCompositor::willMoveOffscreen):
+        (WebCore::RenderLayerCompositor::ensureRootPlatformLayer):
+        Rename 'attached' methods to 'moveOnscreen/moveOffscreen' to match
+        the calls through from Page, FrameView.
+
+        (WebCore::RenderLayerCompositor::layerWillBeRemoved):
+        Dont' try to repaint or update layers if the document is being torn
+        down.
+
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::didMoveOnscreen):
+        (WebCore::RenderView::willMoveOffscreen):
+        * rendering/RenderView.h:
+        New methods.
+
 2009-02-03  Dirk Schulze  <krit@webkit.org>
 
         Reviewed by Holger Hans Peter Freyther.
index b07434e..09b9ba4 100644 (file)
@@ -813,6 +813,8 @@ __ZNK7WebCore4Node18getSubresourceURLsERN3WTF11ListHashSetINS_4KURLENS_8KURLHash
 __ZNK7WebCore4Node9nodeIndexEv
 __ZNK7WebCore4Page10pluginDataEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
+__ZN7WebCore4Page17willMoveOffscreenEv
+__ZN7WebCore4Page15didMoveOnscreenEv
 __ZNK7WebCore4Page9groupNameEv
 __ZNK7WebCore5Frame11currentFormEv
 __ZNK7WebCore5Frame11typingStyleEv
index 5d90b2f..aa9b329 100644 (file)
@@ -52,6 +52,10 @@ namespace WebCore {
     struct FrameLoadRequest;
     struct WindowFeatures;
 
+#if USE(ACCELERATED_COMPOSITING)
+    class GraphicsLayer;
+#endif
+
     class ChromeClient {
     public:
         virtual void chromeDestroyed() = 0;
@@ -154,6 +158,14 @@ namespace WebCore {
         // will be called frequently, so handling should be very fast.
         virtual void formStateDidChange(const Node*) = 0;
 
+#if USE(ACCELERATED_COMPOSITING)
+        // Pass 0 as the GraphicsLayer to detatch the root layer.
+        virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) { }
+        // Sets a flag to specify that the next time content is drawn to the window,
+        // the changes appear on the screen in synchrony with updates to GraphicsLayers.
+        virtual void setNeedsOneShotDrawingSynchronization() { }
+#endif
+
 #if PLATFORM(MAC)
         virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; }
 
index 1c14f07..8bbd108 100644 (file)
 #include "Settings.h"
 #include <wtf/CurrentTime.h>
 
+#if USE(ACCELERATED_COMPOSITING)
+#include "RenderLayerCompositor.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -363,6 +367,41 @@ void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, S
     m_viewportRenderer = o;
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+void FrameView::updateCompositingLayers(CompositingUpdate updateType)
+{
+    RenderView* view = m_frame->contentRenderer();
+    if (!view || !view->usesCompositing())
+        return;
+
+    if (updateType == ForcedUpdate)
+        view->compositor()->setCompositingLayersNeedUpdate();
+    
+    view->compositor()->updateCompositingLayers();
+}
+
+void FrameView::setNeedsOneShotDrawingSynchronization()
+{
+    Page* page = frame() ? frame()->page() : 0;
+    if (page)
+        page->chrome()->client()->setNeedsOneShotDrawingSynchronization();
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void FrameView::didMoveOnscreen()
+{
+    RenderView* view = m_frame->contentRenderer();
+    if (view)
+        view->didMoveOnscreen();
+}
+
+void FrameView::willMoveOffscreen()
+{
+    RenderView* view = m_frame->contentRenderer();
+    if (view)
+        view->willMoveOffscreen();
+}
+
 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
 {
     return onlyDuringLayout && layoutPending() ? 0 : m_layoutRoot;
@@ -537,6 +576,10 @@ void FrameView::layout(bool allowSubtree)
     beginDeferredRepaints();
     layer->updateLayerPositions(m_doFullRepaint);
     endDeferredRepaints();
+
+#if USE(ACCELERATED_COMPOSITING)
+    updateCompositingLayers();
+#endif
     
     m_layoutCount++;
 
index eb5e127..69a69af 100644 (file)
@@ -97,6 +97,18 @@ public:
 
     bool needsFullRepaint() const { return m_doFullRepaint; }
 
+#if USE(ACCELERATED_COMPOSITING)
+    enum CompositingUpdate { NormalCompositingUpdate, ForcedCompositingUpdate };
+    void updateCompositingLayers(CompositingUpdate updateType = NormalCompositingUpdate);
+
+    // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
+    // content rendered via the normal painting path.
+    void setNeedsOneShotDrawingSynchronization();
+#endif
+
+    void didMoveOnscreen();
+    void willMoveOffscreen();
+
     void resetScrollbars();
 
     void clear();
index 460183a..19f8c1d 100644 (file)
@@ -409,6 +409,22 @@ void Page::setMediaVolume(float volume)
     }
 }
 
+void Page::didMoveOnscreen()
+{
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (frame->view())
+            frame->view()->didMoveOnscreen();
+    }
+}
+
+void Page::willMoveOffscreen()
+{
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (frame->view())
+            frame->view()->willMoveOffscreen();
+    }
+}
+
 void Page::userStyleSheetLocationChanged()
 {
 #if !FRAME_LOADS_USER_STYLESHEET
index aea16a2..57b191a 100644 (file)
@@ -153,6 +153,10 @@ namespace WebCore {
         float mediaVolume() const { return m_mediaVolume; }
         void setMediaVolume(float volume);
 
+        // Notifications when the Page starts and stops being presented via a native window.
+        void didMoveOnscreen();
+        void willMoveOffscreen();
+
         void userStyleSheetLocationChanged();
         const String& userStyleSheet() const;
         
index 6e821c7..2bd85c2 100644 (file)
@@ -179,7 +179,7 @@ bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Rend
             // The contents of this layer may be moving between the window
             // and a GraphicsLayer, so we need to make sure the window system
             // synchronizes those changes on the screen.
-            m_renderView->frameView()->setNeedsSynchronizedGraphicsFlush();
+            m_renderView->frameView()->setNeedsOneShotDrawingSynchronization();
         }
 
         layer->renderer()->compositingStateChanged();
@@ -267,13 +267,18 @@ void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer*
     if (child->isComposited())
         setCompositingParent(child, 0);
     
+    // If the document is being torn down (document's renderer() is null), then there's
+    // no need to do any layer updating.
+    if (parent->renderer()->documentBeingDestroyed())
+        return;
+
     RenderLayer* compLayer = enclosingCompositingLayer(parent, false);
     if (compLayer) {
         IntRect ancestorRect = calculateCompositedBounds(child, compLayer);
         compLayer->setBackingNeedsRepaintInRect(ancestorRect);
         // The contents of this layer may be moving from a GraphicsLayer to the window,
         // so we need to make sure the window system synchronizes those changes on the screen.
-        m_renderView->frameView()->setNeedsSynchronizedGraphicsFlush();
+        m_renderView->frameView()->setNeedsOneShotDrawingSynchronization();
     }
 
     setCompositingLayersNeedUpdate();
@@ -585,9 +590,9 @@ GraphicsLayer* RenderLayerCompositor::rootPlatformLayer() const
     return m_rootPlatformLayer;
 }
 
-void RenderLayerCompositor::willBeDetached()
+void RenderLayerCompositor::didMoveOnscreen()
 {
-    if (!m_rootPlatformLayer ||! m_rootLayerAttached)
+    if (!m_rootPlatformLayer)
         return;
 
     Frame* frame = m_renderView->frameView()->frame();
@@ -595,13 +600,13 @@ void RenderLayerCompositor::willBeDetached()
     if (!page)
         return;
 
-    page->chrome()->client()->attachRootGraphicsLayer(frame, 0);
-    m_rootLayerAttached = false;
+    page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer);
+    m_rootLayerAttached = true;
 }
 
-void RenderLayerCompositor::wasAttached()
+void RenderLayerCompositor::willMoveOffscreen()
 {
-    if (!m_rootPlatformLayer)
+    if (!m_rootPlatformLayer || !m_rootLayerAttached)
         return;
 
     Frame* frame = m_renderView->frameView()->frame();
@@ -609,8 +614,8 @@ void RenderLayerCompositor::wasAttached()
     if (!page)
         return;
 
-    page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer);
-    m_rootLayerAttached = true;
+    page->chrome()->client()->attachRootGraphicsLayer(frame, 0);
+    m_rootLayerAttached = false;
 }
 
 void RenderLayerCompositor::updateRootLayerPosition()
@@ -742,7 +747,7 @@ void RenderLayerCompositor::ensureRootPlatformLayer()
     // Need to clip to prevent transformed content showing outside this frame
     m_rootPlatformLayer->setMasksToBounds(true);
     
-    wasAttached();
+    didMoveOnscreen();
 }
 
 } // namespace WebCore
index 060f478..12a1609 100644 (file)
@@ -83,8 +83,9 @@ public:
     RenderLayer* rootRenderLayer() const;
     GraphicsLayer* rootPlatformLayer() const;
 
-    void willBeDetached();
-    void wasAttached();
+    void didMoveOnscreen();
+    void willMoveOffscreen();
+
     void updateRootLayerPosition();
 
 private:
index 8e6fce2..efe360d 100644 (file)
@@ -626,4 +626,14 @@ void RenderView::updateHitTestResult(HitTestResult& result, const IntPoint& poin
     }
 }
 
+void RenderView::didMoveOnscreen()
+{
+    // FIXME: will call into RenderLayerCompositor
+}
+
+void RenderView::willMoveOffscreen()
+{
+    // FIXME: will call into RenderLayerCompositor
+}
+
 } // namespace WebCore
index d9c2a15..46ec4d0 100644 (file)
@@ -146,6 +146,9 @@ public:
 
     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
 
+    void didMoveOnscreen();
+    void willMoveOffscreen();
+
 protected:
     virtual FloatQuad localToContainerQuad(const FloatQuad&, RenderBox* repaintContainer, bool fixed = false) const;
 
index b0f231d..8b840de 100644 (file)
@@ -1,3 +1,58 @@
+2009-02-03  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dave Hyatt
+
+        https://bugs.webkit.org/show_bug.cgi?id=23365
+        
+        Hook up accelerated compositing layers the native
+        view system on Mac.
+
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::attachRootGraphicsLayer):
+        (WebChromeClient::setNeedsOneShotDrawingSynchronization):
+        New methods to hook up the root GraphicsLayer to the native
+        view system, and to synchronize layer changes with view-based
+        drawing when layers come and go.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLViewPrivate clear]):
+        Clear the pointer to layerHostingView.
+
+        (-[WebHTMLView _setAsideSubviews]):
+        (-[WebHTMLView willRemoveSubview:]):
+        Keep the special layer-hosting view in the subviews even 
+        when the rest of the subviews are ripped out for
+        painting.
+
+        (-[WebHTMLView _isUsingAcceleratedCompositing]):
+        New utility method for DumpRenderTree to know if we're
+        hosting layers.
+
+        (-[WebHTMLView drawRect:]):
+        Call -disableScreenUpdatesUntilFlush if we have to
+        synchronize layer changes with painting.
+
+        (-[WebHTMLView attachRootLayer:]):
+        (-[WebHTMLView detachRootLayer]):
+        Attach and detach the root GraphicsLayer.
+
+        * WebView/WebViewInternal.h:
+        * WebView/WebHTMLViewInternal.h:
+        * WebView/WebHTMLViewPrivate.h:
+        New method declarations.
+        
+        * WebView/WebView.mm:
+        (-[WebView _needsOneShotDrawingSynchronization]):
+        (-[WebView _setNeedsOneShotDrawingSynchronization:]):
+        Set the flag to say if we need to synchronize layer
+        changes and painting on the next -drawRect: call.
+
+        (-[WebView viewWillMoveToWindow:]):
+        (-[WebView viewDidMoveToWindow]):
+        Call new notifications that the view was added to or removed from
+        the window, which are required by the layer hosting mechanism.
+
 2009-02-02  Geoffrey Garen  <ggaren@apple.com>
 
         Build fix.
index 29a4c25..21b5a58 100644 (file)
@@ -135,6 +135,11 @@ public:
     virtual void disableSuddenTermination();
     virtual void formStateDidChange(const WebCore::Node*) { }
 
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
+    virtual void setNeedsOneShotDrawingSynchronization();
+#endif
+
 private:
     WebView *m_webView;
 };
index 6b5d138..b5a7543 100644 (file)
 #import <wtf/PassRefPtr.h>
 #import <wtf/Vector.h>
 
+#if USE(ACCELERATED_COMPOSITING)
+#import <WebCore/GraphicsLayer.h>
+#endif
+
 @interface NSView (WebNSViewDetails)
 - (NSView *)_findLastViewInKeyViewLoop;
 @end
@@ -643,6 +647,23 @@ void WebChromeClient::enableSuddenTermination()
 #endif
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
+{
+    WebFrameView *frameView = [kit(frame) frameView];
+    WebHTMLView *docView = (WebHTMLView *)[frameView documentView];
+    if (graphicsLayer)
+        [docView attachRootLayer:graphicsLayer->nativeLayer()];
+    else
+        [docView detachRootLayer];
+}
+
+void WebChromeClient::setNeedsOneShotDrawingSynchronization()
+{
+    [m_webView _setNeedsOneShotDrawingSynchronization:YES];
+}
+#endif
+
 @implementation WebOpenPanelResultListener
 
 - (id)initWithChooser:(PassRefPtr<FileChooser>)chooser
index 27a5d6e..9dda1e3 100644 (file)
 #import <limits>
 #import <runtime/InitializeThreading.h>
 
+#if USE(ACCELERATED_COMPOSITING)
+#import <QuartzCore/QuartzCore.h>
+#endif
+
 using namespace WebCore;
 using namespace HTMLNames;
 using namespace WTF;
@@ -380,6 +384,10 @@ struct WebHTMLViewInterpretKeyEventsParameters {
     
     id savedSubviews;
     BOOL subviewsSetAside;
+    
+#if USE(ACCELERATED_COMPOSITING)
+    NSView *layerHostingView;
+#endif
 
     NSEvent *mouseDownEvent; // Kept after handling the event.
     BOOL handlingMouseDownEvent;
@@ -528,6 +536,10 @@ static NSCellStateValue kit(TriState state)
     dataSource = nil;
     highlighters = nil;
     promisedDragTIFFDataSource = 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+    layerHostingView = nil;
+#endif    
 }
 
 @end
@@ -1136,15 +1148,34 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
     ASSERT(!_private->subviewsSetAside);
     ASSERT(_private->savedSubviews == nil);
     _private->savedSubviews = _subviews;
+#if USE(ACCELERATED_COMPOSITING)
+    // We need to keep the layer-hosting view in the subviews, otherwise the layers flash.
+    if (_private->layerHostingView) {
+        NSArray* newSubviews = [[NSArray alloc] initWithObjects:_private->layerHostingView, nil];
+        _subviews = newSubviews;
+    } else
+        _subviews = nil;
+#else
     _subviews = nil;
+#endif    
     _private->subviewsSetAside = YES;
  }
  
  - (void)_restoreSubviews
  {
     ASSERT(_private->subviewsSetAside);
+#if USE(ACCELERATED_COMPOSITING)
+    if (_private->layerHostingView) {
+        [_subviews release];
+        _subviews = _private->savedSubviews;
+    } else {
+        ASSERT(_subviews == nil);
+        _subviews = _private->savedSubviews;
+    }
+#else
     ASSERT(_subviews == nil);
     _subviews = _private->savedSubviews;
+#endif    
     _private->savedSubviews = nil;
     _private->subviewsSetAside = NO;
 }
@@ -1159,7 +1190,9 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
 
 - (void)willRemoveSubview:(NSView *)subview
 {
-    if (_private->enumeratingSubviews)
+    // Have to null-check _private, since this can be called via -dealloc when
+    // cleaning up the the layerHostingView.
+    if (_private && _private->enumeratingSubviews)
         LOG(View, "A view of class %s was removed during subview enumeration for layout or printing mode change. We will still do layout or the printing mode change even though this view is no longer in the view hierarchy.", object_getClassName([subview class]));
 }
 
@@ -2071,6 +2104,15 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
 } 
 #endif 
 
+- (BOOL)_isUsingAcceleratedCompositing
+{
+#if USE(ACCELERATED_COMPOSITING)
+    return _private->layerHostingView != nil;
+#else
+    return NO;
+#endif
+}
+
 @end
 
 @implementation NSView (WebHTMLViewFileInternal)
@@ -3021,6 +3063,16 @@ static void _updateFocusedAndActiveStateTimerCallback(CFRunLoopTimerRef timer, v
 
     if (subviewsWereSetAside)
         [self _setAsideSubviews];
+        
+#if USE(ACCELERATED_COMPOSITING)
+    if ([[self _webView] _needsOneShotDrawingSynchronization]) {
+        // Disable screen updates so that drawing into the NSView and
+        // CALayer updates appear on the screen at the same time.
+        [[self window] disableScreenUpdatesUntilFlush];
+        [CATransaction flush];
+        [[self _webView] _setNeedsOneShotDrawingSynchronization:NO];
+    }
+#endif
 }
 
 // Turn off the additional clip while computing our visibleRect.
@@ -4973,6 +5025,38 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
     [[self _pluginController] destroyAllPlugins];
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+- (void)attachRootLayer:(CALayer*)layer
+{
+    if (!_private->layerHostingView) {
+        NSView* hostingView = [[NSView alloc] initWithFrame:[self bounds]];
+        [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+        [self addSubview:hostingView];
+        [hostingView release];
+        // hostingView is owned by being a subview of self
+        _private->layerHostingView = hostingView;
+    }
+
+    // Make a container layer, which will get sized/positioned by AppKit and CA
+    CALayer* viewLayer = [CALayer layer];
+    [_private->layerHostingView setLayer:viewLayer];
+    [_private->layerHostingView setWantsLayer:YES];
+    
+    // Parent our root layer in the container layer
+    [viewLayer addSublayer:layer];
+}
+
+- (void)detachRootLayer
+{
+    if (_private->layerHostingView) {
+        [_private->layerHostingView setLayer:nil];
+        [_private->layerHostingView setWantsLayer:NO];
+        [_private->layerHostingView removeFromSuperview];
+        _private->layerHostingView = nil;
+    }
+}
+#endif
+
 @end
 
 @implementation WebHTMLView (WebNSTextInputSupport)
index 0fb0cdc..a984a2c 100644 (file)
@@ -58,4 +58,10 @@ namespace WebCore {
 - (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source;
 - (void)_web_layoutIfNeededRecursive;
 - (void)_destroyAllWebPlugins;
+
+#if USE(ACCELERATED_COMPOSITING)
+- (void)attachRootLayer:(CALayer*)layer;
+- (void)detachRootLayer;
+#endif
+
 @end
index 40de97f..0d73884 100644 (file)
 
 // SPI for DumpRenderTree
 - (void)_updateFocusedAndActiveState;
+- (BOOL)_isUsingAcceleratedCompositing;
 
 // SPI for printing (should be converted to API someday). When the WebHTMLView isn't being printed
 // directly, this method must be called before paginating, or the computed height might be incorrect.
index 44c5034..373bd7a 100644 (file)
@@ -406,6 +406,12 @@ static const char webViewIsOpen[] = "At least one WebView is still open.";
     
     // When this flag is set, we will not make any subviews underneath this WebView.  This means no WebFrameViews and no WebHTMLViews.
     BOOL useDocumentViews;
+
+#if USE(ACCELERATED_COMPOSITING)
+    // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates
+    // so that the NSView drawing is visually synchronized with CALayer updates.
+    BOOL needsOneShotDrawingSynchronization;
+#endif    
 }
 @end
 
@@ -2069,6 +2075,18 @@ WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementati
     return _private->page->areMemoryCacheClientCallsEnabled();
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+- (BOOL)_needsOneShotDrawingSynchronization
+{
+    return _private->needsOneShotDrawingSynchronization;
+}
+
+- (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization
+{
+    _private->needsOneShotDrawingSynchronization = needsSynchronization;
+}
+#endif    
+
 @end
 
 @implementation _WebSafeForwarder
@@ -2498,7 +2516,8 @@ static bool needsWebViewInitThreadWorkaround()
         
         [self removeWindowObservers];
         [self removeSizeObservers];
-    }
+    } else
+        _private->page->willMoveOffscreen();
 }
 
 - (void)viewDidMoveToWindow
@@ -2513,6 +2532,7 @@ static bool needsWebViewInitThreadWorkaround()
     if ([self window]) {
         [self addWindowObservers];
         [self addSizeObservers];
+        _private->page->didMoveOnscreen();
     }
 }
 
index 25afb64..a2d0f79 100644 (file)
@@ -145,6 +145,11 @@ typedef WebCore::Page WebCorePage;
 
 + (BOOL)_canHandleRequest:(NSURLRequest *)request forMainFrame:(BOOL)forMainFrame;
 
+#if USE(ACCELERATED_COMPOSITING)
+- (BOOL)_needsOneShotDrawingSynchronization;
+- (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization;
+#endif    
+
 @end
 
 typedef struct _WebResourceDelegateImplementationCache {