From b4990fa6fa4156e2731c7228f673545ed7b47c5e Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Fri, 12 Jul 2019 10:28:50 -0700 Subject: Renderscript: rename .rs extension to .rscript Reserve .rs extension for Rust. Bug: 137365032 Test: make checkbuild Test: cd frameworks/compile/slang/tests ./slang_tests.py Test: atest CtsRenderscriptTestCases Test: CtsRsCppTestCases Exempt-From-Owner-Approval: Clean CP Change-Id: Ic49fc7f5265d49cd4f8efd6a2b6a60b77bbd40dc Merged-In: Ic49fc7f5265d49cd4f8efd6a2b6a60b77bbd40dc (cherry picked from commit e98dce083cc891a29f8aab489a80606f215c9f1c) (cherry picked from commit bbb75b1263887dfebd9372b60ec7095a7dc6aa1d) --- .../android/test/hwuicompare/errorCalculator.rs | 61 ---------------------- .../test/hwuicompare/errorCalculator.rscript | 61 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs create mode 100644 tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rscript diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs deleted file mode 100644 index 0a1742ef3867..000000000000 --- a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs +++ /dev/null @@ -1,61 +0,0 @@ -#pragma version(1) -#pragma rs java_package_name(com.android.test.hwuicompare) - -int REGION_SIZE; -int WIDTH; -int HEIGHT; - -rs_allocation ideal; -rs_allocation given; - -void countInterestingRegions(const int32_t *v_in, int32_t *v_out) { - int y = v_in[0]; - v_out[0] = 0; - - for (int x = 0; x < HEIGHT; x += REGION_SIZE) { - bool interestingRegion = false; - uchar4 regionColor = rsGetElementAt_uchar4(ideal, x, y); - for (int i = 0; i < REGION_SIZE && !interestingRegion; i++) { - for (int j = 0; j < REGION_SIZE && !interestingRegion; j++) { - uchar4 testVal = rsGetElementAt_uchar4(ideal, x + j, y + i); - interestingRegion |= (testVal.r != regionColor.r); - interestingRegion |= (testVal.g != regionColor.g); - interestingRegion |= (testVal.b != regionColor.b); - interestingRegion |= (testVal.a != regionColor.a); - } - } - if (interestingRegion) { - v_out[0]++; - } - } -} - -void accumulateError(const int32_t *v_in, int32_t *v_out) { - int startY = v_in[0]; - int error = 0; - for (int y = startY; y < startY + REGION_SIZE; y++) { - for (int x = 0; x < HEIGHT; 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); - error += abs(idealPixel.w - givenPixel.w); - } - } - v_out[0] = error; -} - -void displayDifference(const uchar4 *v_in, uchar4 *v_out, uint32_t x, uint32_t y) { - 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; - if (totalDiff < 0) { - v_out[0] = rsPackColorTo8888(0, 0, clamp(-totalDiff/2.f, 0.f, 1.f)); - } else { - v_out[0] = rsPackColorTo8888(clamp(totalDiff/2.f, 0.f, 1.f), 0, 0); - } -} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rscript b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rscript new file mode 100644 index 000000000000..0a1742ef3867 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rscript @@ -0,0 +1,61 @@ +#pragma version(1) +#pragma rs java_package_name(com.android.test.hwuicompare) + +int REGION_SIZE; +int WIDTH; +int HEIGHT; + +rs_allocation ideal; +rs_allocation given; + +void countInterestingRegions(const int32_t *v_in, int32_t *v_out) { + int y = v_in[0]; + v_out[0] = 0; + + for (int x = 0; x < HEIGHT; x += REGION_SIZE) { + bool interestingRegion = false; + uchar4 regionColor = rsGetElementAt_uchar4(ideal, x, y); + for (int i = 0; i < REGION_SIZE && !interestingRegion; i++) { + for (int j = 0; j < REGION_SIZE && !interestingRegion; j++) { + uchar4 testVal = rsGetElementAt_uchar4(ideal, x + j, y + i); + interestingRegion |= (testVal.r != regionColor.r); + interestingRegion |= (testVal.g != regionColor.g); + interestingRegion |= (testVal.b != regionColor.b); + interestingRegion |= (testVal.a != regionColor.a); + } + } + if (interestingRegion) { + v_out[0]++; + } + } +} + +void accumulateError(const int32_t *v_in, int32_t *v_out) { + int startY = v_in[0]; + int error = 0; + for (int y = startY; y < startY + REGION_SIZE; y++) { + for (int x = 0; x < HEIGHT; 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); + error += abs(idealPixel.w - givenPixel.w); + } + } + v_out[0] = error; +} + +void displayDifference(const uchar4 *v_in, uchar4 *v_out, uint32_t x, uint32_t y) { + 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; + if (totalDiff < 0) { + v_out[0] = rsPackColorTo8888(0, 0, clamp(-totalDiff/2.f, 0.f, 1.f)); + } else { + v_out[0] = rsPackColorTo8888(clamp(totalDiff/2.f, 0.f, 1.f), 0, 0); + } +} -- cgit v1.2.3-59-g8ed1b