Title: [136781] trunk/Source
Revision
136781
Author
[email protected]
Date
2012-12-05 17:23:48 -0800 (Wed, 05 Dec 2012)

Log Message

Coordinated Graphics: Enable support for setContentsToBackgroundColor
https://bugs.webkit.org/show_bug.cgi?id=104128

Patch by No'am Rosenthal <[email protected]> on 2012-12-05
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Enable background color in GraphicsLayerTextureMapper, and paint it using TextureMapper::drawSolidColor.
Once https://bugs.webkit.org/show_bug.cgi?id=103786 is enabled, this would enable Qt/GTK/EFL to directly
composite colors that only have a background color, without having to create a backing store for them.
This would eliminate the memory usage for those layers, reduce the time needed for them to draw into the
backing store and upload the texture, and in the future allow direct compositing of things other than
background colors.

Compositing tests cover this, but are still skipped for ports using coordinated graphics.
See https://bugs.webkit.org/show_bug.cgi?id=104129.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::setContentsToBackgroundColor):
(WebCore::GraphicsLayerTextureMapper::backgroundColor):
    Maintain a backgroundColor member variable in GraphicsLayerTextureMapper

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawSolidColor):
    TextureMapperGL::drawSolidColor should allow blending when the solid color has alpha.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::flushCompositingStateSelf):
* platform/graphics/texmap/TextureMapperLayer.h:
(State):

Source/WebKit2:

Enable setContentsToBackgroundColor in CoordinatedGraphicsLayer, and pass it through to the UI process.

* Shared/WebLayerTreeInfo.h:
(WebLayerInfo):
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
(WebKit::LayerTreeRenderer::setLayerState):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsToBackgroundColor):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136780 => 136781)


--- trunk/Source/WebCore/ChangeLog	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/ChangeLog	2012-12-06 01:23:48 UTC (rev 136781)
@@ -1,3 +1,35 @@
+2012-12-05  No'am Rosenthal  <[email protected]>
+
+        Coordinated Graphics: Enable support for setContentsToBackgroundColor
+        https://bugs.webkit.org/show_bug.cgi?id=104128
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Enable background color in GraphicsLayerTextureMapper, and paint it using TextureMapper::drawSolidColor.
+        Once https://bugs.webkit.org/show_bug.cgi?id=103786 is enabled, this would enable Qt/GTK/EFL to directly
+        composite colors that only have a background color, without having to create a backing store for them.
+        This would eliminate the memory usage for those layers, reduce the time needed for them to draw into the
+        backing store and upload the texture, and in the future allow direct compositing of things other than
+        background colors.
+
+        Compositing tests cover this, but are still skipped for ports using coordinated graphics. 
+        See https://bugs.webkit.org/show_bug.cgi?id=104129.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::setContentsToBackgroundColor):
+        (WebCore::GraphicsLayerTextureMapper::backgroundColor):
+            Maintain a backgroundColor member variable in GraphicsLayerTextureMapper
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawSolidColor):
+            TextureMapperGL::drawSolidColor should allow blending when the solid color has alpha.
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintSelf):
+        (WebCore::TextureMapperLayer::flushCompositingStateSelf):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (State):
+
 2012-12-05  Kentaro Hara  <[email protected]>
 
         Unreviewed, rolling out r136481.

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (136780 => 136781)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2012-12-06 01:23:48 UTC (rev 136781)
@@ -351,6 +351,17 @@
     notifyChange(TextureMapperLayer::ContentsRectChange);
 }
 
+void GraphicsLayerTextureMapper::setContentsToBackgroundColor(const Color& color)
+{
+    if (color == m_backgroundColor)
+        return;
+
+    m_backgroundColor = color;
+    setBackgroundColor(color);
+    notifyChange(TextureMapperLayer::ContentChange);
+}
+
+
 /* \reimp (GraphicsLayer.h)
 */
 void GraphicsLayerTextureMapper::setContentsToImage(Image* image)

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (136780 => 136781)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2012-12-06 01:23:48 UTC (rev 136781)
@@ -66,6 +66,8 @@
     virtual void setContentsRect(const IntRect& r);
     virtual void setReplicatedByLayer(GraphicsLayer*);
     virtual void setContentsToImage(Image*);
+    virtual void setContentsToBackgroundColor(const Color&);
+    Color backgroundColor() const { return m_backgroundColor; }
     virtual void setContentsToMedia(PlatformLayer*);
     virtual void setContentsToCanvas(PlatformLayer* canvas) { setContentsToMedia(canvas); }
     virtual void flushCompositingState(const FloatRect&);
@@ -114,6 +116,7 @@
     bool m_needsDisplay;
     bool m_hasOwnBackingStore;
     bool m_fixedToViewport;
+    Color m_backgroundColor;
 
     Color m_debugBorderColor;
     float m_debugBorderWidth;

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (136780 => 136781)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-12-06 01:23:48 UTC (rev 136781)
@@ -462,7 +462,7 @@
     color.getRGBA(r, g, b, a);
     m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
 
-    drawQuad(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, false);
+    drawQuad(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, a < 1);
 }
 
 static TransformationMatrix viewportMatrix(GraphicsContext3D* context3D)

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (136780 => 136781)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-12-06 01:23:48 UTC (rev 136781)
@@ -109,6 +109,14 @@
     float opacity = options.opacity;
     RefPtr<BitmapTexture> mask = options.mask;
 
+    if (m_state.backgroundColor.alpha() && !m_state.contentsRect.isEmpty()) {
+        Color color = m_state.backgroundColor;
+        float r, g, b, a;
+        color.getRGBA(r, g, b, a);
+        color = Color(r * opacity, g * opacity, b * opacity, a * opacity);
+        options.textureMapper->drawSolidColor(m_state.contentsRect, transform, color);
+    }
+
     if (m_backingStore) {
         ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_size.isEmpty());
         ASSERT(!layerRect().isEmpty());
@@ -428,6 +436,7 @@
     m_state.backfaceVisibility = graphicsLayer->backfaceVisibility();
     m_state.childrenTransform = graphicsLayer->childrenTransform();
     m_state.opacity = graphicsLayer->opacity();
+    m_state.backgroundColor = graphicsLayer->backgroundColor();
 #if ENABLE(CSS_FILTERS)
     if (changeMask & FilterChange)
         m_state.filters = graphicsLayer->filters();

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (136780 => 136781)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-12-06 01:23:48 UTC (rev 136781)
@@ -199,6 +199,7 @@
         int descendantsWithContent;
         TextureMapperLayer* maskLayer;
         TextureMapperLayer* replicaLayer;
+        Color backgroundColor;
 #if ENABLE(CSS_FILTERS)
          FilterOperations filters;
 #endif

Modified: trunk/Source/WebKit2/ChangeLog (136780 => 136781)


--- trunk/Source/WebKit2/ChangeLog	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-06 01:23:48 UTC (rev 136781)
@@ -1,3 +1,21 @@
+2012-12-05  No'am Rosenthal  <[email protected]>
+
+        Coordinated Graphics: Enable support for setContentsToBackgroundColor
+        https://bugs.webkit.org/show_bug.cgi?id=104128
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Enable setContentsToBackgroundColor in CoordinatedGraphicsLayer, and pass it through to the UI process.
+
+        * Shared/WebLayerTreeInfo.h:
+        (WebLayerInfo):
+        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
+        (WebKit::LayerTreeRenderer::setLayerState):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setContentsToBackgroundColor):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
+        (CoordinatedGraphicsLayer):
+
 2012-12-05  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/12809890> Should allow sandbox lookup of com.apple.tccd

Modified: trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h (136780 => 136781)


--- trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h	2012-12-06 01:23:48 UTC (rev 136781)
@@ -56,6 +56,7 @@
     WebCore::TransformationMatrix childrenTransform;
     WebCore::IntRect contentsRect;
     float opacity;
+    WebCore::Color backgroundColor;
 
     union {
         struct {

Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp (136780 => 136781)


--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp	2012-12-06 01:23:48 UTC (rev 136781)
@@ -341,6 +341,7 @@
     layer->setBackfaceVisibility(layerInfo.backfaceVisible);
     layer->setContentsOpaque(layerInfo.contentsOpaque);
     layer->setContentsRect(layerInfo.contentsRect);
+    layer->setContentsToBackgroundColor(layerInfo.backgroundColor);
     layer->setDrawsContent(layerInfo.drawsContent);
     layer->setContentsVisible(layerInfo.contentsVisible);
     toGraphicsLayerTextureMapper(layer)->setFixedToViewport(layerInfo.fixedToViewport);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp (136780 => 136781)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp	2012-12-06 01:23:48 UTC (rev 136781)
@@ -359,7 +359,17 @@
 }
 #endif
 
+void CoordinatedGraphicsLayer::setContentsToBackgroundColor(const Color& color)
+{
+    if (m_layerInfo.backgroundColor == color)
+        return;
+    m_layerInfo.backgroundColor = color;
 
+    // This is in line with what CA does.
+    setBackgroundColor(color);
+    didChangeLayerState();
+}
+
 void CoordinatedGraphicsLayer::setContentsToImage(Image* image)
 {
     NativeImagePtr newNativeImagePtr = image ? image->nativeImageForCurrentFrame() : 0;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h (136780 => 136781)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h	2012-12-06 00:53:46 UTC (rev 136780)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h	2012-12-06 01:23:48 UTC (rev 136781)
@@ -111,6 +111,7 @@
     virtual void setOpacity(float) OVERRIDE;
     virtual void setContentsRect(const IntRect&) OVERRIDE;
     virtual void setContentsToImage(Image*) OVERRIDE;
+    virtual void setContentsToBackgroundColor(const Color&) OVERRIDE;
     virtual bool shouldDirectlyCompositeImage(Image*) const OVERRIDE;
     virtual void setContentsToCanvas(PlatformLayer*) OVERRIDE;
     virtual void setMaskLayer(GraphicsLayer*) OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to