diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/graphics/ca | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/graphics/ca')
9 files changed, 118 insertions, 32 deletions
diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp index 427c7bf..8fb4c9f 100644 --- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp +++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp @@ -255,6 +255,7 @@ GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client) , m_contentsLayerHasBackgroundColor(false) , m_uncommittedChanges(NoChange) , m_contentsScale(1) + , m_allowTiledLayer(true) { m_layer = PlatformCALayer::create(PlatformCALayer::LayerTypeWebLayer, this); @@ -492,6 +493,17 @@ void GraphicsLayerCA::setAcceleratesDrawing(bool acceleratesDrawing) noteLayerPropertyChanged(AcceleratesDrawingChanged); } +void GraphicsLayerCA::setAllowTiledLayer(bool allowTiledLayer) +{ + if (allowTiledLayer == m_allowTiledLayer) + return; + + m_allowTiledLayer = allowTiledLayer; + + // Handling this as a SizeChanged will cause use to switch in or out of tiled layer as needed + noteLayerPropertyChanged(SizeChanged); +} + void GraphicsLayerCA::setBackgroundColor(const Color& color) { if (m_backgroundColorSet && m_backgroundColor == color) @@ -2005,7 +2017,7 @@ FloatSize GraphicsLayerCA::constrainedSize() const bool GraphicsLayerCA::requiresTiledLayer(const FloatSize& size) const { - if (!m_drawsContent) + if (!m_drawsContent || !m_allowTiledLayer) return false; // FIXME: catch zero-size height or width here (or earlier)? diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h index 2c39c0a..3f2d3e4 100644 --- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h +++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h @@ -122,6 +122,9 @@ public: virtual void syncCompositingState(); virtual void syncCompositingStateForThisLayerOnly(); + bool allowTiledLayer() const { return m_allowTiledLayer; } + virtual void setAllowTiledLayer(bool b); + protected: virtual void setOpacityInternal(float); @@ -399,6 +402,8 @@ private: float clampedContentsScaleForScale(float) const; float m_contentsScale; + + bool m_allowTiledLayer; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/ca/TransformationMatrixCA.cpp b/Source/WebCore/platform/graphics/ca/TransformationMatrixCA.cpp index 0ef5fd0..e5ff5ba 100644 --- a/Source/WebCore/platform/graphics/ca/TransformationMatrixCA.cpp +++ b/Source/WebCore/platform/graphics/ca/TransformationMatrixCA.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "TransformationMatrix.h" -#if PLATFORM(CA) +#if USE(CA) #include "FloatConversion.h" #include <QuartzCore/CATransform3D.h> @@ -66,4 +66,4 @@ TransformationMatrix::operator CATransform3D() const } -#endif // PLATFORM(CA) +#endif // USE(CA) diff --git a/Source/WebCore/platform/graphics/ca/win/AbstractCACFLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/AbstractCACFLayerTreeHost.h new file mode 100644 index 0000000..13c6746 --- /dev/null +++ b/Source/WebCore/platform/graphics/ca/win/AbstractCACFLayerTreeHost.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009, 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. ``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 COMPUTER, INC. OR + * 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 AbstractCACFLayerTreeHost_h +#define AbstractCACFLayerTreeHost_h + +#if USE(ACCELERATED_COMPOSITING) + +#include <wtf/Forward.h> + +namespace WebCore { + +class PlatformCALayer; + +class AbstractCACFLayerTreeHost { +public: + virtual PlatformCALayer* rootLayer() const = 0; + virtual void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>) = 0; + virtual void layerTreeDidChange() = 0; + virtual void flushPendingLayerChangesNow() = 0; + +protected: + virtual ~AbstractCACFLayerTreeHost() { } +}; + +} + +#endif // USE(ACCELERATED_COMPOSITING) + +#endif // AbstractCACFLayerTreeHost_h diff --git a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h index 6d91a73..507af0f 100644 --- a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h @@ -28,6 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) +#include "AbstractCACFLayerTreeHost.h" #include "COMPtr.h" #include "Timer.h" @@ -50,9 +51,7 @@ namespace WebCore { class CACFLayerTreeHostClient; class PlatformCALayer; -class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost> { - friend PlatformCALayer; - +class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost>, private AbstractCACFLayerTreeHost { public: static PassRefPtr<CACFLayerTreeHost> create(); virtual ~CACFLayerTreeHost(); @@ -66,24 +65,31 @@ public: virtual void paint(); virtual void resize() = 0; void flushPendingGraphicsLayerChangesSoon(); - void flushPendingLayerChangesNow(); + + // AbstractCACFLayerTreeHost + virtual void flushPendingLayerChangesNow(); protected: CACFLayerTreeHost(); CGRect bounds() const; - PlatformCALayer* rootLayer() const; HWND window() const { return m_window; } void notifyAnimationsStarted(); + // AbstractCACFLayerTreeHost + virtual PlatformCALayer* rootLayer() const; + virtual bool createRenderer() = 0; virtual void destroyRenderer(); virtual void contextDidChange(); private: void initialize(); - void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>); - void layerTreeDidChange(); + + // AbstractCACFLayerTreeHost + virtual void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>); + virtual void layerTreeDidChange(); + virtual void flushContext() = 0; virtual CFTimeInterval lastCommitTime() const = 0; diff --git a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp index 3fd857b..ec2a9ff 100644 --- a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp @@ -28,8 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) -#include "CACFLayerTreeHost.h" -#include "WebCoreInstanceHandle.h" +#include "AbstractCACFLayerTreeHost.h" #include <wtf/StdLibExtras.h> #include <wtf/Vector.h> @@ -47,7 +46,7 @@ LayerChangesFlusher::LayerChangesFlusher() { } -void LayerChangesFlusher::flushPendingLayerChangesSoon(CACFLayerTreeHost* host) +void LayerChangesFlusher::flushPendingLayerChangesSoon(AbstractCACFLayerTreeHost* host) { if (!m_hostsWithChangesToFlush.add(host).second || m_hook) return; @@ -55,7 +54,7 @@ void LayerChangesFlusher::flushPendingLayerChangesSoon(CACFLayerTreeHost* host) setHook(); } -void LayerChangesFlusher::cancelPendingFlush(CACFLayerTreeHost* host) +void LayerChangesFlusher::cancelPendingFlush(AbstractCACFLayerTreeHost* host) { m_hostsWithChangesToFlush.remove(host); @@ -80,9 +79,8 @@ LRESULT LayerChangesFlusher::hookFired(int code, WPARAM wParam, LPARAM lParam) ASSERT(m_hook); // Calling out to the hosts can cause m_hostsWithChangesToFlush to be modified, so we copy it - // into a Vector first. We have to hold a reference to them because otherwise they could be - // destroyed while we're calling out to them. - Vector<RefPtr<CACFLayerTreeHost> > hosts; + // into a Vector first. + Vector<AbstractCACFLayerTreeHost*> hosts; copyToVector(m_hostsWithChangesToFlush, hosts); m_hostsWithChangesToFlush.clear(); @@ -108,7 +106,7 @@ void LayerChangesFlusher::setHook() DWORD threadID = ::GetCurrentThreadId(); - m_hook = ::SetWindowsHookExW(WH_GETMESSAGE, hookCallback, instanceHandle(), threadID); + m_hook = ::SetWindowsHookExW(WH_GETMESSAGE, hookCallback, 0, threadID); ASSERT_WITH_MESSAGE(m_hook, "::SetWindowsHookExW failed with error %lu", ::GetLastError()); // Post a message to the message queue to prevent ::GetMessage from blocking, which will ensure diff --git a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h index 6a98a99..1e7ab31 100644 --- a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h @@ -34,15 +34,15 @@ namespace WebCore { -class CACFLayerTreeHost; +class AbstractCACFLayerTreeHost; class LayerChangesFlusher { WTF_MAKE_NONCOPYABLE(LayerChangesFlusher); public: static LayerChangesFlusher& shared(); - void flushPendingLayerChangesSoon(CACFLayerTreeHost*); - void cancelPendingFlush(CACFLayerTreeHost*); + void flushPendingLayerChangesSoon(AbstractCACFLayerTreeHost*); + void cancelPendingFlush(AbstractCACFLayerTreeHost*); private: LayerChangesFlusher(); @@ -53,7 +53,7 @@ private: void setHook(); void removeHook(); - HashSet<CACFLayerTreeHost*> m_hostsWithChangesToFlush; + HashSet<AbstractCACFLayerTreeHost*> m_hostsWithChangesToFlush; HHOOK m_hook; bool m_isCallingHosts; }; diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp index b5a26f4..5d20928 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp @@ -29,7 +29,7 @@ #include "PlatformCALayer.h" -#include "CACFLayerTreeHost.h" +#include "AbstractCACFLayerTreeHost.h" #include "Font.h" #include "GraphicsContext.h" #include "PlatformCALayerWinInternal.h" @@ -65,14 +65,14 @@ static CFStringRef toCACFFilterType(PlatformCALayer::FilterType type) } } -static CACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer) +static AbstractCACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer) { - // We need the CACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext + // We need the AbstractCACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext void* userData = wkCACFLayerGetContextUserData(layer->platformLayer()); if (!userData) return 0; - return static_cast<CACFLayerTreeHost*>(userData); + return static_cast<AbstractCACFLayerTreeHost*>(userData); } static PlatformCALayerWinInternal* intern(const PlatformCALayer* layer) @@ -156,7 +156,7 @@ PlatformLayer* PlatformCALayer::platformLayer() const PlatformCALayer* PlatformCALayer::rootLayer() const { - CACFLayerTreeHost* host = layerTreeHostForLayer(this); + AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this); return host ? host->rootLayer() : 0; } @@ -167,7 +167,7 @@ void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect) void PlatformCALayer::setNeedsCommit() { - CACFLayerTreeHost* host = layerTreeHostForLayer(this); + AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this); if (host) host->layerTreeDidChange(); } @@ -270,7 +270,7 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation* setNeedsCommit(); // Tell the host about it so we can fire the start animation event - CACFLayerTreeHost* host = layerTreeHostForLayer(this); + AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this); if (host) host->addPendingAnimatedLayer(this); } @@ -283,7 +283,7 @@ void PlatformCALayer::removeAnimationForKey(const String& key) RetainPtr<CFStringRef> s(AdoptCF, key.createCFString()); CACFLayerRemoveAnimation(m_layer.get(), s.get()); - // We don't "remove" a layer from CACFLayerTreeHost when it loses an animation. + // We don't "remove" a layer from AbstractCACFLayerTreeHost when it loses an animation. // There may be other active animations on the layer and if an animation // callback is fired on a layer without any animations no harm is done. diff --git a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp index e672c2d..c4c3374 100644 --- a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp @@ -31,6 +31,7 @@ #include "PlatformCALayer.h" #include "SoftLinking.h" #include <wtf/CurrentTime.h> +#include <wtf/Threading.h> typedef struct _CACFLayer* CACFLayerRef; @@ -42,7 +43,13 @@ SOFT_LINK_DEBUG_LIBRARY(WebKitQuartzCoreAdditions) SOFT_LINK_LIBRARY(WebKitQuartzCoreAdditions) #endif -SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewCreate, WKCACFViewRef, __cdecl, (), ()) +enum WKCACFViewDrawingDestination { + kWKCACFViewDrawingDestinationWindow = 0, + kWKCACFViewDrawingDestinationImage, +}; +typedef enum WKCACFViewDrawingDestination WKCACFViewDrawingDestination; + +SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewCreate, WKCACFViewRef, __cdecl, (WKCACFViewDrawingDestination destination), (destination)) SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewSetLayer, void, __cdecl, (WKCACFViewRef view, CACFLayerRef layer), (view, layer)) SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewUpdate, void, __cdecl, (WKCACFViewRef view, HWND window, const CGRect* bounds), (view, window, bounds)) SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewCanDraw, bool, __cdecl, (WKCACFViewRef view), (view)) @@ -63,7 +70,7 @@ PassRefPtr<WKCACFViewLayerTreeHost> WKCACFViewLayerTreeHost::create() } WKCACFViewLayerTreeHost::WKCACFViewLayerTreeHost() - : m_view(AdoptCF, WKCACFViewCreate()) + : m_view(AdoptCF, WKCACFViewCreate(kWKCACFViewDrawingDestinationWindow)) , m_viewNeedsUpdate(true) { } @@ -98,6 +105,12 @@ void WKCACFViewLayerTreeHost::contextDidChangeCallback(WKCACFViewRef view, void* void WKCACFViewLayerTreeHost::contextDidChange() { + // This should only be called on a background thread when no changes have actually + // been committed to the context, eg. when a video frame has been added to an image + // queue, so return without triggering animations etc. + if (!isMainThread()) + return; + // Tell the WKCACFView to start rendering now that we have some contents to render. updateViewIfNeeded(); |