Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25fb0a9b authored by Chenjie Luo's avatar Chenjie Luo Committed by android-build-merger
Browse files

Merge "Fix bug in AssetAtlas packing loop" into cw-e-dev am: b2b2fb01 am:...

Merge "Fix bug in AssetAtlas packing loop" into cw-e-dev am: b2b2fb01 am: 8d6f1956 am: bf9a587c
am: 5d092a13

* commit '5d092a13':
  Fix bug in AssetAtlas packing loop
parents 223531d8 5d092a13
Loading
Loading
Loading
Loading
+18 −8
Original line number Original line Diff line number Diff line
@@ -79,7 +79,7 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
    private static final boolean DEBUG_ATLAS_TEXTURE = false;
    private static final boolean DEBUG_ATLAS_TEXTURE = false;


    // Minimum size in pixels to consider for the resulting texture
    // Minimum size in pixels to consider for the resulting texture
    private static final int MIN_SIZE = 768;
    private static final int MIN_SIZE = 512;
    // Maximum size in pixels to consider for the resulting texture
    // Maximum size in pixels to consider for the resulting texture
    private static final int MAX_SIZE = 2048;
    private static final int MAX_SIZE = 2048;
    // Increment in number of pixels between size variants when looking
    // Increment in number of pixels between size variants when looking
@@ -665,22 +665,32 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
            if (DEBUG_ATLAS) Log.d(LOG_TAG, "Running " + Thread.currentThread().getName());
            if (DEBUG_ATLAS) Log.d(LOG_TAG, "Running " + Thread.currentThread().getName());


            Atlas.Entry entry = new Atlas.Entry();
            Atlas.Entry entry = new Atlas.Entry();
            for (Atlas.Type type : Atlas.Type.values()) {

            for (int width = mEnd; width > mStart; width -= mStep) {
            for (int width = mEnd; width > mStart; width -= mStep) {
                for (int height = MAX_SIZE; height > MIN_SIZE; height -= STEP) {
                for (int height = MAX_SIZE; height > MIN_SIZE; height -= STEP) {
                    // If the atlas is not big enough, skip it
                    // If the atlas is not big enough, skip it
                    if (width * height <= mThreshold) continue;
                    if (width * height <= mThreshold) continue;


                    boolean packSuccess = false;

                    for (Atlas.Type type : Atlas.Type.values()) {
                        final int count = packBitmaps(type, width, height, entry);
                        final int count = packBitmaps(type, width, height, entry);
                        if (count > 0) {
                        if (count > 0) {
                            mResults.add(new WorkerResult(type, width, height, count));
                            mResults.add(new WorkerResult(type, width, height, count));
                            // If we were able to pack everything let's stop here
                            // Increasing the height further won't make things better
                            if (count == mBitmaps.size()) {
                            if (count == mBitmaps.size()) {
                                // If we were able to pack everything let's stop here
                                // Changing the type further won't make things better
                                packSuccess = true;
                                break;
                                break;
                            }
                            }
                        }
                        }
                    }
                    }

                    // If we were not able to pack everything let's stop here
                    // Decreasing the height further won't make things better
                    if (!packSuccess) {
                        break;
                    }
                }
                }
            }
            }