summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2012-05-21 14:29:15 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-21 14:29:15 -0700
commit6d62e2856c7c40b506685d64868333fd39921283 (patch)
treeb1473924464401a97e972f3040598290861657d8
parent8ac715190a8e08ce8fec87fb3a151e12c835750f (diff)
parent0fec40942c5e424610b19929bbcd0a1dd4f53246 (diff)
downloadexternal_webkit-6d62e2856c7c40b506685d64868333fd39921283.zip
external_webkit-6d62e2856c7c40b506685d64868333fd39921283.tar.gz
external_webkit-6d62e2856c7c40b506685d64868333fd39921283.tar.bz2
am 0fec4094: am 6baa213e: Fix memory leak and repaint issues with fixed background elements
* commit '0fec40942c5e424610b19929bbcd0a1dd4f53246': Fix memory leak and repaint issues with fixed background elements
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp2
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp2
5 files changed, 29 insertions, 17 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 3975545..ef355c7 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -124,7 +124,7 @@ GraphicsLayerAndroid::~GraphicsLayerAndroid()
if (m_image)
m_image->deref();
- m_contentLayer->unref();
+ SkSafeUnref(m_contentLayer);
SkSafeUnref(m_fixedBackgroundLayer);
SkSafeUnref(m_foregroundLayer);
SkSafeUnref(m_foregroundClipLayer);
@@ -591,10 +591,10 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() {
return;
if (!view->style()->hasFixedBackgroundImage())
return;
- if (m_contentLayer->isFixedBackground())
- return;
- if (m_fixedBackgroundLayer) // already created
- return;
+
+ SkSafeUnref(m_foregroundClipLayer);
+ SkSafeUnref(m_fixedBackgroundLayer);
+ SkSafeUnref(m_foregroundLayer);
// we will have:
// m_contentLayer
@@ -602,11 +602,10 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() {
// \- m_fixedBackgroundLayer
// \- m_foregroundLayer
- // Grab the background image and create a layer for it
+ // use the background image and create a layer for it
// the layer will be fixed positioned.
Image* image = FixedBackgroundImageLayerAndroid::GetCachedImage(view->style());
-
if (!image)
return;
@@ -634,15 +633,23 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() {
m_foregroundLayer->setIntrinsicallyComposited(true);
// Finally, let's assemble all the layers under a FixedBackgroundLayerAndroid layer
- LayerAndroid* layer = new FixedBackgroundLayerAndroid(*m_contentLayer);
- m_contentLayer->unref();
- m_contentLayer = layer;
-
- m_contentLayer->addChild(m_foregroundClipLayer);
- m_contentLayer->addChild(m_foregroundLayer);
+ if (!m_contentLayer->isFixedBackground()) {
+ m_contentLayer->removeChildren();
+ LayerAndroid* layer = new FixedBackgroundLayerAndroid(*m_contentLayer);
+ m_contentLayer->unref();
+ m_contentLayer = layer;
+ }
- m_needsRepaint = true;
+ if (m_parent) {
+ // The content layer has changed so the parent needs to sync
+ // children.
+ static_cast<GraphicsLayerAndroid*>(m_parent)->m_needsSyncChildren = true;
+ }
+ // Children are all re-parented.
m_needsSyncChildren = true;
+
+ setNeedsDisplay();
+ askForSync();
}
void GraphicsLayerAndroid::updateScrollOffset() {
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index 0fc0790..460e00f 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -29,13 +29,13 @@
#include "SkBitmapRef.h"
#include "Vector.h"
-class FloatPoint3D;
-class Image;
class SkBitmapRef;
class SkRegion;
namespace WebCore {
+class FloatPoint3D;
+class Image;
class LayerAndroid;
class FixedBackgroundImageLayerAndroid;
class ScrollableLayerAndroid;
diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
index a0a1b58..283fa58 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
@@ -244,6 +244,9 @@ Image* FixedBackgroundImageLayerAndroid::GetCachedImage(PassRefPtr<RenderStyle>
Image* image = cachedImage->image();
+ if (image && !image->nativeImageForCurrentFrame())
+ return 0;
+
if (image == Image::nullImage())
return 0;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index 95e6825..6e88081 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -601,7 +601,7 @@ void LayerAndroid::showLayer(int indent)
int count = this->countChildren();
for (int i = 0; i < count; i++)
- this->getChild(i)->showLayer(indent + 1);
+ this->getChild(i)->showLayer(indent + 2);
}
void LayerAndroid::mergeInvalsInto(LayerAndroid* replacementTree)
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index ff45b30..4fab7d4 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -872,6 +872,8 @@ BaseLayerAndroid* WebViewCore::createBaseLayer(GraphicsLayerAndroid* root)
realBase->setSize(content->width(), content->height());
realBase->addChild(baseBackground);
realBase->addChild(base);
+ baseBackground->unref();
+ base->unref();
} else {
realBase = new BaseLayerAndroid(content);
base = realBase;