summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android/LayerAndroid.cpp
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2010-01-25 19:19:18 +0000
committerNicolas Roard <nicolas@android.com>2010-01-26 18:36:17 +0000
commit30e39dd1918530408d55dbead3bf1567661b606e (patch)
tree3e04e9c4edd63f026729ae312c8668c2e0b62ca3 /WebCore/platform/graphics/android/LayerAndroid.cpp
parentec745133ebaf0e3ede2d6656a96399f960a95876 (diff)
downloadexternal_webkit-30e39dd1918530408d55dbead3bf1567661b606e.zip
external_webkit-30e39dd1918530408d55dbead3bf1567661b606e.tar.gz
external_webkit-30e39dd1918530408d55dbead3bf1567661b606e.tar.bz2
Fix memory leak with layers.
This fix bug http://b/2394813 This is a two-parts CL (need a java modif) - The main leak is in WebView.cpp -- nativeUpdateLayers could bail out if the root layer was nil, without deallocating the vector of updates. - fix a leak in LayerAndroid::evaluateAnimations() - adoptRef() for the contentLayer in GraphicsLayerAndroid - simplify AndroidAnimation: remove the reference to the layer (the layer already has a reference to AndroidAnimation) - modify the AndroidAnimation copy() methods to return directly a PassRefPtr, for consistency.
Diffstat (limited to 'WebCore/platform/graphics/android/LayerAndroid.cpp')
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 3b5d5b5..1788f2d 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -105,11 +105,7 @@ LayerAndroid::LayerAndroid(LayerAndroid* layer) :
KeyframesMap::const_iterator end = layer->m_animations.end();
for (KeyframesMap::const_iterator it = layer->m_animations.begin(); it != end; ++it)
- m_animations.add((it->second)->name(), adoptRef((it->second)->copy()));
-
- end = m_animations.end();
- for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it)
- (it->second)->setLayer(this);
+ m_animations.add((it->second)->name(), (it->second)->copy());
gDebugLayerAndroidInstances++;
}
@@ -127,10 +123,11 @@ static int gDebugNbAnims = 0;
Vector<RefPtr<AndroidAnimationValue> >* LayerAndroid::evaluateAnimations() const
{
double time = WTF::currentTime();
- Vector<RefPtr<AndroidAnimationValue> >* result = new Vector<RefPtr<AndroidAnimationValue> >();
+ Vector<RefPtr<AndroidAnimationValue> >* results = new Vector<RefPtr<AndroidAnimationValue> >();
gDebugNbAnims = 0;
- if (evaluateAnimations(time, result))
- return result;
+ if (evaluateAnimations(time, results))
+ return results;
+ delete results;
return 0;
}
@@ -144,22 +141,25 @@ bool LayerAndroid::hasAnimations() const
}
bool LayerAndroid::evaluateAnimations(double time,
- Vector<RefPtr<AndroidAnimationValue> >* result) const
+ Vector<RefPtr<AndroidAnimationValue> >* results) const
{
bool hasRunningAnimations = false;
for (unsigned int i = 0; i < m_children.size(); i++) {
- if (m_children[i]->evaluateAnimations(time, result))
+ if (m_children[i]->evaluateAnimations(time, results))
hasRunningAnimations = true;
}
KeyframesMap::const_iterator end = m_animations.end();
for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it) {
gDebugNbAnims++;
- if ((it->second)->evaluate(time)) {
- result->append((it->second)->result());
+ LayerAndroid* currentLayer = const_cast<LayerAndroid*>(this);
+ if ((it->second)->evaluate(currentLayer, time)) {
+ RefPtr<AndroidAnimationValue> result = (it->second)->result();
+ if (result)
+ results->append(result);
hasRunningAnimations = true;
}
}
-
+
return hasRunningAnimations;
}