Merge "Fix override setBufferCount" am: 378fa1b4c2 am: 736519b8c4 am: a097f75405

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1441702

Change-Id: Id72bda47c23650d9eb9edc305181455e03f5bb09
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index a362bd2..667a751 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -139,7 +139,7 @@
     mAnimationContext->destroy();
 }
 
-static void setBufferCount(ANativeWindow* window, uint32_t extraBuffers) {
+static void setBufferCount(ANativeWindow* window) {
     int query_value;
     int err = window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &query_value);
     if (err != 0 || query_value < 0) {
@@ -148,7 +148,9 @@
     }
     auto min_undequeued_buffers = static_cast<uint32_t>(query_value);
 
-    int bufferCount = min_undequeued_buffers + 2 + extraBuffers;
+    // We only need to set min_undequeued + 2 because the renderahead amount was already factored into the
+    // query for min_undequeued
+    int bufferCount = min_undequeued_buffers + 2;
     native_window_set_buffer_count(window, bufferCount);
 }
 
@@ -179,7 +181,8 @@
             mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior);
 
     if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) {
-        setBufferCount(mNativeSurface->getNativeWindow(), mRenderAheadCapacity);
+        setBufferCount(mNativeSurface->getNativeWindow());
+
     }
 
     mFrameNumber = -1;