diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2018-10-18 15:05:45 -0700 |
---|---|---|
committer | Hyunyoung Song <hyunyoungs@google.com> | 2018-10-19 14:33:46 -0700 |
commit | cda96a5b43b7facfd64ef58f54763862731c9bc4 (patch) | |
tree | 76d0d64e7eac0202689feec3c4985b0722d6f044 /src/com/android/launcher3/icons/IconNormalizer.java | |
parent | 6083c63e81e2ea5e55feb9e46c887d886dbc183f (diff) | |
download | android_packages_apps_Trebuchet-cda96a5b43b7facfd64ef58f54763862731c9bc4.tar.gz android_packages_apps_Trebuchet-cda96a5b43b7facfd64ef58f54763862731c9bc4.tar.bz2 android_packages_apps_Trebuchet-cda96a5b43b7facfd64ef58f54763862731c9bc4.zip |
Setup make icon-loader library
Bug: 115891474
Test: make -j10 icon-loader
Next step: Launcher will depend on icon-loader in next CL
Change-Id: I797ddb857cf8be79f3be6ca2f174c593ca3713a5
Diffstat (limited to 'src/com/android/launcher3/icons/IconNormalizer.java')
-rw-r--r-- | src/com/android/launcher3/icons/IconNormalizer.java | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/com/android/launcher3/icons/IconNormalizer.java b/src/com/android/launcher3/icons/IconNormalizer.java index 73177825b..4052a5514 100644 --- a/src/com/android/launcher3/icons/IconNormalizer.java +++ b/src/com/android/launcher3/icons/IconNormalizer.java @@ -28,14 +28,9 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.AdaptiveIconDrawable; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.Log; -import com.android.launcher3.LauncherAppState; -import com.android.launcher3.Utilities; -import com.android.launcher3.dragndrop.FolderAdaptiveIcon; - import java.nio.ByteBuffer; import androidx.annotation.NonNull; @@ -84,9 +79,9 @@ public class IconNormalizer { private final Matrix mMatrix; /** package private **/ - IconNormalizer(Context context) { + IconNormalizer(Context context, int iconBitmapSize) { // Use twice the icon size as maximum size to avoid scaling down twice. - mMaxSize = LauncherAppState.getIDP(context).iconBitmapSize * 2; + mMaxSize = iconBitmapSize * 2; mBitmap = Bitmap.createBitmap(mMaxSize, mMaxSize, Bitmap.Config.ALPHA_8); mCanvas = new Canvas(mBitmap); mPixels = new byte[mMaxSize * mMaxSize]; @@ -193,17 +188,13 @@ public class IconNormalizer { */ public synchronized float getScale(@NonNull Drawable d, @Nullable RectF outBounds, @Nullable Path path, @Nullable boolean[] outMaskShape) { - if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable) { + if (BaseIconFactory.ATLEAST_OREO && d instanceof AdaptiveIconDrawable) { if (mAdaptiveIconScale != SCALE_NOT_INITIALIZED) { if (outBounds != null) { outBounds.set(mAdaptiveIconBounds); } return mAdaptiveIconScale; } - if (d instanceof FolderAdaptiveIcon) { - // Since we just want the scale, avoid heavy drawing operations - d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null); - } } int width = d.getIntrinsicWidth(); int height = d.getIntrinsicHeight(); @@ -314,7 +305,7 @@ public class IconNormalizer { float areaScale = area / (width * height); // Use sqrt of the final ratio as the images is scaled across both width and height. float scale = areaScale > scaleRequired ? (float) Math.sqrt(scaleRequired / areaScale) : 1; - if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable && + if (BaseIconFactory.ATLEAST_OREO && d instanceof AdaptiveIconDrawable && mAdaptiveIconScale == SCALE_NOT_INITIALIZED) { mAdaptiveIconScale = scale; mAdaptiveIconBounds.set(mBounds); |