Skip to content
Permalink
Browse files
2011-01-25 Anders Carlsson <andersca@apple.com>
        Reviewed by Adam Roben.

        Add and implement LayerTreeHost::scheduleLayerFlush
        https://bugs.webkit.org/show_bug.cgi?id=53135

        * WebKit2.xcodeproj/project.pbxproj:
        Add LayerTreeHostMac.mm.

        * WebProcess/WebPage/DrawingAreaImpl.cpp:
        (WebKit::DrawingAreaImpl::scheduleCompositingLayerSync):
        Call LayerTreeHost::scheduleLayerFlush.

        * WebProcess/WebPage/LayerTreeHost.cpp:
        (WebKit::LayerTreeHost::~LayerTreeHost):
        Call platformInvalidate().

        (WebKit::LayerTreeHost::flushPendingLayerChanges):
        Rename from syncCompositingLayers.

        * WebProcess/WebPage/mac/LayerTreeHostMac.mm: Added.
        (WebKit::LayerTreeHost::scheduleLayerFlush):
        Create a run loop observer if needed. This code is copied from LayerBackedDrawingAreaMac.mm

        (WebKit::LayerTreeHost::platformInvalidate):
        Invalidate the run loop observer.

        (WebKit::LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback):
        Call flushPendingChanges() and remove the run loop observer if it succeeded.


Canonical link: https://commits.webkit.org/66877@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76653 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jan 26, 2011
1 parent 52b5bc3 commit 1b325aff67a5a7c7f308a8122993220d75a4536b
Showing 6 changed files with 121 additions and 3 deletions.
@@ -1,3 +1,34 @@
2011-01-25 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Roben.

Add and implement LayerTreeHost::scheduleLayerFlush
https://bugs.webkit.org/show_bug.cgi?id=53135

* WebKit2.xcodeproj/project.pbxproj:
Add LayerTreeHostMac.mm.

* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::scheduleCompositingLayerSync):
Call LayerTreeHost::scheduleLayerFlush.

* WebProcess/WebPage/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::~LayerTreeHost):
Call platformInvalidate().

(WebKit::LayerTreeHost::flushPendingLayerChanges):
Rename from syncCompositingLayers.

* WebProcess/WebPage/mac/LayerTreeHostMac.mm: Added.
(WebKit::LayerTreeHost::scheduleLayerFlush):
Create a run loop observer if needed. This code is copied from LayerBackedDrawingAreaMac.mm

(WebKit::LayerTreeHost::platformInvalidate):
Invalidate the run loop observer.

(WebKit::LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback):
Call flushPendingChanges() and remove the run loop observer if it succeeded.

2011-01-25 Anders Carlsson <andersca@apple.com>

Reviewed by Simon Fraser.
@@ -69,6 +69,7 @@
1A119A95127B796200A9ECB1 /* MessageSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119A94127B796200A9ECB1 /* MessageSender.h */; };
1A186EEA12EF7618008E5F37 /* LayerTreeHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A186EE812EF7618008E5F37 /* LayerTreeHost.h */; };
1A186EEB12EF7618008E5F37 /* LayerTreeHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A186EE912EF7618008E5F37 /* LayerTreeHost.cpp */; };
1A18718512EF9877008E5F37 /* LayerTreeHostMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A18718412EF9877008E5F37 /* LayerTreeHostMac.mm */; };
1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C648611F415B700553C19 /* WebContextMac.mm */; };
1A1FA285127A13BC0050E709 /* NPObjectProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1FA284127A13BC0050E709 /* NPObjectProxy.cpp */; };
@@ -799,6 +800,7 @@
1A119A94127B796200A9ECB1 /* MessageSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSender.h; sourceTree = "<group>"; };
1A186EE812EF7618008E5F37 /* LayerTreeHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTreeHost.h; sourceTree = "<group>"; };
1A186EE912EF7618008E5F37 /* LayerTreeHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayerTreeHost.cpp; sourceTree = "<group>"; };
1A18718412EF9877008E5F37 /* LayerTreeHostMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayerTreeHostMac.mm; sourceTree = "<group>"; };
1A1C648611F415B700553C19 /* WebContextMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMac.mm; sourceTree = "<group>"; };
1A1FA251127A0E4F0050E709 /* NPRemoteObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRemoteObjectMap.h; sourceTree = "<group>"; };
1A1FA252127A0E4F0050E709 /* NPRemoteObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRemoteObjectMap.cpp; sourceTree = "<group>"; };
@@ -2545,6 +2547,7 @@
29CD55A9128E294F00133C85 /* AccessibilityWebPageObject.mm */,
BC5F7BB8118237990052C02C /* ChunkedUpdateDrawingAreaMac.cpp */,
0F5265B511DD37700006D33C /* LayerBackedDrawingAreaMac.mm */,
1A18718412EF9877008E5F37 /* LayerTreeHostMac.mm */,
1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */,
BC963D6D113DD1A500574BE2 /* WebPageMac.mm */,
);
@@ -3544,6 +3547,7 @@
C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
E134F01A12EA5D99004EC58D /* WKPrintingView.mm in Sources */,
1A186EEB12EF7618008E5F37 /* LayerTreeHost.cpp in Sources */,
1A18718512EF9877008E5F37 /* LayerTreeHostMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -134,6 +134,7 @@ void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)

void DrawingAreaImpl::scheduleCompositingLayerSync()
{
m_layerTreeHost.scheduleLayerFlush();
}

void DrawingAreaImpl::syncCompositingLayers()
@@ -45,6 +45,7 @@ LayerTreeHost::LayerTreeHost(WebPage* webPage)

LayerTreeHost::~LayerTreeHost()
{
platformInvalidate();
}

void LayerTreeHost::attachRootCompositingLayer(GraphicsLayer* graphicsLayer)
@@ -57,7 +58,7 @@ void LayerTreeHost::detachRootCompositingLayer()
// FIXME: Implement.
}

bool LayerTreeHost::syncCompositingLayers()
bool LayerTreeHost::flushPendingLayerChanges()
{
return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
}
@@ -50,10 +50,21 @@ class LayerTreeHost {
void attachRootCompositingLayer(WebCore::GraphicsLayer*);
void detachRootCompositingLayer();

void scheduleLayerFlush();

private:
WebPage* m_webPage;
void platformInvalidate();

bool syncCompositingLayers();
bool flushPendingLayerChanges();

#if PLATFORM(MAC)
static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
void flushPendingLayerChangesRunLoopObserverCallback();

RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
#endif

WebPage* m_webPage;
};

} // namespace WebKit
@@ -0,0 +1,70 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "LayerTreeHost.h"

namespace WebKit {

void LayerTreeHost::scheduleLayerFlush()
{
CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();

// Make sure we wake up the loop or the observer could be delayed until some other source fires.
CFRunLoopWakeUp(currentRunLoop);

if (m_flushPendingLayerChangesRunLoopObserver)
return;

// Run before the Core Animation commit observer, which has order 2000000.
const CFIndex runLoopOrder = 2000000 - 1;
CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
m_flushPendingLayerChangesRunLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, runLoopOrder, flushPendingLayerChangesRunLoopObserverCallback, &context));

CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes);
}

void LayerTreeHost::platformInvalidate()
{
if (m_flushPendingLayerChangesRunLoopObserver)
CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
}

void LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
{
static_cast<LayerTreeHost*>(context)->flushPendingLayerChangesRunLoopObserverCallback();
}

void LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback()
{
if (!flushPendingLayerChanges())
return;

// We successfully flushed the pending layer changes, remove the run loop observer.
ASSERT(m_flushPendingLayerChangesRunLoopObserver);
CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
m_flushPendingLayerChangesRunLoopObserver = 0;
}

} // namespace WebKit

0 comments on commit 1b325af

Please sign in to comment.