Skip to content

Commit

Permalink
Avoid using frame waiting on Q+
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 337935179
  • Loading branch information
sjudd authored and glide-copybara-robot committed Oct 19, 2020
1 parent b0a7efe commit 7d7042c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ public final class HardwareConfigState {
* allocating a hardware Bitmap in this specific circumstance. See b/126573603#comment12 for
* details.
*/
private static final boolean BLOCK_HARDWARE_BITMAPS_WHEN_GL_CONTEXT_MIGHT_NOT_BE_INITIALIZED =
public static final boolean BLOCK_HARDWARE_BITMAPS_WHEN_GL_CONTEXT_MIGHT_NOT_BE_INITIALIZED =
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q;

/** Support for the hardware bitmap config was added in Android O. */
public static final boolean HARDWARE_BITMAPS_SUPPORTED =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;

/**
* The minimum size in pixels a {@link Bitmap} must be in both dimensions to be created with the
* {@link Bitmap.Config#HARDWARE} configuration.
Expand Down Expand Up @@ -149,7 +153,7 @@ public boolean isHardwareConfigAllowed(
}
return false;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (!HARDWARE_BITMAPS_SUPPORTED) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Hardware config disallowed by sdk");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.bumptech.glide.GlideBuilder.WaitForFramesAfterTrimMemory;
import com.bumptech.glide.GlideExperiments;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.resource.bitmap.HardwareConfigState;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import java.util.Collection;
Expand Down Expand Up @@ -83,7 +84,8 @@ public RequestManagerRetriever(
}

private static FrameWaiter buildFrameWaiter(GlideExperiments experiments) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (!HardwareConfigState.HARDWARE_BITMAPS_SUPPORTED
|| !HardwareConfigState.BLOCK_HARDWARE_BITMAPS_WHEN_GL_CONTEXT_MIGHT_NOT_BE_INITIALIZED) {
return new DoNothingFirstFrameWaiter();
}
return experiments.isEnabled(WaitForFramesAfterTrimMemory.class)
Expand Down

0 comments on commit 7d7042c

Please sign in to comment.