Title: [137653] trunk
Revision
137653
Author
pi...@chromium.org
Date
2012-12-13 14:16:28 -0800 (Thu, 13 Dec 2012)

Log Message

[chromium] Add WebPluginContainer::setWebLayer to supersede setBackingTextureId/setBackingIOSurfaceId
https://bugs.webkit.org/show_bug.cgi?id=104875

Reviewed by James Robinson.

* public/WebPluginContainer.h:
(WebKit):
(WebPluginContainer):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::setWebLayer):
(WebKit):
(WebKit::WebPluginContainerImpl::setBackingTextureId):
(WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
(WebKit::WebPluginContainerImpl::commitBackingTexture):
(WebKit::WebPluginContainerImpl::setOpaque):
(WebKit::WebPluginContainerImpl::platformLayer):
(WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
(WebKit::WebPluginContainerImpl::~WebPluginContainerImpl):
* src/WebPluginContainerImpl.h:
(WebPluginContainerImpl):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (137652 => 137653)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-12-13 22:07:04 UTC (rev 137652)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-12-13 22:16:28 UTC (rev 137653)
@@ -1,3 +1,26 @@
+2012-12-13  Antoine Labour  <pi...@chromium.org>
+
+        [chromium] Add WebPluginContainer::setWebLayer to supersede setBackingTextureId/setBackingIOSurfaceId
+        https://bugs.webkit.org/show_bug.cgi?id=104875
+
+        Reviewed by James Robinson.
+
+        * public/WebPluginContainer.h:
+        (WebKit):
+        (WebPluginContainer):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::setWebLayer):
+        (WebKit):
+        (WebKit::WebPluginContainerImpl::setBackingTextureId):
+        (WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
+        (WebKit::WebPluginContainerImpl::commitBackingTexture):
+        (WebKit::WebPluginContainerImpl::setOpaque):
+        (WebKit::WebPluginContainerImpl::platformLayer):
+        (WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
+        (WebKit::WebPluginContainerImpl::~WebPluginContainerImpl):
+        * src/WebPluginContainerImpl.h:
+        (WebPluginContainerImpl):
+
 2012-12-13  Yusuf Ozuysal  <yus...@google.com>
 
         Check whether a touchDown lands on a registered touch event handler from the compositor

Modified: trunk/Source/WebKit/chromium/public/WebPluginContainer.h (137652 => 137653)


--- trunk/Source/WebKit/chromium/public/WebPluginContainer.h	2012-12-13 22:07:04 UTC (rev 137652)
+++ trunk/Source/WebKit/chromium/public/WebPluginContainer.h	2012-12-13 22:16:28 UTC (rev 137653)
@@ -42,6 +42,7 @@
 class WebString;
 class WebURL;
 class WebURLRequest;
+class WebLayer;
 struct WebPoint;
 struct WebRect;
 
@@ -136,6 +137,10 @@
     virtual float pageScaleFactor() = 0;
     virtual float pageZoomFactor() = 0;
 
+    // Sets the layer representing the plugin for compositing. The
+    // WebPluginContainer does *not* take ownership.
+    virtual void setWebLayer(WebLayer*) = 0;
+
 protected:
     ~WebPluginContainer() { }
 };

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (137652 => 137653)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-12-13 22:07:04 UTC (rev 137652)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-12-13 22:16:28 UTC (rev 137653)
@@ -284,6 +284,23 @@
     return frame->pageZoomFactor();
 }
 
+void WebPluginContainerImpl::setWebLayer(WebLayer* layer)
+{
+    if (m_webLayer == layer)
+        return;
+
+    // If anyone of the layers is null we need to switch between hardware
+    // and software compositing. This is done by triggering a style recalc
+    // on the container element.
+    if (!m_webLayer || !layer)
+        m_element->setNeedsStyleRecalc(WebCore::SyntheticStyleChange);
+    if (m_webLayer)
+        GraphicsLayerChromium::unregisterContentsLayer(m_webLayer);
+    if (layer)
+        GraphicsLayerChromium::registerContentsLayer(layer);
+    m_webLayer = layer;
+}
+
 bool WebPluginContainerImpl::supportsPaginatedPrint() const
 {
     return m_webPlugin->supportsPaginatedPrint();
@@ -381,19 +398,12 @@
 
     ASSERT(!m_ioSurfaceLayer);
 
-    if (!m_textureLayer) {
+    if (!m_textureLayer)
         m_textureLayer = adoptPtr(Platform::current()->compositorSupport()->createExternalTextureLayer());
-        GraphicsLayerChromium::registerContentsLayer(m_textureLayer->layer());
-    }
     m_textureLayer->setTextureId(textureId);
-
-    // If anyone of the IDs is zero we need to switch between hardware
-    // and software compositing. This is done by triggering a style recalc
-    // on the container element.
-    if (!m_textureId || !textureId)
-        m_element->setNeedsStyleRecalc(WebCore::SyntheticStyleChange);
-
     m_textureId = textureId;
+
+    setWebLayer(m_textureId ? m_textureLayer->layer() : 0);
 #endif
 }
 
@@ -407,30 +417,20 @@
 
     ASSERT(!m_textureLayer);
 
-    if (!m_ioSurfaceLayer) {
+    if (!m_ioSurfaceLayer)
         m_ioSurfaceLayer = adoptPtr(Platform::current()->compositorSupport()->createIOSurfaceLayer());
-        GraphicsLayerChromium::registerContentsLayer(m_ioSurfaceLayer->layer());
-    }
     m_ioSurfaceLayer->setIOSurfaceProperties(ioSurfaceId, WebSize(width, height));
 
-    // If anyone of the IDs is zero we need to switch between hardware
-    // and software compositing. This is done by triggering a style recalc
-    // on the container element.
-    if (!ioSurfaceId || !m_ioSurfaceId)
-        m_element->setNeedsStyleRecalc(WebCore::SyntheticStyleChange);
-
     m_ioSurfaceId = ioSurfaceId;
+    setWebLayer(m_ioSurfaceId ? m_ioSurfaceLayer->layer() : 0);
 #endif
 }
 
 void WebPluginContainerImpl::commitBackingTexture()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (m_textureLayer)
-        m_textureLayer->layer()->invalidate();
-
-    if (m_ioSurfaceLayer)
-        m_ioSurfaceLayer->layer()->invalidate();
+    if (m_webLayer)
+        m_webLayer->invalidate();
 #endif
 }
 
@@ -493,15 +493,12 @@
     WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
     view->fullFramePluginZoomLevelChanged(zoomLevel);
 }
- 
+
 void WebPluginContainerImpl::setOpaque(bool opaque)
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (m_textureLayer)
-        m_textureLayer->layer()->setOpaque(opaque);
-
-    if (m_ioSurfaceLayer)
-        m_ioSurfaceLayer->layer()->setOpaque(opaque);
+    if (m_webLayer)
+        m_webLayer->setOpaque(opaque);
 #endif
 }
 
@@ -623,11 +620,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 WebLayer* WebPluginContainerImpl::platformLayer() const
 {
-    if (m_textureId)
-        return m_textureLayer->layer();
-    if (m_ioSurfaceId)
-        return m_ioSurfaceLayer->layer();
-    return 0;
+    return m_webLayer;
 }
 #endif
 
@@ -670,6 +663,7 @@
     , m_textureId(0)
     , m_ioSurfaceId(0)
 #endif
+    , m_webLayer(0)
     , m_touchEventRequestType(TouchEventRequestTypeNone)
     , m_wantsWheelEvents(false)
 {
@@ -678,10 +672,8 @@
 WebPluginContainerImpl::~WebPluginContainerImpl()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (m_textureLayer)
-        GraphicsLayerChromium::unregisterContentsLayer(m_textureLayer->layer());
-    if (m_ioSurfaceLayer)
-        GraphicsLayerChromium::unregisterContentsLayer(m_ioSurfaceLayer->layer());
+    if (m_webLayer)
+        GraphicsLayerChromium::unregisterContentsLayer(m_webLayer);
 #endif
 
     if (m_touchEventRequestType != TouchEventRequestTypeNone)

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h (137652 => 137653)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-12-13 22:07:04 UTC (rev 137652)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-12-13 22:16:28 UTC (rev 137653)
@@ -125,6 +125,8 @@
     virtual float pageScaleFactor();
     virtual float pageZoomFactor();
 
+    virtual void setWebLayer(WebLayer*);
+
     // Printing interface. The plugin can support custom printing
     // (which means it controls the layout, number of pages etc).
     // Whether the plugin supports its own paginated print. The other print
@@ -199,6 +201,8 @@
     OwnPtr<WebIOSurfaceLayer> m_ioSurfaceLayer;
 #endif
 
+    WebLayer* m_webLayer;
+
     // The associated scrollbar group object, created lazily. Used for Pepper
     // scrollbars.
     OwnPtr<ScrollbarGroup> m_scrollbarGroup;

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestPlugin.cpp (137652 => 137653)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestPlugin.cpp	2012-12-13 22:07:04 UTC (rev 137652)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestPlugin.cpp	2012-12-13 22:16:28 UTC (rev 137653)
@@ -35,7 +35,12 @@
 #include "WebTouchPoint.h"
 #include "platform/WebGraphicsContext3D.h"
 #include "platform/WebKitPlatformSupport.h"
+#include "public/WebCompositorSupport.h"
+#include "public/WebExternalTextureLayer.h"
+#include "public/WebExternalTextureLayerClient.h"
 #include <wtf/Assertions.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/StringExtras.h>
 #include <wtf/text/CString.h>
 
@@ -143,7 +148,7 @@
     return WebPluginContainer::TouchEventRequestTypeNone;
 }
 
-class WebTestPluginImpl : public WebTestPlugin {
+class WebTestPluginImpl : public WebTestPlugin, public WebExternalTextureLayerClient {
 public:
     WebTestPluginImpl(WebFrame*, const WebPluginParams&, WebTestDelegate*);
     virtual ~WebTestPluginImpl();
@@ -168,6 +173,10 @@
     virtual void didFailLoadingFrameRequest(const WebURL&, void* notifyData, const WebURLError&) { }
     virtual bool isPlaceholder() { return false; }
 
+    // WebExternalTextureLayerClient methods:
+    virtual unsigned prepareTexture(WebTextureUpdater&) { return m_colorTexture; }
+    virtual WebGraphicsContext3D* context() { return m_context; }
+
 private:
     enum Primitive {
         PrimitiveNone,
@@ -223,6 +232,7 @@
     unsigned m_colorTexture;
     unsigned m_framebuffer;
     Scene m_scene;
+    OwnPtr<WebExternalTextureLayer> m_layer;
 
     WebPluginContainer::TouchEventRequestType m_touchEventRequest;
     bool m_printEventDetails;
@@ -291,8 +301,9 @@
     if (!initScene())
         return false;
 
+    m_layer = adoptPtr(webKitPlatformSupport()->compositorSupport()->createExternalTextureLayer(this));
     m_container = container;
-    m_container->setBackingTextureId(m_colorTexture);
+    m_container->setWebLayer(m_layer->layer());
     m_container->requestTouchEventType(m_touchEventRequest);
     m_container->setWantsWheelEvents(true);
     return true;
@@ -300,6 +311,7 @@
 
 void WebTestPluginImpl::destroy()
 {
+    m_layer.clear();
     destroyScene();
 
     delete m_context;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to