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

Commit 86b7e8d0 authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

Fix 1px rounding error

Flag: com.android.window.flags.multi_crop
Bug: 372570518
Test: atest WallpaperManagerTest
Change-Id: Ic9b4a15aed5a49cb729b202e0a7915f0e3c40156
parent 5508c034
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -746,8 +746,8 @@ public class WallpaperCropper {
                    final ImageDecoder.Source srcData =
                            ImageDecoder.createSource(wallpaper.getWallpaperFile());
                    final int finalScale = scale;
                    final int rescaledBitmapWidth = (int) (0.5f + bitmapSize.x / sampleSize);
                    final int rescaledBitmapHeight = (int) (0.5f + bitmapSize.y / sampleSize);
                    final int rescaledBitmapWidth = (int) Math.ceil(bitmapSize.x / sampleSize);
                    final int rescaledBitmapHeight = (int) Math.ceil(bitmapSize.y / sampleSize);
                    Bitmap cropped = ImageDecoder.decodeBitmap(srcData, (decoder, info, src) -> {
                        if (!multiCrop()) decoder.setTargetSampleSize(finalScale);
                        if (multiCrop()) {
+2 −2
Original line number Diff line number Diff line
@@ -2380,8 +2380,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            SparseArray<Rect> relativeSuggestedCrops =
                    mWallpaperCropper.getRelativeCropHints(wallpaper);
            Point croppedBitmapSize = new Point(
                    (int) (0.5f + wallpaper.cropHint.width() / wallpaper.mSampleSize),
                    (int) (0.5f + wallpaper.cropHint.height() / wallpaper.mSampleSize));
                    (int) Math.ceil(wallpaper.cropHint.width() / wallpaper.mSampleSize),
                    (int) Math.ceil(wallpaper.cropHint.height() / wallpaper.mSampleSize));
            if (croppedBitmapSize.equals(0, 0)) {
                // There is an ImageWallpaper, but there are no crop hints and the bitmap size is
                // unknown (e.g. the default wallpaper). Return a special "null" value that will be