Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64ac8b12 authored by Pat Manning's avatar Pat Manning
Browse files

Support Vectors as frames of animation drawables in PointerIcon.

Bug: 305193969
Test: v2/pixel-health-guard/device-boot-test
Flag: ACONFIG com.android.systemui.enable_vector_cursors STAGING
Change-Id: I61d51a462a77e260e34cbcde737641cc57868c3c
parent 0491bba4
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -480,11 +480,19 @@ public final class PointerIcon implements Parcelable {
                mBitmapFrames = new Bitmap[frames - 1];
                final int width = drawable.getIntrinsicWidth();
                final int height = drawable.getIntrinsicHeight();
                final boolean isVectorAnimation = drawable instanceof VectorDrawable;
                mDrawNativeDropShadow = isVectorAnimation;
                for (int i = 1; i < frames; ++i) {
                    Drawable drawableFrame = animationDrawable.getFrame(i);
                    if (!(drawableFrame instanceof BitmapDrawable)) {
                    if (!(drawableFrame instanceof BitmapDrawable)
                            && !(drawableFrame instanceof VectorDrawable)) {
                        throw new IllegalArgumentException("Frame of an animated pointer icon "
                                + "must refer to a bitmap drawable.");
                                + "must refer to a bitmap drawable or vector drawable.");
                    }
                    if (isVectorAnimation != (drawableFrame instanceof VectorDrawable)) {
                        throw new IllegalArgumentException("The drawable of the " + i + "-th frame "
                                + "is a different type from the others. All frames should be the "
                                + "same type.");
                    }
                    if (drawableFrame.getIntrinsicWidth() != width ||
                        drawableFrame.getIntrinsicHeight() != height) {
@@ -492,8 +500,11 @@ public final class PointerIcon implements Parcelable {
                                + "is different. All frames should have the exact same size and "
                                + "share the same hotspot.");
                    }
                    BitmapDrawable bitmapDrawableFrame = (BitmapDrawable) drawableFrame;
                    mBitmapFrames[i - 1] = getBitmapFromDrawable(bitmapDrawableFrame);
                    if (isVectorAnimation) {
                        drawableFrame = getBitmapDrawableFromVectorDrawable(resources,
                                (VectorDrawable) drawableFrame);
                    }
                    mBitmapFrames[i - 1] = getBitmapFromDrawable((BitmapDrawable) drawableFrame);
                }
            }
        }