mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
test-utils: Expose the compare_pixel function
The compare pixel function was a static function used internally by the test_utils_check_* functions. It takes a pointer to a pixel in a buffer read back from Cogl and compares it with an expected value. This function could also be useful in tests wanting to check the data returned from a call to cogl_texture_get_data so we should share it with the rest of the tests. https://bugzilla.gnome.org/show_bug.cgi?id=668913 Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
bd6810de10
commit
cd9e1be6ae
@ -85,8 +85,8 @@ compare_component (int a, int b)
|
||||
return ABS (a - b) <= 1;
|
||||
}
|
||||
|
||||
static void
|
||||
compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel)
|
||||
void
|
||||
test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel)
|
||||
{
|
||||
/* Compare each component with a small fuzz factor */
|
||||
if (!compare_component (screen_pixel[0], expected_pixel >> 24) ||
|
||||
@ -115,7 +115,7 @@ test_utils_check_pixel (int x, int y, guint32 expected_pixel)
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
pixel);
|
||||
|
||||
compare_pixel (pixel, expected_pixel);
|
||||
test_utils_compare_pixel (pixel, expected_pixel);
|
||||
}
|
||||
|
||||
void
|
||||
@ -144,7 +144,7 @@ test_utils_check_region (int x, int y,
|
||||
for (y = 0; y < height; y++)
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
compare_pixel (p, expected_rgba);
|
||||
test_utils_compare_pixel (p, expected_rgba);
|
||||
p += 4;
|
||||
}
|
||||
|
||||
|
@ -88,4 +88,17 @@ test_utils_check_region (int x, int y,
|
||||
int width, int height,
|
||||
guint32 expected_rgba);
|
||||
|
||||
/*
|
||||
* test_utils_compare_pixel:
|
||||
* @screen_pixel: A pixel stored in memory
|
||||
* @expected_pixel: The expected RGBA value
|
||||
*
|
||||
* Compares a pixel from a buffer to an expected value. The pixels are
|
||||
* converted to a string and compared with g_assert_cmpstr so that if
|
||||
* the comparison fails then the assert will display a meaningful
|
||||
* message.
|
||||
*/
|
||||
void
|
||||
test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel);
|
||||
|
||||
#endif /* _TEST_UTILS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user