summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/graphics/android/BaseTile.cpp3
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.cpp54
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.h8
-rw-r--r--WebCore/platform/graphics/android/TileSet.h7
-rw-r--r--WebCore/platform/graphics/android/TiledPage.cpp12
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h5
6 files changed, 74 insertions, 15 deletions
diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp
index b72cb6d..47a154c 100644
--- a/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/WebCore/platform/graphics/android/BaseTile.cpp
@@ -79,8 +79,6 @@ BaseTile::BaseTile(TiledPage* page, int x, int y)
BaseTile::~BaseTile()
{
- removeTexture();
- setUsedLevel(-1);
#ifdef DEBUG_COUNT
gBaseTileCount--;
#endif
@@ -144,6 +142,7 @@ bool BaseTile::isBitmapReady()
// Called from the texture generation thread
bool BaseTile::paintBitmap()
{
+ XLOG("paintBitmap(%x) %d, %d with page %x", this, m_x, m_y, m_page);
// the mutex ensures you are reading the most current value
m_varLock.lock();
const int x = m_x;
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.cpp b/WebCore/platform/graphics/android/TexturesGenerator.cpp
index 1b8baa0..f81a297 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.cpp
+++ b/WebCore/platform/graphics/android/TexturesGenerator.cpp
@@ -69,6 +69,36 @@ void TexturesGenerator::schedulePaintForTileSet(TileSet* set)
m_newRequestLock.unlock();
}
+void TexturesGenerator::removeSetsWithPage(TiledPage* page)
+{
+ mRequestedPixmapsLock.lock();
+ typedef Vector<TileSet*>::const_iterator iterator;
+ iterator end = mRequestedPixmaps.end();
+ for (iterator it = mRequestedPixmaps.begin(); it != end; ++it) {
+ TileSet* set = static_cast<TileSet*>(*it);
+ if (set->page() == page)
+ delete *it;
+ }
+ TileSet* set = m_currentSet;
+ if (set && set->page() != page)
+ set = 0;
+ if (set)
+ m_waitForCompletion = true;
+ mRequestedPixmapsLock.unlock();
+
+ if (!set)
+ return;
+
+ // At this point, it means that we are currently painting a set that
+ // we want to be removed -- we should wait until it is painted, so that
+ // when we return our caller can be sure that there is no more TileSet
+ // in the queue for that TiledPage and can safely deallocate the BaseTiles.
+ mRequestedPixmapsLock.lock();
+ mRequestedPixmapsCond.wait(mRequestedPixmapsLock);
+ m_waitForCompletion = false;
+ mRequestedPixmapsLock.unlock();
+}
+
status_t TexturesGenerator::readyToRun()
{
TilesManager::instance()->enableTextures();
@@ -88,25 +118,29 @@ bool TexturesGenerator::threadLoop()
m_newRequestLock.unlock();
XLOG("threadLoop, got signal");
+ m_currentSet = 0;
bool stop = false;
while (!stop) {
mRequestedPixmapsLock.lock();
- TileSet* set = 0;
- if (mRequestedPixmaps.size())
- set = mRequestedPixmaps.first();
- mRequestedPixmapsLock.unlock();
-
- if (set) {
- set->paint();
- mRequestedPixmapsLock.lock();
+ if (mRequestedPixmaps.size()) {
+ m_currentSet = mRequestedPixmaps.first();
mRequestedPixmaps.remove(0);
- mRequestedPixmapsLock.unlock();
- delete set;
}
+ mRequestedPixmapsLock.unlock();
+
+ if (m_currentSet)
+ m_currentSet->paint();
mRequestedPixmapsLock.lock();
+ if (m_currentSet) {
+ delete m_currentSet;
+ m_currentSet = 0;
+ mRequestedPixmapsCond.signal();
+ }
if (!mRequestedPixmaps.size())
stop = true;
+ if (m_waitForCompletion)
+ mRequestedPixmapsCond.signal();
mRequestedPixmapsLock.unlock();
}
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.h b/WebCore/platform/graphics/android/TexturesGenerator.h
index 4d94705..8e64b27 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.h
+++ b/WebCore/platform/graphics/android/TexturesGenerator.h
@@ -28,6 +28,7 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "TiledPage.h"
#include "TileSet.h"
#include <utils/threads.h>
@@ -37,18 +38,23 @@ using namespace android;
class TexturesGenerator : public Thread {
public:
- TexturesGenerator() : Thread() { }
+ TexturesGenerator() : Thread()
+ , m_waitForCompletion(false) { }
virtual ~TexturesGenerator() { }
virtual status_t readyToRun();
void schedulePaintForTileSet(TileSet* set);
+ void removeSetsWithPage(TiledPage* page);
private:
virtual bool threadLoop();
Vector<TileSet*> mRequestedPixmaps;
android::Mutex mRequestedPixmapsLock;
+ android::Condition mRequestedPixmapsCond;
android::Mutex m_newRequestLock;
android::Condition m_newRequestCond;
+ TileSet* m_currentSet;
+ bool m_waitForCompletion;
};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/android/TileSet.h b/WebCore/platform/graphics/android/TileSet.h
index d6d4aec..adf6d13 100644
--- a/WebCore/platform/graphics/android/TileSet.h
+++ b/WebCore/platform/graphics/android/TileSet.h
@@ -57,6 +57,13 @@ public:
m_tiles.append(texture);
}
+ TiledPage* page()
+ {
+ if (m_tiles.size())
+ return m_tiles[0]->page();
+ return 0;
+ }
+
private:
Vector<BaseTile*> m_tiles;
diff --git a/WebCore/platform/graphics/android/TiledPage.cpp b/WebCore/platform/graphics/android/TiledPage.cpp
index db87224..f52c2f9 100644
--- a/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/WebCore/platform/graphics/android/TiledPage.cpp
@@ -60,7 +60,16 @@ TiledPage::TiledPage(int id, GLWebViewState* state)
}
TiledPage::~TiledPage() {
- deleteAllValues(m_baseTiles);
+ // Stop any pixmap generation
+ if (m_baseTiles.size()) {
+ TilesManager::instance()->removeSetsWithPage(this);
+ }
+ m_glWebViewState = 0;
+ // At this point, we can safely deallocate the BaseTiles, as
+ // there is no more BaseTile painting or scheduled to be painted
+ // by the TextureGenerator, and as we did reset the BaseLayer in GLWebViewState,
+ // in WebView's destructor (so no additional painting can be scheduled)
+ deleteAllValues(m_baseTiles);
}
BaseTile* TiledPage::getBaseTile(int x, int y)
@@ -164,7 +173,6 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, int firstTileX, int firs
nbTilesWidth, nbTilesHeight, firstTileX, firstTileY, this);
TilesManager::instance()->printTextures();
#endif // DEBUG
-
highResSet->reserveTextures();
#ifdef DEBUG
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index 8e6ba1b..1f9cd38 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -48,6 +48,11 @@ public:
m_pixmapsGenerationThread->schedulePaintForTileSet(set);
}
+ void removeSetsWithPage(TiledPage* page)
+ {
+ m_pixmapsGenerationThread->removeSetsWithPage(page);
+ }
+
ShaderProgram* shader() { return &m_shader; }
BackedDoubleBufferedTexture* getAvailableTexture(BaseTile* owner);