aw: Frame rate high for large webview
Adopt heuristic that large webview will remain high frame rate. Note only-video case in a large webview will still request the frame rate of video. But it does effectively break result of setFrameContentVelocity for large webviews. Bug: 346732738 Bug: b/376396847 Change-Id: I8b5a3507cc1d7472b1ff4a2ca70934bef98256a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6305945 Commit-Queue: Bo Liu <boliu@chromium.org> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425746}
This commit is contained in:
@ -28,6 +28,7 @@ import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.DragAndDropPermissions;
|
||||
@ -4333,6 +4334,8 @@ public class AwContents implements SmartClipProvider {
|
||||
private boolean mPreviouslyVisible;
|
||||
private String mPreviousScheme = "";
|
||||
|
||||
private boolean mSizeIsSmallForFrameRateHints;
|
||||
|
||||
@SuppressLint("DrawAllocation") // For new AwFunctor.
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
@ -4363,7 +4366,10 @@ public class AwContents implements SmartClipProvider {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
|
||||
&& AwFeatureMap.isEnabled(VizFeatures.WEBVIEW_FRAME_RATE_HINTS)) {
|
||||
float frame_rate = View.REQUESTED_FRAME_RATE_CATEGORY_DEFAULT;
|
||||
float frame_rate =
|
||||
mSizeIsSmallForFrameRateHints
|
||||
? View.REQUESTED_FRAME_RATE_CATEGORY_DEFAULT
|
||||
: View.REQUESTED_FRAME_RATE_CATEGORY_HIGH;
|
||||
if (mPreferredFrameIntervalNanos > 0) {
|
||||
frame_rate = (float) 1e9 / mPreferredFrameIntervalNanos;
|
||||
}
|
||||
@ -4657,6 +4663,14 @@ public class AwContents implements SmartClipProvider {
|
||||
@Override
|
||||
public void onSizeChanged(int w, int h, int ow, int oh) {
|
||||
if (isDestroyed(NO_WARN)) return;
|
||||
|
||||
DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
|
||||
float pixelCount = (float) displayMetrics.widthPixels * displayMetrics.heightPixels;
|
||||
float displayPixelCount = pixelCount == 0f ? Float.POSITIVE_INFINITY : pixelCount;
|
||||
int viewPixelCount = w * h;
|
||||
float ratio = viewPixelCount / displayPixelCount;
|
||||
mSizeIsSmallForFrameRateHints = ratio < 0.5f;
|
||||
|
||||
mScrollOffsetManager.setContainerViewSize(w, h);
|
||||
// The AwLayoutSizer needs to go first so that if we're in
|
||||
// fixedLayoutSize mode the update to enter fixedLayoutSize mode is sent before the
|
||||
|
Reference in New Issue
Block a user