summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/CanvasContext.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2020-05-08 18:44:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-08 18:44:55 +0000
commitacf8443e9a7e335e47b2ecdb2b41c19c85c1c718 (patch)
tree4f0e9c77447af293f2ff7b73fe5ab915b8392d5c /libs/hwui/renderthread/CanvasContext.cpp
parent6727245a59d634cfa5c127199d580e18b42d7646 (diff)
parent8ddbc59d55881b1595f48facd6f91a4bd2d2453a (diff)
Merge "Avoid excessive KGSL maps" into rvc-dev
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.cpp')
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 335bcdcfc1fb..a362bd220936 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -139,9 +139,30 @@ void CanvasContext::destroy() {
mAnimationContext->destroy();
}
+static void setBufferCount(ANativeWindow* window, uint32_t extraBuffers) {
+ int query_value;
+ int err = window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &query_value);
+ if (err != 0 || query_value < 0) {
+ ALOGE("window->query failed: %s (%d) value=%d", strerror(-err), err, query_value);
+ return;
+ }
+ auto min_undequeued_buffers = static_cast<uint32_t>(query_value);
+
+ int bufferCount = min_undequeued_buffers + 2 + extraBuffers;
+ native_window_set_buffer_count(window, bufferCount);
+}
+
void CanvasContext::setSurface(ANativeWindow* window, bool enableTimeout) {
ATRACE_CALL();
+ if (mRenderAheadDepth == 0 && DeviceInfo::get()->getMaxRefreshRate() > 66.6f) {
+ mFixedRenderAhead = false;
+ mRenderAheadCapacity = 1;
+ } else {
+ mFixedRenderAhead = true;
+ mRenderAheadCapacity = mRenderAheadDepth;
+ }
+
if (window) {
mNativeSurface = std::make_unique<ReliableSurface>(window);
mNativeSurface->init();
@@ -149,21 +170,17 @@ void CanvasContext::setSurface(ANativeWindow* window, bool enableTimeout) {
// TODO: Fix error handling & re-shorten timeout
ANativeWindow_setDequeueTimeout(window, 4000_ms);
}
+ mNativeSurface->setExtraBufferCount(mRenderAheadCapacity);
} else {
mNativeSurface = nullptr;
}
- if (mRenderAheadDepth == 0 && DeviceInfo::get()->getMaxRefreshRate() > 66.6f) {
- mFixedRenderAhead = false;
- mRenderAheadCapacity = 1;
- } else {
- mFixedRenderAhead = true;
- mRenderAheadCapacity = mRenderAheadDepth;
- }
-
bool hasSurface = mRenderPipeline->setSurface(
- mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior,
- mRenderAheadCapacity);
+ mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior);
+
+ if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) {
+ setBufferCount(mNativeSurface->getNativeWindow(), mRenderAheadCapacity);
+ }
mFrameNumber = -1;