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

Commit 2de914dd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure that bitmaps are valid prior to attempting to upload them"

parents a6b1edc3 fa9b4e48
Loading
Loading
Loading
Loading
+28 −23
Original line number Diff line number Diff line
@@ -720,6 +720,7 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, jint target, jint level,
        jint internalformat, jobject bitmapObj, jint type, jint border)
{
    graphics::Bitmap bitmap(env, bitmapObj);
    if (bitmap.isValid() && bitmap.getPixels() != nullptr) {
        AndroidBitmapInfo bitmapInfo = bitmap.getInfo();

        if (internalformat < 0) {
@@ -731,9 +732,11 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, jint target, jint level,

        if (checkInternalFormat(bitmapInfo.format, internalformat, type)) {
            glTexImage2D(target, level, internalformat, bitmapInfo.width, bitmapInfo.height, border,
                     getPixelFormatFromInternalFormat(internalformat), type, bitmap.getPixels());
                         getPixelFormatFromInternalFormat(internalformat), type,
                         bitmap.getPixels());
            return 0;
        }
    }
    return -1;
}

@@ -741,6 +744,7 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz, jint target, jint leve
        jint xoffset, jint yoffset, jobject bitmapObj, jint format, jint type)
{
    graphics::Bitmap bitmap(env, bitmapObj);
    if (bitmap.isValid() && bitmap.getPixels() != nullptr) {
        AndroidBitmapInfo bitmapInfo = bitmap.getInfo();

        int internalFormat = getInternalFormat(bitmapInfo.format);
@@ -755,6 +759,7 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz, jint target, jint leve
                            format, type, bitmap.getPixels());
            return 0;
        }
    }
    return -1;
}