- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
118 lines
4.3 KiB
Java
118 lines
4.3 KiB
Java
package androidx.core.graphics;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BlendMode;
|
|
import android.graphics.ColorSpace;
|
|
import android.graphics.Paint;
|
|
import android.os.Build;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.ReplaceWith;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.VisibleForTesting;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class BitmapCompat {
|
|
@VisibleForTesting
|
|
public static int sizeAtStep(int i, int i2, int i3, int i4) {
|
|
return i3 == 0 ? i2 : i3 > 0 ? i * (1 << (i4 - i3)) : i2 << ((-i3) - 1);
|
|
}
|
|
|
|
@ReplaceWith(expression = "bitmap.hasMipMap()")
|
|
@Deprecated
|
|
public static boolean hasMipMap(@NonNull Bitmap bitmap) {
|
|
return bitmap.hasMipMap();
|
|
}
|
|
|
|
@ReplaceWith(expression = "bitmap.setHasMipMap(hasMipMap)")
|
|
@Deprecated
|
|
public static void setHasMipMap(@NonNull Bitmap bitmap, boolean z) {
|
|
bitmap.setHasMipMap(z);
|
|
}
|
|
|
|
@ReplaceWith(expression = "bitmap.getAllocationByteCount()")
|
|
@Deprecated
|
|
public static int getAllocationByteCount(@NonNull Bitmap bitmap) {
|
|
return bitmap.getAllocationByteCount();
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:97:0x01a9, code lost:
|
|
|
|
if (androidx.core.graphics.BitmapCompat.Api27Impl.isAlreadyF16AndLinear(r11) == false) goto L124;
|
|
*/
|
|
@androidx.annotation.NonNull
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static android.graphics.Bitmap createScaledBitmap(@androidx.annotation.NonNull android.graphics.Bitmap r21, int r22, int r23, @androidx.annotation.Nullable android.graphics.Rect r24, boolean r25) {
|
|
/*
|
|
Method dump skipped, instructions count: 534
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.BitmapCompat.createScaledBitmap(android.graphics.Bitmap, int, int, android.graphics.Rect, boolean):android.graphics.Bitmap");
|
|
}
|
|
|
|
private BitmapCompat() {
|
|
}
|
|
|
|
@RequiresApi(27)
|
|
public static class Api27Impl {
|
|
private Api27Impl() {
|
|
}
|
|
|
|
public static Bitmap createBitmapWithSourceColorspace(int i, int i2, Bitmap bitmap, boolean z) {
|
|
Bitmap.Config config = bitmap.getConfig();
|
|
ColorSpace colorSpace = bitmap.getColorSpace();
|
|
ColorSpace colorSpace2 = ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB);
|
|
if (z && !bitmap.getColorSpace().equals(colorSpace2)) {
|
|
config = Bitmap.Config.RGBA_F16;
|
|
colorSpace = colorSpace2;
|
|
} else if (bitmap.getConfig() == Bitmap.Config.HARDWARE) {
|
|
config = Bitmap.Config.ARGB_8888;
|
|
if (Build.VERSION.SDK_INT >= 31) {
|
|
config = Api31Impl.getHardwareBitmapConfig(bitmap);
|
|
}
|
|
}
|
|
return Bitmap.createBitmap(i, i2, config, bitmap.hasAlpha(), colorSpace);
|
|
}
|
|
|
|
public static boolean isAlreadyF16AndLinear(Bitmap bitmap) {
|
|
return bitmap.getConfig() == Bitmap.Config.RGBA_F16 && bitmap.getColorSpace().equals(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB));
|
|
}
|
|
|
|
public static Bitmap copyBitmapIfHardware(Bitmap bitmap) {
|
|
if (bitmap.getConfig() != Bitmap.Config.HARDWARE) {
|
|
return bitmap;
|
|
}
|
|
Bitmap.Config config = Bitmap.Config.ARGB_8888;
|
|
if (Build.VERSION.SDK_INT >= 31) {
|
|
config = Api31Impl.getHardwareBitmapConfig(bitmap);
|
|
}
|
|
return bitmap.copy(config, true);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(29)
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
public static void setPaintBlendMode(Paint paint) {
|
|
paint.setBlendMode(BlendMode.SRC);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(31)
|
|
public static class Api31Impl {
|
|
private Api31Impl() {
|
|
}
|
|
|
|
public static Bitmap.Config getHardwareBitmapConfig(Bitmap bitmap) {
|
|
if (bitmap.getHardwareBuffer().getFormat() == 22) {
|
|
return Bitmap.Config.RGBA_F16;
|
|
}
|
|
return Bitmap.Config.ARGB_8888;
|
|
}
|
|
}
|
|
}
|