summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-10-04 17:41:15 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-04 17:41:15 -0700
commit9a05db771f2264b0ae687d0adf51a075183f9498 (patch)
treec4ceba81eabd71f06bb03e40b5b4cd1f3356fb2c
parent3b9c0bd54383c370c1e7d872751539371b1aef54 (diff)
parent2c1def4fa6e745a5f5e8d1cafd7b7f49ec571e1d (diff)
downloadexternal_webkit-9a05db771f2264b0ae687d0adf51a075183f9498.zip
external_webkit-9a05db771f2264b0ae687d0adf51a075183f9498.tar.gz
external_webkit-9a05db771f2264b0ae687d0adf51a075183f9498.tar.bz2
Merge "Remove m_contentsImage usage"
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.h1
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h9
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h2
-rw-r--r--Source/WebKit/android/jni/ViewStateSerializer.cpp32
5 files changed, 37 insertions, 11 deletions
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.h b/Source/WebCore/platform/graphics/android/ImageTexture.h
index 7e51d2b..c2ea77c 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.h
@@ -70,6 +70,7 @@ public:
void release();
unsigned int refCount() { return m_refCount; }
SkBitmapRef* imageRef() { return m_imageRef; }
+ SkBitmap* bitmap() { return m_image; }
private:
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index 4ae8bd3..90f4e86 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -57,6 +57,7 @@ namespace android {
class DrawExtra;
void serializeLayer(WebCore::LayerAndroid* layer, SkWStream* stream);
WebCore::LayerAndroid* deserializeLayer(SkStream* stream);
+void cleanupImageRefs(WebCore::LayerAndroid* layer);
}
using namespace android;
@@ -266,8 +267,10 @@ public:
void setIsIframe(bool isIframe) { m_isIframe = isIframe; }
float zValue() const { return m_zValue; }
+ // ViewStateSerializer friends
friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream);
friend LayerAndroid* android::deserializeLayer(SkStream* stream);
+ friend void android::cleanupImageRefs(LayerAndroid* layer);
PaintedSurface* texture() { return m_texture; }
void assignTextureTo(LayerAndroid* newTree);
@@ -324,16 +327,14 @@ private:
float m_anchorPointZ;
float m_drawOpacity;
- // Note that m_recordingPicture and m_contentsImage are mutually exclusive;
+ // Note that m_recordingPicture and m_imageRef are mutually exclusive;
// m_recordingPicture is used when WebKit is asked to paint the layer's
- // content, while m_contentsImage contains an image that we directly
+ // content, while m_imageRef contains an image that we directly
// composite, using the layer's dimensions as a destination rect.
// We do this as if the layer only contains an image, directly compositing
// it is a much faster method than using m_recordingPicture.
SkPicture* m_recordingPicture;
- SkBitmap* m_contentsImage;
-
typedef HashMap<pair<String, int>, RefPtr<AndroidAnimation> > KeyframesMap;
KeyframesMap m_animations;
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index cf66de5..f077d48 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -458,11 +458,11 @@ void TilesManager::showImages()
}
}
-ImageTexture* TilesManager::getTextureForImage(SkBitmapRef* img)
+ImageTexture* TilesManager::getTextureForImage(SkBitmapRef* img, bool retain)
{
android::Mutex::Autolock lock(m_imagesLock);
ImageTexture* image = m_images.get(img);
- if (image)
+ if (retain && image)
image->retain();
return image;
}
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 071aa88..1549581 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -179,7 +179,7 @@ public:
}
void addImage(SkBitmapRef* img);
void removeImage(SkBitmapRef* img);
- ImageTexture* getTextureForImage(SkBitmapRef* img);
+ ImageTexture* getTextureForImage(SkBitmapRef* img, bool retain = true);
void showImages();
private:
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index b3556c3..c896637 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -32,6 +32,7 @@
#include "PictureSet.h"
#include "ScrollableLayerAndroid.h"
#include "SkPicture.h"
+#include "TilesManager.h"
#include <JNIUtility.h>
#include <JNIHelp.h>
@@ -109,6 +110,11 @@ static BaseLayerAndroid* nativeDeserializeViewState(JNIEnv* env, jobject, jobjec
if (childLayer)
layer->addChild(childLayer);
}
+ // Now double back and delete any imageRefs
+ for (int i = 0; i < layer->countChildren(); i++) {
+ LayerAndroid* childLayer = static_cast<LayerAndroid*>(layer->getChild(i));
+ cleanupImageRefs(childLayer);
+ }
delete stream;
return layer;
}
@@ -290,12 +296,15 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream)
stream->writeBool(layer->m_preserves3D);
stream->writeScalar(layer->m_anchorPointZ);
stream->writeScalar(layer->m_drawOpacity);
- bool hasContentsImage = layer->m_contentsImage != 0;
+ bool hasContentsImage = layer->m_imageRef != 0;
stream->writeBool(hasContentsImage);
if (hasContentsImage) {
SkFlattenableWriteBuffer buffer(1024);
buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag);
- layer->m_contentsImage->flatten(buffer);
+ ImageTexture* imagetexture =
+ TilesManager::instance()->getTextureForImage(layer->m_imageRef, false);
+ if (imagetexture && imagetexture->bitmap())
+ imagetexture->bitmap()->flatten(buffer);
stream->write32(buffer.size());
buffer.writeToStream(stream);
}
@@ -374,8 +383,12 @@ LayerAndroid* deserializeLayer(SkStream* stream)
SkAutoMalloc storage(size);
stream->read(storage.get(), size);
SkFlattenableReadBuffer buffer(storage.get(), size);
- layer->m_contentsImage = new SkBitmap();
- layer->m_contentsImage->unflatten(buffer);
+ SkBitmap contentsImage;
+ contentsImage.unflatten(buffer);
+ SkBitmapRef* imageRef = new SkBitmapRef(contentsImage);
+ layer->setContentsImage(imageRef);
+ // We delay deleting the imageRef until after deserialization to make
+ // sure we have unique keys
}
bool hasRecordingPicture = stream->readBool();
if (hasRecordingPicture) {
@@ -404,6 +417,17 @@ LayerAndroid* deserializeLayer(SkStream* stream)
return layer;
}
+void cleanupImageRefs(LayerAndroid* layer)
+{
+ if (!layer)
+ return;
+ int count = layer->countChildren();
+ for (int i = 0; i < count; i++)
+ cleanupImageRefs(layer->getChild(i));
+ if (layer->m_imageRef)
+ delete layer->m_imageRef;
+}
+
/*
* JNI registration
*/