@ -1,5 +1,6 @@
/*
* Copyright © 2012 Intel Corporation
* Copyright © 2013 Collabora , Ltd .
*
* Permission to use , copy , modify , distribute , and sell this software and
* its documentation for any purpose is hereby granted without fee , provided
@ -347,3 +348,71 @@ TEST(test_surface_output)
check_client_move ( client , x , - - y ) ;
assert ( output_contains_client ( client ) ) ;
}
static void
buffer_release_handler ( void * data , struct wl_buffer * buffer )
{
int * released = data ;
* released = 1 ;
}
static struct wl_buffer_listener buffer_listener = {
buffer_release_handler
} ;
TEST ( buffer_release )
{
struct client * client ;
struct wl_surface * surface ;
struct wl_buffer * buf1 ;
struct wl_buffer * buf2 ;
struct wl_buffer * buf3 ;
int buf1_released = 0 ;
int buf2_released = 0 ;
int buf3_released = 0 ;
int frame ;
client = client_create ( 100 , 100 , 100 , 100 ) ;
assert ( client ) ;
surface = client - > surface - > wl_surface ;
buf1 = create_shm_buffer ( client , 100 , 100 , NULL ) ;
wl_buffer_add_listener ( buf1 , & buffer_listener , & buf1_released ) ;
buf2 = create_shm_buffer ( client , 100 , 100 , NULL ) ;
wl_buffer_add_listener ( buf2 , & buffer_listener , & buf2_released ) ;
buf3 = create_shm_buffer ( client , 100 , 100 , NULL ) ;
wl_buffer_add_listener ( buf3 , & buffer_listener , & buf3_released ) ;
/*
* buf1 must never be released , since it is replaced before
* it is committed , therefore it never becomes busy .
*/
wl_surface_attach ( surface , buf1 , 0 , 0 ) ;
wl_surface_attach ( surface , buf2 , 0 , 0 ) ;
frame_callback_set ( surface , & frame ) ;
wl_surface_commit ( surface ) ;
frame_callback_wait ( client , & frame ) ;
assert ( buf1_released = = 0 ) ;
/* buf2 may or may not be released */
assert ( buf3_released = = 0 ) ;
wl_surface_attach ( surface , buf3 , 0 , 0 ) ;
frame_callback_set ( surface , & frame ) ;
wl_surface_commit ( surface ) ;
frame_callback_wait ( client , & frame ) ;
assert ( buf1_released = = 0 ) ;
assert ( buf2_released = = 1 ) ;
/* buf3 may or may not be released */
wl_surface_attach ( surface , client - > surface - > wl_buffer , 0 , 0 ) ;
frame_callback_set ( surface , & frame ) ;
wl_surface_commit ( surface ) ;
frame_callback_wait ( client , & frame ) ;
assert ( buf1_released = = 0 ) ;
assert ( buf2_released = = 1 ) ;
assert ( buf3_released = = 1 ) ;
}