aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/TestUtils.cpp
diff options
context:
space:
mode:
authorGravatar Timothy Liang <timliang@google.com>2018-07-13 13:24:05 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-13 18:38:14 +0000
commit36848f6b30ddaca461c98e13b9976b2c449ca547 (patch)
treeed1626f12d90a0f8f154c2b89fb938f64c8ed499 /tests/TestUtils.cpp
parent81d151103faca621cfe62c9dfbec842ec9f337c4 (diff)
implemented metal gpu backend texture upload testing
Bug: skia: Change-Id: Ia3af58a0710f7f9792b37682a3cc45dd14282b71 Reviewed-on: https://skia-review.googlesource.com/140248 Commit-Queue: Timothy Liang <timliang@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests/TestUtils.cpp')
-rw-r--r--tests/TestUtils.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 44a78c51fb..8b611c2064 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -113,3 +113,32 @@ void test_copy_to_surface(skiatest::Reporter* reporter, GrProxyProvider* proxyPr
}
}
}
+
+void fill_pixel_data(int width, int height, GrColor* data) {
+ for (int j = 0; j < height; ++j) {
+ for (int i = 0; i < width; ++i) {
+ unsigned int red = (unsigned int)(256.f * (i / (float)width));
+ unsigned int green = (unsigned int)(256.f * (j / (float)height));
+ data[i + j * width] = GrColorPackRGBA(red - (red >> 8), green - (green >> 8),
+ 0xff, 0xff);
+ }
+ }
+}
+
+bool does_full_buffer_contain_correct_color(GrColor* srcBuffer,
+ GrColor* dstBuffer,
+ int width,
+ int height) {
+ GrColor* srcPtr = srcBuffer;
+ GrColor* dstPtr = dstBuffer;
+ for (int j = 0; j < height; ++j) {
+ for (int i = 0; i < width; ++i) {
+ if (srcPtr[i] != dstPtr[i]) {
+ return false;
+ }
+ }
+ srcPtr += width;
+ dstPtr += width;
+ }
+ return true;
+}