summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2010-12-13 16:30:13 -0800
committerNicolas Roard <nicolas@android.com>2010-12-13 16:30:13 -0800
commitee5f2ff1ad8be350308b229a10fe53c8d5709be2 (patch)
tree734e687f9261d80f886fbf452163aff7d6645d9c /WebCore/platform
parentc9ab9bf00ba3ce8289f917675f81b40e4438a864 (diff)
downloadexternal_webkit-ee5f2ff1ad8be350308b229a10fe53c8d5709be2.zip
external_webkit-ee5f2ff1ad8be350308b229a10fe53c8d5709be2.tar.gz
external_webkit-ee5f2ff1ad8be350308b229a10fe53c8d5709be2.tar.bz2
Refactoring TexturesGenerator filtering
Change-Id: I58866a481f526105edc4336e517b7e082e0db6dc
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/QueuedOperation.h21
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.cpp28
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.h6
3 files changed, 43 insertions, 12 deletions
diff --git a/WebCore/platform/graphics/android/QueuedOperation.h b/WebCore/platform/graphics/android/QueuedOperation.h
index 3e2b048..7472db7 100644
--- a/WebCore/platform/graphics/android/QueuedOperation.h
+++ b/WebCore/platform/graphics/android/QueuedOperation.h
@@ -46,6 +46,27 @@ class QueuedOperation {
TiledPage* m_page;
};
+class OperationFilter
+{
+ public:
+ virtual ~OperationFilter() {}
+ virtual bool check(QueuedOperation* operation) = 0;
+};
+
+class PageFilter : public OperationFilter
+{
+ public:
+ PageFilter(TiledPage* page) : m_page(page) {}
+ virtual bool check(QueuedOperation* operation)
+ {
+ if (operation->page() == m_page)
+ return true;
+ return false;
+ }
+ private:
+ TiledPage* m_page;
+};
+
}
#endif // QueuedOperation_h
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.cpp b/WebCore/platform/graphics/android/TexturesGenerator.cpp
index 26090b0..234c7f9 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.cpp
+++ b/WebCore/platform/graphics/android/TexturesGenerator.cpp
@@ -73,22 +73,30 @@ void TexturesGenerator::scheduleOperation(QueuedOperation* operation)
void TexturesGenerator::removeOperationsForPage(TiledPage* page)
{
+ removeOperationsForFilter(new PageFilter(page));
+}
+
+void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter)
+{
mRequestedOperationsLock.lock();
- typedef Vector<QueuedOperation*>::const_iterator iterator;
- iterator end = mRequestedOperations.end();
- for (iterator it = mRequestedOperations.begin(); it != end; ++it) {
- QueuedOperation* operation = static_cast<QueuedOperation*>(*it);
- if (operation->page() == page)
- delete *it;
+ for (unsigned int i = 0; i < mRequestedOperations.size();) {
+ QueuedOperation* operation = mRequestedOperations[i];
+ if (filter->check(operation)) {
+ mRequestedOperations.remove(i);
+ delete operation;
+ } else {
+ i++;
+ }
}
+
QueuedOperation* operation = m_currentOperation;
- if (operation && operation->page() != page)
- operation = 0;
- if (operation)
+ if (operation && filter->check(operation))
m_waitForCompletion = true;
+
mRequestedOperationsLock.unlock();
+ delete filter;
- if (!operation)
+ if (!m_waitForCompletion)
return;
// At this point, it means that we are currently painting a operation that
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.h b/WebCore/platform/graphics/android/TexturesGenerator.h
index ae02d14..84dbeab 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.h
+++ b/WebCore/platform/graphics/android/TexturesGenerator.h
@@ -40,11 +40,13 @@ using namespace android;
class TexturesGenerator : public Thread {
public:
TexturesGenerator() : Thread()
- , m_waitForCompletion(false) { }
+ , m_waitForCompletion(false)
+ , m_currentOperation(0) { }
virtual ~TexturesGenerator() { }
virtual status_t readyToRun();
void removeOperationsForPage(TiledPage* page);
+ void removeOperationsForFilter(OperationFilter* filter);
void scheduleOperation(QueuedOperation* operation);
@@ -55,8 +57,8 @@ private:
android::Condition mRequestedOperationsCond;
android::Mutex m_newRequestLock;
android::Condition m_newRequestCond;
- QueuedOperation* m_currentOperation;
bool m_waitForCompletion;
+ QueuedOperation* m_currentOperation;
};
} // namespace WebCore