- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
75 lines
2.4 KiB
Java
75 lines
2.4 KiB
Java
package androidx.core.graphics;
|
|
|
|
import android.graphics.BlendMode;
|
|
import android.graphics.Paint;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.PorterDuffXfermode;
|
|
import android.graphics.Rect;
|
|
import android.os.Build;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.core.graphics.BlendModeUtils;
|
|
import androidx.core.util.Pair;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class PaintCompat {
|
|
private static final String EM_STRING = "m";
|
|
private static final String TOFU_STRING = "\udfffd";
|
|
private static final ThreadLocal<Pair<Rect, Rect>> sRectThreadLocal = new ThreadLocal<>();
|
|
|
|
public static boolean hasGlyph(@NonNull Paint paint, @NonNull String str) {
|
|
return Api23Impl.hasGlyph(paint, str);
|
|
}
|
|
|
|
public static boolean setBlendMode(@NonNull Paint paint, @Nullable BlendModeCompat blendModeCompat) {
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
Api29Impl.setBlendMode(paint, blendModeCompat != null ? BlendModeUtils.Api29Impl.obtainBlendModeFromCompat(blendModeCompat) : null);
|
|
return true;
|
|
}
|
|
if (blendModeCompat != null) {
|
|
PorterDuff.Mode obtainPorterDuffFromCompat = BlendModeUtils.obtainPorterDuffFromCompat(blendModeCompat);
|
|
paint.setXfermode(obtainPorterDuffFromCompat != null ? new PorterDuffXfermode(obtainPorterDuffFromCompat) : null);
|
|
return obtainPorterDuffFromCompat != null;
|
|
}
|
|
paint.setXfermode(null);
|
|
return true;
|
|
}
|
|
|
|
private static Pair<Rect, Rect> obtainEmptyRects() {
|
|
ThreadLocal<Pair<Rect, Rect>> threadLocal = sRectThreadLocal;
|
|
Pair<Rect, Rect> pair = threadLocal.get();
|
|
if (pair == null) {
|
|
Pair<Rect, Rect> pair2 = new Pair<>(new Rect(), new Rect());
|
|
threadLocal.set(pair2);
|
|
return pair2;
|
|
}
|
|
pair.first.setEmpty();
|
|
pair.second.setEmpty();
|
|
return pair;
|
|
}
|
|
|
|
private PaintCompat() {
|
|
}
|
|
|
|
@RequiresApi(29)
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
public static void setBlendMode(Paint paint, Object obj) {
|
|
paint.setBlendMode((BlendMode) obj);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public static class Api23Impl {
|
|
private Api23Impl() {
|
|
}
|
|
|
|
public static boolean hasGlyph(Paint paint, String str) {
|
|
return paint.hasGlyph(str);
|
|
}
|
|
}
|
|
}
|