Commit cc230861 authored by andersca@apple.com's avatar andersca@apple.com

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

        Reviewed by Adam Roben.

        Make LayerTreeHost an abstract base class and make LayerTreeHostMac inherit from it
        https://bugs.webkit.org/show_bug.cgi?id=53432

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

        * WebProcess/WebPage/DrawingAreaImpl.cpp:
        * WebProcess/WebPage/DrawingAreaImpl.h:
        Make m_layerTreeHost an OwnPtr and initialize/destroy it appropriately.

        * WebProcess/WebPage/LayerTreeHost.cpp:
        (WebKit::LayerTreeHost::create):
        On Mac, create a LayerTreeHostMac instance.

        (WebKit::LayerTreeHost::~LayerTreeHost):
        No need to call platformInvalidate anymore.

        * WebProcess/WebPage/LayerTreeHost.h:
        * WebProcess/WebPage/mac/LayerTreeHostMac.h: Added.
        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
        (WebKit::LayerTreeHostMac::~LayerTreeHostMac):
        Invalidate the run loop observer here instead of in platformInvalidate.

        (WebKit::LayerTreeHostMac::scheduleLayerFlush):
        (WebKit::LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback):
        These are now members of LayerTreeHostMac.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77139 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9503c2a5
2011-01-31 Anders Carlsson <andersca@apple.com>
Reviewed by Adam Roben.
Make LayerTreeHost an abstract base class and make LayerTreeHostMac inherit from it
https://bugs.webkit.org/show_bug.cgi?id=53432
* WebKit2.xcodeproj/project.pbxproj:
Add LayerTreeHostMac.h.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
* WebProcess/WebPage/DrawingAreaImpl.h:
Make m_layerTreeHost an OwnPtr and initialize/destroy it appropriately.
* WebProcess/WebPage/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::create):
On Mac, create a LayerTreeHostMac instance.
(WebKit::LayerTreeHost::~LayerTreeHost):
No need to call platformInvalidate anymore.
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/mac/LayerTreeHostMac.h: Added.
* WebProcess/WebPage/mac/LayerTreeHostMac.mm:
(WebKit::LayerTreeHostMac::~LayerTreeHostMac):
Invalidate the run loop observer here instead of in platformInvalidate.
(WebKit::LayerTreeHostMac::scheduleLayerFlush):
(WebKit::LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback):
These are now members of LayerTreeHostMac.
2011-01-30 Geoffrey Garen <ggaren@apple.com> 2011-01-30 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig. Reviewed by Sam Weinig.
...@@ -143,6 +143,7 @@ ...@@ -143,6 +143,7 @@
1A64256812DE42EC00CAAE2C /* BackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A64256612DE42EC00CAAE2C /* BackingStore.h */; }; 1A64256812DE42EC00CAAE2C /* BackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A64256612DE42EC00CAAE2C /* BackingStore.h */; };
1A64256912DE42EC00CAAE2C /* BackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A64256712DE42EC00CAAE2C /* BackingStore.cpp */; }; 1A64256912DE42EC00CAAE2C /* BackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A64256712DE42EC00CAAE2C /* BackingStore.cpp */; };
1A64292D12DE5F9800CAAE2C /* BackingStoreMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A64292C12DE5F9800CAAE2C /* BackingStoreMac.mm */; }; 1A64292D12DE5F9800CAAE2C /* BackingStoreMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A64292C12DE5F9800CAAE2C /* BackingStoreMac.mm */; };
1A690D1712F39E3300ECD289 /* LayerTreeHostMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A690D1612F39E3300ECD289 /* LayerTreeHostMac.h */; };
1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */; }; 1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */; };
1A6F9FB711E1408500DB1371 /* CommandLineMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */; }; 1A6F9FB711E1408500DB1371 /* CommandLineMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */; };
1A6FA01E11E1526300DB1371 /* WebProcessMainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */; }; 1A6FA01E11E1526300DB1371 /* WebProcessMainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */; };
...@@ -889,6 +890,7 @@ ...@@ -889,6 +890,7 @@
1A64256612DE42EC00CAAE2C /* BackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackingStore.h; sourceTree = "<group>"; }; 1A64256612DE42EC00CAAE2C /* BackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackingStore.h; sourceTree = "<group>"; };
1A64256712DE42EC00CAAE2C /* BackingStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackingStore.cpp; sourceTree = "<group>"; }; 1A64256712DE42EC00CAAE2C /* BackingStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackingStore.cpp; sourceTree = "<group>"; };
1A64292C12DE5F9800CAAE2C /* BackingStoreMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackingStoreMac.mm; sourceTree = "<group>"; }; 1A64292C12DE5F9800CAAE2C /* BackingStoreMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackingStoreMac.mm; sourceTree = "<group>"; };
1A690D1612F39E3300ECD289 /* LayerTreeHostMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTreeHostMac.h; sourceTree = "<group>"; };
1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLine.h; sourceTree = "<group>"; }; 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLine.h; sourceTree = "<group>"; };
1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineMac.cpp; sourceTree = "<group>"; }; 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineMac.cpp; sourceTree = "<group>"; };
1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessMainMac.mm; sourceTree = "<group>"; }; 1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessMainMac.mm; sourceTree = "<group>"; };
...@@ -2575,6 +2577,7 @@ ...@@ -2575,6 +2577,7 @@
29CD55A9128E294F00133C85 /* AccessibilityWebPageObject.mm */, 29CD55A9128E294F00133C85 /* AccessibilityWebPageObject.mm */,
BC5F7BB8118237990052C02C /* ChunkedUpdateDrawingAreaMac.cpp */, BC5F7BB8118237990052C02C /* ChunkedUpdateDrawingAreaMac.cpp */,
0F5265B511DD37700006D33C /* LayerBackedDrawingAreaMac.mm */, 0F5265B511DD37700006D33C /* LayerBackedDrawingAreaMac.mm */,
1A690D1612F39E3300ECD289 /* LayerTreeHostMac.h */,
1A18718412EF9877008E5F37 /* LayerTreeHostMac.mm */, 1A18718412EF9877008E5F37 /* LayerTreeHostMac.mm */,
1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */, 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */,
BC963D6D113DD1A500574BE2 /* WebPageMac.mm */, BC963D6D113DD1A500574BE2 /* WebPageMac.mm */,
...@@ -3115,6 +3118,7 @@ ...@@ -3115,6 +3118,7 @@
BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */, BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */,
1A9636BD12F348490078A062 /* ShareableSurface.h in Headers */, 1A9636BD12F348490078A062 /* ShareableSurface.h in Headers */,
1A9639F712F38ECD0078A062 /* CoreAnimationRenderer.h in Headers */, 1A9639F712F38ECD0078A062 /* CoreAnimationRenderer.h in Headers */,
1A690D1712F39E3300ECD289 /* LayerTreeHostMac.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -56,7 +56,6 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete ...@@ -56,7 +56,6 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete
, m_isWaitingForDidUpdate(false) , m_isWaitingForDidUpdate(false)
, m_isPaintingSuspended(!parameters.isVisible) , m_isPaintingSuspended(!parameters.isVisible)
, m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display) , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display)
, m_layerTreeHost(webPage)
{ {
} }
...@@ -128,14 +127,16 @@ void DrawingAreaImpl::detachCompositingContext() ...@@ -128,14 +127,16 @@ void DrawingAreaImpl::detachCompositingContext()
void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer) void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
{ {
if (graphicsLayer) if (graphicsLayer)
m_layerTreeHost.attachRootCompositingLayer(graphicsLayer); m_layerTreeHost = LayerTreeHost::create(m_webPage, graphicsLayer);
else else
m_layerTreeHost.detachRootCompositingLayer(); m_layerTreeHost = nullptr;
} }
void DrawingAreaImpl::scheduleCompositingLayerSync() void DrawingAreaImpl::scheduleCompositingLayerSync()
{ {
m_layerTreeHost.scheduleLayerFlush(); if (!m_layerTreeHost)
return;
m_layerTreeHost->scheduleLayerFlush();
} }
void DrawingAreaImpl::syncCompositingLayers() void DrawingAreaImpl::syncCompositingLayers()
......
...@@ -78,8 +78,8 @@ private: ...@@ -78,8 +78,8 @@ private:
RunLoop::Timer<DrawingAreaImpl> m_displayTimer; RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
// The layer tree host which handles accelerated compositing. // The layer tree host that handles accelerated compositing.
LayerTreeHost m_layerTreeHost; OwnPtr<LayerTreeHost> m_layerTreeHost;
}; };
} // namespace WebKit } // namespace WebKit
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
#include <WebCore/Page.h> #include <WebCore/Page.h>
#include "WebPage.h" #include "WebPage.h"
#if !PLATFORM(MAC) #if PLATFORM(MAC)
#include "LayerTreeHostMac.h"
#else
#error "This class is not ready for use by other ports yet." #error "This class is not ready for use by other ports yet."
#endif #endif
...@@ -39,24 +41,22 @@ using namespace WebCore; ...@@ -39,24 +41,22 @@ using namespace WebCore;
namespace WebKit { namespace WebKit {
LayerTreeHost::LayerTreeHost(WebPage* webPage) PassOwnPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage, GraphicsLayer* graphicsLayer)
: m_webPage(webPage)
{ {
} #if PLATFORM(MAC)
return adoptPtr(static_cast<LayerTreeHost*>(new LayerTreeHostMac(webPage, graphicsLayer)));
#endif
LayerTreeHost::~LayerTreeHost() return 0;
{
platformInvalidate();
} }
void LayerTreeHost::attachRootCompositingLayer(GraphicsLayer* graphicsLayer) LayerTreeHost::LayerTreeHost(WebPage* webPage)
: m_webPage(webPage)
{ {
// FIXME: Implement.
} }
void LayerTreeHost::detachRootCompositingLayer() LayerTreeHost::~LayerTreeHost()
{ {
// FIXME: Implement.
} }
bool LayerTreeHost::flushPendingLayerChanges() bool LayerTreeHost::flushPendingLayerChanges()
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define LayerTreeHost_h #define LayerTreeHost_h
#include <wtf/Noncopyable.h> #include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC) #if PLATFORM(MAC)
#include <wtf/RetainPtr.h> #include <wtf/RetainPtr.h>
...@@ -44,26 +45,18 @@ class LayerTreeHost { ...@@ -44,26 +45,18 @@ class LayerTreeHost {
WTF_MAKE_NONCOPYABLE(LayerTreeHost); WTF_MAKE_NONCOPYABLE(LayerTreeHost);
public: public:
explicit LayerTreeHost(WebPage*); static PassOwnPtr<LayerTreeHost> create(WebPage*, WebCore::GraphicsLayer*);
~LayerTreeHost(); virtual ~LayerTreeHost();
void attachRootCompositingLayer(WebCore::GraphicsLayer*); virtual void scheduleLayerFlush() = 0;
void detachRootCompositingLayer();
void scheduleLayerFlush(); protected:
explicit LayerTreeHost(WebPage*);
bool flushPendingLayerChanges();
private: private:
void platformInvalidate(); void platformInvalidate();
bool flushPendingLayerChanges();
#if PLATFORM(MAC)
static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
void flushPendingLayerChangesRunLoopObserverCallback();
RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
#endif
WebPage* m_webPage; WebPage* m_webPage;
}; };
......
/*
* 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.
*/
#ifndef LayerTreeHostMac_h
#define LayerTreeHostMac_h
#include "LayerTreeHost.h"
#include <wtf/RetainPtr.h>
namespace WebKit {
class LayerTreeHostMac : public LayerTreeHost {
private:
friend class LayerTreeHost;
explicit LayerTreeHostMac(WebPage*, WebCore::GraphicsLayer*);
~LayerTreeHostMac();
// LayerTreeHost.
virtual void scheduleLayerFlush();
static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
void flushPendingLayerChangesRunLoopObserverCallback();
RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
};
} // namespace WebKit
#endif // LayerTreeHostMac_h
...@@ -24,11 +24,24 @@ ...@@ -24,11 +24,24 @@
*/ */
#import "config.h" #import "config.h"
#import "LayerTreeHost.h" #import "LayerTreeHostMac.h"
using namespace WebCore;
namespace WebKit { namespace WebKit {
void LayerTreeHost::scheduleLayerFlush() LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage, GraphicsLayer* graphicsLayer)
: LayerTreeHost(webPage)
{
}
LayerTreeHostMac::~LayerTreeHostMac()
{
if (m_flushPendingLayerChangesRunLoopObserver)
CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
}
void LayerTreeHostMac::scheduleLayerFlush()
{ {
CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent(); CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
...@@ -46,18 +59,12 @@ void LayerTreeHost::scheduleLayerFlush() ...@@ -46,18 +59,12 @@ void LayerTreeHost::scheduleLayerFlush()
CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes); CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes);
} }
void LayerTreeHost::platformInvalidate() void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
{
if (m_flushPendingLayerChangesRunLoopObserver)
CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
}
void LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
{ {
static_cast<LayerTreeHost*>(context)->flushPendingLayerChangesRunLoopObserverCallback(); static_cast<LayerTreeHostMac*>(context)->flushPendingLayerChangesRunLoopObserverCallback();
} }
void LayerTreeHost::flushPendingLayerChangesRunLoopObserverCallback() void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback()
{ {
if (!flushPendingLayerChanges()) if (!flushPendingLayerChanges())
return; return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment