Commit 772c7a30 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Short circuit RenderTestRule comparison

Short circuits RenderTestRule's Bitmap comparison if Bitmap.sameAs
returns true. This comparison is signiciantly faster than the fallback
pixel-by-pixel comparison, particularly when comparing large images like
those produced by VR.

Bug: 904012
Change-Id: Ia9cdd91c91f94079d853ec28fd49fee3c3dd0905
Reviewed-on: https://chromium-review.googlesource.com/c/1334945Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608030}
parent 9db1b4f7
...@@ -340,6 +340,9 @@ public class RenderTestRule extends TestWatcher { ...@@ -340,6 +340,9 @@ public class RenderTestRule extends TestWatcher {
private static Pair<ComparisonResult, Bitmap> compareBitmapToGolden( private static Pair<ComparisonResult, Bitmap> compareBitmapToGolden(
Bitmap render, Bitmap golden) { Bitmap render, Bitmap golden) {
if (golden == null) return Pair.create(ComparisonResult.GOLDEN_NOT_FOUND, null); if (golden == null) return Pair.create(ComparisonResult.GOLDEN_NOT_FOUND, null);
// This comparison is much, much faster than doing a pixel-by-pixel comparison, so try this
// first and only fall back to the pixel comparison if it fails.
if (render.sameAs(golden)) return Pair.create(ComparisonResult.MATCH, null);
Bitmap diff = Bitmap.createBitmap(Math.max(render.getWidth(), golden.getWidth()), Bitmap diff = Bitmap.createBitmap(Math.max(render.getWidth(), golden.getWidth()),
Math.max(render.getHeight(), golden.getHeight()), render.getConfig()); Math.max(render.getHeight(), golden.getHeight()), render.getConfig());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment