diff options
author | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-14 14:36:18 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-21 15:06:36 -0700 |
commit | 39a5be2a1fbb2a2664e85f38855a2be39335c8a5 (patch) | |
tree | 8b254112c21e6788acd702f26c9c36b267ebb44d | |
parent | 198f941ec82202c2f1953dc760d6c3eca9ab4a29 (diff) | |
download | weston-39a5be2a1fbb2a2664e85f38855a2be39335c8a5.tar.gz weston-39a5be2a1fbb2a2664e85f38855a2be39335c8a5.tar.bz2 weston-39a5be2a1fbb2a2664e85f38855a2be39335c8a5.zip |
tests: Add check_surfaces_geometry()
Minor refactoring to simplify initial sanity checks of surfaces.
Conceivably useful for other basic checking.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
-rw-r--r-- | tests/weston-test-client-helper.c | 40 | ||||
-rw-r--r-- | tests/weston-test-client-helper.h | 3 |
2 files changed, 30 insertions, 13 deletions
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index e6817bd9..1bfd43f9 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -877,6 +877,31 @@ screenshot_reference_filename(const char *basename, uint32_t seq) { } /** + * check_surfaces_geometry() - verifies two surfaces are same size + * + * @returns true if surfaces have the same width and height, or false + * if not, or if there is no actual data. + */ +bool +check_surfaces_geometry(const struct surface *a, const struct surface *b) +{ + if (a == NULL || b == NULL) { + printf("Undefined surfaces\n"); + return false; + } + else if (a->data == NULL || b->data == NULL) { + printf("Undefined data\n"); + return false; + } + else if (a->width != b->width || a->height != b->height) { + printf("Mismatched dimensions: %d,%d != %d,%d\n", + a->width, a->height, b->width, b->height); + return false; + } + return true; +} + +/** * check_surfaces_equal() - tests if two surfaces are pixel-identical * * Returns true if surface buffers have all the same byte values, @@ -888,9 +913,7 @@ check_surfaces_equal(const struct surface *a, const struct surface *b) { int bpp = 4; /* Assumes ARGB */ - if (a == NULL || b == NULL) - return false; - if (a->width != b->width || a->height != b->height) + if (!check_surfaces_geometry(a, b)) return false; return (memcmp(a->data, b->data, bpp * a->width * a->height) == 0); @@ -912,18 +935,9 @@ check_surfaces_match_in_clip(const struct surface *a, const struct surface *b, c void *p, *q; int bpp = 4; /* Assumes ARGB */ - if (a == NULL || b == NULL || clip_rect == NULL) + if (!check_surfaces_geometry(a, b) || clip_rect == NULL) return false; - if (a->data == NULL || b->data == NULL) { - printf("Undefined data\n"); - return false; - } - if (a->width != b->width || a->height != b->height) { - printf("Mismatched dimensions: %d,%d != %d,%d\n", - a->width, a->height, b->width, b->height); - return false; - } if (clip_rect->x > a->width || clip_rect->y > a->height) { printf("Clip outside image boundaries\n"); return true; diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index 0ff28770..5762258f 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -200,6 +200,9 @@ char* screenshot_reference_filename(const char *basename, uint32_t seq); bool +check_surfaces_geometry(const struct surface *a, const struct surface *b); + +bool check_surfaces_equal(const struct surface *a, const struct surface *b); bool |