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

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

Make getRelativeCropHints static, rename some variables

This is to make next CL more clear.

Flag: EXEMPT small refactor
Bug: 278261563
Test: presubmit
Change-Id: If95cd7529ae85273da0605348c04c95c6b9d1c46
parent 1a798ad0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ public class WallpaperCropper {
     * The crops stored in {@link WallpaperData#mCropHints} are relative to the original image.
     * This computes the crops relative to the sub-image that will actually be rendered on a window.
     */
    SparseArray<Rect> getRelativeCropHints(WallpaperData wallpaper) {
    static SparseArray<Rect> getRelativeCropHints(WallpaperData wallpaper) {
        SparseArray<Rect> result = new SparseArray<>();
        for (int i = 0; i < wallpaper.mCropHints.size(); i++) {
            Rect adjustedRect = new Rect(wallpaper.mCropHints.valueAt(i));
+8 −8
Original line number Diff line number Diff line
@@ -931,7 +931,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    mToken, (which & FLAG_LOCK) != 0);
            if (multiCrop() && mImageWallpaper.equals(wallpaper.getComponent())) {
                mWindowManagerInternal.setWallpaperCropHints(mToken,
                        mWallpaperCropper.getRelativeCropHints(wallpaper));
                        WallpaperCropper.getRelativeCropHints(wallpaper));
            } else {
                mWindowManagerInternal.setWallpaperCropHints(mToken, new SparseArray<>());
            }
@@ -2519,23 +2519,23 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            if (wallpaper == null || !mImageWallpaper.equals(wallpaper.getComponent())) {
                return null;
            }
            SparseArray<Rect> relativeSuggestedCrops =
                    mWallpaperCropper.getRelativeCropHints(wallpaper);
            Point croppedBitmapSize = new Point(
            SparseArray<Rect> relativeCropHints =
                    WallpaperCropper.getRelativeCropHints(wallpaper);
            Point relativeCropSize = new Point(
                    (int) Math.ceil(wallpaper.cropHint.width() / wallpaper.mSampleSize),
                    (int) Math.ceil(wallpaper.cropHint.height() / wallpaper.mSampleSize));
            if (croppedBitmapSize.equals(0, 0)) {
            if (relativeCropSize.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
                // handled by WallpaperManager, which will fetch the dimensions of the wallpaper.
                return null;
            }
            SparseArray<Rect> relativeDefaultCrops =
                    mWallpaperCropper.getDefaultCrops(relativeSuggestedCrops, croppedBitmapSize);
                    mWallpaperCropper.getDefaultCrops(relativeCropHints, relativeCropSize);
            SparseArray<Rect> adjustedRelativeSuggestedCrops = new SparseArray<>();
            for (int i = 0; i < relativeDefaultCrops.size(); i++) {
                int key = relativeDefaultCrops.keyAt(i);
                if (relativeSuggestedCrops.contains(key)) {
                if (relativeCropHints.contains(key)) {
                    adjustedRelativeSuggestedCrops.put(key, relativeDefaultCrops.get(key));
                }
            }
@@ -2546,7 +2546,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    mWallpaperDisplayHelper.getDefaultDisplayInfo();
            for (Point displaySize : displaySizes) {
                result.add(WallpaperCropper.getCrop(displaySize, defaultDisplayInfo,
                        croppedBitmapSize, adjustedRelativeSuggestedCrops, rtl));
                        relativeCropSize, adjustedRelativeSuggestedCrops, rtl));
            }
            if (originalBitmap) result = WallpaperCropper.getOriginalCropHints(wallpaper, result);
            return result;