@ -31,6 +31,11 @@
# include <libweston/libweston.h>
# include <libweston/libweston.h>
# include "libweston-internal.h"
# include "libweston-internal.h"
struct noop_renderer {
struct weston_renderer base ;
unsigned char seed ; /* see comment in attach() */
} ;
static int
static int
noop_renderer_read_pixels ( struct weston_output * output ,
noop_renderer_read_pixels ( struct weston_output * output ,
pixman_format_code_t format , void * pixels ,
pixman_format_code_t format , void * pixels ,
@ -55,10 +60,12 @@ noop_renderer_flush_damage(struct weston_surface *surface,
static void
static void
noop_renderer_attach ( struct weston_surface * es , struct weston_buffer * buffer )
noop_renderer_attach ( struct weston_surface * es , struct weston_buffer * buffer )
{
{
struct noop_renderer * renderer =
wl_container_of ( es - > compositor - > renderer , renderer , base ) ;
struct wl_shm_buffer * shm_buffer ;
struct wl_shm_buffer * shm_buffer ;
uint8_t * data ;
uint8_t * data ;
uint32_t size , i , height , stride ;
uint32_t size , i , height , stride ;
__attribute__ ( ( unused ) ) int unused = 0 ;
unsigned char unused = 0 ;
if ( ! buffer )
if ( ! buffer )
return ;
return ;
@ -90,11 +97,18 @@ noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
unused ^ = data [ i ] ;
unused ^ = data [ i ] ;
wl_shm_buffer_end_access ( shm_buffer ) ;
wl_shm_buffer_end_access ( shm_buffer ) ;
/* Make sure that our unused is actually used, otherwise the compiler
* is free to notice that our reads have no effect and elide them . */
renderer - > seed = unused ;
}
}
static void
static void
noop_renderer_destroy ( struct weston_compositor * ec )
noop_renderer_destroy ( struct weston_compositor * ec )
{
{
struct noop_renderer * renderer =
wl_container_of ( ec - > renderer , renderer , base ) ;
weston_log ( " no-op renderer SHM seed: %d \n " , renderer - > seed ) ;
free ( ec - > renderer ) ;
free ( ec - > renderer ) ;
ec - > renderer = NULL ;
ec - > renderer = NULL ;
}
}
@ -102,18 +116,18 @@ noop_renderer_destroy(struct weston_compositor *ec)
WL_EXPORT int
WL_EXPORT int
noop_renderer_init ( struct weston_compositor * ec )
noop_renderer_init ( struct weston_compositor * ec )
{
{
struct westo n_renderer * renderer ;
struct noop _renderer * renderer ;
renderer = zalloc ( sizeof * renderer ) ;
renderer = zalloc ( sizeof * renderer ) ;
if ( renderer = = NULL )
if ( renderer = = NULL )
return - 1 ;
return - 1 ;
renderer - > read_pixels = noop_renderer_read_pixels ;
renderer - > base . read_pixels = noop_renderer_read_pixels ;
renderer - > repaint_output = noop_renderer_repaint_output ;
renderer - > base . repaint_output = noop_renderer_repaint_output ;
renderer - > flush_damage = noop_renderer_flush_damage ;
renderer - > base . flush_damage = noop_renderer_flush_damage ;
renderer - > attach = noop_renderer_attach ;
renderer - > base . attach = noop_renderer_attach ;
renderer - > destroy = noop_renderer_destroy ;
renderer - > base . destroy = noop_renderer_destroy ;
ec - > renderer = renderer ;
ec - > renderer = & renderer - > base ;
return 0 ;
return 0 ;
}
}