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

Commit fa9b4e48 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Ensure that bitmaps are valid prior to attempting to upload them

Test: atest CtsGraphicsTestCases
Bug: 189259476
Change-Id: I80957f6e4f6c05640968e99129f968638d892ac8
parent 996f8af3
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;
}