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

Commit f9bf5d63 authored by henry.uh_chen's avatar henry.uh_chen Committed by Steve Kondik
Browse files

[AssetAtlas] Avoid packing 1-pixel width or height asset into AssetAtlas

Symptom: For preloaded asset which has 1-pixel width (or 1-pixel height),
         sampling the atlas texture will get a color mixed with the surrounding
         pixels' color.
         If we have padding in the atlas texture , sampling will mix the
         padding's black color and result in an obvious defect.

Solugion: We avoid packing 1-pixel width (or 1-pixel height) asset into
          AssetAtlas.

Change-Id: I765673dfa13cf3f3709196cf15f35d3493d1edd8
parent f303ff63
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -143,10 +143,17 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
        for (int i = 0; i < count; i++) {
            final Bitmap bitmap = drawables.valueAt(i).getBitmap();
            if (bitmap != null && bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
                // For preloaded asset which has 1-pixel width (or 1-pixel height), sampling the atlas texture
                // will get a color mixed with the surrounding pixels' color.
                // If we have padding in the atlas texture , sampling will mix the padding's black color and
                // result in a obvious defect.
                // We avoid packing 1-pixel width (or 1-pixel height) asset into AssetAtlas.
                if(bitmap.getWidth() != 1 && bitmap.getHeight() != 1) {
                    bitmaps.add(bitmap);
                    totalPixelCount += bitmap.getWidth() * bitmap.getHeight();
                }
            }
        }

        // Our algorithms perform better when the bitmaps are first sorted
        // The comparator will sort the bitmap by width first, then by height