summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-03-20 16:17:04 -0700
committerJohn Reck <jreck@google.com>2012-03-23 13:30:19 -0700
commit7a09d1cde40c92dfd028e68ca2408478b9fe152b (patch)
treea06ad925275d1290c08f086200f9519ebf260cc3 /Source
parenta83257eb9d324048471edcf2974b54c20894a940 (diff)
downloadexternal_webkit-7a09d1cde40c92dfd028e68ca2408478b9fe152b.zip
external_webkit-7a09d1cde40c92dfd028e68ca2408478b9fe152b.tar.gz
external_webkit-7a09d1cde40c92dfd028e68ca2408478b9fe152b.tar.bz2
Fix TilesManager race condition
Change-Id: Ibbb8d6fa7565cf7d2205b28c8a9e870eb338ea14
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/TexturesGenerator.cpp5
-rw-r--r--Source/WebCore/platform/graphics/android/TexturesGenerator.h8
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h19
4 files changed, 13 insertions, 29 deletions
diff --git a/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp b/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
index 83e04dc..3279ec2 100644
--- a/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
+++ b/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
@@ -76,7 +76,7 @@ void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter, bool
// The solution is use this as a flag to tell Tex Gen thread that
// UI thread is waiting now, Tex Gen thread should not wait for the
// queue any more.
- TilesManager::instance()->transferQueue()->interruptTransferQueue(true);
+ m_tilesManager->transferQueue()->interruptTransferQueue(true);
}
delete filter;
@@ -94,7 +94,6 @@ void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter, bool
status_t TexturesGenerator::readyToRun()
{
- TilesManager::instance()->markGeneratorAsReady();
ALOGV("Thread ready to run");
return NO_ERROR;
}
@@ -165,7 +164,7 @@ bool TexturesGenerator::threadLoop()
stop = true;
if (m_waitForCompletion) {
m_waitForCompletion = false;
- TilesManager::instance()->transferQueue()->interruptTransferQueue(false);
+ m_tilesManager->transferQueue()->interruptTransferQueue(false);
mRequestedOperationsCond.signal();
}
mRequestedOperationsLock.unlock();
diff --git a/Source/WebCore/platform/graphics/android/TexturesGenerator.h b/Source/WebCore/platform/graphics/android/TexturesGenerator.h
index b79baa7..35a3386 100644
--- a/Source/WebCore/platform/graphics/android/TexturesGenerator.h
+++ b/Source/WebCore/platform/graphics/android/TexturesGenerator.h
@@ -38,11 +38,14 @@ namespace WebCore {
using namespace android;
+class TilesManager;
+
class TexturesGenerator : public Thread {
public:
- TexturesGenerator() : Thread(false)
+ TexturesGenerator(TilesManager* instance) : Thread(false)
, m_waitForCompletion(false)
- , m_currentOperation(0) { }
+ , m_currentOperation(0)
+ , m_tilesManager(instance) { }
virtual ~TexturesGenerator() { }
virtual status_t readyToRun();
@@ -58,6 +61,7 @@ private:
android::Condition mRequestedOperationsCond;
bool m_waitForCompletion;
QueuedOperation* m_currentOperation;
+ TilesManager* m_tilesManager;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index e6577c6..1e9aee4 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -100,7 +100,7 @@ TilesManager::TilesManager()
m_availableTextures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
m_tilesTextures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
m_availableTilesTextures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
- m_pixmapsGenerationThread = new TexturesGenerator();
+ m_pixmapsGenerationThread = new TexturesGenerator(this);
m_pixmapsGenerationThread->run("TexturesGenerator");
}
@@ -414,8 +414,9 @@ void TilesManager::setMaxLayerTextureCount(int max)
TransferQueue* TilesManager::transferQueue()
{
- // To minimize the memory usage, transfer queue can be set to minimal size
- // if required.
+ // m_queue will be created on the UI thread, although it may
+ // be accessed from the TexturesGenerator. However, that can only happen after
+ // a previous transferQueue() call due to a prepare.
if (!m_queue)
m_queue = new TransferQueue(m_useMinimalMemory);
return m_queue;
@@ -446,9 +447,6 @@ TilesManager* TilesManager::instance()
if (!gInstance) {
gInstance = new TilesManager();
ALOGV("instance(), new gInstance is %x", gInstance);
- ALOGV("Waiting for the generator...");
- gInstance->waitForGenerator();
- ALOGV("Generator ready!");
}
return gInstance;
}
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 0640825..eed99c2 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -45,6 +45,7 @@ namespace WebCore {
class TilesManager {
public:
+ // May only be called from the UI thread
static TilesManager* instance();
static GLint getMaxTextureSize();
static int getMaxTextureAllocation();
@@ -75,15 +76,6 @@ public:
BaseTileTexture* getAvailableTexture(BaseTile* owner);
- void markGeneratorAsReady()
- {
- {
- android::Mutex::Autolock lock(m_generatorLock);
- m_generatorReady = true;
- }
- m_generatorReadyCond.signal();
- }
-
void printTextures();
// m_highEndGfx is written/read only on UI thread, no need for a lock.
@@ -170,13 +162,6 @@ public:
private:
TilesManager();
- void waitForGenerator()
- {
- android::Mutex::Autolock lock(m_generatorLock);
- while (!m_generatorReady)
- m_generatorReadyCond.wait(m_generatorLock);
- }
-
void discardTexturesVector(unsigned long long sparedDrawCount,
WTF::Vector<BaseTileTexture*>& textures,
bool deallocateGLTextures);
@@ -206,8 +191,6 @@ private:
sp<TexturesGenerator> m_pixmapsGenerationThread;
android::Mutex m_texturesLock;
- android::Mutex m_generatorLock;
- android::Condition m_generatorReadyCond;
static TilesManager* gInstance;