diff options
| author | Steven Ng <stevenckng@google.com> | 2021-06-29 23:16:56 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-29 23:16:56 +0000 |
| commit | 71113c210725b5873b531b042bec01a4acde8f20 (patch) | |
| tree | cad91857f0b5eb7c2405d6db6fcf419a2f2a7a99 | |
| parent | 9fee641640938b6b245e513df471747eef999c97 (diff) | |
| parent | badf5f5f90b54d03ff994487b4be719545022db0 (diff) | |
Expose disabled color filter for drawable am: badf5f5f90
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/systemui/+/15108726
Change-Id: Icdf4e4342deed4820cd6c27a898a618f1a002e91
| -rw-r--r-- | iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java index 96ee291..4aa2846 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +++ b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java @@ -253,22 +253,7 @@ public class FastBitmapDrawable extends Drawable { private ColorFilter getDisabledColorFilter() { if (sDisabledFColorFilter == null) { - ColorMatrix tempBrightnessMatrix = new ColorMatrix(); - ColorMatrix tempFilterMatrix = new ColorMatrix(); - - tempFilterMatrix.setSaturation(1f - DISABLED_DESATURATION); - float scale = 1 - DISABLED_BRIGHTNESS; - int brightnessI = (int) (255 * DISABLED_BRIGHTNESS); - float[] mat = tempBrightnessMatrix.getArray(); - mat[0] = scale; - mat[6] = scale; - mat[12] = scale; - mat[4] = brightnessI; - mat[9] = brightnessI; - mat[14] = brightnessI; - mat[18] = mDisabledAlpha; - tempFilterMatrix.preConcat(tempBrightnessMatrix); - sDisabledFColorFilter = new ColorMatrixColorFilter(tempFilterMatrix); + sDisabledFColorFilter = getDisabledFColorFilter(mDisabledAlpha); } return sDisabledFColorFilter; } @@ -286,6 +271,25 @@ public class FastBitmapDrawable extends Drawable { return new FastBitmapConstantState(mBitmap, mIconColor, mIsDisabled); } + public static ColorFilter getDisabledFColorFilter(float disabledAlpha) { + ColorMatrix tempBrightnessMatrix = new ColorMatrix(); + ColorMatrix tempFilterMatrix = new ColorMatrix(); + + tempFilterMatrix.setSaturation(1f - DISABLED_DESATURATION); + float scale = 1 - DISABLED_BRIGHTNESS; + int brightnessI = (int) (255 * DISABLED_BRIGHTNESS); + float[] mat = tempBrightnessMatrix.getArray(); + mat[0] = scale; + mat[6] = scale; + mat[12] = scale; + mat[4] = brightnessI; + mat[9] = brightnessI; + mat[14] = brightnessI; + mat[18] = disabledAlpha; + tempFilterMatrix.preConcat(tempBrightnessMatrix); + return new ColorMatrixColorFilter(tempBrightnessMatrix); + } + protected static class FastBitmapConstantState extends ConstantState { protected final Bitmap mBitmap; protected final int mIconColor; |
