qtwebkit/0009-TexMap-Remove-ParentCh...

277 lines
11 KiB
Diff

From fa54af90c55c5264e2e2510a24311a77c9e569b0 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@digia.com>
Date: Thu, 26 Sep 2013 13:43:10 +0200
Subject: [PATCH 9/9] [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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
---
Source/WebCore/ChangeLog | 33 +++++++++
.../graphics/texmap/GraphicsLayerTextureMapper.cpp | 25 ++-----
.../graphics/texmap/GraphicsLayerTextureMapper.h | 2 -
.../graphics/texmap/TextureMapperLayer.cpp | 79 +++++++++++++---------
.../platform/graphics/texmap/TextureMapperLayer.h | 6 +-
5 files changed, 91 insertions(+), 54 deletions(-)
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 75c29ab..e70115f 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1205,6 +1205,39 @@
(GenerateGetOwnPropertySlotBody): Use getStaticValueSlotEntryWithoutCaching to climb up the class
hierarchy.
+2012-12-20 Huang Dongsung <luxtella@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-13 Filip Pizlo <fpizlo@apple.com>
Named lookups on HTML documents produce inconsistent results in JavaScriptCore bindings
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
index 5ba1090..364ddd2 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
@@ -123,18 +123,13 @@ void GraphicsLayerTextureMapper::setNeedsDisplayInRect(const FloatRect& rect)
/* \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)
@@ -182,16 +177,6 @@ bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, GraphicsL
/* \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())
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
index 00b0fe7..5a11503 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
@@ -42,14 +42,12 @@ public:
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);
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
index 4024333..8463622 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
@@ -366,37 +366,8 @@ void TextureMapperLayer::flushCompositingStateSelf(GraphicsLayerTextureMapper* g
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) {
- // 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;
- }
- }
+ if (changeMask & ChildrenChange)
+ setChildren(graphicsLayer->children());
m_size = graphicsLayer->size();
@@ -446,6 +417,52 @@ void TextureMapperLayer::flushCompositingStateSelf(GraphicsLayerTextureMapper* g
m_transform.setChildrenTransform(m_state.childrenTransform);
}
+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())
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
index 27a77f6..e4a422f 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
@@ -57,7 +57,6 @@ public:
enum ChangeMask {
NoChanges = 0,
- ParentChange = (1L << 0),
ChildrenChange = (1L << 1),
MaskLayerChange = (1L << 2),
PositionChange = (1L << 3),
@@ -145,6 +144,11 @@ private:
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&);
--
1.8.3.1