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

Commit bd28e2d9 authored by Deepanshu Gupta's avatar Deepanshu Gupta
Browse files

Manual merge of changes from klp-dev

Manually merged the following changes from klp-dev branch and fixed
merge conflicts:
78cfdf31
d0581d27
1f92d7fc
0baec410
24541255

Change-Id: I426729bb90a26746bfff3a0e4a03ea9f37972528
parent f3560a13
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ built_framework_classes := $(call java-lib-files,framework-base)
built_core_dep := $(call java-lib-deps,core)
built_core_classes := $(call java-lib-files,core)

built_ext_dep := $(call java-lib-deps,ext)
built_ext_classes := $(call java-lib-files,ext)

built_layoutlib_create_jar := $(call intermediates-dir-for, \
			JAVA_LIBRARIES,layoutlib_create,HOST)/javalib.jar

@@ -47,6 +50,7 @@ include $(BUILD_SYSTEM)/base_rules.mk

$(LOCAL_BUILT_MODULE): $(built_core_dep) \
                       $(built_framework_dep) \
                       $(built_ext_dep) \
                       $(built_layoutlib_create_jar)
	$(hide) echo "host layoutlib_create: $@"
	$(hide) mkdir -p $(dir $@)
@@ -55,7 +59,8 @@ $(LOCAL_BUILT_MODULE): $(built_core_dep) \
	$(hide) java -jar $(built_layoutlib_create_jar) \
	             $@ \
	             $(built_core_classes) \
	             $(built_framework_classes)
	             $(built_framework_classes) \
	             $(built_ext_classes)
	$(hide) ls -l $(built_framework_classes)


+0 −63
Original line number Diff line number Diff line
@@ -44,62 +44,13 @@ import java.util.Set;
 */
/*package*/ class BitmapFactory_Delegate {

    // ------ Java delegates ------

    @LayoutlibDelegate
    /*package*/ static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) {
        if (bm == null || opts == null) {
            return bm;
        }

        final int density = opts.inDensity;
        if (density == 0) {
            return bm;
        }

        bm.setDensity(density);
        final int targetDensity = opts.inTargetDensity;
        if (targetDensity == 0 || density == targetDensity || density == opts.inScreenDensity) {
            return bm;
        }

        byte[] np = bm.getNinePatchChunk();
        final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
        // DELEGATE CHANGE: never scale 9-patch
        if (opts.inScaled && isNinePatch == false) {
            float scale = targetDensity / (float)density;
            // TODO: This is very inefficient and should be done in native by Skia
            final Bitmap oldBitmap = bm;
            bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
                    (int) (bm.getHeight() * scale + 0.5f), true);
            oldBitmap.recycle();

            if (isNinePatch) {
                np = nativeScaleNinePatch(np, scale, outPadding);
                bm.setNinePatchChunk(np);
            }
            bm.setDensity(targetDensity);
        }

        return bm;
    }


    // ------ Native Delegates ------

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
            Rect padding, Options opts) {
        return nativeDecodeStream(is, storage, padding, opts, false, 1.f);
    }

    @LayoutlibDelegate
    /*package*/ static  Bitmap nativeDecodeStream(InputStream is, byte[] storage,
            Rect padding, Options opts, boolean applyScale, float scale) {
        Bitmap bm = null;

        //TODO support rescaling

        Density density = Density.MEDIUM;
        Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
        if (opts != null) {
@@ -156,13 +107,6 @@ import java.util.Set;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts,
            boolean applyScale, float scale) {
        opts.inBitmap = null;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset,
            int length, Options opts) {
@@ -170,13 +114,6 @@ import java.util.Set;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad) {
        // don't scale for now. This should not be called anyway since we re-implement
        // BitmapFactory.finishDecode();
        return chunk;
    }

    @LayoutlibDelegate
    /*package*/ static boolean nativeIsSeekable(FileDescriptor fd) {
        return true;
+24 −32
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public final class Bitmap_Delegate {
            throws IOException {
        return createBitmap(input, getPremultipliedBitmapCreateFlags(isMutable), density);
    }

    /**
     * Creates and returns a {@link Bitmap} initialized with the given file content.
     *
@@ -175,6 +176,7 @@ public final class Bitmap_Delegate {
     * @param createFlags
     * @param density the density associated with the bitmap
     *
     * @see Bitmap#isPremultiplied()
     * @see Bitmap#isMutable()
     * @see Bitmap#getDensity()
     */
@@ -306,8 +308,16 @@ public final class Bitmap_Delegate {
    }

    @LayoutlibDelegate
    /*package*/ static void nativeRecycle(long nativeBitmap) {
    /*package*/ static boolean nativeRecycle(long nativeBitmap) {
        sManager.removeJavaReferenceFor(nativeBitmap);
        return true;
    }

    @LayoutlibDelegate
    /*package*/ static void nativeReconfigure(long nativeBitmap, int width, int height,
            int config, int allocSize) {
        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
                "Bitmap.reconfigure() is not supported", null /*data*/);
    }

    @LayoutlibDelegate
@@ -338,28 +348,6 @@ public final class Bitmap_Delegate {
        }
    }

    @LayoutlibDelegate
    /*package*/ static int nativeWidth(long nativeBitmap) {
        // get the delegate from the native int.
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return 0;
        }

        return delegate.mImage.getWidth();
    }

    @LayoutlibDelegate
    /*package*/ static int nativeHeight(long nativeBitmap) {
        // get the delegate from the native int.
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return 0;
        }

        return delegate.mImage.getHeight();
    }

    @LayoutlibDelegate
    /*package*/ static int nativeRowBytes(long nativeBitmap) {
        // get the delegate from the native int.
@@ -405,19 +393,21 @@ public final class Bitmap_Delegate {
    }

    @LayoutlibDelegate
    /*package*/ static int nativeGetPixel(long nativeBitmap, int x, int y) {
    /*package*/ static int nativeGetPixel(long nativeBitmap, int x, int y,
            boolean isPremultiplied) {
        // get the delegate from the native int.
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return 0;
        }

        // TODO: Support isPremultiplied.
        return delegate.mImage.getRGB(x, y);
    }

    @LayoutlibDelegate
    /*package*/ static void nativeGetPixels(long nativeBitmap, int[] pixels, int offset,
            int stride, int x, int y, int width, int height) {
            int stride, int x, int y, int width, int height, boolean isPremultiplied) {
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return;
@@ -428,7 +418,8 @@ public final class Bitmap_Delegate {


    @LayoutlibDelegate
    /*package*/ static void nativeSetPixel(long nativeBitmap, int x, int y, int color) {
    /*package*/ static void nativeSetPixel(long nativeBitmap, int x, int y, int color,
            boolean isPremultiplied) {
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return;
@@ -439,7 +430,7 @@ public final class Bitmap_Delegate {

    @LayoutlibDelegate
    /*package*/ static void nativeSetPixels(long nativeBitmap, int[] colors, int offset,
            int stride, int x, int y, int width, int height) {
            int stride, int x, int y, int width, int height, boolean isPremultiplied) {
        Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
        if (delegate == null) {
            return;
@@ -621,6 +612,7 @@ public final class Bitmap_Delegate {
        }
        return createFlags;
    }

    /**
     * Creates and returns a copy of a given BufferedImage.
     * <p/>
+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ public final class NinePatch_Delegate {
        return sManager.addNewDelegate(newDelegate);
    }

    @LayoutlibDelegate
    /*package*/ static void nativeFinalize(long chunk) {
        sManager.removeJavaReferenceFor(chunk);
    }
+6 −0
Original line number Diff line number Diff line
@@ -473,6 +473,12 @@ public final class Path_Delegate {
        native_transform(nPath, matrix, 0);
    }

    @LayoutlibDelegate
    /*package*/ static boolean native_op(long nPath1, long nPath2, int op, int result) {
        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Path.op() not supported", null);
        return false;
    }

    @LayoutlibDelegate
    /*package*/ static void finalizer(long nPath) {
        sManager.removeJavaReferenceFor(nPath);
Loading