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

Commit 9758e22d authored by Jerome Gaillard's avatar Jerome Gaillard
Browse files

Implement delegate for new native method from Bitmap

The method Bitmap.nativeCopyPreserveInternalConfig was introduced by
Change Ic128dfed.

Test: Run layoutlib tests
Change-Id: I13da7deece9eb1d0d3e6a42203522fcf0b332ba9
parent 82e955fc
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public final class Bitmap_Delegate {


    public enum BitmapCreateFlags {
        PREMULTIPLIED, MUTABLE
        NONE, PREMULTIPLIED, MUTABLE
    }

    // ---- delegate manager ----
@@ -616,6 +616,26 @@ public final class Bitmap_Delegate {
        // do nothing as Bitmap_Delegate does not have caches
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeCopyPreserveInternalConfig(long nativeBitmap) {
        Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(nativeBitmap);
        if (srcBmpDelegate == null) {
            return null;
        }

        BufferedImage srcImage = srcBmpDelegate.getImage();

        // create the image
        BufferedImage image = new BufferedImage(srcImage.getColorModel(), srcImage.copyData(null),
                srcImage.isAlphaPremultiplied(), null);

        // create a delegate with the content of the stream.
        Bitmap_Delegate delegate = new Bitmap_Delegate(image, srcBmpDelegate.getConfig());

        return createBitmap(delegate, EnumSet.of(BitmapCreateFlags.NONE),
                Bitmap.getDefaultDensity());
    }

    // ---- Private delegate/helper methods ----

    private Bitmap_Delegate(BufferedImage image, Config config) {