[chromium] Add CompositorSupport interface for constructing compositor classes
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2012 19:52:42 +0000 (19:52 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2012 19:52:42 +0000 (19:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95040

Reviewed by Darin Fisher.

Source/Platform:

Adds a WebCompositorSupport interface as a tear-off of PlatformSupport so the embedder can handle provide
implementations of compositor interfaces.

Adds a new WebPassOwnPtr<> type for use when the caller of an API must take ownership of the provided parameter.

* Platform.gypi:
* chromium/public/Platform.h:
(WebKit):
(WebKit::Platform::compositorSupport):
(Platform):
* chromium/public/WebCompositorSupport.h: Added.
(WebKit):
(WebCompositorSupport):
(WebKit::WebCompositorSupport::~WebCompositorSupport):

Source/WebCore:

Uses WebCompositorSupport interfaces where appropriate to construct compositor types.

* platform/graphics/chromium/AnimationTranslationUtil.cpp:
(WebCore::createWebAnimation):
* platform/graphics/chromium/Canvas2DLayerBridge.cpp:
(WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBufferPrivate::DrawingBufferPrivate):
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::GraphicsLayerChromium):
(WebCore::GraphicsLayerChromium::setContentsToImage):
(WebCore::GraphicsLayerChromium::setContentsTo):
(WebCore::GraphicsLayerChromium::addAnimation):
(WebCore::GraphicsLayerChromium::updateLayerPreserves3D):

Source/WebKit/chromium:

* src/LinkHighlight.cpp:
(WebKit::LinkHighlight::LinkHighlight):
(WebKit::LinkHighlight::startHighlightAnimation):
* src/WebMediaPlayerClientImpl.cpp:
(WebKit::WebMediaPlayerClientImpl::readyStateChanged):
* src/WebMediaPlayerClientImpl.h:
(WebKit):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::setBackingTextureId):
(WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
* src/WebPluginContainerImpl.h:
(WebKit):

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

16 files changed:
Source/Platform/ChangeLog
Source/Platform/Platform.gypi
Source/Platform/chromium/public/Platform.h
Source/Platform/chromium/public/WebCompositorSupport.h [new file with mode: 0644]
Source/Platform/chromium/public/WebPassOwnPtr.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp
Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp
Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/LinkHighlight.cpp
Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h
Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
Source/WebKit/chromium/src/WebPluginContainerImpl.h

index 3d63c20..a3d8376 100644 (file)
@@ -1,3 +1,25 @@
+2012-08-27  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Add CompositorSupport interface for constructing compositor classes
+        https://bugs.webkit.org/show_bug.cgi?id=95040
+
+        Reviewed by Darin Fisher.
+
+        Adds a WebCompositorSupport interface as a tear-off of PlatformSupport so the embedder can handle provide
+        implementations of compositor interfaces.
+
+        Adds a new WebPassOwnPtr<> type for use when the caller of an API must take ownership of the provided parameter.
+
+        * Platform.gypi:
+        * chromium/public/Platform.h:
+        (WebKit):
+        (WebKit::Platform::compositorSupport):
+        (Platform):
+        * chromium/public/WebCompositorSupport.h: Added.
+        (WebKit):
+        (WebCompositorSupport):
+        (WebKit::WebCompositorSupport::~WebCompositorSupport):
+
 2012-08-30  Tommy Widenflycht  <tommyw@google.com>
 
         MediaStream API: Introduce MediaConstraints
index bcd3d72..406b391 100644 (file)
@@ -44,6 +44,8 @@
             'chromium/public/WebClipboard.h',
             'chromium/public/WebColor.h',
             'chromium/public/WebCommon.h',
+            'chromium/public/WebCompositor.h',
+            'chromium/public/WebCompositorSurface.h',
             'chromium/public/WebCompositorOutputSurface.h',
             'chromium/public/WebCompositorOutputSurfaceClient.h',
             'chromium/public/WebContentLayer.h',
@@ -92,6 +94,7 @@
             'chromium/public/WebMessagePortChannelClient.h',
             'chromium/public/WebMimeRegistry.h',
             'chromium/public/WebNonCopyable.h',
+            'chromium/public/WebPassOwnPtr.h',
             'chromium/public/WebPeerConnection00Handler.h',
             'chromium/public/WebPeerConnection00HandlerClient.h',
             'chromium/public/WebPeerConnectionHandler.h',
index d6ba86f..47d9905 100644 (file)
@@ -49,6 +49,7 @@ namespace WebKit {
 class WebAudioBus;
 class WebBlobRegistry;
 class WebClipboard;
+class WebCompositorSupport;
 class WebCookieJar;
 class WebFileSystem;
 class WebFileUtilities;
@@ -411,6 +412,8 @@ public:
     // This value must be checked again after a context loss event as the platform's capabilities may have changed.
     virtual bool canAccelerate2dCanvas() { return false; }
 
+    virtual WebCompositorSupport* compositorSupport() { return 0; }
+
     virtual WebFlingAnimator* createFlingAnimator() { return 0; }
 
     // WebRTC ----------------------------------------------------------
diff --git a/Source/Platform/chromium/public/WebCompositorSupport.h b/Source/Platform/chromium/public/WebCompositorSupport.h
new file mode 100644 (file)
index 0000000..927cfbe
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Google 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 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 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 WebCompositorSupport_h
+#define WebCompositorSupport_h
+
+#include "WebAnimation.h"
+#include "WebCommon.h"
+#include "WebContentLayer.h"
+#include "WebExternalTextureLayer.h"
+#include "WebFloatAnimationCurve.h"
+#include "WebIOSurfaceLayer.h"
+#include "WebImageLayer.h"
+#include "WebLayer.h"
+#include "WebLayerTreeView.h"
+#include "WebPassOwnPtr.h"
+#include "WebScrollbar.h"
+#include "WebScrollbarLayer.h"
+#include "WebScrollbarThemeGeometry.h"
+#include "WebScrollbarThemePainter.h"
+#include "WebSolidColorLayer.h"
+#include "WebTransformAnimationCurve.h"
+#include "WebVideoLayer.h"
+
+namespace WebKit {
+
+class WebContentLayerClient;
+class WebExternalTextureLayerClient;
+class WebVideoFrameProvider;
+
+class WebCompositorSupport {
+public:
+    // May return 0 if initialization fails.
+    virtual WebPassOwnPtr<WebLayerTreeView> createLayerTreeView(WebLayerTreeViewClient*, const WebLayer& root, const WebLayerTreeView::Settings&) { return WebPassOwnPtr<WebLayerTreeView>(); }
+
+
+    // Layers -------------------------------------------------------
+
+    virtual WebPassOwnPtr<WebLayer> createLayer() { return WebPassOwnPtr<WebLayer>(); }
+
+    virtual WebPassOwnPtr<WebContentLayer> createContentLayer(WebContentLayerClient*) { return WebPassOwnPtr<WebContentLayer>(); }
+
+    virtual WebPassOwnPtr<WebExternalTextureLayer> createExternalTextureLayer(WebExternalTextureLayerClient* = 0) { return WebPassOwnPtr<WebExternalTextureLayer>(); }
+
+    virtual WebPassOwnPtr<WebIOSurfaceLayer> createIOSurfaceLayer() { return WebPassOwnPtr<WebIOSurfaceLayer>(); }
+
+    virtual WebPassOwnPtr<WebImageLayer> createImageLayer() { return WebPassOwnPtr<WebImageLayer>(); }
+
+    virtual WebPassOwnPtr<WebSolidColorLayer> createSolidColorLayer() { return WebPassOwnPtr<WebSolidColorLayer>(); }
+
+    virtual WebPassOwnPtr<WebVideoLayer> createVideoLayer(WebVideoFrameProvider*) { return WebPassOwnPtr<WebVideoLayer>(); }
+
+    virtual WebPassOwnPtr<WebScrollbarLayer> createScrollbarLayer(WebPassOwnPtr<WebScrollbar>, WebScrollbarThemePainter, WebPassOwnPtr<WebScrollbarThemeGeometry>) { return WebPassOwnPtr<WebScrollbarLayer>(); }
+
+
+    // Animation ----------------------------------------------------
+
+    virtual WebPassOwnPtr<WebAnimation> createAnimation(const WebAnimationCurve&, WebAnimation::TargetProperty, int animationId = 0) { return WebPassOwnPtr<WebAnimation>(); }
+
+    virtual WebPassOwnPtr<WebFloatAnimationCurve> createFloatAnimationCurve() { return WebPassOwnPtr<WebFloatAnimationCurve>(); }
+
+    virtual WebPassOwnPtr<WebTransformAnimationCurve> createTransformAnimationCurve() { return WebPassOwnPtr<WebTransformAnimationCurve>(); }
+
+private:
+    virtual ~WebCompositorSupport() { }
+};
+
+}
+
+#endif // WebCompositorSupport_h
diff --git a/Source/Platform/chromium/public/WebPassOwnPtr.h b/Source/Platform/chromium/public/WebPassOwnPtr.h
new file mode 100644 (file)
index 0000000..cd71825
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2012 Google 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 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 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 WebPassOwnPtr_h
+#define WebPassOwnPtr_h
+
+#include "WebCommon.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#else
+#include "base/memory/scoped_ptr.h"
+#endif
+
+namespace WebKit {
+
+// Use a return value of type WebPassOwnPtr<T> when the caller takes ownership of the returned value, for instance
+// in a createFoo() factory function. Example:
+//
+// To implement the class WebPassOwnPtr<Foo> createFoo() in chromium code, write:
+//
+// WebPassOwnPtr<Foo> createFoo() {
+//   scoped_ptr<Foo> foo = ...;
+//   return foo.Pass();
+// }
+//
+// To use on the WebKit side:
+//
+//   OwnPtr<Foo> foo = ...->createFoo();
+//
+// To implement WebPassOwnPtr<Foo> createFoo() in WebKit and use it from chromium, write:
+//
+// WebPassOwnPtr<Foo> createFoo()
+// {
+//     OwnPtr<Foo> foo = ...;
+//     return foo.release();
+// }
+//
+// and
+//
+//   scoped_ptr<Foo> = ...->createFoo();
+
+template <typename T>
+class WebPassOwnPtr : public WebNonCopyable {
+public:
+    WebPassOwnPtr()
+        : m_ptr(0)
+    {
+    }
+
+    ~WebPassOwnPtr()
+    {
+        WEBKIT_ASSERT(!m_ptr);
+    }
+
+
+#if WEBKIT_IMPLEMENTATION
+    WebPassOwnPtr(PassOwnPtr<T> ptr)
+        : m_ptr(ptr.leakPtr())
+    {
+    }
+
+    operator PassOwnPtr<T>()
+    {
+        OwnPtr<T> ret = adoptPtr(m_ptr);
+        m_ptr = 0;
+        return ret.release();
+    }
+#else
+    WebPassOwnPtr(scoped_ptr<T> ptr)
+        : m_ptr(ptr.release())
+    {
+    }
+
+    operator scoped_ptr<T>()
+    {
+        scoped_ptr<T> ret(m_ptr);
+        m_ptr = 0;
+        return ret.Pass();
+    }
+#endif
+
+private:
+    T* m_ptr;
+
+    // This constructor has to be declared but not defined to trigger move emulation.
+    WebPassOwnPtr(WebPassOwnPtr&);
+};
+
+}
+
+#endif // WebPassOwnPtr_h
index 469dd70..25483af 100644 (file)
@@ -1,3 +1,25 @@
+2012-08-27  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Add CompositorSupport interface for constructing compositor classes
+        https://bugs.webkit.org/show_bug.cgi?id=95040
+
+        Reviewed by Darin Fisher.
+
+        Uses WebCompositorSupport interfaces where appropriate to construct compositor types.
+
+        * platform/graphics/chromium/AnimationTranslationUtil.cpp:
+        (WebCore::createWebAnimation):
+        * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
+        (WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBufferPrivate::DrawingBufferPrivate):
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::GraphicsLayerChromium):
+        (WebCore::GraphicsLayerChromium::setContentsToImage):
+        (WebCore::GraphicsLayerChromium::setContentsTo):
+        (WebCore::GraphicsLayerChromium::addAnimation):
+        (WebCore::GraphicsLayerChromium::updateLayerPreserves3D):
+
 2012-08-30  Dan Bernstein  <mitz@apple.com>
 
         [CG] ImageCG.cpp contains a mix of Image and BitmapImage functions
index ae8f900..2dac22e 100644 (file)
 #include "TransformOperations.h"
 #include "TranslateTransformOperation.h"
 
+#include <public/Platform.h>
 #include <public/WebAnimation.h>
 #include <public/WebAnimationCurve.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebFloatAnimationCurve.h>
 #include <public/WebTransformAnimationCurve.h>
 #include <public/WebTransformOperations.h>
@@ -170,7 +172,7 @@ bool appendKeyframeWithCustomBezierTimingFunction<TransformAnimationValue, WebTr
 }
 
 template <class Value, class Keyframe, class Curve>
-PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& valueList, const Animation* animation, int animationId, double timeOffset, WebKit::WebAnimation::TargetProperty targetProperty, const FloatSize& boxSize)
+PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& valueList, const Animation* animation, int animationId, double timeOffset, Curve* curve, WebKit::WebAnimation::TargetProperty targetProperty, const FloatSize& boxSize)
 {
     bool alternate = false;
     bool reverse = false;
@@ -182,8 +184,6 @@ PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& val
             reverse = true;
     }
 
-    OwnPtr<Curve> curve = adoptPtr(Curve::create());
-
     for (size_t i = 0; i < valueList.size(); i++) {
         size_t index = reverse ? valueList.size() - i - 1 : i;
         const Value* originalValue = static_cast<const Value*>(valueList.at(index));
@@ -234,32 +234,50 @@ PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& val
 
         bool addedKeyframe = false;
         if (isUsingCustomBezierTimingFunction)
-            addedKeyframe = appendKeyframeWithCustomBezierTimingFunction<Value, Keyframe, Curve>(curve.get(), keyTime, originalValue, lastOriginalValue, x1, y1, x2, y2, boxSize);
+            addedKeyframe = appendKeyframeWithCustomBezierTimingFunction<Value, Keyframe, Curve>(curve, keyTime, originalValue, lastOriginalValue, x1, y1, x2, y2, boxSize);
         else
-            addedKeyframe = appendKeyframeWithStandardTimingFunction<Value, Keyframe, Curve>(curve.get(), keyTime, originalValue, lastOriginalValue, timingFunctionType, boxSize);
+            addedKeyframe = appendKeyframeWithStandardTimingFunction<Value, Keyframe, Curve>(curve, keyTime, originalValue, lastOriginalValue, timingFunctionType, boxSize);
         if (!addedKeyframe)
             return nullptr;
     }
 
-    OwnPtr<WebKit::WebAnimation> anim(adoptPtr(WebKit::WebAnimation::create(*curve, targetProperty, animationId)));
+    OwnPtr<WebKit::WebAnimation> webAnimation;
+    if (WebCompositorSupport* compositorSupport = WebKit::Platform::current()->compositorSupport())
+        webAnimation = compositorSupport->createAnimation(*curve, targetProperty, animationId);
+    else
+        webAnimation = adoptPtr(WebKit::WebAnimation::create(*curve, targetProperty, animationId));
 
     int iterations = (animation && animation->isIterationCountSet()) ? animation->iterationCount() : 1;
-    anim->setIterations(iterations);
-    anim->setAlternatesDirection(alternate);
+    webAnimation->setIterations(iterations);
+    webAnimation->setAlternatesDirection(alternate);
 
     // If timeOffset > 0, then the animation has started in the past.
-    anim->setTimeOffset(timeOffset);
+    webAnimation->setTimeOffset(timeOffset);
 
-    return anim.release();
+    return webAnimation.release();
 }
 
 PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& values, const Animation* animation, int animationId, double timeOffset, const FloatSize& boxSize)
 {
-    if (values.property() == AnimatedPropertyWebkitTransform)
-        return createWebAnimation<TransformAnimationValue, WebTransformKeyframe, WebTransformAnimationCurve>(values, animation, animationId, timeOffset, WebKit::WebAnimation::TargetPropertyTransform, FloatSize(boxSize));
 
-    if (values.property() == AnimatedPropertyOpacity)
-        return createWebAnimation<FloatAnimationValue, WebFloatKeyframe, WebFloatAnimationCurve>(values, animation, animationId, timeOffset, WebKit::WebAnimation::TargetPropertyOpacity, FloatSize());
+
+    if (values.property() == AnimatedPropertyWebkitTransform) {
+        OwnPtr<WebTransformAnimationCurve> curve;
+        if (WebCompositorSupport* compositorSupport = WebKit::Platform::current()->compositorSupport())
+            curve = compositorSupport->createTransformAnimationCurve();
+        else
+            curve = adoptPtr(WebTransformAnimationCurve::create());
+        return createWebAnimation<TransformAnimationValue, WebTransformKeyframe, WebTransformAnimationCurve>(values, animation, animationId, timeOffset, curve.get(), WebKit::WebAnimation::TargetPropertyTransform, FloatSize(boxSize));
+    }
+
+    if (values.property() == AnimatedPropertyOpacity) {
+        OwnPtr<WebFloatAnimationCurve> curve;
+        if (WebCompositorSupport* compositorSupport = WebKit::Platform::current()->compositorSupport())
+            curve = compositorSupport->createFloatAnimationCurve();
+        else
+            curve = adoptPtr(WebFloatAnimationCurve::create());
+        return createWebAnimation<FloatAnimationValue, WebFloatKeyframe, WebFloatAnimationCurve>(values, animation, animationId, timeOffset, curve.get(), WebKit::WebAnimation::TargetPropertyOpacity, FloatSize());
+    }
 
     return nullptr;
 }
index 192b58a..2f57155 100644 (file)
@@ -34,7 +34,9 @@
 #include "GraphicsContext3DPrivate.h"
 #include "GraphicsLayerChromium.h"
 #include "TraceEvent.h"
+#include <public/Platform.h>
 #include <public/WebCompositor.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebGraphicsContext3D.h>
 
 using WebKit::WebExternalTextureLayer;
@@ -74,7 +76,11 @@ Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context,
             grContext->resetContext();
     }
 
-    m_layer = adoptPtr(WebExternalTextureLayer::create(this));
+    if (WebKit::WebCompositorSupport* compositorSupport = WebKit::Platform::current()->compositorSupport())
+        m_layer = compositorSupport->createExternalTextureLayer(this);
+    else
+        m_layer = adoptPtr(WebKit::WebExternalTextureLayer::create(this));
+
     m_layer->setTextureId(textureId);
     m_layer->setRateLimitContext(!WebKit::WebCompositor::threadingEnabled() || m_useDoubleBuffering);
     GraphicsLayerChromium::registerContentsLayer(m_layer->layer());
index f149521..6217a63 100644 (file)
@@ -38,7 +38,9 @@
 #include "GraphicsContext3DPrivate.h"
 #include "GraphicsLayerChromium.h"
 #include <algorithm>
+#include <public/Platform.h>
 #include <public/WebCompositor.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebExternalTextureLayer.h>
 #include <public/WebExternalTextureLayerClient.h>
 #include <public/WebGraphicsContext3D.h>
@@ -163,8 +165,12 @@ class DrawingBufferPrivate : public WebKit::WebExternalTextureLayerClient {
 public:
     explicit DrawingBufferPrivate(DrawingBuffer* drawingBuffer)
         : m_drawingBuffer(drawingBuffer)
-        , m_layer(adoptPtr(WebKit::WebExternalTextureLayer::create(this)))
     {
+        if (WebKit::WebCompositorSupport* compositorSupport = WebKit::Platform::current()->compositorSupport())
+            m_layer = compositorSupport->createExternalTextureLayer(this);
+        else
+            m_layer = adoptPtr(WebKit::WebExternalTextureLayer::create(this));
+
         GraphicsContext3D::Attributes attributes = m_drawingBuffer->graphicsContext3D()->getContextAttributes();
         m_layer->setOpaque(!attributes.alpha);
         m_layer->setPremultipliedAlpha(attributes.premultipliedAlpha);
index f7ee2d8..a897847 100644 (file)
@@ -56,7 +56,9 @@
 #include "PlatformString.h"
 #include "SkMatrix44.h"
 #include "SystemTime.h"
+#include <public/Platform.h>
 #include <public/WebAnimation.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebFilterOperation.h>
 #include <public/WebFilterOperations.h>
 #include <public/WebFloatPoint.h>
@@ -90,7 +92,12 @@ GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
     , m_pageScaleChanged(false)
 {
     m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this));
-    m_layer = adoptPtr(WebContentLayer::create(m_opaqueRectTrackingContentLayerDelegate.get()));
+
+    if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+        m_layer = compositorSupport->createContentLayer(m_opaqueRectTrackingContentLayerDelegate.get());
+    else
+        m_layer = adoptPtr(WebContentLayer::create(m_opaqueRectTrackingContentLayerDelegate.get()));
+
     m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
     if (client)
         deviceOrPageScaleFactorChanged();
@@ -469,8 +476,12 @@ void GraphicsLayerChromium::setContentsToImage(Image* image)
     bool childrenChanged = false;
     if (image) {
         if (m_contentsLayerPurpose != ContentsLayerForImage) {
-            m_imageLayer = adoptPtr(WebImageLayer::create());
+            if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+                m_imageLayer = compositorSupport->createImageLayer();
+            else
+                m_imageLayer = adoptPtr(WebImageLayer::create());
             registerContentsLayer(m_imageLayer->layer());
+
             setupContentsLayer(m_imageLayer->layer());
             m_contentsLayerPurpose = ContentsLayerForImage;
             childrenChanged = true;
@@ -538,7 +549,7 @@ void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
     setContentsTo(ContentsLayerForVideo, layer);
 }
 
-void GraphicsLayerChromium::setContentsTo(ContentsLayerPurpose purpose, WebKit::WebLayer* layer)
+void GraphicsLayerChromium::setContentsTo(ContentsLayerPurpose purpose, WebLayer* layer)
 {
     bool childrenChanged = false;
     if (layer) {
@@ -573,7 +584,7 @@ bool GraphicsLayerChromium::addAnimation(const KeyframeValueList& values, const
     if (m_animationIdMap.contains(animationName))
         animationId = m_animationIdMap.get(animationName);
 
-    OwnPtr<WebKit::WebAnimation> toAdd(createWebAnimation(values, animation, animationId, timeOffset, boxSize));
+    OwnPtr<WebAnimation> toAdd(createWebAnimation(values, animation, animationId, timeOffset, boxSize));
 
     if (toAdd) {
         animationId = toAdd->id();
@@ -721,8 +732,11 @@ void GraphicsLayerChromium::updateMasksToBounds()
 void GraphicsLayerChromium::updateLayerPreserves3D()
 {
     if (m_preserves3D && !m_transformLayer) {
-        // Create the transform layer.
-        m_transformLayer = adoptPtr(WebLayer::create());
+        if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+            m_transformLayer = compositorSupport->createLayer();
+        else
+            m_transformLayer = adoptPtr(WebLayer::create());
+
         m_transformLayer->setPreserves3D(true);
         m_transformLayer->setAnimationDelegate(this);
         m_layer->layer()->transferAnimationsTo(m_transformLayer.get());
index f695507..ede7b15 100644 (file)
@@ -1,3 +1,23 @@
+2012-08-27  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Add CompositorSupport interface for constructing compositor classes
+        https://bugs.webkit.org/show_bug.cgi?id=95040
+
+        Reviewed by Darin Fisher.
+
+        * src/LinkHighlight.cpp:
+        (WebKit::LinkHighlight::LinkHighlight):
+        (WebKit::LinkHighlight::startHighlightAnimation):
+        * src/WebMediaPlayerClientImpl.cpp:
+        (WebKit::WebMediaPlayerClientImpl::readyStateChanged):
+        * src/WebMediaPlayerClientImpl.h:
+        (WebKit):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::setBackingTextureId):
+        (WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
+        * src/WebPluginContainerImpl.h:
+        (WebKit):
+
 2012-08-30  Gavin Peters  <gavinp@chromium.org>
 
         [chromium] Disable CCLayerTreeHostTestScrollMultipleRedraw.runMultiThread
index a0c5bfb..6f97460 100644 (file)
@@ -41,7 +41,9 @@
 #include "WebFrameImpl.h"
 #include "WebKit.h"
 #include "WebViewImpl.h"
+#include <public/Platform.h>
 #include <public/WebAnimationCurve.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebFloatAnimationCurve.h>
 #include <public/WebFloatPoint.h>
 #include <public/WebRect.h>
@@ -59,16 +61,20 @@ PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningW
 }
 
 LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl)
-    : m_contentLayer(adoptPtr(WebContentLayer::create(this)))
-    , m_clipLayer(adoptPtr(WebLayer::create()))
-    , m_node(node)
+    : m_node(node)
     , m_owningWebViewImpl(owningWebViewImpl)
     , m_currentGraphicsLayer(0)
     , m_geometryNeedsUpdate(false)
 {
     ASSERT(m_node);
     ASSERT(owningWebViewImpl);
-
+    if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport()) {
+        m_contentLayer = compositorSupport->createContentLayer(this);
+        m_clipLayer = compositorSupport->createLayer();
+    } else {
+        m_contentLayer = adoptPtr(WebContentLayer::create(this));
+        m_clipLayer = adoptPtr(WebLayer::create());
+    }
     m_clipLayer->setAnchorPoint(WebFloatPoint());
     m_clipLayer->addChild(m_contentLayer->layer());
     m_contentLayer->layer()->setDrawsContent(false);
@@ -200,13 +206,24 @@ void LinkHighlight::startHighlightAnimation()
 
     m_contentLayer->layer()->setOpacity(startOpacity);
 
-    OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::create());
+    WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport();
+
+    OwnPtr<WebFloatAnimationCurve> curve;
+    if (compositorSupport)
+        curve = compositorSupport->createFloatAnimationCurve();
+    else
+        curve = adoptPtr(WebFloatAnimationCurve::create());
+
     curve->add(WebFloatKeyframe(0, startOpacity));
     curve->add(WebFloatKeyframe(duration / 2, startOpacity));
     // For layout tests we don't fade out.
     curve->add(WebFloatKeyframe(duration, WebKit::layoutTestMode() ? startOpacity : 0));
 
-    m_animation = adoptPtr(WebAnimation::create(*curve, WebAnimation::TargetPropertyOpacity));
+    if (compositorSupport)
+        m_animation = compositorSupport->createAnimation(*curve, WebAnimation::TargetPropertyOpacity);
+    else
+        m_animation = adoptPtr(WebAnimation::create(*curve, WebAnimation::TargetPropertyOpacity));
+
     m_contentLayer->layer()->setDrawsContent(true);
     m_contentLayer->layer()->addAnimation(m_animation.get());
 
index 26d2f73..93fcdea 100644 (file)
 #include <public/Platform.h>
 #include <public/WebCString.h>
 #include <public/WebCanvas.h>
+#include <public/WebCompositorSupport.h>
 #include <public/WebMimeRegistry.h>
 #include <public/WebRect.h>
 #include <public/WebSize.h>
 #include <public/WebString.h>
 #include <public/WebURL.h>
+#include <public/WebVideoLayer.h>
 
 #if USE(ACCELERATED_COMPOSITING)
 #include "RenderLayerCompositor.h"
@@ -116,7 +118,11 @@ void WebMediaPlayerClientImpl::readyStateChanged()
     m_mediaPlayer->readyStateChanged();
 #if USE(ACCELERATED_COMPOSITING)
     if (hasVideo() && supportsAcceleratedRendering() && !m_videoLayer) {
-        m_videoLayer = adoptPtr(WebVideoLayer::create(this));
+        if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+            m_videoLayer = compositorSupport->createVideoLayer(this);
+        else
+            m_videoLayer = adoptPtr(WebVideoLayer::create(this));
+
         m_videoLayer->layer()->setOpaque(m_opaque);
         GraphicsLayerChromium::registerContentsLayer(m_videoLayer->layer());
     }
index 329fd9e..bd2907e 100644 (file)
@@ -39,7 +39,6 @@
 #include "WebMediaPlayerClient.h"
 #include "WebStreamTextureClient.h"
 #include <public/WebVideoFrameProvider.h>
-#include <public/WebVideoLayer.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
@@ -50,6 +49,7 @@ namespace WebKit {
 class WebHelperPluginImpl;
 class WebAudioSourceProvider;
 class WebMediaPlayer;
+class WebVideoLayer;
 
 // This class serves as a bridge between WebCore::MediaPlayer and
 // WebKit::WebMediaPlayer.
index c317176..ecf8663 100644 (file)
@@ -72,6 +72,8 @@
 #include "WheelEvent.h"
 #include <public/Platform.h>
 #include <public/WebClipboard.h>
+#include <public/WebCompositorSupport.h>
+#include <public/WebExternalTextureLayer.h>
 #include <public/WebRect.h>
 #include <public/WebString.h>
 #include <public/WebURL.h>
@@ -370,7 +372,10 @@ void WebPluginContainerImpl::setBackingTextureId(unsigned textureId)
     ASSERT(!m_ioSurfaceLayer);
 
     if (!m_textureLayer) {
-        m_textureLayer = adoptPtr(WebExternalTextureLayer::create());
+        if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+            m_textureLayer = compositorSupport->createExternalTextureLayer();
+        else
+            m_textureLayer = adoptPtr(WebExternalTextureLayer::create());
         GraphicsLayerChromium::registerContentsLayer(m_textureLayer->layer());
     }
     m_textureLayer->setTextureId(textureId);
@@ -396,7 +401,10 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width,
     ASSERT(!m_textureLayer);
 
     if (!m_ioSurfaceLayer) {
-        m_ioSurfaceLayer = adoptPtr(WebIOSurfaceLayer::create());
+        if (WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport())
+            m_ioSurfaceLayer = compositorSupport->createIOSurfaceLayer();
+        else
+            m_ioSurfaceLayer = adoptPtr(WebIOSurfaceLayer::create());
         GraphicsLayerChromium::registerContentsLayer(m_ioSurfaceLayer->layer());
     }
     m_ioSurfaceLayer->setIOSurfaceProperties(ioSurfaceId, WebSize(width, height));
index 998be6e..e203a73 100644 (file)
@@ -35,7 +35,6 @@
 #include "WebPluginContainer.h"
 #include "Widget.h"
 
-#include <public/WebExternalTextureLayer.h>
 #include <public/WebIOSurfaceLayer.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
@@ -67,6 +66,7 @@ struct WebPrintParams;
 class ScrollbarGroup;
 class WebPlugin;
 class WebPluginLoadObserver;
+class WebExternalTextureLayer;
 
 class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
 public: