Loading core/java/android/app/wallpaper.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -30,3 +30,13 @@ flag { description: "Move APIs related to bitmap and crops to @SystemApi." bug: "372344184" } flag { name: "accurate_wallpaper_downsampling" namespace: "systemui" description: "Accurate downsampling of wallpaper bitmap for high resolution images" bug: "355665230" metadata { purpose: PURPOSE_BUGFIX } } services/core/java/com/android/server/wallpaper/WallpaperCropper.java +14 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.wallpaper; import static android.app.WallpaperManager.ORIENTATION_UNKNOWN; import static android.app.WallpaperManager.getOrientation; import static android.app.WallpaperManager.getRotatedOrientation; import static android.app.Flags.accurateWallpaperDownsampling; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.server.wallpaper.WallpaperUtils.RECORD_FILE; Loading Loading @@ -378,7 +379,14 @@ public class WallpaperCropper { for (int i = 0; i < wallpaper.mCropHints.size(); i++) { Rect adjustedRect = new Rect(wallpaper.mCropHints.valueAt(i)); adjustedRect.offset(-wallpaper.cropHint.left, -wallpaper.cropHint.top); if (accurateWallpaperDownsampling()) { adjustedRect.left = (int) (0.5f + adjustedRect.left / wallpaper.mSampleSize); adjustedRect.top = (int) (0.5f + adjustedRect.top / wallpaper.mSampleSize); adjustedRect.right = (int) Math.floor(adjustedRect.right / wallpaper.mSampleSize); adjustedRect.bottom = (int) Math.floor(adjustedRect.bottom / wallpaper.mSampleSize); } else { adjustedRect.scale(1f / wallpaper.mSampleSize); } result.put(wallpaper.mCropHints.keyAt(i), adjustedRect); } return result; Loading Loading @@ -603,6 +611,11 @@ public class WallpaperCropper { float sampleSizeForThisOrientation = Math.max(1f, Math.min( crop.width() / displayForThisOrientation.x, crop.height() / displayForThisOrientation.y)); if (accurateWallpaperDownsampling()) { sampleSizeForThisOrientation = Math.max(1f, Math.min( (float) crop.width() / displayForThisOrientation.x, (float) crop.height() / displayForThisOrientation.y)); } sampleSize = Math.min(sampleSize, sampleSizeForThisOrientation); } // If the total crop has more width or height than either the max texture size Loading Loading
core/java/android/app/wallpaper.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -30,3 +30,13 @@ flag { description: "Move APIs related to bitmap and crops to @SystemApi." bug: "372344184" } flag { name: "accurate_wallpaper_downsampling" namespace: "systemui" description: "Accurate downsampling of wallpaper bitmap for high resolution images" bug: "355665230" metadata { purpose: PURPOSE_BUGFIX } }
services/core/java/com/android/server/wallpaper/WallpaperCropper.java +14 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.wallpaper; import static android.app.WallpaperManager.ORIENTATION_UNKNOWN; import static android.app.WallpaperManager.getOrientation; import static android.app.WallpaperManager.getRotatedOrientation; import static android.app.Flags.accurateWallpaperDownsampling; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.server.wallpaper.WallpaperUtils.RECORD_FILE; Loading Loading @@ -378,7 +379,14 @@ public class WallpaperCropper { for (int i = 0; i < wallpaper.mCropHints.size(); i++) { Rect adjustedRect = new Rect(wallpaper.mCropHints.valueAt(i)); adjustedRect.offset(-wallpaper.cropHint.left, -wallpaper.cropHint.top); if (accurateWallpaperDownsampling()) { adjustedRect.left = (int) (0.5f + adjustedRect.left / wallpaper.mSampleSize); adjustedRect.top = (int) (0.5f + adjustedRect.top / wallpaper.mSampleSize); adjustedRect.right = (int) Math.floor(adjustedRect.right / wallpaper.mSampleSize); adjustedRect.bottom = (int) Math.floor(adjustedRect.bottom / wallpaper.mSampleSize); } else { adjustedRect.scale(1f / wallpaper.mSampleSize); } result.put(wallpaper.mCropHints.keyAt(i), adjustedRect); } return result; Loading Loading @@ -603,6 +611,11 @@ public class WallpaperCropper { float sampleSizeForThisOrientation = Math.max(1f, Math.min( crop.width() / displayForThisOrientation.x, crop.height() / displayForThisOrientation.y)); if (accurateWallpaperDownsampling()) { sampleSizeForThisOrientation = Math.max(1f, Math.min( (float) crop.width() / displayForThisOrientation.x, (float) crop.height() / displayForThisOrientation.y)); } sampleSize = Math.min(sampleSize, sampleSizeForThisOrientation); } // If the total crop has more width or height than either the max texture size Loading