summaryrefslogtreecommitdiff
path: root/libs/hwui/PathCache.h
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2013-03-08 17:44:20 -0800
committer Romain Guy <romainguy@google.com> 2013-03-11 17:05:28 -0700
commitca89e2a68703bd428e8b66547d033a6ed35b3595 (patch)
tree5661de81848f7d26559531a1ea650ed7fea2decd /libs/hwui/PathCache.h
parent6e2004089305cf2cd958b52b234459a49a4e5c83 (diff)
Precache paths from a worker thread
Change-Id: I3e7b53d67e0e03e403beaf55c39350ead7f1e309
Diffstat (limited to 'libs/hwui/PathCache.h')
-rw-r--r--libs/hwui/PathCache.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 8a0235b88a64..1d28ecbf6a00 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -17,14 +17,21 @@
#ifndef ANDROID_HWUI_PATH_CACHE_H
#define ANDROID_HWUI_PATH_CACHE_H
+#include <utils/Thread.h>
#include <utils/Vector.h>
#include "Debug.h"
#include "ShapeCache.h"
+#include "thread/Signal.h"
+
+class SkPaint;
+class SkPath;
namespace android {
namespace uirenderer {
+class Caches;
+
///////////////////////////////////////////////////////////////////////////////
// Classes
///////////////////////////////////////////////////////////////////////////////
@@ -69,6 +76,7 @@ inline hash_t hash_type(const PathCacheEntry& entry) {
class PathCache: public ShapeCache<PathCacheEntry> {
public:
PathCache();
+ ~PathCache();
/**
* Returns the texture associated with the specified path. If the texture
@@ -89,7 +97,35 @@ public:
*/
void clearGarbage();
+ void precache(SkPath* path, SkPaint* paint);
+
private:
+ class PrecacheThread: public Thread {
+ public:
+ PrecacheThread(): mSignal(Condition::WAKE_UP_ONE) { }
+
+ void addTask(PathTexture* texture, SkPath* path, SkPaint* paint);
+ void exit();
+
+ private:
+ struct Task {
+ PathTexture* texture;
+ SkPath* path;
+ SkPaint* paint;
+ };
+
+ virtual bool threadLoop();
+
+ // Lock for the list of tasks
+ Mutex mLock;
+ Vector<Task> mTasks;
+
+ // Signal used to wake up the thread when a new
+ // task is available in the list
+ mutable Signal mSignal;
+ };
+
+ sp<PrecacheThread> mThread;
Vector<SkPath*> mGarbage;
mutable Mutex mLock;
}; // class PathCache