Title: [138291] trunk/Source/WebCore
Revision
138291
Author
commit-qu...@webkit.org
Date
2012-12-20 13:22:08 -0800 (Thu, 20 Dec 2012)

Log Message

[TexMap] Remove ParentChange in TextureMapperLayer.
https://bugs.webkit.org/show_bug.cgi?id=105494

Patch by Huang Dongsung <luxte...@company100.net> on 2012-12-20
Reviewed by Noam Rosenthal.

ParentChange is useless, because ChildrenChange is enough. In addition,
GraphicsLayer uses setParent() method internally. This patch copies
GraphicsLayer::setChildren() into TextureMapperLayer::setChildren().

No new tests. Covered by existing tests.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore):
(WebCore::GraphicsLayerTextureMapper::setChildren):
  Match the similar style of replaceChild().
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
(GraphicsLayerTextureMapper):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::flushCompositingStateForThisLayerOnly):
(WebCore::TextureMapperLayer::setChildren):
  Copied from GraphicsLayer::setChildren().
(WebCore):
(WebCore::TextureMapperLayer::addChild):
  Copied from GraphicsLayer::addChild().
(WebCore::TextureMapperLayer::removeFromParent):
  Copied from GraphicsLayer::removeFromParent().
(WebCore::TextureMapperLayer::removeAllChildren):
  Copied from GraphicsLayer::removeAllChildren().
* platform/graphics/texmap/TextureMapperLayer.h:
(TextureMapperLayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (138290 => 138291)


--- trunk/Source/WebCore/ChangeLog	2012-12-20 21:20:23 UTC (rev 138290)
+++ trunk/Source/WebCore/ChangeLog	2012-12-20 21:22:08 UTC (rev 138291)
@@ -1,3 +1,36 @@
+2012-12-20  Huang Dongsung  <luxte...@company100.net>
+
+        [TexMap] Remove ParentChange in TextureMapperLayer.
+        https://bugs.webkit.org/show_bug.cgi?id=105494
+
+        Reviewed by Noam Rosenthal.
+
+        ParentChange is useless, because ChildrenChange is enough. In addition,
+        GraphicsLayer uses setParent() method internally. This patch copies
+        GraphicsLayer::setChildren() into TextureMapperLayer::setChildren().
+
+        No new tests. Covered by existing tests.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore):
+        (WebCore::GraphicsLayerTextureMapper::setChildren):
+          Match the similar style of replaceChild().
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        (GraphicsLayerTextureMapper):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::flushCompositingStateForThisLayerOnly):
+        (WebCore::TextureMapperLayer::setChildren):
+          Copied from GraphicsLayer::setChildren().
+        (WebCore):
+        (WebCore::TextureMapperLayer::addChild):
+          Copied from GraphicsLayer::addChild().
+        (WebCore::TextureMapperLayer::removeFromParent):
+          Copied from GraphicsLayer::removeFromParent().
+        (WebCore::TextureMapperLayer::removeAllChildren):
+          Copied from GraphicsLayer::removeAllChildren().
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (TextureMapperLayer):
+
 2012-12-20  Alec Flett  <alecfl...@chromium.org>
 
         IndexedDB: Cursor and IndexWriter cleanup for refactor

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2012-12-20 21:20:23 UTC (rev 138290)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2012-12-20 21:22:08 UTC (rev 138291)
@@ -120,18 +120,13 @@
 
 /* \reimp (GraphicsLayer.h)
 */
-void GraphicsLayerTextureMapper::setParent(GraphicsLayer* layer)
-{
-    notifyChange(TextureMapperLayer::ParentChange);
-    GraphicsLayer::setParent(layer);
-}
-
-/* \reimp (GraphicsLayer.h)
-*/
 bool GraphicsLayerTextureMapper::setChildren(const Vector<GraphicsLayer*>& children)
 {
-    notifyChange(TextureMapperLayer::ChildrenChange);
-    return GraphicsLayer::setChildren(children);
+    if (GraphicsLayer::setChildren(children)) {
+        notifyChange(TextureMapperLayer::ChildrenChange);
+        return true;
+    }
+    return false;
 }
 
 /* \reimp (GraphicsLayer.h)
@@ -179,16 +174,6 @@
 
 /* \reimp (GraphicsLayer.h)
 */
-void GraphicsLayerTextureMapper::removeFromParent()
-{
-    if (!parent())
-        return;
-    notifyChange(TextureMapperLayer::ParentChange);
-    GraphicsLayer::removeFromParent();
-}
-
-/* \reimp (GraphicsLayer.h)
-*/
 void GraphicsLayerTextureMapper::setMaskLayer(GraphicsLayer* value)
 {
     if (value == maskLayer())

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2012-12-20 21:20:23 UTC (rev 138290)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2012-12-20 21:22:08 UTC (rev 138291)
@@ -40,14 +40,12 @@
     virtual void setNeedsDisplay();
     virtual void setContentsNeedsDisplay();
     virtual void setNeedsDisplayInRect(const FloatRect&);
-    virtual void setParent(GraphicsLayer* layer);
     virtual bool setChildren(const Vector<GraphicsLayer*>&);
     virtual void addChild(GraphicsLayer*);
     virtual void addChildAtIndex(GraphicsLayer*, int index);
     virtual void addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling);
     virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
     virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
-    virtual void removeFromParent();
     virtual void setMaskLayer(GraphicsLayer* layer);
     virtual void setPosition(const FloatPoint& p);
     virtual void setAnchorPoint(const FloatPoint3D& p);

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-12-20 21:20:23 UTC (rev 138290)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-12-20 21:22:08 UTC (rev 138291)
@@ -374,38 +374,9 @@
 
     graphicsLayer->updateDebugIndicators();
 
-    if (changeMask & ParentChange) {
-        TextureMapperLayer* newParent = toTextureMapperLayer(graphicsLayer->parent());
-        if (newParent != m_parent) {
-            // Remove layer from current from child list first.
-            if (m_parent) {
-                size_t index = m_parent->m_children.find(this);
-                m_parent->m_children.remove(index);
-                m_parent = 0;
-            }
-            // Set new layer parent and add layer to the parents child list.
-            if (newParent) {
-                m_parent = newParent;
-                m_parent->m_children.append(this);
-            }
-        }
-    }
+    if (changeMask & ChildrenChange)
+        setChildren(graphicsLayer->children());
 
-    if (changeMask & ChildrenChange) {
-        // Clear children parent pointer to avoid unsync and crash on layer delete.
-        for (size_t i = 0; i < m_children.size(); i++)
-            m_children[i]->m_parent = 0;
-
-        m_children.clear();
-        for (size_t i = 0; i < graphicsLayer->children().size(); ++i) {
-            TextureMapperLayer* child = toTextureMapperLayer(graphicsLayer->children()[i]);
-            if (!child)
-                continue;
-            m_children.append(child);
-            child->m_parent = this;
-        }
-    }
-
     m_size = graphicsLayer->size();
 
     if (changeMask & MaskLayerChange) {
@@ -454,6 +425,52 @@
     syncAnimations();
 }
 
+void TextureMapperLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
+{
+    removeAllChildren();
+    for (size_t i = 0; i < newChildren.size(); ++i) {
+        TextureMapperLayer* child = toTextureMapperLayer(newChildren[i]);
+        ASSERT(child);
+        addChild(child);
+    }
+}
+
+void TextureMapperLayer::addChild(TextureMapperLayer* childLayer)
+{
+    ASSERT(childLayer != this);
+
+    if (childLayer->m_parent)
+        childLayer->removeFromParent();
+
+    childLayer->m_parent = this;
+    m_children.append(childLayer);
+}
+
+void TextureMapperLayer::removeFromParent()
+{
+    if (m_parent) {
+        unsigned i;
+        for (i = 0; i < m_parent->m_children.size(); i++) {
+            if (this == m_parent->m_children[i]) {
+                m_parent->m_children.remove(i);
+                break;
+            }
+        }
+
+        m_parent = 0;
+    }
+}
+
+void TextureMapperLayer::removeAllChildren()
+{
+    while (m_children.size()) {
+        TextureMapperLayer* curLayer = m_children[0];
+        ASSERT(curLayer->m_parent);
+        curLayer->removeFromParent();
+    }
+}
+
+
 bool TextureMapperLayer::descendantsOrSelfHaveRunningAnimations() const
 {
     if (m_animations.hasRunningAnimations())

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-12-20 21:20:23 UTC (rev 138290)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-12-20 21:22:08 UTC (rev 138291)
@@ -57,7 +57,6 @@
     enum ChangeMask {
         NoChanges =                 0,
 
-        ParentChange =              (1L << 0),
         ChildrenChange =            (1L << 1),
         MaskLayerChange =           (1L << 2),
         PositionChange =            (1L << 3),
@@ -138,6 +137,11 @@
     FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta; }
     bool isAncestorFixedToViewport() const;
 
+    void setChildren(const Vector<GraphicsLayer*>&);
+    void addChild(TextureMapperLayer*);
+    void removeFromParent();
+    void removeAllChildren();
+
     void paintRecursive(const TextureMapperPaintOptions&);
     void paintSelf(const TextureMapperPaintOptions&);
     void paintSelfAndChildren(const TextureMapperPaintOptions&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to