@ -43,6 +43,7 @@
# include "launcher-util.h"
# include "launcher-util.h"
# include "pixman-renderer.h"
# include "pixman-renderer.h"
# include "udev-seat.h"
# include "udev-seat.h"
# include "gl-renderer.h"
struct fbdev_compositor {
struct fbdev_compositor {
struct weston_compositor base ;
struct weston_compositor base ;
@ -51,6 +52,7 @@ struct fbdev_compositor {
struct udev * udev ;
struct udev * udev ;
struct tty * tty ;
struct tty * tty ;
struct udev_input input ;
struct udev_input input ;
int use_pixman ;
} ;
} ;
struct fbdev_screeninfo {
struct fbdev_screeninfo {
@ -90,6 +92,7 @@ struct fbdev_output {
struct fbdev_parameters {
struct fbdev_parameters {
int tty ;
int tty ;
char * device ;
char * device ;
int use_gl ;
} ;
} ;
static const char default_seat [ ] = " seat0 " ;
static const char default_seat [ ] = " seat0 " ;
@ -118,7 +121,7 @@ fbdev_output_start_repaint_loop(struct weston_output *output)
}
}
static void
static void
fbdev_output_repaint ( struct weston_output * base , pixman_region32_t * damage )
fbdev_output_repaint_pixman ( struct weston_output * base , pixman_region32_t * damage )
{
{
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct weston_compositor * ec = output - > base . compositor ;
struct weston_compositor * ec = output - > base . compositor ;
@ -191,6 +194,26 @@ fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
1000000 / output - > mode . refresh ) ;
1000000 / output - > mode . refresh ) ;
}
}
static void
fbdev_output_repaint ( struct weston_output * base , pixman_region32_t * damage )
{
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_compositor * fbc = output - > compositor ;
struct weston_compositor * ec = & fbc - > base ;
if ( fbc - > use_pixman ) {
fbdev_output_repaint_pixman ( base , damage ) ;
} else {
ec - > renderer - > repaint_output ( base , damage ) ;
/* Update the damage region. */
pixman_region32_subtract ( & ec - > primary_plane . damage ,
& ec - > primary_plane . damage , damage ) ;
wl_event_source_timer_update ( output - > finish_frame_timer ,
1000000 / output - > mode . refresh ) ;
}
}
static int
static int
finish_frame_handler ( void * data )
finish_frame_handler ( void * data )
{
{
@ -496,11 +519,12 @@ fbdev_output_create(struct fbdev_compositor *compositor,
weston_log ( " Creating frame buffer failed. \n " ) ;
weston_log ( " Creating frame buffer failed. \n " ) ;
goto out_free ;
goto out_free ;
}
}
if ( compositor - > use_pixman ) {
if ( fbdev_frame_buffer_map ( output , fb_fd ) < 0 ) {
if ( fbdev_frame_buffer_map ( output , fb_fd ) < 0 ) {
weston_log ( " Mapping frame buffer failed. \n " ) ;
weston_log ( " Mapping frame buffer failed. \n " ) ;
goto out_free ;
goto out_free ;
}
}
}
output - > base . start_repaint_loop = fbdev_output_start_repaint_loop ;
output - > base . start_repaint_loop = fbdev_output_start_repaint_loop ;
output - > base . repaint = fbdev_output_repaint ;
output - > base . repaint = fbdev_output_repaint ;
@ -593,8 +617,18 @@ fbdev_output_create(struct fbdev_compositor *compositor,
if ( output - > base . transform ! = WL_OUTPUT_TRANSFORM_NORMAL )
if ( output - > base . transform ! = WL_OUTPUT_TRANSFORM_NORMAL )
pixman_image_set_transform ( output - > shadow_surface , & transform ) ;
pixman_image_set_transform ( output - > shadow_surface , & transform ) ;
if ( compositor - > use_pixman ) {
if ( pixman_renderer_output_create ( & output - > base ) < 0 )
if ( pixman_renderer_output_create ( & output - > base ) < 0 )
goto out_shadow_surface ;
goto out_shadow_surface ;
} else {
setenv ( " HYBRIS_EGLPLATFORM " , " wayland " , 1 ) ;
if ( gl_renderer_output_create ( & output - > base ,
( EGLNativeWindowType ) NULL ) < 0 ) {
weston_log ( " gl_renderer_output_create failed. \n " ) ;
goto out_shadow_surface ;
}
}
loop = wl_display_get_event_loop ( compositor - > base . wl_display ) ;
loop = wl_display_get_event_loop ( compositor - > base . wl_display ) ;
output - > finish_frame_timer =
output - > finish_frame_timer =
@ -628,12 +662,14 @@ static void
fbdev_output_destroy ( struct weston_output * base )
fbdev_output_destroy ( struct weston_output * base )
{
{
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_compositor * compositor = output - > compositor ;
weston_log ( " Destroying fbdev output. \n " ) ;
weston_log ( " Destroying fbdev output. \n " ) ;
/* Close the frame buffer. */
/* Close the frame buffer. */
fbdev_output_disable ( base ) ;
fbdev_output_disable ( base ) ;
if ( compositor - > use_pixman ) {
if ( base - > renderer_state ! = NULL )
if ( base - > renderer_state ! = NULL )
pixman_renderer_output_destroy ( base ) ;
pixman_renderer_output_destroy ( base ) ;
@ -646,6 +682,9 @@ fbdev_output_destroy(struct weston_output *base)
free ( output - > shadow_buf ) ;
free ( output - > shadow_buf ) ;
output - > shadow_buf = NULL ;
output - > shadow_buf = NULL ;
}
}
} else {
gl_renderer_output_destroy ( base ) ;
}
/* Remove the output. */
/* Remove the output. */
wl_list_remove ( & output - > base . link ) ;
wl_list_remove ( & output - > base . link ) ;
@ -713,10 +752,12 @@ fbdev_output_reenable(struct fbdev_compositor *compositor,
}
}
/* Map the device if it has the same details as before. */
/* Map the device if it has the same details as before. */
if ( compositor - > use_pixman ) {
if ( fbdev_frame_buffer_map ( output , fb_fd ) < 0 ) {
if ( fbdev_frame_buffer_map ( output , fb_fd ) < 0 ) {
weston_log ( " Mapping frame buffer failed. \n " ) ;
weston_log ( " Mapping frame buffer failed. \n " ) ;
goto err ;
goto err ;
}
}
}
return 0 ;
return 0 ;
@ -731,9 +772,12 @@ static void
fbdev_output_disable ( struct weston_output * base )
fbdev_output_disable ( struct weston_output * base )
{
{
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_output * output = to_fbdev_output ( base ) ;
struct fbdev_compositor * compositor = output - > compositor ;
weston_log ( " Disabling fbdev output. \n " ) ;
weston_log ( " Disabling fbdev output. \n " ) ;
if ( ! compositor - > use_pixman ) return ;
if ( output - > hw_surface ! = NULL ) {
if ( output - > hw_surface ! = NULL ) {
pixman_image_unref ( output - > hw_surface ) ;
pixman_image_unref ( output - > hw_surface ) ;
output - > hw_surface = NULL ;
output - > hw_surface = NULL ;
@ -869,15 +913,23 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
compositor - > base . focus = 1 ;
compositor - > base . focus = 1 ;
compositor - > prev_state = WESTON_COMPOSITOR_ACTIVE ;
compositor - > prev_state = WESTON_COMPOSITOR_ACTIVE ;
compositor - > use_pixman = ! param - > use_gl ;
for ( key = KEY_F1 ; key < KEY_F9 ; key + + )
for ( key = KEY_F1 ; key < KEY_F9 ; key + + )
weston_compositor_add_key_binding ( & compositor - > base , key ,
weston_compositor_add_key_binding ( & compositor - > base , key ,
MODIFIER_CTRL | MODIFIER_ALT ,
MODIFIER_CTRL | MODIFIER_ALT ,
switch_vt_binding ,
switch_vt_binding ,
compositor ) ;
compositor ) ;
if ( compositor - > use_pixman ) {
if ( pixman_renderer_init ( & compositor - > base ) < 0 )
if ( pixman_renderer_init ( & compositor - > base ) < 0 )
goto out_tty ;
goto out_tty ;
} else {
if ( gl_renderer_create ( & compositor - > base , EGL_DEFAULT_DISPLAY ,
gl_renderer_opaque_attribs , NULL ) < 0 ) {
weston_log ( " gl_renderer_create failed. \n " ) ;
goto out_tty ;
}
}
if ( fbdev_output_create ( compositor , param - > device ) < 0 )
if ( fbdev_output_create ( compositor , param - > device ) < 0 )
goto out_pixman ;
goto out_pixman ;
@ -913,11 +965,13 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
struct fbdev_parameters param = {
struct fbdev_parameters param = {
. tty = 0 , /* default to current tty */
. tty = 0 , /* default to current tty */
. device = " /dev/fb0 " , /* default frame buffer */
. device = " /dev/fb0 " , /* default frame buffer */
. use_gl = 0 ,
} ;
} ;
const struct weston_option fbdev_options [ ] = {
const struct weston_option fbdev_options [ ] = {
{ WESTON_OPTION_INTEGER , " tty " , 0 , & param . tty } ,
{ WESTON_OPTION_INTEGER , " tty " , 0 , & param . tty } ,
{ WESTON_OPTION_STRING , " device " , 0 , & param . device } ,
{ WESTON_OPTION_STRING , " device " , 0 , & param . device } ,
{ WESTON_OPTION_BOOLEAN , " use-gl " , 0 , & param . use_gl } ,
} ;
} ;
parse_options ( fbdev_options , ARRAY_LENGTH ( fbdev_options ) , argc , argv ) ;
parse_options ( fbdev_options , ARRAY_LENGTH ( fbdev_options ) , argc , argv ) ;