@ -339,12 +339,13 @@ TEST(join_arrays_modifier_invalid)
TEST ( intersect_arrays )
TEST ( intersect_arrays )
{
{
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_C , * format_array_result ;
struct weston_drm_format_array * format_array_C ;
uint32_t formats_A [ ] = { 1 , 2 , 6 , 9 , 10 } ;
uint32_t formats_A [ ] = { 1 , 2 , 6 , 9 , 10 } ;
uint32_t formats_B [ ] = { 2 , 5 , 7 , 9 , 10 } ;
uint32_t formats_B [ ] = { 2 , 5 , 7 , 9 , 10 } ;
uint64_t modifiers_A [ ] = { 1 , 2 , 3 , 4 , 7 } ;
uint64_t modifiers_A [ ] = { 1 , 2 , 3 , 4 , 7 } ;
uint64_t modifiers_B [ ] = { 0 , 2 , 3 , 5 , 6 } ;
uint64_t modifiers_B [ ] = { 0 , 2 , 3 , 5 , 6 } ;
uint64_t modifiers_intersect [ ] = { 2 , 3 } ;
uint64_t modifiers_intersect [ ] = { 2 , 3 } ;
int ret ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
@ -355,26 +356,24 @@ TEST(intersect_arrays)
ADD_FORMATS_AND_MODS ( format_array_A , formats_A , modifiers_A ) ;
ADD_FORMATS_AND_MODS ( format_array_A , formats_A , modifiers_A ) ;
ADD_FORMATS_AND_MODS ( format_array_B , formats_B , modifiers_B ) ;
ADD_FORMATS_AND_MODS ( format_array_B , formats_B , modifiers_B ) ;
format_array_result = weston_drm_format_array_intersect ( format_array_A ,
ret = weston_drm_format_array_intersect ( format_array_A , format_array_B ) ;
format_array_B ) ;
assert ( ret = = 0 ) ;
assert ( format_array_result ) ;
/* The result of the intersection should have the same content as C. */
/* The result of the intersection (stored in A) should have the same
* content as C . */
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 2 } , modifiers_intersect ) ;
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 2 } , modifiers_intersect ) ;
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 9 } , modifiers_intersect ) ;
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 9 } , modifiers_intersect ) ;
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 10 } , modifiers_intersect ) ;
ADD_FORMATS_AND_MODS ( format_array_C , ( uint32_t [ ] ) { 10 } , modifiers_intersect ) ;
assert ( weston_drm_format_array_equal ( format_array_result , format_array_C ) ) ;
assert ( weston_drm_format_array_equal ( format_array_A , format_array_C ) ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_C ) ;
weston_drm_format_array_destroy ( format_array_C ) ;
weston_drm_format_array_destroy ( format_array_result ) ;
}
}
TEST ( intersect_arrays_same_content )
TEST ( intersect_arrays_same_content )
{
{
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_result ;
uint32_t formats [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint32_t formats [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint64_t modifiers [ ] = { 11 , 12 , 13 , 14 , 15 } ;
uint64_t modifiers [ ] = { 11 , 12 , 13 , 14 , 15 } ;
int ret ;
int ret ;
@ -386,36 +385,31 @@ TEST(intersect_arrays_same_content)
/* The intersection between two empty arrays must be an
/* The intersection between two empty arrays must be an
* empty array . */
* empty array . */
format_array_result = weston_drm_format_array_intersect ( format_array_A ,
ret = weston_drm_format_array_intersect ( format_array_A , format_array_B ) ;
format_array_B ) ;
assert ( ret = = 0 ) ;
assert ( format_array_result ) ;
assert ( format_array_A - > arr . size = = 0 ) ;
assert ( format_array_result - > arr . size = = 0 ) ;
weston_drm_format_array_destroy ( format_array_result ) ;
/* DRM-format arrays A and B have the same content, so the intersection
/* DRM-format arrays A and B have the same content, so the intersection
* should be equal to them . */
* should be equal to them . A keeps the result of the intersection , and B
* does not change . So we compare them . */
ADD_FORMATS_AND_MODS ( format_array_A , formats , modifiers ) ;
ADD_FORMATS_AND_MODS ( format_array_A , formats , modifiers ) ;
ret = weston_drm_format_array_replace ( format_array_B , format_array_A ) ;
ret = weston_drm_format_array_replace ( format_array_B , format_array_A ) ;
assert ( ret = = 0 ) ;
assert ( ret = = 0 ) ;
format_array_result = weston_drm_format_array_intersect ( format_array_A ,
ret = weston_drm_format_array_intersect ( format_array_A , format_array_B ) ;
format_array_B ) ;
assert ( ret = = 0 ) ;
assert ( format_array_result ) ;
assert ( weston_drm_format_array_equal ( format_array_A , format_array_B ) ) ;
assert ( weston_drm_format_array_equal ( format_array_result ,
format_array_A ) ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_result ) ;
}
}
TEST ( intersect_arrays_exclusive_formats )
TEST ( intersect_arrays_exclusive_formats )
{
{
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_result ;
uint64_t formats_A [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint64_t formats_A [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint64_t formats_B [ ] = { 6 , 7 , 8 , 9 , 10 } ;
uint64_t formats_B [ ] = { 6 , 7 , 8 , 9 , 10 } ;
uint64_t modifiers [ ] = { 11 , 12 , 13 , 14 , 15 } ;
uint64_t modifiers [ ] = { 11 , 12 , 13 , 14 , 15 } ;
int ret ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
@ -423,25 +417,23 @@ TEST(intersect_arrays_exclusive_formats)
assert ( format_array_B ) ;
assert ( format_array_B ) ;
/* DRM-format arrays A and B have formats that are mutually exclusive,
/* DRM-format arrays A and B have formats that are mutually exclusive,
* so the intersection must be empty . */
* so the intersection ( which is stored in A ) must be empty . */
ADD_FORMATS_AND_MODS ( format_array_A , formats_A , modifiers ) ;
ADD_FORMATS_AND_MODS ( format_array_A , formats_A , modifiers ) ;
ADD_FORMATS_AND_MODS ( format_array_B , formats_B , modifiers ) ;
ADD_FORMATS_AND_MODS ( format_array_B , formats_B , modifiers ) ;
format_array_result = weston_drm_format_array_intersect ( format_array_A ,
ret = weston_drm_format_array_intersect ( format_array_A , format_array_B ) ;
format_array_B ) ;
assert ( ret = = 0 ) ;
assert ( format_array_result ) ;
assert ( format_array_A - > arr . size = = 0 ) ;
assert ( format_array_result - > arr . size = = 0 ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_result ) ;
}
}
TEST ( intersect_arrays_exclusive_modifiers )
TEST ( intersect_arrays_exclusive_modifiers )
{
{
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_A , * format_array_B ;
struct weston_drm_format_array * format_array_result ;
uint64_t modifiers_A [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint64_t modifiers_A [ ] = { 1 , 2 , 3 , 4 , 5 } ;
uint64_t modifiers_B [ ] = { 6 , 7 , 8 , 9 , 10 } ;
uint64_t modifiers_B [ ] = { 6 , 7 , 8 , 9 , 10 } ;
int ret ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_A = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
format_array_B = weston_drm_format_array_create ( ) ;
@ -449,19 +441,18 @@ TEST(intersect_arrays_exclusive_modifiers)
assert ( format_array_B ) ;
assert ( format_array_B ) ;
/* Both DRM-format arrays A and B have the same format but with modifier
/* Both DRM-format arrays A and B have the same format but with modifier
* sets that are mutually exclusive . The intersection between mutually
* sets that are mutually exclusive . The intersection ( which is stored
* exclusive modifier must be empty , and so the format should not be
* in A ) between mutually exclusive modifier must be empty , and so the
* added to the array . So the array must also be empty . */
* format should not be added to the array . So the array must also be
* empty . */
ADD_FORMATS_AND_MODS ( format_array_A , ( uint32_t [ ] ) { 1 } , modifiers_A ) ;
ADD_FORMATS_AND_MODS ( format_array_A , ( uint32_t [ ] ) { 1 } , modifiers_A ) ;
ADD_FORMATS_AND_MODS ( format_array_B , ( uint32_t [ ] ) { 1 } , modifiers_B ) ;
ADD_FORMATS_AND_MODS ( format_array_B , ( uint32_t [ ] ) { 1 } , modifiers_B ) ;
format_array_result = weston_drm_format_array_intersect ( format_array_A ,
ret = weston_drm_format_array_intersect ( format_array_A , format_array_B ) ;
format_array_B ) ;
assert ( ret = = 0 ) ;
assert ( format_array_result ) ;
assert ( format_array_A - > arr . size = = 0 ) ;
assert ( format_array_result - > arr . size = = 0 ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_A ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_B ) ;
weston_drm_format_array_destroy ( format_array_result ) ;
}
}
TEST ( subtract_arrays )
TEST ( subtract_arrays )