summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jian-Syuan (Shane) Wong <shanewong@google.com> 2023-11-17 16:06:22 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-11-17 16:06:22 +0000
commit173f2b4d70b802e2fb11ced71c0cbbfc7d7b372d (patch)
tree5ac55b988194032956d20f3146506da9603ba8eb
parent3df2d13102a920aafc9bd83f3ad26ff9db7861cb (diff)
parentf64a89759fcec07a0815a340368003ca8e6cca27 (diff)
Merge "Use applyAsyncUnsafe() instead of apply() to apply a transaction" into main
-rw-r--r--core/java/android/view/ViewRootImpl.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index d5b4e4187fe4..7b456007e4ae 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3991,9 +3991,7 @@ public final class ViewRootImpl implements ViewParent,
// when the values are applicable.
setPreferredFrameRate(mPreferredFrameRate);
setPreferredFrameRateCategory(mPreferredFrameRateCategory);
- mLastPreferredFrameRateCategory = mPreferredFrameRateCategory;
mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE;
- mLastPreferredFrameRate = mPreferredFrameRate;
mPreferredFrameRate = 0;
}
@@ -11982,8 +11980,11 @@ public final class ViewRootImpl implements ViewParent,
? FRAME_RATE_CATEGORY_HIGH : preferredFrameRateCategory;
try {
- mFrameRateTransaction.setFrameRateCategory(mSurfaceControl,
- frameRateCategory, false).apply();
+ if (mLastPreferredFrameRateCategory != frameRateCategory) {
+ mFrameRateTransaction.setFrameRateCategory(mSurfaceControl,
+ frameRateCategory, false).applyAsyncUnsafe();
+ mLastPreferredFrameRateCategory = frameRateCategory;
+ }
} catch (Exception e) {
Log.e(mTag, "Unable to set frame rate category", e);
}
@@ -12003,8 +12004,11 @@ public final class ViewRootImpl implements ViewParent,
}
try {
- mFrameRateTransaction.setFrameRate(mSurfaceControl,
- preferredFrameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT).apply();
+ if (mLastPreferredFrameRate != preferredFrameRate) {
+ mFrameRateTransaction.setFrameRate(mSurfaceControl, preferredFrameRate,
+ Surface.FRAME_RATE_COMPATIBILITY_DEFAULT).applyAsyncUnsafe();
+ mLastPreferredFrameRate = preferredFrameRate;
+ }
} catch (Exception e) {
Log.e(mTag, "Unable to set frame rate", e);
}