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

Commit de0dfb7b authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #2125720 Weather Forecast Widget - graphics do not scale

I forgot to add the new density field to the Bitmaps' parcelable data.

Change-Id: I77cf3e93e356297e0caed6fc71b62b5cd8f79124
parent 5dd7c726
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
    const int               width = p->readInt32();
    const int               height = p->readInt32();
    const int               rowBytes = p->readInt32();
    const int               density = p->readInt32();

    if (SkBitmap::kARGB_8888_Config != config &&
            SkBitmap::kRGB_565_Config != config &&
@@ -369,12 +370,13 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
    memcpy(bitmap->getPixels(), p->readInplace(size), size);
    bitmap->unlockPixels();

    return GraphicsJNI::createBitmap(env, bitmap, isMutable, NULL);
    return GraphicsJNI::createBitmap(env, bitmap, isMutable, NULL, density);
}

static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
                                     const SkBitmap* bitmap,
                                     jboolean isMutable, jobject parcel) {
                                     jboolean isMutable, jint density,
                                     jobject parcel) {
    if (parcel == NULL) {
        SkDebugf("------- writeToParcel null parcel\n");
        return false;
@@ -387,6 +389,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
    p->writeInt32(bitmap->width());
    p->writeInt32(bitmap->height());
    p->writeInt32(bitmap->rowBytes());
    p->writeInt32(density);

    if (bitmap->getConfig() == SkBitmap::kIndex8_Config) {
        SkColorTable* ctable = bitmap->getColorTable();
@@ -546,7 +549,7 @@ static JNINativeMethod gBitmapMethods[] = {
    {   "nativeCreateFromParcel",
        "(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
        (void*)Bitmap_createFromParcel },
    {   "nativeWriteToParcel",      "(IZLandroid/os/Parcel;)Z",
    {   "nativeWriteToParcel",      "(IZILandroid/os/Parcel;)Z",
        (void*)Bitmap_writeToParcel },
    {   "nativeExtractAlpha",       "(II[I)Landroid/graphics/Bitmap;",
        (void*)Bitmap_extractAlpha },
+3 −3
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ SkRegion* GraphicsJNI::getNativeRegion(JNIEnv* env, jobject region)
///////////////////////////////////////////////////////////////////////////////////////////

jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
                                  jbyteArray ninepatch)
                                  jbyteArray ninepatch, int density)
{
    SkASSERT(bitmap != NULL);
    SkASSERT(NULL != bitmap->pixelRef());
@@ -359,7 +359,7 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
    jobject obj = env->AllocObject(gBitmap_class);
    if (obj) {
        env->CallVoidMethod(obj, gBitmap_constructorMethodID,
                            (jint)bitmap, isMutable, ninepatch);
                            (jint)bitmap, isMutable, ninepatch, density);
        if (hasException(env)) {
            obj = NULL;
        }
@@ -541,7 +541,7 @@ int register_android_graphics_Graphics(JNIEnv* env)
    gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
    gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I");    
    gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
                                            "(IZ[B)V");
                                            "(IZ[BI)V");

    gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config");
    gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public:
        then the bitmap must be an owner of its natively allocated pixels (via allocPixels).
        */
    static jobject createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
                                jbyteArray ninePatch);
                                jbyteArray ninePatch, int density = -1);
    
    static jobject createRegion(JNIEnv* env, SkRegion* region);

+2 −2
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
  jobject obj = env->AllocObject(gBitmap_class);
  if (obj) {
    env->CallVoidMethod(obj, gBitmap_constructorMethodID,
                        reinterpret_cast<jint>(bitmap), false, NULL);
                        reinterpret_cast<jint>(bitmap), false, NULL, -1);
    if (env->ExceptionCheck() != 0) {
      LOGE("*** Uncaught exception returned from Java call!\n");
      env->ExceptionDescribe();
@@ -297,7 +297,7 @@ static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
int register_android_emoji_EmojiFactory(JNIEnv* env) {
  gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
  gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
                                                 "(IZ[B)V");
                                                 "(IZ[BI)V");
  gEmojiFactory_class = make_globalref(env, "android/emoji/EmojiFactory");
  gEmojiFactory_constructorMethodID = env->GetMethodID(
      gEmojiFactory_class, "<init>", "(ILjava/lang/String;)V");
+7 −2
Original line number Diff line number Diff line
@@ -77,7 +77,8 @@ public final class Bitmap implements Parcelable {

        This can be called from JNI code.
    */
    private Bitmap(int nativeBitmap, boolean isMutable, byte[] ninePatchChunk) {
    private Bitmap(int nativeBitmap, boolean isMutable, byte[] ninePatchChunk,
            int density) {
        if (nativeBitmap == 0) {
            throw new RuntimeException("internal error: native bitmap is 0");
        }
@@ -86,6 +87,9 @@ public final class Bitmap implements Parcelable {
        mNativeBitmap = nativeBitmap;
        mIsMutable = isMutable;
        mNinePatchChunk = ninePatchChunk;
        if (density >= 0) {
            mDensity = density;
        }
    }

    /**
@@ -892,7 +896,7 @@ public final class Bitmap implements Parcelable {
     */
    public void writeToParcel(Parcel p, int flags) {
        checkRecycled("Can't parcel a recycled bitmap");
        if (!nativeWriteToParcel(mNativeBitmap, mIsMutable, p)) {
        if (!nativeWriteToParcel(mNativeBitmap, mIsMutable, mDensity, p)) {
            throw new RuntimeException("native writeToParcel failed");
        }
    }
@@ -1006,6 +1010,7 @@ public final class Bitmap implements Parcelable {
    // returns true on success
    private static native boolean nativeWriteToParcel(int nativeBitmap,
                                                      boolean isMutable,
                                                      int density,
                                                      Parcel p);
    // returns a new bitmap built from the native bitmap's alpha, and the paint
    private static native Bitmap nativeExtractAlpha(int nativeBitmap,
Loading