Merge "Cleaned up CanvasCompare tests."
diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java
index c90b626..08d7667 100644
--- a/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java
+++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java
@@ -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 @@
         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 @@
         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 @@
         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 @@
         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);
diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs
index 3681784..caa947d 100644
--- a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs
+++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs
@@ -5,8 +5,8 @@
 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 @@
 
     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 @@
     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 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;