summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-03-11 20:48:31 -0700
committerRomain Guy <romainguy@google.com>2013-03-12 15:06:42 -0700
commit5dc7fa709646799a5207a5d217f70aa02bf4a3aa (patch)
tree3ebf45fa51bd0373f77aa451868df2d6ae1a8a87 /tests/HwAccelerationTest
parent8818d84a3540de6e53e5d82e2112292102574118 (diff)
downloadframeworks_base-5dc7fa709646799a5207a5d217f70aa02bf4a3aa.zip
frameworks_base-5dc7fa709646799a5207a5d217f70aa02bf4a3aa.tar.gz
frameworks_base-5dc7fa709646799a5207a5d217f70aa02bf4a3aa.tar.bz2
Add TaskManager API
This API can be used to run arbitrary tasks on a pool of worker threads. The number of threads is calculated based on the number of CPU cores available. The API is made of 3 classes: TaskManager Creates and manages the worker threads. Task Describes the work to be done and the type of the output. A task contains a future used to wait for the worker thread to be done computing the result of the task. TaskProcessor The processor dispatches tasks to the TaskManager and is responsible for performing the computation required by each task. A processor will only be asked to process tasks sent to the manager through the processor. A typical use case: class MyTask: Task<MyType> class MyProcessor: TaskProcessor<MyType> TaskManager m = new TaskManager(); MyProcessor p = new MyProcessor(m); MyTask t = new MyTask(); p.add(t); // Waits until the result is available MyType result = t->getResult(); Change-Id: I1fe845ba4c49bb0e1b0627ab147f9a861c8e0749
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java
index ac8ab1f..9f97311 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java
@@ -33,6 +33,7 @@ public class PathsCacheActivity extends Activity {
private Path mPath;
private final Random mRandom = new Random();
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final ArrayList<Path> mPathList = new ArrayList<Path>();
@Override
@@ -58,6 +59,19 @@ public class PathsCacheActivity extends Activity {
path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
}
+ private static Path makeLargePath() {
+ Path path = new Path();
+ buildLargePath(path);
+ return path;
+ }
+
+ private static void buildLargePath(Path path) {
+ path.moveTo(0.0f, 0.0f);
+ path.cubicTo(0.0f, 0.0f, 10000.0f, 15000.0f, 10000.0f, 20000.0f);
+ path.cubicTo(10000.0f, 20000.0f, 5000.0f, 30000.0f, -8000.0f, 20000.0f);
+ path.cubicTo(-8000.0f, 20000.0f, 10000.0f, 20000.0f, 20000.0f, 0.0f);
+ }
+
public class PathsView extends View {
private final Paint mMediumPaint;
@@ -97,6 +111,9 @@ public class PathsCacheActivity extends Activity {
int r = mRandom.nextInt(10);
if (r == 5 || r == 3) {
mPathList.add(path);
+ } else if (r == 7) {
+ path = makeLargePath();
+ mPathList.add(path);
}
canvas.save();