summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp34
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h4
-rw-r--r--WebCore/platform/graphics/android/LayerTexture.h2
-rw-r--r--WebCore/platform/graphics/android/TilesManager.cpp6
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h1
5 files changed, 32 insertions, 15 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
index dd69c4c..846b9ca 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
@@ -38,22 +38,32 @@
namespace WebCore {
BackedDoubleBufferedTexture::BackedDoubleBufferedTexture(uint32_t w, uint32_t h,
- SkBitmap::Config config)
+ SkBitmap* bitmap,
+ SkBitmap::Config config)
: DoubleBufferedTexture(eglGetCurrentContext())
, m_usedLevel(-1)
, m_owner(0)
, m_busy(false)
{
m_size.set(w, h);
- m_bitmap.setConfig(config, w, h);
- m_bitmap.allocPixels();
- m_bitmap.eraseColor(0);
- m_canvas = new SkCanvas(m_bitmap);
+ if (bitmap) {
+ m_bitmap = bitmap;
+ m_sharedBitmap = true;
+ } else {
+ m_bitmap = new SkBitmap();
+ m_bitmap->setConfig(config, w, h);
+ m_bitmap->allocPixels();
+ m_bitmap->eraseColor(0);
+ }
+ m_canvas = new SkCanvas(*m_bitmap);
}
BackedDoubleBufferedTexture::~BackedDoubleBufferedTexture()
{
- m_bitmap.reset();
+ if (!m_sharedBitmap) {
+ m_bitmap->reset();
+ delete m_bitmap;
+ }
delete m_canvas;
SharedTexture* textures[3] = { &m_textureA, &m_textureB, 0 };
destroyTextures(textures);
@@ -107,17 +117,17 @@ bool BackedDoubleBufferedTexture::busy()
void BackedDoubleBufferedTexture::producerUpdate(TextureInfo* textureInfo)
{
// no need to upload a texture since the bitmap is empty
- if (!m_bitmap.width() && !m_bitmap.height()) {
+ if (!m_bitmap->width() && !m_bitmap->height()) {
producerRelease();
return;
}
- if (textureInfo->m_width == m_bitmap.width() && textureInfo->m_height == m_bitmap.height())
- GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, m_bitmap);
+ if (textureInfo->m_width == m_bitmap->width() && textureInfo->m_height == m_bitmap->height())
+ GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, *m_bitmap);
else {
- GLUtils::createTextureWithBitmap(textureInfo->m_textureId, m_bitmap);
- textureInfo->m_width = m_bitmap.width();
- textureInfo->m_height = m_bitmap.height();
+ GLUtils::createTextureWithBitmap(textureInfo->m_textureId, *m_bitmap);
+ textureInfo->m_width = m_bitmap->width();
+ textureInfo->m_height = m_bitmap->height();
}
producerReleaseAndSwap();
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
index 0b62224..1454d47 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
@@ -43,6 +43,7 @@ public:
// This object is to be constructed on the consumer's thread and must have
// a width and height greater than 0.
BackedDoubleBufferedTexture(uint32_t w, uint32_t h,
+ SkBitmap* bitmap = 0,
SkBitmap::Config config = SkBitmap::kARGB_8888_Config);
virtual ~BackedDoubleBufferedTexture();
@@ -83,7 +84,8 @@ public:
private:
void destroyTextures(SharedTexture** textures);
- SkBitmap m_bitmap;
+ SkBitmap* m_bitmap;
+ bool m_sharedBitmap;
SkSize m_size;
SkCanvas* m_canvas;
int m_usedLevel;
diff --git a/WebCore/platform/graphics/android/LayerTexture.h b/WebCore/platform/graphics/android/LayerTexture.h
index 042422d..0632abb 100644
--- a/WebCore/platform/graphics/android/LayerTexture.h
+++ b/WebCore/platform/graphics/android/LayerTexture.h
@@ -35,7 +35,7 @@ class LayerTexture : public BackedDoubleBufferedTexture {
public:
LayerTexture(uint32_t w, uint32_t h,
SkBitmap::Config config = SkBitmap::kARGB_8888_Config)
- : BackedDoubleBufferedTexture(w, h, config)
+ : BackedDoubleBufferedTexture(w, h, 0, config)
, m_id(0)
, m_scale(1)
, m_pictureUsed(0)
diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp
index 16282c4..9d42058 100644
--- a/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/WebCore/platform/graphics/android/TilesManager.cpp
@@ -72,9 +72,13 @@ TilesManager::TilesManager()
{
XLOG("TilesManager ctor");
m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
+ m_tilesBitmap = new SkBitmap();
+ m_tilesBitmap->setConfig(SkBitmap::kARGB_8888_Config, tileWidth(), tileHeight());
+ m_tilesBitmap->allocPixels();
+ m_tilesBitmap->eraseColor(0);
for (int i = 0; i < MAX_TEXTURE_ALLOCATION; i++) {
BackedDoubleBufferedTexture* texture = new BackedDoubleBufferedTexture(
- tileWidth(), tileHeight());
+ tileWidth(), tileHeight(), m_tilesBitmap);
// the atomic load ensures that the texture has been fully initialized
// before we pass a pointer for other threads to operate on
m_textures.append(reinterpret_cast<BackedDoubleBufferedTexture*>(
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index 0338ece..6cd8bcd 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -121,6 +121,7 @@ private:
static TilesManager* gInstance;
ShaderProgram m_shader;
+ SkBitmap* m_tilesBitmap;
};
} // namespace WebCore