Title: [102098] trunk/Source
Revision
102098
Author
[email protected]
Date
2011-12-05 22:56:03 -0800 (Mon, 05 Dec 2011)

Log Message

Set opaque flag for WebGLLayerChromium
https://bugs.webkit.org/show_bug.cgi?id=73876

Patch by Dana Jansens <[email protected]> on 2011-12-05
Reviewed by James Robinson.

Source/WebCore:

New unit test in tests/WebGLLayerChromiumTest.cpp

* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBuffer::platformLayer):

Source/WebKit/chromium:

* WebKit.gypi:
* tests/WebGLLayerChromiumTest.cpp: Added.
(WebKit::CompositorMockWebGraphicsContext3D::create):
(WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
(WebKit::CompositorMockWebGraphicsContext3D::createProgram):
(WebKit::CompositorMockWebGraphicsContext3D::createShader):
(WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
(WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
(WebKit::CompositorMockWebGraphicsContext3D::getContextAttributes):
(WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
(WebKit::createGraphicsContext):
(WebKit::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102097 => 102098)


--- trunk/Source/WebCore/ChangeLog	2011-12-06 06:31:37 UTC (rev 102097)
+++ trunk/Source/WebCore/ChangeLog	2011-12-06 06:56:03 UTC (rev 102098)
@@ -1,3 +1,15 @@
+2011-12-05  Dana Jansens  <[email protected]>
+
+        Set opaque flag for WebGLLayerChromium
+        https://bugs.webkit.org/show_bug.cgi?id=73876
+
+        Reviewed by James Robinson.
+
+        New unit test in tests/WebGLLayerChromiumTest.cpp
+
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::platformLayer):
+
 2011-12-05  Benjamin Poulain  <[email protected]>
 
         Upstream the Cursor implementation of iOS

Modified: trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp (102097 => 102098)


--- trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2011-12-06 06:31:37 UTC (rev 102097)
+++ trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2011-12-06 06:56:03 UTC (rev 102098)
@@ -145,6 +145,7 @@
     if (!m_platformLayer) {
         m_platformLayer = WebGLLayerChromium::create(0);
         m_platformLayer->setDrawingBuffer(this);
+        m_platformLayer->setOpaque(!m_context->getContextAttributes().alpha);
     }
 
     return m_platformLayer.get();

Modified: trunk/Source/WebKit/chromium/ChangeLog (102097 => 102098)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-12-06 06:31:37 UTC (rev 102097)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-12-06 06:56:03 UTC (rev 102098)
@@ -1,3 +1,23 @@
+2011-12-05  Dana Jansens  <[email protected]>
+
+        Set opaque flag for WebGLLayerChromium
+        https://bugs.webkit.org/show_bug.cgi?id=73876
+
+        Reviewed by James Robinson.
+
+        * WebKit.gypi:
+        * tests/WebGLLayerChromiumTest.cpp: Added.
+        (WebKit::CompositorMockWebGraphicsContext3D::create):
+        (WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
+        (WebKit::CompositorMockWebGraphicsContext3D::createProgram):
+        (WebKit::CompositorMockWebGraphicsContext3D::createShader):
+        (WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
+        (WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
+        (WebKit::CompositorMockWebGraphicsContext3D::getContextAttributes):
+        (WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
+        (WebKit::createGraphicsContext):
+        (WebKit::TEST):
+
 2011-12-05  Adrienne Walker  <[email protected]>
 
         [chromium] setNeedsCommit on non-composited host layers should trigger commit

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (102097 => 102098)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2011-12-06 06:31:37 UTC (rev 102097)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2011-12-06 06:56:03 UTC (rev 102098)
@@ -93,6 +93,7 @@
             'tests/TreeTestHelpers.h',
             'tests/WebCompositorInputHandlerImplTest.cpp',
             'tests/WebFrameTest.cpp',
+            'tests/WebGLLayerChromiumTest.cpp',
             'tests/WebLayerTest.cpp',
             'tests/WebPageNewSerializerTest.cpp',
             'tests/WebPageSerializerTest.cpp',

Added: trunk/Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp (0 => 102098)


--- trunk/Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp	2011-12-06 06:56:03 UTC (rev 102098)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2011 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 INC. 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 INC. 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 "WebGLLayerChromium.h"
+
+#include "DrawingBuffer.h"
+#include "GraphicsContext3DPrivate.h"
+#include "MockWebGraphicsContext3D.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace {
+
+// Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
+class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
+public:
+    static PassOwnPtr<CompositorMockWebGraphicsContext3D> create(GraphicsContext3D::Attributes attrs) { return adoptPtr(new CompositorMockWebGraphicsContext3D(attrs)); }
+    virtual bool makeContextCurrent() { return true; }
+    virtual WebGLId createProgram() { return 1; }
+    virtual WebGLId createShader(WGC3Denum) { return 1; }
+    virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual WebGraphicsContext3D::Attributes getContextAttributes() { return m_attrs; }
+
+private:
+    CompositorMockWebGraphicsContext3D(GraphicsContext3D::Attributes attrs) { m_attrs.alpha = attrs.alpha; }
+
+    WebGraphicsContext3D::Attributes m_attrs;
+};
+
+static PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attributes attrs)
+{
+    OwnPtr<WebGraphicsContext3D> webContext = CompositorMockWebGraphicsContext3D::create(attrs);
+    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(
+        webContext.release(), attrs, 0,
+        GraphicsContext3D::RenderDirectlyToHostWindow,
+        GraphicsContext3DPrivate::ForUseOnAnotherThread);
+}
+
+TEST(WebGLLayerChromiumTest, opaqueFormats)
+{
+    RefPtr<DrawingBuffer> buffer;
+
+    GraphicsContext3D::Attributes alphaAttrs;
+    alphaAttrs.alpha = true;
+    GraphicsContext3D::Attributes opaqueAttrs;
+    opaqueAttrs.alpha = false;
+
+    RefPtr<GraphicsContext3D> alphaContext = createGraphicsContext(alphaAttrs);
+    EXPECT_TRUE(alphaContext);
+    RefPtr<GraphicsContext3D> opaqueContext = createGraphicsContext(opaqueAttrs);
+    EXPECT_TRUE(opaqueContext);
+
+    buffer = DrawingBuffer::create(alphaContext.get(), IntSize(), false);
+    EXPECT_FALSE(buffer->platformLayer()->opaque());
+    buffer = DrawingBuffer::create(alphaContext.get(), IntSize(), true);
+    EXPECT_FALSE(buffer->platformLayer()->opaque());
+
+    buffer = DrawingBuffer::create(opaqueContext.get(), IntSize(), false);
+    EXPECT_TRUE(buffer->platformLayer()->opaque());
+    buffer = DrawingBuffer::create(opaqueContext.get(), IntSize(), true);
+    EXPECT_TRUE(buffer->platformLayer()->opaque());
+}
+
+} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to