summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2015-04-01 13:26:08 -0700
committerztenghui <ztenghui@google.com>2015-04-01 14:42:33 -0700
commit072be09aafc258a8d9d8c4f1dbf4f800b3983434 (patch)
tree523fa96a9e0a7dc778b90d7dd33f5c03125a0154 /services
parentb929d65800fcc91c04d385fe9ec23a924868883b (diff)
downloadframeworks_base-072be09aafc258a8d9d8c4f1dbf4f800b3983434.zip
frameworks_base-072be09aafc258a8d9d8c4f1dbf4f800b3983434.tar.gz
frameworks_base-072be09aafc258a8d9d8c4f1dbf4f800b3983434.tar.bz2
Start searching the dimension configuration for atlas from the biggest value.
The old way will almost always miss the MAX_SIZE * MAX_SIZE case. Most of time, it will be fine. But if the threshold is just fall a bit short from MAX_SIZE * MAX_SIZE, then it is likely that no generated configuration can be bigger than the threshold. At the same time, a power of 2 size texture is more likely be used in the new way. Better for memory alignment (or usage) and potential performance. b/19966623 Change-Id: I4683fd5dea347158bc05d95cc7d777cc391b7fba
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/AssetAtlasService.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/AssetAtlasService.java b/services/core/java/com/android/server/AssetAtlasService.java
index e6dc1c7..f106667 100644
--- a/services/core/java/com/android/server/AssetAtlasService.java
+++ b/services/core/java/com/android/server/AssetAtlasService.java
@@ -403,13 +403,13 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
if (cpuCount == 1) {
new ComputeWorker(MIN_SIZE, MAX_SIZE, STEP, bitmaps, pixelCount, results, null).run();
} else {
- int start = MIN_SIZE;
- int end = MAX_SIZE - (cpuCount - 1) * STEP;
+ int start = MIN_SIZE + (cpuCount - 1) * STEP;
+ int end = MAX_SIZE;
int step = STEP * cpuCount;
final CountDownLatch signal = new CountDownLatch(cpuCount);
- for (int i = 0; i < cpuCount; i++, start += STEP, end += STEP) {
+ for (int i = 0; i < cpuCount; i++, start -= STEP, end -= STEP) {
ComputeWorker worker = new ComputeWorker(start, end, step,
bitmaps, pixelCount, results, signal);
new Thread(worker, "Atlas Worker #" + (i + 1)).start();
@@ -435,7 +435,8 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
if (DEBUG_ATLAS) {
float delay = (System.nanoTime() - begin) / 1000.0f / 1000.0f / 1000.0f;
- Log.d(LOG_TAG, String.format("Found best atlas configuration in %.2fs", delay));
+ Log.d(LOG_TAG, String.format("Found best atlas configuration (out of %d) in %.2fs",
+ results.size(), delay));
}
WorkerResult result = results.get(0);
@@ -696,8 +697,8 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
Atlas.Entry entry = new Atlas.Entry();
for (Atlas.Type type : Atlas.Type.values()) {
- for (int width = mStart; width < mEnd; width += mStep) {
- for (int height = MIN_SIZE; height < MAX_SIZE; height += STEP) {
+ for (int width = mEnd; width > mStart; width -= mStep) {
+ for (int height = MAX_SIZE; height > MIN_SIZE; height -= STEP) {
// If the atlas is not big enough, skip it
if (width * height <= mThreshold) continue;