Title: [104728] trunk/Source/WebCore
Revision
104728
Author
noam.rosent...@nokia.com
Date
2012-01-11 11:49:40 -0800 (Wed, 11 Jan 2012)

Log Message

[Qt][Texmap] LayoutTests/compositing/masks/masked-ancestor does not render correctly.
https://bugs.webkit.org/show_bug.cgi?id=75910

Reviewed by Simon Hausmann.

Handle the mask surface correctly when drawing in two passes. Also, improve the readability
of the code that decides whether to draw in two passes.

LayoutTests/compositing/masks/masked-ancestor.html tests this.

* platform/graphics/texmap/TextureMapperNode.cpp:
(WebCore::TextureMapperNode::computeAllTransforms):
(WebCore::TextureMapperNode::hasMoreThanOneTile):
(WebCore::TextureMapperNode::paintRecursive):
* platform/graphics/texmap/TextureMapperNode.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104727 => 104728)


--- trunk/Source/WebCore/ChangeLog	2012-01-11 19:38:24 UTC (rev 104727)
+++ trunk/Source/WebCore/ChangeLog	2012-01-11 19:49:40 UTC (rev 104728)
@@ -1,3 +1,21 @@
+2012-01-11  No'am Rosenthal  <noam.rosent...@nokia.com>
+
+        [Qt][Texmap] LayoutTests/compositing/masks/masked-ancestor does not render correctly.
+        https://bugs.webkit.org/show_bug.cgi?id=75910
+
+        Reviewed by Simon Hausmann.
+
+        Handle the mask surface correctly when drawing in two passes. Also, improve the readability
+        of the code that decides whether to draw in two passes.
+
+        LayoutTests/compositing/masks/masked-ancestor.html tests this.
+
+        * platform/graphics/texmap/TextureMapperNode.cpp:
+        (WebCore::TextureMapperNode::computeAllTransforms):
+        (WebCore::TextureMapperNode::hasMoreThanOneTile):
+        (WebCore::TextureMapperNode::paintRecursive):
+        * platform/graphics/texmap/TextureMapperNode.h:
+
 2012-01-11  Dmitry Titov  <dim...@chromium.org>
 
         Add new CSS enum value to a switch() in CSSStyleSelector::applyProperty() to fix compile error.

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp (104727 => 104728)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp	2012-01-11 19:38:24 UTC (rev 104727)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp	2012-01-11 19:49:40 UTC (rev 104728)
@@ -112,14 +112,15 @@
     computeReplicaTransformIfNeeded();
     computePerspectiveTransformIfNeeded();
 
-    m_transforms.target = TransformationMatrix(m_parent ? m_parent->m_transforms.forDescendants : TransformationMatrix()).multiply(m_transforms.local);
+    TextureMapperNode* parent = m_parent ? m_parent : m_effectTarget;
+    m_transforms.target = TransformationMatrix(parent ? parent->m_transforms.forDescendants : TransformationMatrix()).multiply(m_transforms.local);
 
     m_state.visible = m_state.backfaceVisibility || m_transforms.target.inverse().m33() >= 0;
     if (!m_state.visible)
         return;
 
     // This transform is only applied if using a two-pass for the replica, because the transform needs to be adjusted to the size of the intermediate surface, insteaf of the size of the content layer.
-    if (m_parent && m_parent->m_state.preserves3D)
+    if (parent && parent->m_state.preserves3D)
         m_transforms.centerZ = m_transforms.target.mapPoint(FloatPoint3D(m_size.width() / 2, m_size.height() / 2, 0)).z();
 
     if (!m_children.size())
@@ -248,6 +249,35 @@
 }
 #endif
 
+bool TextureMapperNode::hasMoreThanOneTile() const
+{
+    int tiles = 0;
+
+#if USE(TILED_BACKING_STORE)
+    if (m_state.tileOwnership == ExternallyManagedTiles) {
+        HashMap<int, ExternallyManagedTile>::const_iterator end = m_externallyManagedTiles.end();
+        for (HashMap<int, ExternallyManagedTile>::const_iterator it = m_externallyManagedTiles.begin(); it != end; ++it) {
+            if (it->second.frontBuffer.texture) {
+                if (++tiles > 1)
+                    return true;
+            }
+        }
+
+        return false;
+    }
+#endif
+
+    for (size_t i = 0; i < m_ownedTiles.size(); ++i) {
+        if (m_ownedTiles[i].texture) {
+            if (++tiles > 1)
+                return true;
+        }
+    }
+
+    return false;
+}
+
+
 void TextureMapperNode::renderContent(TextureMapper* textureMapper, GraphicsLayer* layer)
 {
 #if USE(TILED_BACKING_STORE)
@@ -515,8 +545,14 @@
 
     options.opacity *= m_opacity;
     RefPtr<BitmapTexture> surface;
-    const bool needsTwoPass = ((m_state.replicaLayer || m_state.maskLayer) && !m_children.isEmpty()) || (m_opacity < 0.99 && m_state.mightHaveOverlaps) || (m_opacity < 0.99 && m_state.replicaLayer);
+
+    bool hasReplica = m_state.replicaLayer;
+    bool hasMask = m_state.maskLayer;
+    bool needsBlending = m_opacity < 0.99 || hasMask;
+    bool paintsMoreThanOneTexture = !m_children.isEmpty() || hasMoreThanOneTile() || (hasMask && m_state.maskLayer->hasMoreThanOneTile());
+    bool hasOverlaps = m_state.mightHaveOverlaps || hasReplica;
     const IntSize viewportSize = options.textureMapper->viewportSize();
+    bool needsTwoPass = ((hasReplica || hasMask) && paintsMoreThanOneTexture) || (needsBlending && hasOverlaps);
     options.isSurface = false;
 
     TextureMapperPaintOptions optionsForDescendants(options);
@@ -530,11 +566,12 @@
 
     RefPtr<BitmapTexture> maskSurface;
 
-    // The mask has to be adjusted to target coordinates.
     if (m_state.maskLayer) {
         maskSurface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
         options.textureMapper->bindSurface(maskSurface.get());
-        options.textureMapper->drawTexture(*m_state.maskLayer->texture(), entireRect(), m_transforms.target, 1.0, 0);
+        TextureMapperPaintOptions optionsForMask(options);
+        optionsForMask.isSurface = true;
+        m_state.maskLayer->paintSelf(optionsForMask);
     }
 
     surface = options.textureMapper->acquireTextureFromPool(options.textureMapper->viewportSize());
@@ -547,7 +584,7 @@
 
     if (!paintReflection(options, surface.get())) {
         options.textureMapper->bindSurface(options.surface);
-        options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), options.opacity, 0);
+        options.textureMapper->drawTexture(*surface.get(), viewportRect, TransformationMatrix(), options.opacity, maskSurface.get());
     }
 
     options.textureMapper->releaseTextureToPool(surface.get());

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h (104727 => 104728)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h	2012-01-11 19:38:24 UTC (rev 104727)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h	2012-01-11 19:49:40 UTC (rev 104728)
@@ -206,7 +206,7 @@
     void applyTransformAnimation(const TextureMapperAnimation&, const TransformOperations* start, const TransformOperations* end, double);
     bool hasOpacityAnimation() const;
     bool hasTransformAnimation() const;
-
+    bool hasMoreThanOneTile() const;
     struct TransformData {
         TransformationMatrix target;
         TransformationMatrix replica;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to