@ -127,20 +127,35 @@ static const struct wl_buffer_listener buffer_listener = {
. release = buffer_handle_release ,
. release = buffer_handle_release ,
} ;
} ;
static struct wlr_wl_buffer * create_wl _buffer( struct wlr_wl_backend * wl ,
static bool test _buffer( struct wlr_wl_backend * wl ,
struct wlr_buffer * wlr_buffer ,
struct wlr_buffer * wlr_buffer ,
int required_width , int required_height ) {
int required_width , int required_height ) {
struct wlr_dmabuf_attributes attribs ;
struct wlr_dmabuf_attributes attribs ;
if ( ! wlr_buffer_get_dmabuf ( wlr_buffer , & attribs ) ) {
if ( ! wlr_buffer_get_dmabuf ( wlr_buffer , & attribs ) ) {
return NULL ;
return false ;
}
}
if ( attribs . width ! = required_width | | attribs . height ! = required_height ) {
if ( attribs . width ! = required_width | | attribs . height ! = required_height ) {
return NULL ;
return false ;
}
}
if ( ! wlr_drm_format_set_has ( & wl - > linux_dmabuf_v1_formats ,
if ( ! wlr_drm_format_set_has ( & wl - > linux_dmabuf_v1_formats ,
attribs . format , attribs . modifier ) ) {
attribs . format , attribs . modifier ) ) {
return false ;
}
return true ;
}
static struct wlr_wl_buffer * create_wl_buffer ( struct wlr_wl_backend * wl ,
struct wlr_buffer * wlr_buffer ,
int required_width , int required_height ) {
if ( ! test_buffer ( wl , wlr_buffer , required_width , required_height ) ) {
return NULL ;
}
struct wlr_dmabuf_attributes attribs ;
if ( ! wlr_buffer_get_dmabuf ( wlr_buffer , & attribs ) ) {
return NULL ;
return NULL ;
}
}
@ -180,23 +195,6 @@ static struct wlr_wl_buffer *create_wl_buffer(struct wlr_wl_backend *wl,
return buffer ;
return buffer ;
}
}
static bool output_attach_buffer ( struct wlr_output * wlr_output ,
struct wlr_buffer * wlr_buffer ) {
struct wlr_wl_output * output =
get_wl_output_from_output ( wlr_output ) ;
struct wlr_wl_backend * wl = output - > backend ;
struct wlr_wl_buffer * buffer = create_wl_buffer ( wl , wlr_buffer ,
wlr_output - > width , wlr_output - > height ) ;
if ( buffer = = NULL ) {
return false ;
}
destroy_wl_buffer ( output - > pending_buffer ) ;
output - > pending_buffer = buffer ;
return true ;
}
static bool output_test ( struct wlr_output * wlr_output ) {
static bool output_test ( struct wlr_output * wlr_output ) {
if ( wlr_output - > pending . committed & WLR_OUTPUT_STATE_ENABLED ) {
if ( wlr_output - > pending . committed & WLR_OUTPUT_STATE_ENABLED ) {
wlr_log ( WLR_DEBUG , " Cannot disable a Wayland output " ) ;
wlr_log ( WLR_DEBUG , " Cannot disable a Wayland output " ) ;
@ -254,10 +252,14 @@ static bool output_commit(struct wlr_output *wlr_output) {
return false ;
return false ;
}
}
break ;
break ;
case WLR_OUTPUT_STATE_BUFFER_SCANOUT :
case WLR_OUTPUT_STATE_BUFFER_SCANOUT : ;
assert ( output - > pending_buffer ! = NULL ) ;
struct wlr_wl_buffer * buffer = create_wl_buffer ( output - > backend ,
wl_surface_attach ( output - > surface ,
wlr_output - > pending . buffer , wlr_output - > width , wlr_output - > height ) ;
output - > pending_buffer - > wl_buffer , 0 , 0 ) ;
if ( buffer = = NULL ) {
return false ;
}
wl_surface_attach ( output - > surface , buffer - > wl_buffer , 0 , 0 ) ;
if ( damage = = NULL ) {
if ( damage = = NULL ) {
wl_surface_damage_buffer ( output - > surface ,
wl_surface_damage_buffer ( output - > surface ,
@ -273,8 +275,6 @@ static bool output_commit(struct wlr_output *wlr_output) {
}
}
}
}
wl_surface_commit ( output - > surface ) ;
wl_surface_commit ( output - > surface ) ;
output - > pending_buffer = NULL ;
break ;
break ;
}
}
@ -400,8 +400,6 @@ static void output_destroy(struct wlr_output *wlr_output) {
presentation_feedback_destroy ( feedback ) ;
presentation_feedback_destroy ( feedback ) ;
}
}
destroy_wl_buffer ( output - > pending_buffer ) ;
wlr_egl_destroy_surface ( & output - > backend - > egl , output - > egl_surface ) ;
wlr_egl_destroy_surface ( & output - > backend - > egl , output - > egl_surface ) ;
wl_egl_window_destroy ( output - > egl_window ) ;
wl_egl_window_destroy ( output - > egl_window ) ;
if ( output - > zxdg_toplevel_decoration_v1 ) {
if ( output - > zxdg_toplevel_decoration_v1 ) {
@ -429,7 +427,6 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
static const struct wlr_output_impl output_impl = {
static const struct wlr_output_impl output_impl = {
. destroy = output_destroy ,
. destroy = output_destroy ,
. attach_render = output_attach_render ,
. attach_render = output_attach_render ,
. attach_buffer = output_attach_buffer ,
. test = output_test ,
. test = output_test ,
. commit = output_commit ,
. commit = output_commit ,
. set_cursor = output_set_cursor ,
. set_cursor = output_set_cursor ,