diff options
| -rw-r--r-- | apct-tests/perftests/core/src/android/graphics/perftests/CanvasPerfTest.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/apct-tests/perftests/core/src/android/graphics/perftests/CanvasPerfTest.java b/apct-tests/perftests/core/src/android/graphics/perftests/CanvasPerfTest.java index e5a06c9bd146..3c361d772d3d 100644 --- a/apct-tests/perftests/core/src/android/graphics/perftests/CanvasPerfTest.java +++ b/apct-tests/perftests/core/src/android/graphics/perftests/CanvasPerfTest.java @@ -16,12 +16,14 @@ package android.graphics.perftests; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Color; +import android.graphics.ColorSpace; import android.graphics.ImageDecoder; import android.graphics.Paint; import android.graphics.RecordingCanvas; @@ -104,15 +106,36 @@ public class CanvasPerfTest { } @Test - public void testCreateScaledBitmap() throws IOException { + public void testCreateScaledSrgbBitmap() throws IOException { BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final Context context = InstrumentationRegistry.getContext(); Bitmap source = ImageDecoder.decodeBitmap( ImageDecoder.createSource(context.getResources(), R.drawable.fountain_night), (decoder, info, source1) -> { decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE); + decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB)); }); source.setGainmap(null); + assertEquals(source.getColorSpace().getId(), ColorSpace.Named.SRGB.ordinal()); + + while (state.keepRunning()) { + Bitmap.createScaledBitmap(source, source.getWidth() / 2, source.getHeight() / 2, true) + .recycle(); + } + } + + @Test + public void testCreateScaledP3Bitmap() throws IOException { + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final Context context = InstrumentationRegistry.getContext(); + Bitmap source = ImageDecoder.decodeBitmap( + ImageDecoder.createSource(context.getResources(), R.drawable.fountain_night), + (decoder, info, source1) -> { + decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE); + decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.DISPLAY_P3)); + }); + source.setGainmap(null); + assertEquals(source.getColorSpace().getId(), ColorSpace.Named.DISPLAY_P3.ordinal()); while (state.keepRunning()) { Bitmap.createScaledBitmap(source, source.getWidth() / 2, source.getHeight() / 2, true) |