[chromium] Separate IOSurface layer type from texture layers
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2012 23:15:53 +0000 (23:15 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2012 23:15:53 +0000 (23:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85030

Reviewed by Adrienne Walker.

Source/Platform:

Adds a new layer type for IOSurface backed layers, instead of sharing that functionality in
WebExternalTextureLayer. IOSurface backed layers do not share any other properties with external texture layers.

* Platform.gypi:
* chromium/public/WebExternalTextureLayer.h:
(WebExternalTextureLayer):
* chromium/public/WebIOSurfaceLayer.h:
(WebCore):
(WebKit):
(WebIOSurfaceLayer):
(WebKit::WebIOSurfaceLayer::WebIOSurfaceLayer):
(WebKit::WebIOSurfaceLayer::~WebIOSurfaceLayer):

Source/WebCore:

Adds a new layer type for IOSurface layers and pipes through a separate path through to rendering. IOSurface
layers are very simple - they have an IOSurface id and size, nothing else. All IOSurface layers are "flipped" in
our terminology.

* WebCore.gypi:
* platform/graphics/chromium/IOSurfaceLayerChromium.cpp:
(WebCore):
(WebCore::IOSurfaceLayerChromium::create):
(WebCore::IOSurfaceLayerChromium::IOSurfaceLayerChromium):
(WebCore::IOSurfaceLayerChromium::~IOSurfaceLayerChromium):
(WebCore::IOSurfaceLayerChromium::setIOSurfaceProperties):
(WebCore::IOSurfaceLayerChromium::createCCLayerImpl):
(WebCore::IOSurfaceLayerChromium::drawsContent):
(WebCore::IOSurfaceLayerChromium::pushPropertiesTo):
* platform/graphics/chromium/IOSurfaceLayerChromium.h:
(WebCore):
(IOSurfaceLayerChromium):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawIOSurfaceQuad):
(WebCore::LayerRendererChromium::cleanupSharedObjects):
* platform/graphics/chromium/LayerRendererChromium.h:
(LayerRendererChromium):
* platform/graphics/chromium/TextureLayerChromium.cpp:
(WebCore::TextureLayerChromium::TextureLayerChromium):
(WebCore::TextureLayerChromium::drawsContent):
(WebCore::TextureLayerChromium::pushPropertiesTo):
* platform/graphics/chromium/TextureLayerChromium.h:
(TextureLayerChromium):
* platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp:
(WebCore::CCIOSurfaceDrawQuad::create):
(WebCore::CCIOSurfaceDrawQuad::CCIOSurfaceDrawQuad):
* platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h:
(CCIOSurfaceDrawQuad):
* platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp:
(WebCore):
(WebCore::CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl):
(WebCore::CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl):
(WebCore::CCIOSurfaceLayerImpl::willDraw):
(WebCore::CCIOSurfaceLayerImpl::appendQuads):
(WebCore::CCIOSurfaceLayerImpl::dumpLayerProperties):
(WebCore::CCIOSurfaceLayerImpl::didLoseContext):
(WebCore::CCIOSurfaceLayerImpl::setIOSurfaceProperties):
* platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h:
(WebCore):
(CCIOSurfaceLayerImpl):
(WebCore::CCIOSurfaceLayerImpl::create):
* platform/graphics/chromium/cc/CCTextureLayerImpl.cpp:
(WebCore::CCTextureLayerImpl::CCTextureLayerImpl):
(WebCore::CCTextureLayerImpl::~CCTextureLayerImpl):
(WebCore::CCTextureLayerImpl::appendQuads):
(WebCore::CCTextureLayerImpl::didLoseContext):
* platform/graphics/chromium/cc/CCTextureLayerImpl.h:
(CCTextureLayerImpl):

Source/WebKit/chromium:

Update WebPluginContainerImpl to support having either a texture or IOSurface layer (but never both) depending
on the plugin's contents.

* WebKit.gyp:
* src/WebExternalTextureLayer.cpp:
* src/WebIOSurfaceLayer.cpp:
(WebKit):
(WebKit::WebIOSurfaceLayer::create):
(WebKit::WebIOSurfaceLayer::setIOSurfaceProperties):
(WebKit::WebIOSurfaceLayer::WebIOSurfaceLayer):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::setBackingTextureId):
(WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
(WebKit::WebPluginContainerImpl::commitBackingTexture):
(WebKit::WebPluginContainerImpl::setOpaque):
(WebKit::WebPluginContainerImpl::platformLayer):
(WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
* src/WebPluginContainerImpl.h:
(WebPluginContainerImpl):

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

24 files changed:
Source/Platform/ChangeLog
Source/Platform/Platform.gypi
Source/Platform/chromium/public/WebExternalTextureLayer.h
Source/Platform/chromium/public/WebIOSurfaceLayer.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/TextureLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TextureLayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp
Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h
Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/src/WebExternalTextureLayer.cpp
Source/WebKit/chromium/src/WebIOSurfaceLayer.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
Source/WebKit/chromium/src/WebPluginContainerImpl.h

index f8b3fba..02cd92b 100644 (file)
@@ -1,3 +1,23 @@
+2012-04-26  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Separate IOSurface layer type from texture layers
+        https://bugs.webkit.org/show_bug.cgi?id=85030
+
+        Reviewed by Adrienne Walker.
+
+        Adds a new layer type for IOSurface backed layers, instead of sharing that functionality in
+        WebExternalTextureLayer. IOSurface backed layers do not share any other properties with external texture layers.
+
+        * Platform.gypi:
+        * chromium/public/WebExternalTextureLayer.h:
+        (WebExternalTextureLayer):
+        * chromium/public/WebIOSurfaceLayer.h:
+        (WebCore):
+        (WebKit):
+        (WebIOSurfaceLayer):
+        (WebKit::WebIOSurfaceLayer::WebIOSurfaceLayer):
+        (WebKit::WebIOSurfaceLayer::~WebIOSurfaceLayer):
+
 2012-04-25  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Remove guarded virtual methods from WebFilterOperation API
index 6376140..77d7aa0 100644 (file)
@@ -55,6 +55,7 @@
             'chromium/public/WebHTTPLoadInfo.h',
             'chromium/public/WebICECandidateDescriptor.h',
             'chromium/public/WebICEOptions.h',
+            'chromium/public/WebIOSurfaceLayer.h',
             'chromium/public/WebLayer.h',
             'chromium/public/WebLayerTreeView.h',
             'chromium/public/WebLayerTreeViewClient.h',
index 83330d3..0b34a2d 100644 (file)
@@ -53,10 +53,6 @@ public:
     // compositor context.
     WEBKIT_EXPORT void setTextureId(unsigned);
 
-    // Sets the IO surface id that represents this layer. setTextureId() and setIOSurfaceProperties() are mutually
-    // exclusive - a layer can be either backed by a texture or an IO surface, but not both.
-    WEBKIT_EXPORT void setIOSurfaceProperties(const WebSize&, unsigned ioSurfaceId);
-
     // Sets whether or not the texture should be flipped in the Y direction when
     // rendered.
     WEBKIT_EXPORT void setFlipped(bool);
diff --git a/Source/Platform/chromium/public/WebIOSurfaceLayer.h b/Source/Platform/chromium/public/WebIOSurfaceLayer.h
new file mode 100644 (file)
index 0000000..37a4c67
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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 WebIOSurfaceLayer_h
+#define WebIOSurfaceLayer_h
+
+#include "WebCommon.h"
+#include "WebLayer.h"
+#include "WebSize.h"
+
+namespace WebCore {
+class IOSurfaceLayerChromium;
+}
+
+namespace WebKit {
+
+// This class represents a layer that renders an externally managed IOSurface.
+class WebIOSurfaceLayer : public WebLayer {
+public:
+    WEBKIT_EXPORT static WebIOSurfaceLayer create();
+
+    WebIOSurfaceLayer() { }
+    virtual ~WebIOSurfaceLayer() { }
+
+    // Sets the IO surface id that represents this layer's contents.
+    WEBKIT_EXPORT void setIOSurfaceProperties(unsigned ioSurfaceId, WebSize);
+
+private:
+#if WEBKIT_IMPLEMENTATION
+    explicit WebIOSurfaceLayer(PassRefPtr<WebCore::IOSurfaceLayerChromium>);
+#endif
+};
+
+} // namespace WebKit
+
+#endif // WebIOSurfaceLayer_h
index f08445f..936e899 100644 (file)
@@ -1,3 +1,64 @@
+2012-04-26  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Separate IOSurface layer type from texture layers
+        https://bugs.webkit.org/show_bug.cgi?id=85030
+
+        Reviewed by Adrienne Walker.
+
+        Adds a new layer type for IOSurface layers and pipes through a separate path through to rendering. IOSurface
+        layers are very simple - they have an IOSurface id and size, nothing else. All IOSurface layers are "flipped" in
+        our terminology.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/IOSurfaceLayerChromium.cpp:
+        (WebCore):
+        (WebCore::IOSurfaceLayerChromium::create):
+        (WebCore::IOSurfaceLayerChromium::IOSurfaceLayerChromium):
+        (WebCore::IOSurfaceLayerChromium::~IOSurfaceLayerChromium):
+        (WebCore::IOSurfaceLayerChromium::setIOSurfaceProperties):
+        (WebCore::IOSurfaceLayerChromium::createCCLayerImpl):
+        (WebCore::IOSurfaceLayerChromium::drawsContent):
+        (WebCore::IOSurfaceLayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/IOSurfaceLayerChromium.h:
+        (WebCore):
+        (IOSurfaceLayerChromium):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawIOSurfaceQuad):
+        (WebCore::LayerRendererChromium::cleanupSharedObjects):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (LayerRendererChromium):
+        * platform/graphics/chromium/TextureLayerChromium.cpp:
+        (WebCore::TextureLayerChromium::TextureLayerChromium):
+        (WebCore::TextureLayerChromium::drawsContent):
+        (WebCore::TextureLayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/TextureLayerChromium.h:
+        (TextureLayerChromium):
+        * platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp:
+        (WebCore::CCIOSurfaceDrawQuad::create):
+        (WebCore::CCIOSurfaceDrawQuad::CCIOSurfaceDrawQuad):
+        * platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h:
+        (CCIOSurfaceDrawQuad):
+        * platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp:
+        (WebCore):
+        (WebCore::CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl):
+        (WebCore::CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl):
+        (WebCore::CCIOSurfaceLayerImpl::willDraw):
+        (WebCore::CCIOSurfaceLayerImpl::appendQuads):
+        (WebCore::CCIOSurfaceLayerImpl::dumpLayerProperties):
+        (WebCore::CCIOSurfaceLayerImpl::didLoseContext):
+        (WebCore::CCIOSurfaceLayerImpl::setIOSurfaceProperties):
+        * platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h:
+        (WebCore):
+        (CCIOSurfaceLayerImpl):
+        (WebCore::CCIOSurfaceLayerImpl::create):
+        * platform/graphics/chromium/cc/CCTextureLayerImpl.cpp:
+        (WebCore::CCTextureLayerImpl::CCTextureLayerImpl):
+        (WebCore::CCTextureLayerImpl::~CCTextureLayerImpl):
+        (WebCore::CCTextureLayerImpl::appendQuads):
+        (WebCore::CCTextureLayerImpl::didLoseContext):
+        * platform/graphics/chromium/cc/CCTextureLayerImpl.h:
+        (CCTextureLayerImpl):
+
 2012-04-27  Arvid Nilsson  <anilsson@rim.com>
 
         [BlackBerry] OpenGL related bug fixes
index f9f03c4..c14fadf 100644 (file)
             'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp',
             'platform/graphics/chromium/GraphicsLayerChromium.cpp',
             'platform/graphics/chromium/GraphicsLayerChromium.h',
+            'platform/graphics/chromium/IOSurfaceLayerChromium.cpp',
+            'platform/graphics/chromium/IOSurfaceLayerChromium.h',
             'platform/graphics/chromium/IconChromium.cpp',
             'platform/graphics/chromium/IconChromiumAndroid.cpp',
             'platform/graphics/chromium/ImageBufferDataSkia.h',
             'platform/graphics/chromium/LayerPainterChromium.h',
             'platform/graphics/chromium/LayerRendererChromium.cpp',
             'platform/graphics/chromium/LayerRendererChromium.h',
-            'platform/graphics/chromium/ManagedTexture.cpp',
-            'platform/graphics/chromium/ManagedTexture.h',
             'platform/graphics/chromium/LayerTextureSubImage.cpp',
             'platform/graphics/chromium/LayerTextureSubImage.h',
             'platform/graphics/chromium/LayerTextureUpdater.h',
+            'platform/graphics/chromium/ManagedTexture.cpp',
+            'platform/graphics/chromium/ManagedTexture.h',
             'platform/graphics/chromium/MediaPlayerPrivateChromium.h',
-            'platform/graphics/chromium/ScrollbarLayerChromium.cpp',
-            'platform/graphics/chromium/ScrollbarLayerChromium.h',
-            'platform/graphics/chromium/SolidColorLayerChromium.cpp',
-            'platform/graphics/chromium/SolidColorLayerChromium.h',
             'platform/graphics/chromium/PlatformCanvas.cpp',
             'platform/graphics/chromium/PlatformCanvas.h',
             'platform/graphics/chromium/PlatformColor.h',
             'platform/graphics/chromium/PlatformIcon.h',
             'platform/graphics/chromium/PlatformImage.cpp',
             'platform/graphics/chromium/PlatformImage.h',
-            'platform/graphics/chromium/TextureLayerChromium.cpp',
-            'platform/graphics/chromium/TextureLayerChromium.h',
             'platform/graphics/chromium/ProgramBinding.cpp',
             'platform/graphics/chromium/ProgramBinding.h',
             'platform/graphics/chromium/RateLimiter.cpp',
             'platform/graphics/chromium/RateLimiter.h',
             'platform/graphics/chromium/RenderSurfaceChromium.cpp',
             'platform/graphics/chromium/RenderSurfaceChromium.h',
+            'platform/graphics/chromium/ScrollbarLayerChromium.cpp',
+            'platform/graphics/chromium/ScrollbarLayerChromium.h',
             'platform/graphics/chromium/ShaderChromium.cpp',
             'platform/graphics/chromium/ShaderChromium.h',
             'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
             'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp',
             'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h',
-            'platform/graphics/chromium/TrackingTextureAllocator.cpp',
-            'platform/graphics/chromium/TrackingTextureAllocator.h',
+            'platform/graphics/chromium/SolidColorLayerChromium.cpp',
+            'platform/graphics/chromium/SolidColorLayerChromium.h',
             'platform/graphics/chromium/TextureCopier.cpp',
             'platform/graphics/chromium/TextureCopier.h',
+            'platform/graphics/chromium/TextureLayerChromium.cpp',
+            'platform/graphics/chromium/TextureLayerChromium.h',
             'platform/graphics/chromium/TextureManager.cpp',
             'platform/graphics/chromium/TextureManager.h',
             'platform/graphics/chromium/TextureUploader.cpp',
             'platform/graphics/chromium/TextureUploader.h',
             'platform/graphics/chromium/TiledLayerChromium.cpp',
             'platform/graphics/chromium/TiledLayerChromium.h',
+            'platform/graphics/chromium/TrackingTextureAllocator.cpp',
+            'platform/graphics/chromium/TrackingTextureAllocator.h',
             'platform/graphics/chromium/TransparencyWin.cpp',
             'platform/graphics/chromium/TransparencyWin.h',
             'platform/graphics/chromium/TreeSynchronizer.cpp',
             'platform/graphics/chromium/cc/CCHeadsUpDisplay.h',
             'platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp',
             'platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h',
+            'platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp',
+            'platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h',
             'platform/graphics/chromium/cc/CCInputHandler.h',
             'platform/graphics/chromium/cc/CCKeyframedAnimationCurve.cpp',
             'platform/graphics/chromium/cc/CCKeyframedAnimationCurve.h',
diff --git a/Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.cpp
new file mode 100644 (file)
index 0000000..df6d6c8
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "IOSurfaceLayerChromium.h"
+
+#include "cc/CCIOSurfaceLayerImpl.h"
+
+namespace WebCore {
+
+PassRefPtr<IOSurfaceLayerChromium> IOSurfaceLayerChromium::create()
+{
+    return adoptRef(new IOSurfaceLayerChromium());
+}
+
+IOSurfaceLayerChromium::IOSurfaceLayerChromium()
+    : LayerChromium()
+    , m_ioSurfaceId(0)
+{
+}
+
+IOSurfaceLayerChromium::~IOSurfaceLayerChromium()
+{
+}
+
+void IOSurfaceLayerChromium::setIOSurfaceProperties(uint32_t ioSurfaceId, const IntSize& size)
+{
+    m_ioSurfaceId = ioSurfaceId;
+    m_ioSurfaceSize = size;
+    setNeedsCommit();
+}
+
+PassOwnPtr<CCLayerImpl> IOSurfaceLayerChromium::createCCLayerImpl()
+{
+    return CCIOSurfaceLayerImpl::create(m_layerId);
+}
+
+bool IOSurfaceLayerChromium::drawsContent() const
+{
+    return m_ioSurfaceId && LayerChromium::drawsContent();
+}
+
+void IOSurfaceLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
+{
+    LayerChromium::pushPropertiesTo(layer);
+
+    CCIOSurfaceLayerImpl* textureLayer = static_cast<CCIOSurfaceLayerImpl*>(layer);
+    textureLayer->setIOSurfaceProperties(m_ioSurfaceId, m_ioSurfaceSize);
+}
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.h b/Source/WebCore/platform/graphics/chromium/IOSurfaceLayerChromium.h
new file mode 100644 (file)
index 0000000..17f943b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 IOSurfaceLayerChromium_h
+#define IOSurfaceLayerChromium_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerChromium.h"
+
+namespace WebCore {
+
+class IOSurfaceLayerChromium : public LayerChromium {
+public:
+    static PassRefPtr<IOSurfaceLayerChromium> create();
+    virtual ~IOSurfaceLayerChromium();
+
+    void setIOSurfaceProperties(uint32_t ioSurfaceId, const IntSize&);
+
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() OVERRIDE;
+    virtual bool drawsContent() const OVERRIDE;
+    virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
+
+protected:
+    IOSurfaceLayerChromium();
+
+private:
+
+    uint32_t m_ioSurfaceId;
+    IntSize m_ioSurfaceSize;
+};
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
index 0afcae8..8a2afd1 100644 (file)
@@ -1023,10 +1023,7 @@ void LayerRendererChromium::drawIOSurfaceQuad(const CCIOSurfaceDrawQuad* quad)
 {
     ASSERT(CCProxy::isImplThread());
     TexTransformTextureProgramBinding binding;
-    if (quad->flipped())
-        binding.set(textureIOSurfaceProgramFlip());
-    else
-        binding.set(textureIOSurfaceProgram());
+    binding.set(textureIOSurfaceProgram());
 
     GLC(context(), context()->useProgram(binding.programId));
     GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
@@ -1567,17 +1564,6 @@ const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::tex
     return m_textureIOSurfaceProgram.get();
 }
 
-const LayerRendererChromium::TextureIOSurfaceProgramFlip* LayerRendererChromium::textureIOSurfaceProgramFlip()
-{
-    if (!m_textureIOSurfaceProgramFlip)
-        m_textureIOSurfaceProgramFlip = adoptPtr(new TextureIOSurfaceProgramFlip(m_context.get()));
-    if (!m_textureIOSurfaceProgramFlip->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::textureIOSurfaceProgramFlip::initialize", this, 0);
-        m_textureIOSurfaceProgramFlip->initialize(m_context.get());
-    }
-    return m_textureIOSurfaceProgramFlip.get();
-}
-
 const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVProgram()
 {
     if (!m_videoYUVProgram)
@@ -1636,8 +1622,6 @@ void LayerRendererChromium::cleanupSharedObjects()
         m_textureProgramFlip->cleanup(m_context.get());
     if (m_textureIOSurfaceProgram)
         m_textureIOSurfaceProgram->cleanup(m_context.get());
-    if (m_textureIOSurfaceProgramFlip)
-        m_textureIOSurfaceProgramFlip->cleanup(m_context.get());
 
     if (m_videoYUVProgram)
         m_videoYUVProgram->cleanup(m_context.get());
index ace5084..44bf28d 100644 (file)
@@ -223,8 +223,7 @@ private:
     // Texture shaders.
     typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexAlpha> TextureProgram;
     typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexFlipAlpha> TextureProgramFlip;
-    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectAlpha> TextureIOSurfaceProgram;
-    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectFlipAlpha> TextureIOSurfaceProgramFlip;
+    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectFlipAlpha> TextureIOSurfaceProgram;
 
     // Video shaders.
     typedef ProgramBinding<VertexShaderVideoTransform, FragmentShaderOESImageExternal> VideoStreamTextureProgram;
@@ -253,7 +252,6 @@ private:
     const TextureProgram* textureProgram();
     const TextureProgramFlip* textureProgramFlip();
     const TextureIOSurfaceProgram* textureIOSurfaceProgram();
-    const TextureIOSurfaceProgramFlip* textureIOSurfaceProgramFlip();
 
     const VideoYUVProgram* videoYUVProgram();
     const VideoStreamTextureProgram* videoStreamTextureProgram();
@@ -278,7 +276,6 @@ private:
     OwnPtr<TextureProgram> m_textureProgram;
     OwnPtr<TextureProgramFlip> m_textureProgramFlip;
     OwnPtr<TextureIOSurfaceProgram> m_textureIOSurfaceProgram;
-    OwnPtr<TextureIOSurfaceProgramFlip> m_textureIOSurfaceProgramFlip;
 
     OwnPtr<VideoYUVProgram> m_videoYUVProgram;
     OwnPtr<VideoStreamTextureProgram> m_videoStreamTextureProgram;
index 9767e3e..b0a1ec4 100644 (file)
@@ -49,7 +49,6 @@ TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client)
     , m_rateLimitContext(false)
     , m_contextLost(false)
     , m_textureId(0)
-    , m_ioSurfaceId(0)
 {
 }
 
@@ -96,13 +95,6 @@ void TextureLayerChromium::setTextureId(unsigned id)
     setNeedsCommit();
 }
 
-void TextureLayerChromium::setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId)
-{
-    m_ioSurfaceSize = IntSize(width, height);
-    m_ioSurfaceId = ioSurfaceId;
-    setNeedsCommit();
-}
-
 void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
 {
     LayerChromium::setNeedsDisplayRect(dirtyRect);
@@ -113,7 +105,7 @@ void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
 
 bool TextureLayerChromium::drawsContent() const
 {
-    return (m_client || m_textureId || m_ioSurfaceId) && !m_contextLost && LayerChromium::drawsContent();
+    return (m_client || m_textureId) && !m_contextLost && LayerChromium::drawsContent();
 }
 
 void TextureLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker*)
@@ -135,7 +127,6 @@ void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
     textureLayer->setUVRect(m_uvRect);
     textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
     textureLayer->setTextureId(m_textureId);
-    textureLayer->setIOSurfaceProperties(m_ioSurfaceSize, m_ioSurfaceId);
 }
 
 }
index 24f5ac5..a306012 100644 (file)
@@ -77,9 +77,6 @@ public:
     // Code path for plugins which supply their own texture ID.
     void setTextureId(unsigned);
 
-    // Code path for plugins which render via an IOSurface.
-    void setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId);
-
     virtual void setNeedsDisplayRect(const FloatRect&) OVERRIDE;
 
     virtual bool drawsContent() const OVERRIDE;
@@ -99,9 +96,6 @@ private:
     bool m_contextLost;
 
     unsigned m_textureId;
-
-    IntSize m_ioSurfaceSize;
-    uint32_t m_ioSurfaceId;
 };
 
 }
index e9cfc7b..2fdb4ef 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<CCIOSurfaceDrawQuad> CCIOSurfaceDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
+PassOwnPtr<CCIOSurfaceDrawQuad> CCIOSurfaceDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
 {
-    return adoptPtr(new CCIOSurfaceDrawQuad(sharedQuadState, quadRect, flipped, ioSurfaceSize, ioSurfaceTextureId));
+    return adoptPtr(new CCIOSurfaceDrawQuad(sharedQuadState, quadRect, ioSurfaceSize, ioSurfaceTextureId));
 }
 
-CCIOSurfaceDrawQuad::CCIOSurfaceDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
+CCIOSurfaceDrawQuad::CCIOSurfaceDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
     : CCDrawQuad(sharedQuadState, CCDrawQuad::IOSurfaceContent, quadRect)
-    , m_flipped(flipped)
     , m_ioSurfaceSize(ioSurfaceSize)
     , m_ioSurfaceTextureId(ioSurfaceTextureId)
 {
index 51b59c5..27f863e 100644 (file)
@@ -34,16 +34,14 @@ namespace WebCore {
 class CCIOSurfaceDrawQuad : public CCDrawQuad {
     WTF_MAKE_NONCOPYABLE(CCIOSurfaceDrawQuad);
 public:
-    static PassOwnPtr<CCIOSurfaceDrawQuad> create(const CCSharedQuadState*, const IntRect&, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
+    static PassOwnPtr<CCIOSurfaceDrawQuad> create(const CCSharedQuadState*, const IntRect&, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
 
-    bool flipped() const { return m_flipped; }
     const IntSize& ioSurfaceSize() const { return m_ioSurfaceSize; }
     unsigned ioSurfaceTextureId() const { return m_ioSurfaceTextureId; }
 
 private:
-    CCIOSurfaceDrawQuad(const CCSharedQuadState*, const IntRect&, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
+    CCIOSurfaceDrawQuad(const CCSharedQuadState*, const IntRect&, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
 
-    bool m_flipped;
     IntSize m_ioSurfaceSize;
     unsigned m_ioSurfaceTextureId;
 };
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp
new file mode 100644 (file)
index 0000000..95c32bd
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "cc/CCIOSurfaceLayerImpl.h"
+
+#include "Extensions3DChromium.h"
+#include "GraphicsContext3D.h"
+#include "LayerRendererChromium.h"
+#include "cc/CCIOSurfaceDrawQuad.h"
+#include "cc/CCProxy.h"
+#include "cc/CCQuadCuller.h"
+
+namespace WebCore {
+
+CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl(int id)
+    : CCLayerImpl(id)
+    , m_ioSurfaceId(0)
+    , m_ioSurfaceChanged(false)
+    , m_ioSurfaceTextureId(0)
+{
+}
+
+CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl()
+{
+    // FIXME: it seems there is no layer renderer / GraphicsContext3D available here. Ideally we
+    // would like to delete m_ioSurfaceTextureId.
+    m_ioSurfaceTextureId = 0;
+}
+
+void CCIOSurfaceLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
+{
+    CCLayerImpl::willDraw(layerRenderer);
+
+    if (m_ioSurfaceChanged) {
+        GraphicsContext3D* context = layerRenderer->context();
+        Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
+        ASSERT(extensions->supports("GL_CHROMIUM_iosurface"));
+        ASSERT(extensions->supports("GL_ARB_texture_rectangle"));
+
+        if (!m_ioSurfaceTextureId)
+            m_ioSurfaceTextureId = context->createTexture();
+
+        GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
+        GLC(context, context->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, m_ioSurfaceTextureId));
+        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
+        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
+        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
+        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
+        extensions->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB,
+                                                m_ioSurfaceSize.width(),
+                                                m_ioSurfaceSize.height(),
+                                                m_ioSurfaceId,
+                                                0);
+        // Do not check for error conditions. texImageIOSurface2DCHROMIUM is supposed to hold on to
+        // the last good IOSurface if the new one is already closed. This is only a possibility
+        // during live resizing of plugins. However, it seems that this is not sufficient to
+        // completely guard against garbage being drawn. If this is found to be a significant issue,
+        // it may be necessary to explicitly tell the embedder when to free the surfaces it has
+        // allocated.
+        m_ioSurfaceChanged = false;
+    }
+}
+
+void CCIOSurfaceLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
+{
+    IntRect quadRect(IntPoint(), bounds());
+    quadList.append(CCIOSurfaceDrawQuad::create(sharedQuadState, quadRect, m_ioSurfaceSize, m_ioSurfaceTextureId));
+}
+
+void CCIOSurfaceLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
+{
+    writeIndent(ts, indent);
+    ts << "iosurface id: " << m_ioSurfaceId << " texture id: " << m_ioSurfaceTextureId;
+    CCLayerImpl::dumpLayerProperties(ts, indent);
+}
+
+void CCIOSurfaceLayerImpl::didLoseContext()
+{
+    // We don't have a valid texture ID in the new context; however,
+    // the IOSurface is still valid.
+    m_ioSurfaceTextureId = 0;
+    m_ioSurfaceChanged = true;
+}
+
+void CCIOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const IntSize& size)
+{
+    if (m_ioSurfaceId != ioSurfaceId)
+        m_ioSurfaceChanged = true;
+
+    m_ioSurfaceId = ioSurfaceId;
+    m_ioSurfaceSize = size;
+}
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.h
new file mode 100644 (file)
index 0000000..5d66496
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 CCIOSurfaceLayerImpl_h
+#define CCIOSurfaceLayerImpl_h
+
+#include "IntSize.h"
+#include "cc/CCLayerImpl.h"
+
+namespace WebCore {
+
+class CCIOSurfaceLayerImpl : public CCLayerImpl {
+public:
+    static PassOwnPtr<CCIOSurfaceLayerImpl> create(int id)
+    {
+        return adoptPtr(new CCIOSurfaceLayerImpl(id));
+    }
+    virtual ~CCIOSurfaceLayerImpl();
+
+    void setIOSurfaceProperties(unsigned ioSurfaceId, const IntSize&);
+
+    virtual void appendQuads(CCQuadCuller&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
+
+    virtual void willDraw(LayerRendererChromium*) OVERRIDE;
+    virtual void didLoseContext() OVERRIDE;
+
+    virtual void dumpLayerProperties(TextStream&, int indent) const OVERRIDE;
+
+private:
+    explicit CCIOSurfaceLayerImpl(int);
+
+    virtual const char* layerTypeAsString() const OVERRIDE { return "IOSurfaceLayer"; }
+
+    unsigned m_ioSurfaceId;
+    IntSize m_ioSurfaceSize;
+    bool m_ioSurfaceChanged;
+    unsigned m_ioSurfaceTextureId;
+};
+
+}
+
+#endif // CCIOSurfaceLayerImpl_h
index b881a1e..44d9ff3 100644 (file)
@@ -45,60 +45,17 @@ CCTextureLayerImpl::CCTextureLayerImpl(int id)
     , m_premultipliedAlpha(true)
     , m_flipped(true)
     , m_uvRect(0, 0, 1, 1)
-    , m_ioSurfaceId(0)
-    , m_ioSurfaceChanged(false)
-    , m_ioSurfaceTextureId(0)
 {
 }
 
 CCTextureLayerImpl::~CCTextureLayerImpl()
 {
-    // FIXME: it seems there is no layer renderer / GraphicsContext3D available here. Ideally we
-    // would like to delete m_ioSurfaceTextureId.
-    m_ioSurfaceTextureId = 0;
-}
-
-void CCTextureLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
-{
-    CCLayerImpl::willDraw(layerRenderer);
-
-    if (m_ioSurfaceChanged) {
-        GraphicsContext3D* context = layerRenderer->context();
-        Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
-        ASSERT(extensions->supports("GL_CHROMIUM_iosurface"));
-        ASSERT(extensions->supports("GL_ARB_texture_rectangle"));
-
-        if (!m_ioSurfaceTextureId)
-            m_ioSurfaceTextureId = context->createTexture();
-
-        GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
-        GLC(context, context->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, m_ioSurfaceTextureId));
-        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
-        GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
-        extensions->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB,
-                                                m_ioSurfaceSize.width(),
-                                                m_ioSurfaceSize.height(),
-                                                m_ioSurfaceId,
-                                                0);
-        // Do not check for error conditions. texImageIOSurface2DCHROMIUM is supposed to hold on to
-        // the last good IOSurface if the new one is already closed. This is only a possibility
-        // during live resizing of plugins. However, it seems that this is not sufficient to
-        // completely guard against garbage being drawn. If this is found to be a significant issue,
-        // it may be necessary to explicitly tell the embedder when to free the surfaces it has
-        // allocated.
-        m_ioSurfaceChanged = false;
-    }
 }
 
 void CCTextureLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
 {
     IntRect quadRect(IntPoint(), bounds());
-    if (m_textureId)
-        quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_premultipliedAlpha, m_uvRect, m_flipped));
-    else if (m_ioSurfaceTextureId)
-        quadList.append(CCIOSurfaceDrawQuad::create(sharedQuadState, quadRect, m_flipped, m_ioSurfaceSize, m_ioSurfaceTextureId));
+    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_premultipliedAlpha, m_uvRect, m_flipped));
 }
 
 void CCTextureLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
@@ -111,22 +68,8 @@ void CCTextureLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
 void CCTextureLayerImpl::didLoseContext()
 {
     m_textureId = 0;
-    if (m_ioSurfaceId) {
-        // We don't have a valid texture ID in the new context; however,
-        // the IOSurface is still valid.
-        m_ioSurfaceTextureId = 0;
-        m_ioSurfaceChanged = true;
-    }
 }
 
-void CCTextureLayerImpl::setIOSurfaceProperties(const IntSize& size, unsigned ioSurfaceId)
-{
-    if (m_ioSurfaceId != ioSurfaceId)
-        m_ioSurfaceChanged = true;
-
-    m_ioSurfaceSize = size;
-    m_ioSurfaceId = ioSurfaceId;
-}
 }
 
 #endif // USE(ACCELERATED_COMPOSITING)
index ec5c04f..4abdb51 100644 (file)
@@ -40,7 +40,6 @@ public:
 
     virtual void appendQuads(CCQuadCuller&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
 
-    virtual void willDraw(LayerRendererChromium*) OVERRIDE;
     virtual void didLoseContext() OVERRIDE;
 
     virtual void dumpLayerProperties(TextStream&, int indent) const OVERRIDE;
@@ -50,8 +49,6 @@ public:
     void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
     void setFlipped(bool flipped) { m_flipped = flipped; }
     void setUVRect(const FloatRect& rect) { m_uvRect = rect; }
-    void setIOSurfaceProperties(const IntSize&, unsigned ioSurfaceId);
-
 
 private:
     explicit CCTextureLayerImpl(int);
@@ -62,12 +59,6 @@ private:
     bool m_premultipliedAlpha;
     bool m_flipped;
     FloatRect m_uvRect;
-
-    // Internals for IOSurface-backed textures.
-    unsigned m_ioSurfaceId;
-    IntSize m_ioSurfaceSize;
-    bool m_ioSurfaceChanged;
-    unsigned m_ioSurfaceTextureId;
 };
 
 }
index 0f7a60b..d7ddd54 100644 (file)
@@ -1,3 +1,30 @@
+2012-04-26  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Separate IOSurface layer type from texture layers
+        https://bugs.webkit.org/show_bug.cgi?id=85030
+
+        Reviewed by Adrienne Walker.
+
+        Update WebPluginContainerImpl to support having either a texture or IOSurface layer (but never both) depending
+        on the plugin's contents.
+
+        * WebKit.gyp:
+        * src/WebExternalTextureLayer.cpp:
+        * src/WebIOSurfaceLayer.cpp:
+        (WebKit):
+        (WebKit::WebIOSurfaceLayer::create):
+        (WebKit::WebIOSurfaceLayer::setIOSurfaceProperties):
+        (WebKit::WebIOSurfaceLayer::WebIOSurfaceLayer):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::setBackingTextureId):
+        (WebKit::WebPluginContainerImpl::setBackingIOSurfaceId):
+        (WebKit::WebPluginContainerImpl::commitBackingTexture):
+        (WebKit::WebPluginContainerImpl::setOpaque):
+        (WebKit::WebPluginContainerImpl::platformLayer):
+        (WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
+        * src/WebPluginContainerImpl.h:
+        (WebPluginContainerImpl):
+
 2012-04-27  Hans Wennborg  <hans@chromium.org>
 
         Speech JavaScript API: Fix Vector use failure
index 569896d..4162b98 100644 (file)
                 'src/WebIDBTransactionImpl.h',
                 'src/WebIDBTransactionCallbacksImpl.cpp',
                 'src/WebIDBTransactionCallbacksImpl.h',
+                'src/WebIOSurfaceLayer.cpp',
                 'src/WebImageCG.cpp',
                 'src/WebImageDecoder.cpp',
                 'src/WebImageSkia.cpp',
index d2439e8..8f7b58a 100644 (file)
@@ -46,11 +46,6 @@ void WebExternalTextureLayer::setTextureId(unsigned id)
     unwrap<TextureLayerChromium>()->setTextureId(id);
 }
 
-void WebExternalTextureLayer::setIOSurfaceProperties(const WebSize& size, unsigned ioSurfaceId)
-{
-    unwrap<TextureLayerChromium>()->setIOSurfaceProperties(size.width, size.height, ioSurfaceId);
-}
-
 void WebExternalTextureLayer::setFlipped(bool flipped)
 {
     unwrap<TextureLayerChromium>()->setFlipped(flipped);
diff --git a/Source/WebKit/chromium/src/WebIOSurfaceLayer.cpp b/Source/WebKit/chromium/src/WebIOSurfaceLayer.cpp
new file mode 100644 (file)
index 0000000..77db0c8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include <public/WebIOSurfaceLayer.h>
+
+#include "IOSurfaceLayerChromium.h"
+#include <public/WebSize.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIOSurfaceLayer WebIOSurfaceLayer::create()
+{
+    RefPtr<IOSurfaceLayerChromium> layer = IOSurfaceLayerChromium::create();
+    layer->setIsDrawable(true);
+    return WebIOSurfaceLayer(layer.release());
+}
+
+void WebIOSurfaceLayer::setIOSurfaceProperties(unsigned ioSurfaceId, WebSize size)
+{
+    unwrap<IOSurfaceLayerChromium>()->setIOSurfaceProperties(ioSurfaceId, size);
+}
+
+WebIOSurfaceLayer::WebIOSurfaceLayer(PassRefPtr<IOSurfaceLayerChromium> layer)
+    : WebLayer(layer)
+{
+}
+
+} // namespace WebKit
index 2a46224..a4a585b 100644 (file)
@@ -339,7 +339,11 @@ void WebPluginContainerImpl::setBackingTextureId(unsigned textureId)
     if (m_textureId == textureId)
         return;
 
-    m_layer.setTextureId(textureId);
+    ASSERT(m_ioSurfaceLayer.isNull());
+
+    if (m_textureLayer.isNull())
+        m_textureLayer = WebExternalTextureLayer::create();
+    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
@@ -355,11 +359,15 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width,
                                                    int height,
                                                    uint32_t ioSurfaceId)
 {
-#if OS(DARWIN) && USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING)
     if (ioSurfaceId == m_ioSurfaceId)
         return;
 
-    m_layer.setIOSurfaceProperties(WebSize(width, height), ioSurfaceId);
+    ASSERT(m_textureLayer.isNull());
+
+    if (m_ioSurfaceLayer.isNull())
+        m_ioSurfaceLayer = WebIOSurfaceLayer::create();
+    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
@@ -374,8 +382,11 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width,
 void WebPluginContainerImpl::commitBackingTexture()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (!m_layer.isNull())
-        m_layer.invalidate();
+    if (!m_textureLayer.isNull())
+        m_textureLayer.invalidate();
+
+    if (!m_ioSurfaceLayer.isNull())
+        m_ioSurfaceLayer.invalidate();
 #endif
 }
 
@@ -442,8 +453,11 @@ void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
 void WebPluginContainerImpl::setOpaque(bool opaque)
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (!m_layer.isNull())
-        m_layer.setOpaque(opaque);
+    if (!m_textureLayer.isNull())
+        m_textureLayer.setOpaque(opaque);
+
+    if (!m_ioSurfaceLayer.isNull())
+        m_ioSurfaceLayer.setOpaque(opaque);
 #endif
 }
 
@@ -518,7 +532,11 @@ void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver
 #if USE(ACCELERATED_COMPOSITING)
 WebCore::LayerChromium* WebPluginContainerImpl::platformLayer() const
 {
-    return (m_textureId || m_ioSurfaceId) ? m_layer.unwrap<LayerChromium>() : 0;
+    if (m_textureId)
+        return m_textureLayer.unwrap<LayerChromium>();
+    if (m_ioSurfaceId)
+        return m_ioSurfaceLayer.unwrap<LayerChromium>();
+    return 0;
 }
 #endif
 
@@ -558,7 +576,6 @@ WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* eleme
     , m_element(element)
     , m_webPlugin(webPlugin)
 #if USE(ACCELERATED_COMPOSITING)
-    , m_layer(WebExternalTextureLayer::create())
     , m_textureId(0)
     , m_ioSurfaceId(0)
 #endif
index e7d2a65..0487845 100644 (file)
@@ -36,6 +36,7 @@
 #include "Widget.h"
 
 #include <public/WebExternalTextureLayer.h>
+#include <public/WebIOSurfaceLayer.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
@@ -173,9 +174,13 @@ private:
     Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
 
 #if USE(ACCELERATED_COMPOSITING)
-    WebExternalTextureLayer m_layer;
+    // A composited plugin will either have no composited layer, a texture layer, or an IOSurface layer.
+    // It will never have both a texture and IOSurface output.
     unsigned m_textureId;
+    WebExternalTextureLayer m_textureLayer;
+
     unsigned m_ioSurfaceId;
+    WebIOSurfaceLayer m_ioSurfaceLayer;
 #endif
 
     // The associated scrollbar group object, created lazily. Used for Pepper