Skip to content
Snippets Groups Projects
Commit c81808f8 authored by John Reck's avatar John Reck
Browse files

Add a benchmark for createScaled of P3 & sRGB

Bug: 316972621
Test: atest android.graphics.perftests.CanvasPerfTest
Change-Id: I73ccfab4e9f325b1f864eb1d8f41c71a7c6ed7a5
parent aa38e194
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment