Commit a60ce714 authored by aroben@apple.com's avatar aroben@apple.com
Browse files

Make WKCACFLayerRenderer ref-counted

This will be needed to handle cases where the client might release its reference to us while
we're calling out to it.

WKCACFLayerRenderer now has a setClient function, which is used rather than passing the
client to create(). This allows clients to null out the client pointer when they're done
with the renderer.

Fixes <http://webkit.org/b/52749> WKCACFLayerRenderer should be
ref-counted

Reviewed by Simon Fraser.

Source/WebCore:

* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
(WebCore::MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow):
* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
Updated for WKCACFLayerRenderer changes.

* platform/graphics/win/WKCACFLayerRenderer.cpp:
(WebCore::WKCACFLayerRenderer::acceleratedCompositingAvailable): Updated for changes to
create().
(WebCore::WKCACFLayerRenderer::create): No longer takes a WKCACFLayerRendererClient. Now
returns a PassOwnPtr.
(WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer): No longer takes a
WKCACFLayerRendererClient.

* platform/graphics/win/WKCACFLayerRenderer.h: Made WKCACFLayerRenderer inherit from
RefCounted.
(WebCore::WKCACFLayerRenderer::setClient): Added this simple setter.

Source/WebKit/win:

Update for WKCACFLayerRenderer changes

* WebView.cpp:
(WebView::~WebView): Added some assertions to make sure we've gotten rid of our
compositing-related members. My biggest concern was making sure that m_layerRenderer was
gone, which would also mean we had nulled out its client pointer.
(WebView::setAcceleratedCompositing): Changed to call WKCACFLayerRenderer::setClient instead
of passing the client into create(), and to clear out the client before nulling out
m_layerRenderer.

* WebView.h: Changed m_layerRenderer from an OwnPtr to a RefPtr.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76256 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 16f98219
2011-01-19 Adam Roben <aroben@apple.com>
Make WKCACFLayerRenderer ref-counted
This will be needed to handle cases where the client might release its reference to us while
we're calling out to it.
WKCACFLayerRenderer now has a setClient function, which is used rather than passing the
client to create(). This allows clients to null out the client pointer when they're done
with the renderer.
Fixes <http://webkit.org/b/52749> WKCACFLayerRenderer should be
ref-counted
Reviewed by Simon Fraser.
* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
(WebCore::MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow):
* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
Updated for WKCACFLayerRenderer changes.
* platform/graphics/win/WKCACFLayerRenderer.cpp:
(WebCore::WKCACFLayerRenderer::acceleratedCompositingAvailable): Updated for changes to
create().
(WebCore::WKCACFLayerRenderer::create): No longer takes a WKCACFLayerRendererClient. Now
returns a PassOwnPtr.
(WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer): No longer takes a
WKCACFLayerRendererClient.
* platform/graphics/win/WKCACFLayerRenderer.h: Made WKCACFLayerRenderer inherit from
RefCounted.
(WebCore::WKCACFLayerRenderer::setClient): Added this simple setter.
2011-01-20 Csaba Osztrogonác <ossy@webkit.org>
 
[Qt][V8] Unreviewed buildfix after r76248.
......@@ -40,7 +40,7 @@ MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlay
: m_client(client)
, m_hwnd(0)
#if USE(ACCELERATED_COMPOSITING)
, m_layerRenderer(WKCACFLayerRenderer::create(0))
, m_layerRenderer(WKCACFLayerRenderer::create())
#endif
{
}
......
......@@ -30,7 +30,6 @@
#include "PlatformCALayer.h"
#include "WKCACFLayerRenderer.h"
#endif
#include <wtf/OwnPtr.h>
typedef unsigned WPARAM;
typedef long LPARAM;
......@@ -71,7 +70,7 @@ private:
MediaPlayerPrivateFullscreenClient* m_client;
#if USE(ACCELERATED_COMPOSITING)
OwnPtr<WKCACFLayerRenderer> m_layerRenderer;
RefPtr<WKCACFLayerRenderer> m_layerRenderer;
RefPtr<PlatformCALayer> m_rootChild;
#endif
HWND m_hwnd;
......
......@@ -165,7 +165,7 @@ bool WKCACFLayerRenderer::acceleratedCompositingAvailable()
return available;
}
OwnPtr<WKCACFLayerRenderer> testLayerRenderer = WKCACFLayerRenderer::create(0);
RefPtr<WKCACFLayerRenderer> testLayerRenderer = WKCACFLayerRenderer::create();
testLayerRenderer->setHostWindow(testWindow);
available = testLayerRenderer->createRenderer();
::DestroyWindow(testWindow);
......@@ -173,15 +173,15 @@ bool WKCACFLayerRenderer::acceleratedCompositingAvailable()
return available;
}
PassOwnPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create(WKCACFLayerRendererClient* client)
PassRefPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create()
{
if (!acceleratedCompositingAvailable())
return 0;
return new WKCACFLayerRenderer(client);
return adoptRef(new WKCACFLayerRenderer());
}
WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client)
: m_client(client)
WKCACFLayerRenderer::WKCACFLayerRenderer()
: m_client(0)
, m_mightBeAbleToCreateDeviceLater(true)
, m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0))
, m_context(wkCACFContextCreate())
......
......@@ -32,9 +32,8 @@
#include "Timer.h"
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
......@@ -60,16 +59,17 @@ public:
// FIXME: Currently there is a WKCACFLayerRenderer for each WebView and each
// has its own CARenderOGLContext and Direct3DDevice9, which is inefficient.
// (https://bugs.webkit.org/show_bug.cgi?id=31855)
class WKCACFLayerRenderer {
WTF_MAKE_NONCOPYABLE(WKCACFLayerRenderer);
class WKCACFLayerRenderer : public RefCounted<WKCACFLayerRenderer> {
friend PlatformCALayer;
public:
static PassOwnPtr<WKCACFLayerRenderer> create(WKCACFLayerRendererClient*);
static PassRefPtr<WKCACFLayerRenderer> create();
~WKCACFLayerRenderer();
static bool acceleratedCompositingAvailable();
void setClient(WKCACFLayerRendererClient* client) { m_client = client; }
void setRootChildLayer(PlatformCALayer*);
void layerTreeDidChange();
void setHostWindow(HWND);
......@@ -82,7 +82,7 @@ protected:
void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
private:
WKCACFLayerRenderer(WKCACFLayerRendererClient*);
WKCACFLayerRenderer();
bool createRenderer();
void destroyRenderer();
......
2011-01-19 Adam Roben <aroben@apple.com>
Update for WKCACFLayerRenderer changes
Fixes <http://webkit.org/b/52749> WKCACFLayerRenderer should be
ref-counted
Reviewed by Simon Fraser.
* WebView.cpp:
(WebView::~WebView): Added some assertions to make sure we've gotten rid of our
compositing-related members. My biggest concern was making sure that m_layerRenderer was
gone, which would also mean we had nulled out its client pointer.
(WebView::setAcceleratedCompositing): Changed to call WKCACFLayerRenderer::setClient instead
of passing the client into create(), and to clear out the client before nulling out
m_layerRenderer.
* WebView.h: Changed m_layerRenderer from an OwnPtr to a RefPtr.
2011-01-19 Adam Roben <aroben@apple.com>
Teach WebView::scrollBackingStore about compositing mode
......
......@@ -387,6 +387,11 @@ WebView::~WebView()
ASSERT(!m_preferences);
ASSERT(!m_viewWindow);
#if USE(ACCELERATED_COMPOSITING)
ASSERT(!m_layerRenderer);
ASSERT(!m_backingLayer);
#endif
WebViewCount--;
gClassCount--;
gClassNameCount.remove("WebView");
......@@ -6280,11 +6285,11 @@ void WebView::setAcceleratedCompositing(bool accelerated)
return;
if (accelerated) {
m_layerRenderer = WKCACFLayerRenderer::create(this);
m_layerRenderer = WKCACFLayerRenderer::create();
if (m_layerRenderer) {
m_isAcceleratedCompositing = true;
// Create the root layer
m_layerRenderer->setClient(this);
ASSERT(m_viewWindow);
m_layerRenderer->setHostWindow(m_viewWindow);
......@@ -6307,6 +6312,8 @@ void WebView::setAcceleratedCompositing(bool accelerated)
deleteBackingStoreSoon();
}
} else {
ASSERT(m_layerRenderer);
m_layerRenderer->setClient(0);
m_layerRenderer = 0;
m_backingLayer = 0;
m_isAcceleratedCompositing = false;
......
......@@ -1056,7 +1056,7 @@ protected:
bool isAcceleratedCompositing() const { return m_isAcceleratedCompositing; }
void setAcceleratedCompositing(bool);
OwnPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer;
RefPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer;
OwnPtr<WebCore::GraphicsLayer> m_backingLayer;
bool m_isAcceleratedCompositing;
#endif
......
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