diff options
Diffstat (limited to 'WebCore/platform')
5 files changed, 102 insertions, 27 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h index 9c1d245..2d19806 100644 --- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h +++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h @@ -42,6 +42,7 @@ class TextureTileInfo { TextureTileInfo() : m_x(-1) , m_y(-1) + , m_layerId(-1) , m_scale(0) , m_texture(0) , m_picture(0) @@ -49,6 +50,7 @@ class TextureTileInfo { } int m_x; int m_y; + int m_layerId; float m_scale; TextureInfo* m_texture; unsigned int m_picture; @@ -105,11 +107,12 @@ public: void setTile(TextureInfo* info, int x, int y, float scale, unsigned int pictureCount); bool readyFor(BaseTile* baseTile); +protected: + HashMap<SharedTexture*, TextureTileInfo*> m_texturesInfo; + private: void destroyTextures(SharedTexture** textures); - HashMap<SharedTexture*, TextureTileInfo*> m_texturesInfo; - SkBitmap* m_bitmap; bool m_sharedBitmap; SkSize m_size; diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 76fb2f2..839798d 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -878,13 +878,10 @@ bool LayerAndroid::needsScheduleRepaint(LayerTexture* texture) if (!texture) return false; - if (!texture->ready() || - texture->scale() != m_scale || - texture->pictureUsed() != m_pictureUsed) { - XLOG("We mark layer %d (%x) as dirty because: m_pictureUsed(%d == 0?), texture picture used %x", - uniqueId(), this, m_pictureUsed, texture->pictureUsed()); + TextureInfo* textureInfo = texture->consumerLock(); + if (!texture->readyFor(this)) m_dirty = true; - } + texture->consumerRelease(); return m_dirty; } @@ -1007,13 +1004,14 @@ void LayerAndroid::paintBitmapGL() canvas->restore(); m_atomicSync.lock(); + texture->setTextureInfoFor(this); + m_dirty = false; m_requestSent = false; XLOG("LayerAndroid %d paintBitmapGL PAINTING DONE, updating the texture", uniqueId()); texture->producerUpdate(textureInfo); - texture->setPictureUsed(m_pictureUsed); m_atomicSync.unlock(); XLOG("LayerAndroid %d paintBitmapGL UPDATING DONE", uniqueId()); diff --git a/WebCore/platform/graphics/android/LayerTexture.cpp b/WebCore/platform/graphics/android/LayerTexture.cpp new file mode 100644 index 0000000..f311f32 --- /dev/null +++ b/WebCore/platform/graphics/android/LayerTexture.cpp @@ -0,0 +1,71 @@ +/* + * Copyright 2011, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LayerTexture.h" + +#include "LayerAndroid.h" + +namespace WebCore { + +unsigned int LayerTexture::pictureUsed() +{ + consumerLock(); + TextureTileInfo* info = m_texturesInfo.get(getReadableTexture()); + unsigned int pictureUsed = 0; + if (info) + pictureUsed = info->m_picture; + consumerRelease(); + return pictureUsed; +} + +void LayerTexture::setTextureInfoFor(LayerAndroid* layer) +{ + TextureTileInfo* textureInfo = m_texturesInfo.get(getWriteableTexture()); + if (!textureInfo) { + textureInfo = new TextureTileInfo(); + } + textureInfo->m_layerId = layer->uniqueId(); + textureInfo->m_picture = layer->pictureUsed(); + textureInfo->m_scale = layer->getScale(); + m_texturesInfo.set(getWriteableTexture(), textureInfo); + m_layerId = layer->uniqueId(); + m_scale = layer->getScale(); + if (!m_ready) + m_ready = true; +} + +bool LayerTexture::readyFor(LayerAndroid* layer) +{ + TextureTileInfo* info = m_texturesInfo.get(getReadableTexture()); + if (info && + info->m_layerId == layer->uniqueId() && + info->m_scale == layer->getScale() && + info->m_picture == layer->pictureUsed()) + return true; + return false; +} + +} // namespace WebCore diff --git a/WebCore/platform/graphics/android/LayerTexture.h b/WebCore/platform/graphics/android/LayerTexture.h index d323d6f..be3594f 100644 --- a/WebCore/platform/graphics/android/LayerTexture.h +++ b/WebCore/platform/graphics/android/LayerTexture.h @@ -37,9 +37,8 @@ class LayerTexture : public BackedDoubleBufferedTexture { LayerTexture(uint32_t w, uint32_t h, SkBitmap::Config config = SkBitmap::kARGB_8888_Config) : BackedDoubleBufferedTexture(w, h, 0, config) - , m_id(0) + , m_layerId(0) , m_scale(1) - , m_pictureUsed(0) , m_ready(false) { #ifdef DEBUG_COUNT @@ -53,28 +52,22 @@ class LayerTexture : public BackedDoubleBufferedTexture { #endif }; - int id() { return m_id; } - void setId(int id) { m_id = id; } - bool ready() { return m_ready; } - - unsigned int pictureUsed() { return m_pictureUsed; } - void setPictureUsed(unsigned pictureUsed) - { - if (!m_ready) - m_ready = true; - m_pictureUsed = pictureUsed; - } + void setTextureInfoFor(LayerAndroid* layer); + bool readyFor(LayerAndroid* layer); void setRect(const IntRect& r) { m_rect = r; } IntRect& rect() { return m_rect; } + int id() { return m_layerId; } float scale() { return m_scale; } + void setId(int id) { m_layerId = id; } void setScale(float scale) { m_scale = scale; } + bool ready() { return m_ready; } + unsigned int pictureUsed(); private: - int m_id; IntRect m_rect; + int m_layerId; float m_scale; - unsigned int m_pictureUsed; bool m_ready; }; diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp index 0cb30d2..bff1551 100644 --- a/WebCore/platform/graphics/android/TilesManager.cpp +++ b/WebCore/platform/graphics/android/TilesManager.cpp @@ -226,6 +226,8 @@ LayerTexture* TilesManager::getExistingTextureForLayer(LayerAndroid* layer, LayerTexture* texture) { android::Mutex::Autolock lock(m_texturesLock); + LayerTexture* best = 0; + unsigned newestPictureUsed = 0; for (unsigned int i = 0; i< m_layersTextures.size(); i++) { if (m_layersTextures[i]->id() != layer->uniqueId()) continue; @@ -236,13 +238,21 @@ LayerTexture* TilesManager::getExistingTextureForLayer(LayerAndroid* layer, if (any && texture == m_layersTextures[i]) continue; + if (m_layersTextures[i]->ready()) { + unsigned int pictureUsed = m_layersTextures[i]->pictureUsed(); + if (pictureUsed >= newestPictureUsed) { + newestPictureUsed = pictureUsed; + best = m_layersTextures[i]; + } + } + XLOG("return layer %d (%x) for tile %d (%x)", i, m_layersTextures[i], layer->uniqueId(), layer); - - if (m_layersTextures[i]->acquire(layer)) - return m_layersTextures[i]; } + + if (best && best->acquire(layer)) + return best; return 0; } |