summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-02-04 22:08:27 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-04 22:08:27 +0000
commitc7e6b93aba9dce93aacb05b5d9f59d09eddb0329 (patch)
tree4ac6ea4f9cdc30c08c5a6f81f3301220667e5679
parent4c49b1fb774d59d3a6e8a6bb5a4549828504c5af (diff)
parentaf6eaf656ec0de5fcbea03968daffe2c845e2089 (diff)
downloadframeworks_base-c7e6b93aba9dce93aacb05b5d9f59d09eddb0329.zip
frameworks_base-c7e6b93aba9dce93aacb05b5d9f59d09eddb0329.tar.gz
frameworks_base-c7e6b93aba9dce93aacb05b5d9f59d09eddb0329.tar.bz2
am af6eaf65: Merge "Fix ANR caused by hwuiTask thread" automerge: 5ad36d4
* commit 'af6eaf656ec0de5fcbea03968daffe2c845e2089': Fix ANR caused by hwuiTask thread
-rw-r--r--libs/hwui/PathCache.cpp4
-rw-r--r--libs/hwui/TessellationCache.cpp8
-rw-r--r--libs/hwui/thread/TaskManager.cpp6
-rw-r--r--libs/hwui/thread/TaskProcessor.h8
4 files changed, 13 insertions, 13 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 80f9c2f..f3d1b34 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -493,7 +493,9 @@ void PathCache::precache(const SkPath* path, const SkPaint* paint) {
if (mProcessor == NULL) {
mProcessor = new PathProcessor(Caches::getInstance());
}
- mProcessor->add(task);
+ if (!mProcessor->add(task)) {
+ mProcessor->process(task);
+ }
}
}
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index 1e38f9e..bc956be 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -385,7 +385,9 @@ void TessellationCache::precacheShadows(const Matrix4* drawTransform, const Rect
if (mShadowProcessor == NULL) {
mShadowProcessor = new ShadowProcessor(Caches::getInstance());
}
- mShadowProcessor->add(task);
+ if (!mShadowProcessor->add(task)) {
+ mShadowProcessor->process(task);
+ }
task->incStrong(NULL); // not using sp<>s, so manually ref while in the cache
mShadowCache.put(key, task.get());
@@ -421,7 +423,9 @@ TessellationCache::Buffer* TessellationCache::getOrCreateBuffer(
if (mProcessor == NULL) {
mProcessor = new TessellationProcessor(Caches::getInstance());
}
- mProcessor->add(task);
+ if (!mProcessor->add(task)) {
+ mProcessor->process(task);
+ }
mCache.put(entry, buffer);
}
return buffer;
diff --git a/libs/hwui/thread/TaskManager.cpp b/libs/hwui/thread/TaskManager.cpp
index 3c30aab..c69b2fd 100644
--- a/libs/hwui/thread/TaskManager.cpp
+++ b/libs/hwui/thread/TaskManager.cpp
@@ -105,6 +105,8 @@ bool TaskManager::WorkerThread::threadLoop() {
bool TaskManager::WorkerThread::addTask(TaskWrapper task) {
if (!isRunning()) {
run(mName.string(), PRIORITY_DEFAULT);
+ } else if (exitPending()) {
+ return false;
}
Mutex::Autolock l(mLock);
@@ -120,10 +122,6 @@ size_t TaskManager::WorkerThread::getTaskCount() const {
}
void TaskManager::WorkerThread::exit() {
- {
- Mutex::Autolock l(mLock);
- mTasks.clear();
- }
requestExit();
mSignal.signal();
}
diff --git a/libs/hwui/thread/TaskProcessor.h b/libs/hwui/thread/TaskProcessor.h
index d1269f0..30b3719 100644
--- a/libs/hwui/thread/TaskProcessor.h
+++ b/libs/hwui/thread/TaskProcessor.h
@@ -30,9 +30,6 @@ public:
TaskProcessorBase() { }
virtual ~TaskProcessorBase() { };
-private:
- friend class TaskManager;
-
virtual void process(const sp<TaskBase>& task) = 0;
};
@@ -44,9 +41,6 @@ public:
bool add(const sp<Task<T> >& task);
- virtual void onProcess(const sp<Task<T> >& task) = 0;
-
-private:
virtual void process(const sp<TaskBase>& task) {
sp<Task<T> > realTask = static_cast<Task<T>* >(task.get());
// This is the right way to do it but sp<> doesn't play nice
@@ -54,6 +48,8 @@ private:
onProcess(realTask);
}
+ virtual void onProcess(const sp<Task<T> >& task) = 0;
+
TaskManager* mManager;
};