[GTK][Threaded Compositor] Web view background colors don't work
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 07:25:26 +0000 (07:25 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 07:25:26 +0000 (07:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159465

Reviewed by Michael Catanzaro.

Source/WebCore:

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): Initialize frame view layer opacity for platforms not
using the tiled cache layer.

Source/WebKit2:

* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::setDrawsBackground): Set m_drawsBackground in compositing thread and schedule a
layer flush.
(WebKit::ThreadedCompositor::renderLayerTree): Clear the area when not rendering backgrounds.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Notify the compositor.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h

index 3cb0990..2feab95 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK][Threaded Compositor] Web view background colors don't work
+        https://bugs.webkit.org/show_bug.cgi?id=159465
+
+        Reviewed by Michael Catanzaro.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): Initialize frame view layer opacity for platforms not
+        using the tiled cache layer.
+
 2016-07-20  Youenn Fablet  <youenn@apple.com>
 
         [XHR] Cache response JS object in case of arraybuffer and blob response types
index 1851c06..77da52f 100644 (file)
@@ -315,7 +315,7 @@ void RenderLayerBacking::createPrimaryGraphicsLayer()
 #if !PLATFORM(IOS)
     if (m_isMainFrameRenderViewLayer) {
         // Page scale is applied above the RenderView on iOS.
-        m_graphicsLayer->setContentsOpaque(true);
+        m_graphicsLayer->setContentsOpaque(!compositor().viewHasTransparentBackground());
         m_graphicsLayer->setAppliesPageScale();
     }
 #endif
index d85860f..6032b53 100644 (file)
@@ -1,5 +1,21 @@
 2016-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK][Threaded Compositor] Web view background colors don't work
+        https://bugs.webkit.org/show_bug.cgi?id=159465
+
+        Reviewed by Michael Catanzaro.
+
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::setDrawsBackground): Set m_drawsBackground in compositing thread and schedule a
+        layer flush.
+        (WebKit::ThreadedCompositor::renderLayerTree): Clear the area when not rendering backgrounds.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Notify the compositor.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+
+2016-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] Web view background colors don't work in accelerated compositing mode
         https://bugs.webkit.org/show_bug.cgi?id=159455
 
index 92426ec..697496b 100644 (file)
@@ -87,6 +87,14 @@ void ThreadedCompositor::setDeviceScaleFactor(float scale)
     });
 }
 
+void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
+{
+    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), drawsBackground] {
+        m_drawsBackground = drawsBackground;
+        scheduleDisplayImmediately();
+    });
+}
+
 void ThreadedCompositor::didChangeViewportSize(const IntSize& size)
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), size] {
@@ -202,7 +210,11 @@ void ThreadedCompositor::renderLayerTree()
     viewportTransform.scale(m_viewportController->pageScaleFactor() * m_deviceScaleFactor);
     viewportTransform.translate(-scrollPostion.x(), -scrollPostion.y());
 
-    m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::white, false, scrollPostion);
+    if (!m_drawsBackground) {
+        glClearColor(0, 0, 0, 0);
+        glClear(GL_COLOR_BUFFER_BIT);
+    }
+    m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, scrollPostion);
 
     glContext()->swapBuffers();
 }
index e63842f..dde4bea 100644 (file)
@@ -66,6 +66,7 @@ public:
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
     void setDeviceScaleFactor(float);
+    void setDrawsBackground(bool);
 
     void updateSceneState(const WebCore::CoordinatedGraphicsState&);
 
@@ -106,6 +107,7 @@ private:
 
     WebCore::IntSize m_viewportSize;
     float m_deviceScaleFactor { 1 };
+    bool m_drawsBackground { true };
     uint64_t m_nativeSurfaceHandle { 0 };
 
     std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
index bd242ba..1752055 100644 (file)
@@ -77,6 +77,12 @@ void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
     m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
 }
 
+void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
+{
+    CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged();
+    m_compositor->setDrawsBackground(m_webPage.drawsBackground());
+}
+
 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
 {
     CoordinatedLayerTreeHost::sizeDidChange(size);
index efeb0e1..a99533f 100644 (file)
@@ -54,6 +54,7 @@ private:
     void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
     void sizeDidChange(const WebCore::IntSize&) override;
     void deviceOrPageScaleFactorChanged() override;
+    void pageBackgroundTransparencyChanged() override;
 
     void contentsSizeChanged(const WebCore::IntSize&) override;
     void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;