Skip to content

Commit

Permalink
Preload url bar resource
Browse files Browse the repository at this point in the history
We know we're going to need this so we might as well preload it to avoid
the hit from doing so during a scroll.

(cherry picked from commit aaa8ddd)

Bug: 1063346
Change-Id: I8c3145c3720b279e5bdedf9533dd16d411b585c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189503
Reviewed-by: David Trainor <dtrainor@chromium.org>
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Reviewed-by: Sky Malice <skym@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1096297}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4220531
Owners-Override: Krishna Govind <govind@chromium.org>
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: Krishna Govind <govind@chromium.org>
Auto-Submit: Sky Malice <skym@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5481@{#911}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Patrick Noland authored and Chromium LUCI CQ committed Feb 3, 2023
1 parent 19681dd commit 9fae5b8
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
import android.content.Context;

import org.chromium.chrome.R;
import org.chromium.chrome.browser.toolbar.ToolbarFeatures;
import org.chromium.ui.base.DeviceFormFactor;

import java.util.Arrays;

/**
* Tracks all high priority resources that should be loaded at startup to be used by CC layers.
* TODO(dtrainor): Add the high priority and low priority resources here as they get ported over.
*/
public class StaticResourcePreloads {
/** A list of resources to load synchronously once the compositor is initialized. */
private static int[] sSynchronousResources = new int[] {
private static final int[] sSynchronousResources = new int[] {
R.drawable.bg_tabstrip_tab,
R.drawable.bg_tabstrip_tab_detached,
R.drawable.bg_tabstrip_tab_folio,
Expand All @@ -26,18 +29,27 @@ public class StaticResourcePreloads {
};

/** A list of resources to load asynchronously once the compositor is initialized. */
private static int[] sAsynchronousResources = new int[] {
private static final int[] sAsynchronousResources = new int[] {
R.drawable.btn_tabstrip_switch_normal, R.drawable.location_bar_incognito_badge};

private static int[] sEmptyList = new int[] {};
private static final int[] sEmptyList = new int[] {};

private static final int sUrlBarResourceId = R.drawable.modern_location_bar;

public static int[] getSynchronousResources(Context context) {
return DeviceFormFactor.isNonMultiDisplayContextOnTablet(context) ? sSynchronousResources
: sEmptyList;
}

public static int[] getAsynchronousResources(Context context) {
return DeviceFormFactor.isNonMultiDisplayContextOnTablet(context) ? sAsynchronousResources
: sEmptyList;
int[] resources = DeviceFormFactor.isNonMultiDisplayContextOnTablet(context)
? sAsynchronousResources
: sEmptyList;
if (ToolbarFeatures.shouldSuppressCaptures()) {
resources = Arrays.copyOf(resources, resources.length + 1);
resources[resources.length - 1] = sUrlBarResourceId;
}

return resources;
}
}

0 comments on commit 9fae5b8

Please sign in to comment.