[chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer...
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 02:00:47 +0000 (02:00 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 02:00:47 +0000 (02:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84311

Reviewed by Adrienne Walker.

Source/Platform:

Remove some unused getters.

* chromium/public/WebExternalTextureLayer.h:
(WebExternalTextureLayer):

Source/WebCore:

WebGL content's interface with the compositor can be expressed in terms of two basic operations:
1.) Do some stuff
2.) Provide a texture ID for the compositor to use

This implements (1) in DrawingBufferChromium and uses the already-existing TextureLayerChromium to handle (2).
This cuts down the compositor interface significantly and allows for more code reuse in exchange for more code
in TextureLayerChromium to handle the features WebGL needs.

* WebCore.gypi:
* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBuffer::~DrawingBuffer):
(DrawingBufferPrivate):
(WebCore::DrawingBufferPrivate::DrawingBufferPrivate):
(WebCore::DrawingBufferPrivate::~DrawingBufferPrivate):
(WebCore::DrawingBufferPrivate::layer):
(WebCore):
(WebCore::DrawingBuffer::platformLayer):
* platform/graphics/chromium/LayerRendererChromium.cpp:
* platform/graphics/chromium/TextureLayerChromium.h:
(TextureLayerChromiumClient):
(WebCore::TextureLayerChromiumClient::~TextureLayerChromiumClient):
(WebCore):
(TextureLayerChromium):
(WebCore::TextureLayerChromium::clearClient):
* platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
* platform/graphics/chromium/WebGLLayerChromium.h: Removed.
* platform/graphics/gpu/DrawingBuffer.h:
(WebCore):
(WebCore::DrawingBuffer::graphicsContext3D):
(DrawingBuffer):

Source/WebKit/chromium:

* WebKit.gypi:
* src/WebExternalTextureLayer.cpp:
(WebKit::WebExternalTextureLayer::create):
* src/WebLayer.cpp:
* tests/WebGLLayerChromiumTest.cpp: Removed.
* tests/WebLayerTest.cpp:

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

21 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebExternalTextureLayer.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/TextureLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TextureLayerChromium.h
Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp [deleted file]
Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h [deleted file]
Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.h
Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/src/WebExternalTextureLayer.cpp
Source/WebKit/chromium/src/WebLayer.cpp
Source/WebKit/chromium/tests/DrawingBufferChromiumTest.cpp [moved from Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp with 95% similarity]
Source/WebKit/chromium/tests/WebLayerTest.cpp

index b688a1415073e5064f5c716f70e815047604ecf8..4d0dbdb85388e3b6dd39fd817c131cb4f92f83d0 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-18  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer type
+        https://bugs.webkit.org/show_bug.cgi?id=84311
+
+        Reviewed by Adrienne Walker.
+
+        Remove some unused getters.
+
+        * chromium/public/WebExternalTextureLayer.h:
+        (WebExternalTextureLayer):
+
 2012-04-20  Dana Jansens  <danakj@chromium.org>
 
         [chromium] WebFilterOperations API does not compile or dynamically link
index 52efbb7eb38206b31f7e7fe8ebc757dc56f614a8..83330d33c052b198185e964eb123893e20f7339c 100644 (file)
@@ -60,12 +60,10 @@ public:
     // Sets whether or not the texture should be flipped in the Y direction when
     // rendered.
     WEBKIT_EXPORT void setFlipped(bool);
-    WEBKIT_EXPORT bool flipped() const;
 
     // Sets the rect in UV space of the texture that is mapped to the layer
     // bounds.
     WEBKIT_EXPORT void setUVRect(const WebFloatRect&);
-    WEBKIT_EXPORT WebFloatRect uvRect() const;
 
 private:
 #if WEBKIT_IMPLEMENTATION
index 8c1df958a0707849e33f7da7ce8c8687a7a7fac0..0050e1b722c904e66d212c1153624852629a1f2a 100644 (file)
@@ -1,3 +1,41 @@
+2012-04-18  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer type
+        https://bugs.webkit.org/show_bug.cgi?id=84311
+
+        Reviewed by Adrienne Walker.
+
+        WebGL content's interface with the compositor can be expressed in terms of two basic operations:
+        1.) Do some stuff
+        2.) Provide a texture ID for the compositor to use
+
+        This implements (1) in DrawingBufferChromium and uses the already-existing TextureLayerChromium to handle (2).
+        This cuts down the compositor interface significantly and allows for more code reuse in exchange for more code
+        in TextureLayerChromium to handle the features WebGL needs.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::~DrawingBuffer):
+        (DrawingBufferPrivate):
+        (WebCore::DrawingBufferPrivate::DrawingBufferPrivate):
+        (WebCore::DrawingBufferPrivate::~DrawingBufferPrivate):
+        (WebCore::DrawingBufferPrivate::layer):
+        (WebCore):
+        (WebCore::DrawingBuffer::platformLayer):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        * platform/graphics/chromium/TextureLayerChromium.h:
+        (TextureLayerChromiumClient):
+        (WebCore::TextureLayerChromiumClient::~TextureLayerChromiumClient):
+        (WebCore):
+        (TextureLayerChromium):
+        (WebCore::TextureLayerChromium::clearClient):
+        * platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
+        * platform/graphics/chromium/WebGLLayerChromium.h: Removed.
+        * platform/graphics/gpu/DrawingBuffer.h:
+        (WebCore):
+        (WebCore::DrawingBuffer::graphicsContext3D):
+        (DrawingBuffer):
+
 2012-04-23  Alec Flett  <alecflett@chromium.org>
 
         IndexedDB: remove IDB(Index|ObjectStore)BackendImpl::get/getKey for IDBKey
index f456899712327b4c40e9f254f25625a4358de22f..27146f60f343c82cf385a088f9a31ac60ee7649f 100644 (file)
             'platform/graphics/chromium/VDMXParser.h',
             'platform/graphics/chromium/VideoLayerChromium.cpp',
             'platform/graphics/chromium/VideoLayerChromium.h',
-            'platform/graphics/chromium/WebGLLayerChromium.cpp',
-            'platform/graphics/chromium/WebGLLayerChromium.h',
             'platform/graphics/chromium/cc/CCActiveAnimation.cpp',
             'platform/graphics/chromium/cc/CCActiveAnimation.h',
             'platform/graphics/chromium/cc/CCActiveGestureAnimation.cpp',
index 92956cf90f09bbfc25f7e0993d244ceb0ac195dc..e33dc27eb6d08f863dae5787cb11ba652ab5bc1b 100644 (file)
@@ -35,8 +35,9 @@
 #include "CanvasRenderingContext.h"
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
-#include "WebGLLayerChromium.h"
+#include "TextureLayerChromium.h"
 #include "cc/CCProxy.h"
+#include "cc/CCTextureUpdater.h"
 #include <algorithm>
 
 using namespace std;
@@ -90,9 +91,6 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
 
 DrawingBuffer::~DrawingBuffer()
 {
-    if (m_platformLayer)
-        m_platformLayer->setDrawingBuffer(0);
-
     if (!m_context)
         return;
 
@@ -149,16 +147,56 @@ unsigned DrawingBuffer::frontColorBuffer() const
 }
 #endif
 
+class DrawingBufferPrivate : public TextureLayerChromiumClient {
+    WTF_MAKE_NONCOPYABLE(DrawingBufferPrivate);
+public:
+    explicit DrawingBufferPrivate(DrawingBuffer* drawingBuffer)
+        : m_drawingBuffer(drawingBuffer)
+        , m_layer(TextureLayerChromium::create(this))
+    {
+        GraphicsContext3D::Attributes attributes = m_drawingBuffer->graphicsContext3D()->getContextAttributes();
+        m_layer->setOpaque(!attributes.alpha);
+        m_layer->setPremultipliedAlpha(attributes.premultipliedAlpha);
+    }
+
+    virtual ~DrawingBufferPrivate()
+    {
+        m_layer->clearClient();
+    }
+
+    virtual unsigned prepareTexture(CCTextureUpdater& updater) OVERRIDE
+    {
+        m_drawingBuffer->prepareBackBuffer();
+
+        context()->flush();
+        context()->markLayerComposited();
+
+        unsigned textureId = m_drawingBuffer->frontColorBuffer();
+        if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
+            updater.appendCopy(m_drawingBuffer->colorBuffer(), textureId, m_drawingBuffer->size());
+
+        return textureId;
+    }
+
+    virtual GraphicsContext3D* context() OVERRIDE
+    {
+        return m_drawingBuffer->graphicsContext3D();
+    }
+
+    LayerChromium* layer() const { return m_layer.get(); }
+
+private:
+    DrawingBuffer* m_drawingBuffer;
+    RefPtr<TextureLayerChromium> m_layer;
+};
+
 #if USE(ACCELERATED_COMPOSITING)
 PlatformLayer* DrawingBuffer::platformLayer()
 {
-    if (!m_platformLayer) {
-        m_platformLayer = WebGLLayerChromium::create();
-        m_platformLayer->setDrawingBuffer(this);
-        m_platformLayer->setOpaque(m_alpha == Opaque);
-    }
+    if (!m_private)
+        m_private = adoptPtr(new DrawingBufferPrivate(this));
 
-    return m_platformLayer.get();
+    return m_private->layer();
 }
 #endif
 
index d83c8e5b67397c3adb3d1c162c6bf7c309e6ca7f..6348e149687f43550965ca86d441bd6d8ff62b21 100644 (file)
@@ -51,7 +51,6 @@
 #include "TraceEvent.h"
 #include "TrackingTextureAllocator.h"
 #include "TreeSynchronizer.h"
-#include "WebGLLayerChromium.h"
 #include "cc/CCCheckerboardDrawQuad.h"
 #include "cc/CCDamageTracker.h"
 #include "cc/CCDebugBorderDrawQuad.h"
@@ -1067,7 +1066,7 @@ void LayerRendererChromium::drawTextureQuad(const CCTextureDrawQuad* quad)
     GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
     GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
 
-    if (quad->hasAlpha() && !quad->premultipliedAlpha())
+    if (!quad->premultipliedAlpha())
         GLC(context(), context()->blendFunc(GraphicsContext3D::SRC_ALPHA, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
 
     const IntSize& bounds = quad->quadRect().size();
index 29cc6ba0b124c0fceeaaa03c6c05edca936dbf05..9767e3e9d62466c0ca78e2d871ca76f8d28d1874 100644 (file)
 
 #include "TextureLayerChromium.h"
 
+#include "Extensions3D.h"
+#include "cc/CCLayerTreeHost.h"
 #include "cc/CCTextureLayerImpl.h"
 
 namespace WebCore {
 
-PassRefPtr<TextureLayerChromium> TextureLayerChromium::create()
+PassRefPtr<TextureLayerChromium> TextureLayerChromium::create(TextureLayerChromiumClient* client)
 {
-    return adoptRef(new TextureLayerChromium);
+    return adoptRef(new TextureLayerChromium(client));
 }
 
-TextureLayerChromium::TextureLayerChromium()
+TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client)
     : LayerChromium()
-    , m_textureId(0)
+    , m_client(client)
     , m_flipped(true)
     , m_uvRect(0, 0, 1, 1)
+    , m_premultipliedAlpha(true)
+    , m_rateLimitContext(false)
+    , m_contextLost(false)
+    , m_textureId(0)
     , m_ioSurfaceId(0)
 {
 }
 
+TextureLayerChromium::~TextureLayerChromium()
+{
+    if (m_rateLimitContext && m_client && layerTreeHost())
+        layerTreeHost()->stopRateLimiter(m_client->context());
+}
+
 PassOwnPtr<CCLayerImpl> TextureLayerChromium::createCCLayerImpl()
 {
     return CCTextureLayerImpl::create(m_layerId);
 }
 
-bool TextureLayerChromium::drawsContent() const
+void TextureLayerChromium::setFlipped(bool flipped)
 {
-    return (m_textureId || m_ioSurfaceId) && LayerChromium::drawsContent();
+    m_flipped = flipped;
+    setNeedsCommit();
 }
 
-void TextureLayerChromium::setTextureId(unsigned id)
+void TextureLayerChromium::setUVRect(const FloatRect& rect)
 {
-    m_textureId = id;
+    m_uvRect = rect;
     setNeedsCommit();
 }
 
-void TextureLayerChromium::setFlipped(bool flipped)
+void TextureLayerChromium::setPremultipliedAlpha(bool premultipliedAlpha)
 {
-    m_flipped = flipped;
+    m_premultipliedAlpha = premultipliedAlpha;
     setNeedsCommit();
 }
 
-void TextureLayerChromium::setUVRect(const FloatRect& rect)
+void TextureLayerChromium::setRateLimitContext(bool rateLimit)
 {
-    m_uvRect = rect;
+    if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost())
+        layerTreeHost()->stopRateLimiter(m_client->context());
+
+    m_rateLimitContext = rateLimit;
+}
+
+void TextureLayerChromium::setTextureId(unsigned id)
+{
+    m_textureId = id;
     setNeedsCommit();
 }
 
@@ -82,14 +103,38 @@ void TextureLayerChromium::setIOSurfaceProperties(int width, int height, uint32_
     setNeedsCommit();
 }
 
+void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
+{
+    LayerChromium::setNeedsDisplayRect(dirtyRect);
+
+    if (m_rateLimitContext && m_client && layerTreeHost())
+        layerTreeHost()->startRateLimiter(m_client->context());
+}
+
+bool TextureLayerChromium::drawsContent() const
+{
+    return (m_client || m_textureId || m_ioSurfaceId) && !m_contextLost && LayerChromium::drawsContent();
+}
+
+void TextureLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker*)
+{
+    if (m_client) {
+        m_textureId = m_client->prepareTexture(updater);
+        m_contextLost = m_client->context()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
+    }
+
+    m_needsDisplay = false;
+}
+
 void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
 {
     LayerChromium::pushPropertiesTo(layer);
 
     CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
-    textureLayer->setTextureId(m_textureId);
     textureLayer->setFlipped(m_flipped);
     textureLayer->setUVRect(m_uvRect);
+    textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
+    textureLayer->setTextureId(m_textureId);
     textureLayer->setIOSurfaceProperties(m_ioSurfaceSize, m_ioSurfaceId);
 }
 
index 7a9109248151b4d11018c7e86709f39aac51c559..24f5ac594127a340c2931d1f46100181be83fa0b 100644 (file)
 
 namespace WebCore {
 
+class TextureLayerChromiumClient {
+public:
+    // Called to prepare this layer's texture for compositing. The client may queue a texture
+    // upload or copy on the CCTextureUpdater.
+    // Returns the texture ID to be used for compositing.
+    virtual unsigned prepareTexture(CCTextureUpdater&) = 0;
+
+    // Returns the context that is providing the texture. Used for rate limiting and detecting lost context.
+    virtual GraphicsContext3D* context() = 0;
+
+protected:
+    virtual ~TextureLayerChromiumClient() { }
+};
+
 // A Layer containing a the rendered output of a plugin instance.
 class TextureLayerChromium : public LayerChromium {
 public:
-    static PassRefPtr<TextureLayerChromium> create();
+    // If this texture layer requires special preparation logic for each frame driven by
+    // the compositor, pass in a non-nil client. Pass in a nil client pointer if texture updates
+    // are driven by an external process.
+    static PassRefPtr<TextureLayerChromium> create(TextureLayerChromiumClient*);
+    virtual ~TextureLayerChromium();
+
+    void clearClient() { m_client = 0; }
 
     virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() OVERRIDE;
 
-    virtual bool drawsContent() const OVERRIDE;
+    // Sets whether this texture should be Y-flipped at draw time. Defaults to true.
+    void setFlipped(bool);
+
+    // Sets a UV transform to be used at draw time. Defaults to (0, 0, 1, 1).
+    void setUVRect(const FloatRect&);
+
+    // Sets whether the alpha channel is premultiplied or unpremultiplied. Defaults to true.
+    void setPremultipliedAlpha(bool);
+
+    // Sets whether this context should rate limit on damage to prevent too many frames from
+    // being queued up before the compositor gets a chance to run. Requires a non-nil client.
+    // Defaults to false.
+    void setRateLimitContext(bool);
 
     // Code path for plugins which supply their own texture ID.
     void setTextureId(unsigned);
-    void setFlipped(bool);
-    bool flipped() const { return m_flipped; }
-    void setUVRect(const FloatRect&);
-    const FloatRect& uvRect() const { return m_uvRect; }
 
     // 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;
+    virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
     virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
 
 protected:
-    TextureLayerChromium();
+    explicit TextureLayerChromium(TextureLayerChromiumClient*);
 
 private:
-    unsigned m_textureId;
+    TextureLayerChromiumClient* m_client;
+
     bool m_flipped;
     FloatRect m_uvRect;
+    bool m_premultipliedAlpha;
+    bool m_rateLimitContext;
+    bool m_contextLost;
+
+    unsigned m_textureId;
+
     IntSize m_ioSurfaceSize;
     uint32_t m_ioSurfaceId;
 };
diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
deleted file mode 100644 (file)
index a8457dd..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2010 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:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "WebGLLayerChromium.h"
-
-#include "DrawingBuffer.h"
-#include "Extensions3DChromium.h"
-#include "GraphicsContext3D.h"
-#include "TextureCopier.h"
-#include "TraceEvent.h"
-#include "cc/CCLayerTreeHost.h"
-#include "cc/CCTextureLayerImpl.h"
-#include "cc/CCTextureUpdater.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLLayerChromium> WebGLLayerChromium::create()
-{
-    return adoptRef(new WebGLLayerChromium());
-}
-
-WebGLLayerChromium::WebGLLayerChromium()
-    : CanvasLayerChromium()
-    , m_hasAlpha(true)
-    , m_premultipliedAlpha(true)
-    , m_contextLost(false)
-    , m_textureId(0)
-    , m_drawingBuffer(0)
-{
-}
-
-WebGLLayerChromium::~WebGLLayerChromium()
-{
-    if (context() && layerTreeHost())
-        layerTreeHost()->stopRateLimiter(context());
-}
-
-bool WebGLLayerChromium::drawsContent() const
-{
-    return LayerChromium::drawsContent() && !m_contextLost;
-}
-
-void WebGLLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker*)
-{
-    if (!drawsContent() || !m_needsDisplay || !m_drawingBuffer)
-        return;
-
-    m_drawingBuffer->prepareBackBuffer();
-
-    context()->flush();
-    context()->markLayerComposited();
-    m_needsDisplay = false;
-    m_contextLost = context()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
-
-    m_textureId = m_drawingBuffer->frontColorBuffer();
-    if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
-        updater.appendCopy(m_drawingBuffer->colorBuffer(), m_textureId, bounds());
-
-    m_drawingBuffer->restoreFramebufferBinding();
-}
-
-void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
-{
-    CanvasLayerChromium::pushPropertiesTo(layer);
-
-    CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
-    textureLayer->setTextureId(m_textureId);
-    textureLayer->setHasAlpha(m_hasAlpha);
-    textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
-}
-
-void WebGLLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
-{
-    LayerChromium::setNeedsDisplayRect(dirtyRect);
-
-    // If WebGL commands are issued outside of a the animation callbacks, then use
-    // call rateLimitOffscreenContextCHROMIUM() to keep the context from getting too far ahead.
-    if (layerTreeHost())
-        layerTreeHost()->startRateLimiter(context());
-}
-
-void WebGLLayerChromium::setDrawingBuffer(DrawingBuffer* drawingBuffer)
-{
-    bool drawingBufferChanged = (m_drawingBuffer != drawingBuffer);
-
-    // The GraphicsContext3D used by the layer is the context associated with
-    // the drawing buffer. If the drawing buffer is changing, make sure
-    // to stop the rate limiter on the old context, not the new context from the
-    // new drawing buffer.
-    GraphicsContext3D* context3D = context();
-    if (layerTreeHost() && drawingBufferChanged && context3D)
-        layerTreeHost()->stopRateLimiter(context3D);
-
-    m_drawingBuffer = drawingBuffer;
-    if (!m_drawingBuffer)
-        return;
-
-    GraphicsContext3D::Attributes attributes = context()->getContextAttributes();
-    m_hasAlpha = attributes.alpha;
-    m_premultipliedAlpha = attributes.premultipliedAlpha;
-    m_contextLost = context()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
-}
-
-GraphicsContext3D* WebGLLayerChromium::context() const
-{
-    if (drawingBuffer())
-        return drawingBuffer()->graphicsContext3D().get();
-
-    return 0;
-}
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
deleted file mode 100644 (file)
index b15f563..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2010 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:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#ifndef WebGLLayerChromium_h
-#define WebGLLayerChromium_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "CanvasLayerChromium.h"
-#include "DrawingBuffer.h"
-
-namespace WebCore {
-
-class GraphicsContext3D;
-class WebGLLayerChromiumRateLimitTask;
-
-// A Layer containing a WebGL canvas
-class WebGLLayerChromium : public CanvasLayerChromium {
-public:
-    static PassRefPtr<WebGLLayerChromium> create();
-
-    virtual ~WebGLLayerChromium();
-
-    virtual bool drawsContent() const OVERRIDE;
-    virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
-    virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
-    virtual void setNeedsDisplayRect(const FloatRect&) OVERRIDE;
-
-    GraphicsContext3D* context() const;
-
-    void setDrawingBuffer(DrawingBuffer*);
-    DrawingBuffer* drawingBuffer() const { return m_drawingBuffer; }
-private:
-    WebGLLayerChromium();
-    friend class WebGLLayerChromiumRateLimitTask;
-
-    bool m_hasAlpha;
-    bool m_premultipliedAlpha;
-    bool m_contextLost;
-    unsigned m_textureId;
-
-    // The DrawingBuffer holding the WebGL contents for this layer.
-    // A reference is not held here, because the DrawingBuffer already holds
-    // a reference to the WebGLLayerChromium.
-    DrawingBuffer* m_drawingBuffer;
-};
-
-}
-#endif // USE(ACCELERATED_COMPOSITING)
-
-#endif
index 64238b794d1b432f0c7be9cad65ebe0b80083e8b..bf57840dbb4d0ef45e23c1b05d54e0605fcd6cdc 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<CCTextureDrawQuad> CCTextureDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
+PassOwnPtr<CCTextureDrawQuad> CCTextureDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
 {
-    return adoptPtr(new CCTextureDrawQuad(sharedQuadState, quadRect, textureId, hasAlpha, premultipliedAlpha, uvRect, flipped, ioSurfaceSize, ioSurfaceTextureId));
+    return adoptPtr(new CCTextureDrawQuad(sharedQuadState, quadRect, textureId, premultipliedAlpha, uvRect, flipped, ioSurfaceSize, ioSurfaceTextureId));
 }
 
-CCTextureDrawQuad::CCTextureDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
+CCTextureDrawQuad::CCTextureDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
     : CCDrawQuad(sharedQuadState, CCDrawQuad::TextureContent, quadRect)
     , m_textureId(textureId)
-    , m_hasAlpha(hasAlpha)
     , m_premultipliedAlpha(premultipliedAlpha)
     , m_uvRect(uvRect)
     , m_flipped(flipped)
index 1a831571bad50dc896110bd85eb884c38382c292..f342bc8285f30283b83c4e9a2bce7d6d1107ad99 100644 (file)
@@ -35,10 +35,9 @@ class CCLayerImpl;
 class CCTextureDrawQuad : public CCDrawQuad {
     WTF_MAKE_NONCOPYABLE(CCTextureDrawQuad);
 public:
-    static PassOwnPtr<CCTextureDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
+    static PassOwnPtr<CCTextureDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
 
     unsigned textureId() const { return  m_textureId; }
-    bool hasAlpha() const { return  m_hasAlpha; }
     bool premultipliedAlpha() const { return  m_premultipliedAlpha; }
     FloatRect uvRect() const { return m_uvRect; }
     bool flipped() const { return m_flipped; }
@@ -47,10 +46,9 @@ public:
     unsigned ioSurfaceTextureId() const { return m_ioSurfaceTextureId; }
  
 private:
-    CCTextureDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
+    CCTextureDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
     
     unsigned m_textureId;
-    bool m_hasAlpha;
     bool m_premultipliedAlpha;
     FloatRect m_uvRect;
     bool m_flipped;
index 8534a8c85fdddbf10d83e7283d02f554f8e58f2f..25cbe4b5953013a87aafee632697b9944603de8e 100644 (file)
@@ -41,7 +41,6 @@ namespace WebCore {
 CCTextureLayerImpl::CCTextureLayerImpl(int id)
     : CCLayerImpl(id)
     , m_textureId(0)
-    , m_hasAlpha(true)
     , m_premultipliedAlpha(true)
     , m_flipped(true)
     , m_uvRect(0, 0, 1, 1)
@@ -93,7 +92,7 @@ void CCTextureLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
 void CCTextureLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
 {
     IntRect quadRect(IntPoint(), bounds());
-    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_hasAlpha, m_premultipliedAlpha, m_uvRect, m_flipped, m_ioSurfaceSize, m_ioSurfaceTextureId));
+    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_premultipliedAlpha, m_uvRect, m_flipped, m_ioSurfaceSize, m_ioSurfaceTextureId));
 }
 
 void CCTextureLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
index c6c9b145034b53c354ab1dbf9bdd92f8978874c5..f1c265fa1e1eb20b219ff761ceee47e579fc07a3 100644 (file)
@@ -55,7 +55,6 @@ public:
 
     unsigned textureId() const { return m_textureId; }
     void setTextureId(unsigned id) { m_textureId = id; }
-    void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
     void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
     void setFlipped(bool flipped) { m_flipped = flipped; }
     void setUVRect(const FloatRect& rect) { m_uvRect = rect; }
@@ -68,7 +67,6 @@ private:
     virtual const char* layerTypeAsString() const OVERRIDE { return "TextureLayer"; }
 
     unsigned m_textureId;
-    bool m_hasAlpha;
     bool m_premultipliedAlpha;
     bool m_flipped;
     FloatRect m_uvRect;
index 3ec6357092e50b2cc5f624c54ebc07c6ff7c21f1..a84dcdc132c7e47e73579b8024a14335a00a4489 100644 (file)
@@ -48,7 +48,7 @@ class CanvasRenderingContext;
 class GraphicsContext3D;
 class ImageData;
 #if PLATFORM(CHROMIUM)
-class WebGLLayerChromium;
+class DrawingBufferPrivate;
 #endif
 
 // Manages a rendering target (framebuffer + attachment) for a canvas.  Can publish its rendering
@@ -130,7 +130,7 @@ public:
     void paintCompositedResultsToCanvas(CanvasRenderingContext*);
 #endif
 
-    PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
+    GraphicsContext3D* graphicsContext3D() const { return m_context.get(); }
 
 private:
     DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported,
@@ -166,7 +166,7 @@ private:
     Platform3DObject m_multisampleColorBuffer;
 
 #if PLATFORM(CHROMIUM)
-    RefPtr<WebGLLayerChromium> m_platformLayer;
+    OwnPtr<DrawingBufferPrivate> m_private;
 #endif
 
 #if PLATFORM(MAC)
index 8b2159bee2df40a1e4977880d03b1bef7293a5e3..529b2eeecdf6adf2fe9289f7648ce2d8d5f0f08a 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-18  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use TextureLayerChromium for WebGL content instead of a dedicated layer type
+        https://bugs.webkit.org/show_bug.cgi?id=84311
+
+        Reviewed by Adrienne Walker.
+
+        * WebKit.gypi:
+        * src/WebExternalTextureLayer.cpp:
+        (WebKit::WebExternalTextureLayer::create):
+        * src/WebLayer.cpp:
+        * tests/WebGLLayerChromiumTest.cpp: Removed.
+        * tests/WebLayerTest.cpp:
+
 2012-04-23  Alec Flett  <alecflett@chromium.org>
 
         IndexedDB: remove IDB(Index|ObjectStore)BackendImpl::get/getKey for IDBKey
index 9548b2a0f65db199392a8bfe55a9f97d0e7267f4..91f3b0e9be71ffbd4545816059b71386252d020a 100644 (file)
@@ -95,6 +95,7 @@
             'tests/CompositorFakeGraphicsContext3D.h',
             'tests/CompositorFakeWebGraphicsContext3D.h',
             'tests/DragImageTest.cpp',
+            'tests/DrawingBufferChromiumTest.cpp',
             'tests/FakeCCLayerTreeHostClient.h',
             'tests/FakeGraphicsContext3DTest.cpp',
             'tests/FakeWebGraphicsContext3D.h',
             'tests/TreeTestHelpers.h',
             'tests/WebCompositorInputHandlerImplTest.cpp',
             'tests/WebFrameTest.cpp',
-            'tests/WebGLLayerChromiumTest.cpp',
             'tests/WebLayerTest.cpp',
             'tests/WebPageNewSerializerTest.cpp',
             'tests/WebPageSerializerTest.cpp',
index 2620026bfb7f183542f5c782a0d7490b30cdac6d..d2439e88d2d0c1955c5b8ad4775812b03f396b85 100644 (file)
@@ -36,7 +36,7 @@ namespace WebKit {
 
 WebExternalTextureLayer WebExternalTextureLayer::create()
 {
-    RefPtr<TextureLayerChromium> layer = TextureLayerChromium::create();
+    RefPtr<TextureLayerChromium> layer = TextureLayerChromium::create(0);
     layer->setIsDrawable(true);
     return WebExternalTextureLayer(layer.release());
 }
@@ -56,21 +56,11 @@ void WebExternalTextureLayer::setFlipped(bool flipped)
     unwrap<TextureLayerChromium>()->setFlipped(flipped);
 }
 
-bool WebExternalTextureLayer::flipped() const
-{
-    return constUnwrap<TextureLayerChromium>()->flipped();
-}
-
 void WebExternalTextureLayer::setUVRect(const WebFloatRect& rect)
 {
     unwrap<TextureLayerChromium>()->setUVRect(rect);
 }
 
-WebFloatRect WebExternalTextureLayer::uvRect() const
-{
-    return WebFloatRect(constUnwrap<TextureLayerChromium>()->uvRect());
-}
-
 WebExternalTextureLayer::WebExternalTextureLayer(PassRefPtr<TextureLayerChromium> layer)
     : WebLayer(layer)
 {
index 7ce075393503e71c5cadd86c4447a6877de1a237..ecf7452fc654a1f76e7ea63988f76e63edd19066 100644 (file)
 #include "SkMatrix44.h"
 #include "TransformationMatrix.h"
 #include "WebLayerImpl.h"
-
+#include <public/WebFilterOperations.h>
 #include <public/WebFloatPoint.h>
 #include <public/WebFloatRect.h>
 #include <public/WebSize.h>
 
-#include <public/WebFilterOperations.h>
-
 using namespace WebCore;
 
 namespace {
similarity index 95%
rename from Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp
rename to Source/WebKit/chromium/tests/DrawingBufferChromiumTest.cpp
index 4b3fd01e597553b0b651dd04bfdcbd9ce1c64156..27ef49281bdf94385d1fca3b00000913f82a3632 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * 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
 
 #include "config.h"
 
-#include "WebGLLayerChromium.h"
+#include "DrawingBuffer.h"
 
 #include "CompositorFakeGraphicsContext3D.h"
-#include "DrawingBuffer.h"
+#include "LayerChromium.h"
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
@@ -36,7 +36,7 @@ using namespace WebKit;
 
 namespace {
 
-TEST(WebGLLayerChromiumTest, opaqueFormats)
+TEST(DrawingBufferChromiumTest, opaqueFormats)
 {
     RefPtr<DrawingBuffer> buffer;
 
index 2b6cba562c24e3426486de703974c0ebd96ce8e7..7c0831f90358740bb9e1dd242b07fb38c2f643fd 100644 (file)
@@ -164,13 +164,11 @@ TEST_F(WebLayerTest, Client)
     EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
     textureLayer.setFlipped(true);
     Mock::VerifyAndClearExpectations(&m_client);
-    EXPECT_TRUE(textureLayer.flipped());
 
     EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
     WebFloatRect uvRect(0.1f, 0.1f, 0.9f, 0.9f);
     textureLayer.setUVRect(uvRect);
     Mock::VerifyAndClearExpectations(&m_client);
-    EXPECT_TRUE(textureLayer.flipped());
 
 
     // Content layer.