@ -141,38 +141,29 @@ create_screenshot_surface(struct client *client) {
return screenshot ;
return screenshot ;
}
}
TEST ( internal_screenshot )
/** capture_screenshot_of_output()
{
*
struct client * client ;
* Requests a screenshot from the server of the output that the
struct surface * screenshot = NULL ;
* client appears on . The image data returned from the server
struct surface * reference = NULL ;
* can be accessed from the screenshot surface ' s data member .
struct rectangle clip ;
*
const char * fname ;
* @ returns a new surface object , which should be free ' d when no
bool match = false ;
* longer needed .
bool dump_all_images = true ;
*/
static struct surface *
printf ( " Starting test \n " ) ;
capture_screenshot_of_output ( struct client * client ) {
struct surface * screenshot ;
/* Create the client */
client = create_client_and_test_surface ( 100 , 100 , 100 , 100 ) ;
assert ( client ) ;
printf ( " Client created \n " ) ;
/* Create a surface to hold the screenshot */
/* Create a surface to hold the screenshot */
screenshot = create_screenshot_surface ( client ) ;
screenshot = create_screenshot_surface ( client ) ;
assert ( screenshot ) ;
printf ( " Screenshot buffer created and attached to surface \n " ) ;
/* Take a snapshot. Result will be in screenshot->wl_buffer. */
client - > test - > buffer_copy_done = 0 ;
client - > test - > buffer_copy_done = 0 ;
weston_test_capture_screenshot ( client - > test - > weston_test ,
weston_test_capture_screenshot ( client - > test - > weston_test ,
client - > output - > wl_output ,
client - > output - > wl_output ,
screenshot - > wl_buffer ) ;
screenshot - > wl_buffer ) ;
printf ( " Capture request sent \n " ) ;
while ( client - > test - > buffer_copy_done = = 0 )
while ( client - > test - > buffer_copy_done = = 0 )
if ( wl_display_dispatch ( client - > wl_display ) < 0 )
if ( wl_display_dispatch ( client - > wl_display ) < 0 )
break ;
break ;
printf ( " Roundtrip done \n " ) ;
/* FIXME: Document somewhere the orientation the screenshot is taken
/* FIXME: Document somewhere the orientation the screenshot is taken
* and how the clip coords are interpreted , in case of scaling / transform .
* and how the clip coords are interpreted , in case of scaling / transform .
@ -180,6 +171,29 @@ TEST(internal_screenshot)
* Protocol docs in the XML , comparison function docs in Doxygen style .
* Protocol docs in the XML , comparison function docs in Doxygen style .
*/
*/
return screenshot ;
}
TEST ( internal_screenshot )
{
struct client * client ;
struct surface * screenshot = NULL ;
struct surface * reference = NULL ;
struct rectangle clip ;
const char * fname ;
bool match = false ;
bool dump_all_images = true ;
/* Create the client */
printf ( " Creating client for test \n " ) ;
client = create_client_and_test_surface ( 100 , 100 , 100 , 100 ) ;
assert ( client ) ;
/* Take a snapshot. Result will be in screenshot->wl_buffer. */
printf ( " Taking a screenshot \n " ) ;
screenshot = capture_screenshot_of_output ( client ) ;
assert ( screenshot ) ;
/* Load reference image */
/* Load reference image */
fname = screenshot_reference_filename ( " internal-screenshot " , 0 ) ;
fname = screenshot_reference_filename ( " internal-screenshot " , 0 ) ;
printf ( " Loading reference image %s \n " , fname ) ;
printf ( " Loading reference image %s \n " , fname ) ;