Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f775255 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Cleaned up CanvasCompare tests."

parents f2985ba3 db22de8c
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.test.hwuicompare;

import com.android.test.hwuicompare.R;
import com.android.test.hwuicompare.ScriptC_errorCalculator;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -52,7 +49,6 @@ public class ErrorCalculator {
        int height = resources.getDimensionPixelSize(R.dimen.layer_height);
        mOutputRowRegions = new int[height / REGION_SIZE];

/*
        mRS = RenderScript.create(c);
        int[] rowIndices = new int[height / REGION_SIZE];
        for (int i = 0; i < rowIndices.length; i++)
@@ -68,15 +64,12 @@ public class ErrorCalculator {
        mInputRowsAllocation.copyFrom(rowIndices);
        mOutputRegionsAllocation = Allocation.createSized(mRS, Element.I32(mRS),
                mOutputRowRegions.length, Allocation.USAGE_SCRIPT);
*/
    }


    private static long startMillis, middleMillis;

    public float calcErrorRS(Bitmap ideal, Bitmap given) {
        if (true)
            return calcError(ideal, given);
        if (LOG_TIMING) {
            startMillis = System.currentTimeMillis();
        }
@@ -86,8 +79,8 @@ public class ErrorCalculator {
        mGivenPixelsAllocation = Allocation.createFromBitmap(mRS, given,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);

        mScript.bind_ideal(mIdealPixelsAllocation);
        mScript.bind_given(mGivenPixelsAllocation);
        mScript.set_ideal(mIdealPixelsAllocation);
        mScript.set_given(mGivenPixelsAllocation);

        mScript.forEach_countInterestingRegions(mInputRowsAllocation, mOutputRegionsAllocation);
        mOutputRegionsAllocation.copyTo(mOutputRowRegions);
@@ -127,8 +120,8 @@ public class ErrorCalculator {
        mGivenPixelsAllocation = Allocation.createFromBitmap(mRS, given,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);

        mScript.bind_ideal(mIdealPixelsAllocation);
        mScript.bind_given(mGivenPixelsAllocation);
        mScript.set_ideal(mIdealPixelsAllocation);
        mScript.set_given(mGivenPixelsAllocation);

        mOutputPixelsAllocation = Allocation.createFromBitmap(mRS, output,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+9 −8
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@ int REGION_SIZE;
int WIDTH;
int HEIGHT;

const uchar4 *ideal;
const uchar4 *given;
rs_allocation ideal;
rs_allocation given;

void countInterestingRegions(const int32_t *v_in, int32_t *v_out) {
    int y = v_in[0];
@@ -14,10 +14,10 @@ void countInterestingRegions(const int32_t *v_in, int32_t *v_out) {

    for (int x = 0; x < HEIGHT; x += REGION_SIZE) {
        bool interestingRegion = false;
        int regionColor = (int)ideal[y * WIDTH + x];
        int regionColor = (int) rsGetElementAt_uchar4(ideal, x, y);
        for (int i = 0; i < REGION_SIZE && !interestingRegion; i++) {
            for (int j = 0; j < REGION_SIZE && !interestingRegion; j++) {
                interestingRegion |= (int)(ideal[(y + i) * WIDTH + (x + j)]) != regionColor;
                interestingRegion |= ((int) rsGetElementAt_uchar4(ideal, x + j, y + i)) != regionColor;
            }
        }
        if (interestingRegion) {
@@ -31,8 +31,9 @@ void accumulateError(const int32_t *v_in, int32_t *v_out) {
    int error = 0;
    for (int y = startY; y < startY + REGION_SIZE; y++) {
        for (int x = 0; x < HEIGHT; x++) {
            uchar4 idealPixel = ideal[y * WIDTH + x];
            uchar4 givenPixel = given[y * WIDTH + x];
            uchar4 idealPixel = rsGetElementAt_uchar4(ideal, x, y);
            uchar4 givenPixel = rsGetElementAt_uchar4(given, x, y);

            error += abs(idealPixel.x - givenPixel.x);
            error += abs(idealPixel.y - givenPixel.y);
            error += abs(idealPixel.z - givenPixel.z);
@@ -43,8 +44,8 @@ void accumulateError(const int32_t *v_in, int32_t *v_out) {
}

void displayDifference(const uchar4 *v_in, uchar4 *v_out, uint32_t x, uint32_t y) {
    float4 idealPixel = rsUnpackColor8888(ideal[y * WIDTH + x]);
    float4 givenPixel = rsUnpackColor8888(given[y * WIDTH + x]);
    float4 idealPixel = rsGetElementAt_float4(ideal, x, y);
    float4 givenPixel = rsGetElementAt_float4(given, x, y);

    float4 diff = idealPixel - givenPixel;
    float totalDiff = diff.x + diff.y + diff.z + diff.w;