Changeset 138291 in webkit


Ignore:
Timestamp:
Dec 20, 2012, 1:22:08 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Huang Dongsung <luxtella@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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r138290 r138291  
     12012-12-20  Huang Dongsung  <luxtella@company100.net>
     2
     3        [TexMap] Remove ParentChange in TextureMapperLayer.
     4        https://bugs.webkit.org/show_bug.cgi?id=105494
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        ParentChange is useless, because ChildrenChange is enough. In addition,
     9        GraphicsLayer uses setParent() method internally. This patch copies
     10        GraphicsLayer::setChildren() into TextureMapperLayer::setChildren().
     11
     12        No new tests. Covered by existing tests.
     13
     14        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     15        (WebCore):
     16        (WebCore::GraphicsLayerTextureMapper::setChildren):
     17          Match the similar style of replaceChild().
     18        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
     19        (GraphicsLayerTextureMapper):
     20        * platform/graphics/texmap/TextureMapperLayer.cpp:
     21        (WebCore::TextureMapperLayer::flushCompositingStateForThisLayerOnly):
     22        (WebCore::TextureMapperLayer::setChildren):
     23          Copied from GraphicsLayer::setChildren().
     24        (WebCore):
     25        (WebCore::TextureMapperLayer::addChild):
     26          Copied from GraphicsLayer::addChild().
     27        (WebCore::TextureMapperLayer::removeFromParent):
     28          Copied from GraphicsLayer::removeFromParent().
     29        (WebCore::TextureMapperLayer::removeAllChildren):
     30          Copied from GraphicsLayer::removeAllChildren().
     31        * platform/graphics/texmap/TextureMapperLayer.h:
     32        (TextureMapperLayer):
     33
    1342012-12-20  Alec Flett  <alecflett@chromium.org>
    235
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r138234 r138291  
    121121/* \reimp (GraphicsLayer.h)
    122122*/
    123 void GraphicsLayerTextureMapper::setParent(GraphicsLayer* layer)
    124 {
    125     notifyChange(TextureMapperLayer::ParentChange);
    126     GraphicsLayer::setParent(layer);
    127 }
    128 
    129 /* \reimp (GraphicsLayer.h)
    130 */
    131123bool GraphicsLayerTextureMapper::setChildren(const Vector<GraphicsLayer*>& children)
    132124{
    133     notifyChange(TextureMapperLayer::ChildrenChange);
    134     return GraphicsLayer::setChildren(children);
     125    if (GraphicsLayer::setChildren(children)) {
     126        notifyChange(TextureMapperLayer::ChildrenChange);
     127        return true;
     128    }
     129    return false;
    135130}
    136131
     
    176171    }
    177172    return false;
    178 }
    179 
    180 /* \reimp (GraphicsLayer.h)
    181 */
    182 void GraphicsLayerTextureMapper::removeFromParent()
    183 {
    184     if (!parent())
    185         return;
    186     notifyChange(TextureMapperLayer::ParentChange);
    187     GraphicsLayer::removeFromParent();
    188173}
    189174
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r137867 r138291  
    4141    virtual void setContentsNeedsDisplay();
    4242    virtual void setNeedsDisplayInRect(const FloatRect&);
    43     virtual void setParent(GraphicsLayer* layer);
    4443    virtual bool setChildren(const Vector<GraphicsLayer*>&);
    4544    virtual void addChild(GraphicsLayer*);
     
    4847    virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
    4948    virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
    50     virtual void removeFromParent();
    5149    virtual void setMaskLayer(GraphicsLayer* layer);
    5250    virtual void setPosition(const FloatPoint& p);
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r137867 r138291  
    375375    graphicsLayer->updateDebugIndicators();
    376376
    377     if (changeMask & ParentChange) {
    378         TextureMapperLayer* newParent = toTextureMapperLayer(graphicsLayer->parent());
    379         if (newParent != m_parent) {
    380             // Remove layer from current from child list first.
    381             if (m_parent) {
    382                 size_t index = m_parent->m_children.find(this);
    383                 m_parent->m_children.remove(index);
    384                 m_parent = 0;
    385             }
    386             // Set new layer parent and add layer to the parents child list.
    387             if (newParent) {
    388                 m_parent = newParent;
    389                 m_parent->m_children.append(this);
    390             }
    391         }
    392     }
    393 
    394     if (changeMask & ChildrenChange) {
    395         // Clear children parent pointer to avoid unsync and crash on layer delete.
    396         for (size_t i = 0; i < m_children.size(); i++)
    397             m_children[i]->m_parent = 0;
    398 
    399         m_children.clear();
    400         for (size_t i = 0; i < graphicsLayer->children().size(); ++i) {
    401             TextureMapperLayer* child = toTextureMapperLayer(graphicsLayer->children()[i]);
    402             if (!child)
    403                 continue;
    404             m_children.append(child);
    405             child->m_parent = this;
    406         }
    407     }
     377    if (changeMask & ChildrenChange)
     378        setChildren(graphicsLayer->children());
    408379
    409380    m_size = graphicsLayer->size();
     
    455426}
    456427
     428void TextureMapperLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
     429{
     430    removeAllChildren();
     431    for (size_t i = 0; i < newChildren.size(); ++i) {
     432        TextureMapperLayer* child = toTextureMapperLayer(newChildren[i]);
     433        ASSERT(child);
     434        addChild(child);
     435    }
     436}
     437
     438void TextureMapperLayer::addChild(TextureMapperLayer* childLayer)
     439{
     440    ASSERT(childLayer != this);
     441
     442    if (childLayer->m_parent)
     443        childLayer->removeFromParent();
     444
     445    childLayer->m_parent = this;
     446    m_children.append(childLayer);
     447}
     448
     449void TextureMapperLayer::removeFromParent()
     450{
     451    if (m_parent) {
     452        unsigned i;
     453        for (i = 0; i < m_parent->m_children.size(); i++) {
     454            if (this == m_parent->m_children[i]) {
     455                m_parent->m_children.remove(i);
     456                break;
     457            }
     458        }
     459
     460        m_parent = 0;
     461    }
     462}
     463
     464void TextureMapperLayer::removeAllChildren()
     465{
     466    while (m_children.size()) {
     467        TextureMapperLayer* curLayer = m_children[0];
     468        ASSERT(curLayer->m_parent);
     469        curLayer->removeFromParent();
     470    }
     471}
     472
     473
    457474bool TextureMapperLayer::descendantsOrSelfHaveRunningAnimations() const
    458475{
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r137867 r138291  
    5858        NoChanges =                 0,
    5959
    60         ParentChange =              (1L << 0),
    6160        ChildrenChange =            (1L << 1),
    6261        MaskLayerChange =           (1L << 2),
     
    138137    FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta; }
    139138    bool isAncestorFixedToViewport() const;
     139
     140    void setChildren(const Vector<GraphicsLayer*>&);
     141    void addChild(TextureMapperLayer*);
     142    void removeFromParent();
     143    void removeAllChildren();
    140144
    141145    void paintRecursive(const TextureMapperPaintOptions&);
Note: See TracChangeset for help on using the changeset viewer.