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

Commit e9cf71df authored by Elliott Hughes's avatar Elliott Hughes Committed by Android (Google) Code Review
Browse files

Merge "Don't allocate a raw object then call its constructor manually..."

parents fda06c0c cf6f7a0f
Loading
Loading
Loading
Loading
+11 −26
Original line number Diff line number Diff line
@@ -350,14 +350,10 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, jbyteArray buff
    SkASSERT(bitmap);
    SkASSERT(bitmap->pixelRef());

    jobject obj = env->AllocObject(gBitmap_class);
    if (obj) {
        env->CallVoidMethod(obj, gBitmap_constructorMethodID,
                            (jint)bitmap, buffer, isMutable, ninepatch, density);
        if (hasException(env)) {
            obj = NULL;
        }
    }
    jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID,
            static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)),
            buffer, isMutable, ninepatch, density);
    hasException(env); // For the side effect of logging.
    return obj;
}

@@ -372,30 +368,19 @@ jobject GraphicsJNI::createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecode
{
    SkASSERT(bitmap != NULL);

    jobject obj = env->AllocObject(gBitmapRegionDecoder_class);
    if (hasException(env)) {
        obj = NULL;
        return obj;
    }
    if (obj) {
        env->CallVoidMethod(obj, gBitmapRegionDecoder_constructorMethodID, (jint)bitmap);
        if (hasException(env)) {
            obj = NULL;
        }
    }
    jobject obj = env->NewObject(gBitmapRegionDecoder_class,
            gBitmapRegionDecoder_constructorMethodID,
            static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)));
    hasException(env); // For the side effect of logging.
    return obj;
}

jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region)
{
    SkASSERT(region != NULL);
    jobject obj = env->AllocObject(gRegion_class);
    if (obj) {
        env->CallVoidMethod(obj, gRegion_constructorMethodID, (jint)region, 0);
        if (hasException(env)) {
            obj = NULL;
        }
    }
    jobject obj = env->NewObject(gRegion_class, gRegion_constructorMethodID,
            static_cast<jint>(reinterpret_cast<uintptr_t>(region)), 0);
    hasException(env); // For the side effect of logging.
    return obj;
}

+2 −5
Original line number Diff line number Diff line
@@ -23,11 +23,8 @@ jobject create_jmovie(JNIEnv* env, SkMovie* moov) {
    if (NULL == moov) {
        return NULL;
    }
    jobject obj = env->AllocObject(gMovie_class);
    if (obj) {
        env->CallVoidMethod(obj, gMovie_constructorMethodID, (jint)moov);
    }
    return obj;
    return env->NewObject(gMovie_class, gMovie_constructorMethodID,
            static_cast<jint>(reinterpret_cast<uintptr_t>(moov)));
}

static SkMovie* J2Movie(JNIEnv* env, jobject movie) {
+10 −19
Original line number Diff line number Diff line
@@ -106,15 +106,11 @@ static void InitializeCaller() {

static jobject create_java_EmojiFactory(
    JNIEnv* env, EmojiFactory* factory, jstring name) {
  jobject obj = env->AllocObject(gEmojiFactory_class);
  if (obj) {
    env->CallVoidMethod(obj, gEmojiFactory_constructorMethodID,
                        (jint)factory, name);
  jobject obj = env->NewObject(gEmojiFactory_class, gEmojiFactory_constructorMethodID,
      static_cast<jint>(reinterpret_cast<uintptr_t>(factory)), name);
  if (env->ExceptionCheck() != 0) {
    LOGE("*** Uncaught exception returned from Java call!\n");
    env->ExceptionDescribe();
      obj = NULL;
    }
  }
  return obj;
}
@@ -180,17 +176,12 @@ static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
    return NULL;
  }

  jobject obj = env->AllocObject(gBitmap_class);
  if (obj) {
    env->CallVoidMethod(obj, gBitmap_constructorMethodID,
                        reinterpret_cast<jint>(bitmap), NULL, false, NULL, -1);
  jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID,
      static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)), NULL, false, NULL, -1);
  if (env->ExceptionCheck() != 0) {
    LOGE("*** Uncaught exception returned from Java call!\n");
    env->ExceptionDescribe();
      return NULL;
  }
  }

  return obj;
}