Merge "Clean up RBO destroy code and fix regression" am: c42560cc9d

Original change: https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/2121913

Change-Id: I750d38259b0b1088bd0790085c21c87a08cdb1ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/shared/OpenglCodecCommon/GLClientState.cpp b/shared/OpenglCodecCommon/GLClientState.cpp
index e9ff9f0..77aab13 100644
--- a/shared/OpenglCodecCommon/GLClientState.cpp
+++ b/shared/OpenglCodecCommon/GLClientState.cpp
@@ -2115,7 +2115,6 @@
 }
 
 void GLClientState::removeRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
-    std::vector<std::shared_ptr<RboProps>> to_remove;
     bool unbindCurrent = false;
     {
         RenderbufferInfo::ScopedView view(mRboState.rboData);
@@ -2125,18 +2124,12 @@
                 if (!rboPtr) {
                     continue;
                 }
-                to_remove.push_back(rboPtr);
+                unbindCurrent |=
+                        (mRboState.boundRenderbuffer == rboPtr);
                 setFboCompletenessDirtyForRbo(rboPtr);
+                view.remove(renderbuffers[i]);
             }
         }
-
-        for (size_t i = 0; i < to_remove.size(); i++) {
-            if (mRboState.boundRenderbuffer == to_remove[i]) {
-                unbindCurrent = true;
-                break;
-            }
-            view.remove(to_remove[i]->id);
-        }
     }
 
     if (unbindCurrent) {