Skip to content

Commit

Permalink
Add an in config set for RGBA_F16 in SizeConfigStrategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Jan 17, 2018
1 parent 73277df commit 2cd953c
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
@RequiresApi(Build.VERSION_CODES.KITKAT)
public class SizeConfigStrategy implements LruPoolStrategy {
private static final int MAX_SIZE_MULTIPLE = 8;

// TODO: This can probably be combined with ARGB_8888, it's separate only because we haven't
// yet tested ARGB_8888/RGBA_F16 re-use thoroughly yet.
private static final Bitmap.Config[] RGBA_F16_IN_CONFIGS;
static {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
RGBA_F16_IN_CONFIGS = new Bitmap.Config[] { Bitmap.Config.RGBA_F16 };
} else {
// THis will never be used pre O.
RGBA_F16_IN_CONFIGS = new Bitmap.Config[0];
}
}

private static final Bitmap.Config[] ARGB_8888_IN_CONFIGS =
new Bitmap.Config[] {
Bitmap.Config.ARGB_8888,
Expand Down Expand Up @@ -232,6 +245,12 @@ static String getBitmapString(int size, Bitmap.Config config) {
}

private static Bitmap.Config[] getInConfigs(Bitmap.Config requested) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Bitmap.Config.RGBA_F16.equals(requested)) { // NOPMD - Avoid short circuiting sdk checks.
return RGBA_F16_IN_CONFIGS;
}
}

switch (requested) {
case ARGB_8888:
return ARGB_8888_IN_CONFIGS;
Expand Down

0 comments on commit 2cd953c

Please sign in to comment.