Merge "Fixes YUV Hardwarebuffer tests to not use renderbuffers." am: 64ef0867df

Bug: 155338195

Change-Id: I0cb3cacfa2760776d9f44b46130864a6f7f88875
(cherry picked from commit 1c29ccc2e2906de84cab2fedc48a7a113dab87d8)
diff --git a/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp b/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
index afaea87..c6f7184 100644
--- a/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
+++ b/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
@@ -1627,6 +1627,7 @@
                 if (isGlFormat) {
                     glRenderbufferStorage(GL_RENDERBUFFER, GetParam().format, width, height);
                 } else {
+                    ASSERT_FALSE(FormatIsYuv(GetParam().format)) << "YUV renderbuffers unsupported";
                     glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
                                                            static_cast<GLeglImageOES>(mEGLImage));
                 }
@@ -1869,8 +1870,17 @@
 
     for (int i = 0; i < mContextCount; ++i) {
         MakeCurrent(i);
-        ASSERT_NO_FATAL_FAILURE(
-            SetUpFramebuffer(desc.width, desc.height, 0, kBufferAsRenderbuffer));
+
+        // YUV renderbuffers are unsupported, so we attach as a texture in this case.
+        AttachmentType attachmentType;
+        if (FormatIsYuv(desc.format)) {
+            ASSERT_NO_FATAL_FAILURE(SetUpTexture(desc, 1));
+            attachmentType = kBufferAsTexture;
+        } else {
+            attachmentType = kBufferAsRenderbuffer;
+        }
+
+        ASSERT_NO_FATAL_FAILURE(SetUpFramebuffer(desc.width, desc.height, 0, attachmentType));
     }
 
     // Draw a simple checkerboard pattern in the second context, which will
@@ -1903,8 +1913,18 @@
     if (!SetUpBuffer(desc)) return;
 
     MakeCurrent(1);
-    ASSERT_NO_FATAL_FAILURE(
-        SetUpFramebuffer(desc.width, desc.height, 0, kBufferAsRenderbuffer));
+
+    // YUV renderbuffers are unsupported, so we attach as a texture in this case.
+    AttachmentType attachmentType;
+    if (FormatIsYuv(desc.format)) {
+        ASSERT_NO_FATAL_FAILURE(SetUpTexture(desc, 1));
+        attachmentType = kBufferAsTexture;
+    } else {
+        attachmentType = kBufferAsRenderbuffer;
+    }
+
+    ASSERT_NO_FATAL_FAILURE(SetUpFramebuffer(desc.width, desc.height, 0, attachmentType));
+
     // Draw a simple checkerboard pattern in the second context, which will
     // be current after the loop above, then read it in the first.
     DrawCheckerboard(desc.width, desc.height, desc.format);
@@ -2614,4 +2634,4 @@
         AHardwareBuffer_Desc{17, 23, 7, AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT, 0, 0, 0, 0}),
     &GetTestName);
 
-}  // namespace android
+}  // namespace android
\ No newline at end of file