compositor: Introduce a weston_renderer object
Move the gles2 render functions to vfuncs on the renderer object.
This commit is contained in:
@@ -153,7 +153,7 @@ android_output_repaint(struct weston_output *base, pixman_region32_t *damage)
|
|||||||
struct android_compositor *compositor = output->compositor;
|
struct android_compositor *compositor = output->compositor;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
|
|
||||||
gles2_renderer_repaint_output(&output->base, damage);
|
compositor->base.renderer->repaint_output(&output->base, damage);
|
||||||
|
|
||||||
/* FIXME: does Android have a way to signal page flip done? */
|
/* FIXME: does Android have a way to signal page flip done? */
|
||||||
loop = wl_display_get_event_loop(compositor->base.wl_display);
|
loop = wl_display_get_event_loop(compositor->base.wl_display);
|
||||||
|
|||||||
@@ -323,9 +323,10 @@ drm_output_prepare_scanout_surface(struct weston_output *_output,
|
|||||||
static void
|
static void
|
||||||
drm_output_render(struct drm_output *output, pixman_region32_t *damage)
|
drm_output_render(struct drm_output *output, pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
|
struct weston_compositor *ec = output->base.compositor;
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
|
|
||||||
gles2_renderer_repaint_output(&output->base, damage);
|
ec->renderer->repaint_output(&output->base, damage);
|
||||||
|
|
||||||
bo = gbm_surface_lock_front_buffer(output->surface);
|
bo = gbm_surface_lock_front_buffer(output->surface);
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
|
|||||||
@@ -342,9 +342,10 @@ wayland_output_repaint(struct weston_output *output_base,
|
|||||||
pixman_region32_t *damage)
|
pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
struct wayland_output *output = (struct wayland_output *) output_base;
|
struct wayland_output *output = (struct wayland_output *) output_base;
|
||||||
|
struct weston_compositor *ec = output->base.compositor;
|
||||||
struct wl_callback *callback;
|
struct wl_callback *callback;
|
||||||
|
|
||||||
gles2_renderer_repaint_output(output_base, damage);
|
ec->renderer->repaint_output(&output->base, damage);
|
||||||
|
|
||||||
callback = wl_surface_frame(output->parent.surface);
|
callback = wl_surface_frame(output->parent.surface);
|
||||||
wl_callback_add_listener(callback, &frame_listener, output);
|
wl_callback_add_listener(callback, &frame_listener, output);
|
||||||
|
|||||||
@@ -324,8 +324,9 @@ x11_output_repaint(struct weston_output *output_base,
|
|||||||
pixman_region32_t *damage)
|
pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
struct x11_output *output = (struct x11_output *)output_base;
|
struct x11_output *output = (struct x11_output *)output_base;
|
||||||
|
struct weston_compositor *ec = output->base.compositor;
|
||||||
|
|
||||||
gles2_renderer_repaint_output(output_base, damage);
|
ec->renderer->repaint_output(output_base, damage);
|
||||||
|
|
||||||
wl_event_source_timer_update(output->finish_frame_timer, 10);
|
wl_event_source_timer_update(output->finish_frame_timer, 10);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -188,7 +188,7 @@ surface_handle_buffer_destroy(struct wl_listener *listener, void *data)
|
|||||||
buffer_destroy_listener);
|
buffer_destroy_listener);
|
||||||
|
|
||||||
if (es->buffer && wl_buffer_is_shm(es->buffer))
|
if (es->buffer && wl_buffer_is_shm(es->buffer))
|
||||||
gles2_renderer_flush_damage(es);
|
es->compositor->renderer->flush_damage(es);
|
||||||
|
|
||||||
es->buffer = NULL;
|
es->buffer = NULL;
|
||||||
}
|
}
|
||||||
@@ -752,7 +752,7 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
|
|||||||
weston_surface_unmap(es);
|
weston_surface_unmap(es);
|
||||||
}
|
}
|
||||||
|
|
||||||
gles2_renderer_attach(es, buffer);
|
es->compositor->renderer->attach(es, buffer);
|
||||||
es->buffer = buffer;
|
es->buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,7 +834,7 @@ surface_accumulate_damage(struct weston_surface *surface,
|
|||||||
pixman_region32_t *opaque)
|
pixman_region32_t *opaque)
|
||||||
{
|
{
|
||||||
if (surface->buffer && wl_buffer_is_shm(surface->buffer))
|
if (surface->buffer && wl_buffer_is_shm(surface->buffer))
|
||||||
gles2_renderer_flush_damage(surface);
|
surface->compositor->renderer->flush_damage(surface);
|
||||||
|
|
||||||
if (surface->transform.enabled) {
|
if (surface->transform.enabled) {
|
||||||
pixman_box32_t *extents;
|
pixman_box32_t *extents;
|
||||||
|
|||||||
+9
-7
@@ -267,6 +267,13 @@ struct weston_plane {
|
|||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct weston_renderer {
|
||||||
|
void (*repaint_output)(struct weston_output *output,
|
||||||
|
pixman_region32_t *output_damage);
|
||||||
|
void (*flush_damage)(struct weston_surface *surface);
|
||||||
|
void (*attach)(struct weston_surface *es, struct wl_buffer *buffer);
|
||||||
|
};
|
||||||
|
|
||||||
struct weston_compositor {
|
struct weston_compositor {
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
struct wl_signal destroy_signal;
|
struct wl_signal destroy_signal;
|
||||||
@@ -327,6 +334,8 @@ struct weston_compositor {
|
|||||||
|
|
||||||
uint32_t focus;
|
uint32_t focus;
|
||||||
|
|
||||||
|
struct weston_renderer *renderer;
|
||||||
|
|
||||||
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
|
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
|
||||||
image_target_renderbuffer_storage;
|
image_target_renderbuffer_storage;
|
||||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
||||||
@@ -794,12 +803,5 @@ weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode
|
|||||||
|
|
||||||
int
|
int
|
||||||
gles2_renderer_init(struct weston_compositor *ec);
|
gles2_renderer_init(struct weston_compositor *ec);
|
||||||
void
|
|
||||||
gles2_renderer_repaint_output(struct weston_output *output,
|
|
||||||
pixman_region32_t *output_damage);
|
|
||||||
void
|
|
||||||
gles2_renderer_flush_damage(struct weston_surface *surface);
|
|
||||||
void
|
|
||||||
gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+17
-3
@@ -620,7 +620,7 @@ repaint_surfaces(struct weston_output *output, pixman_region32_t *damage)
|
|||||||
draw_surface(surface, output, damage);
|
draw_surface(surface, output, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
static void
|
||||||
gles2_renderer_repaint_output(struct weston_output *output,
|
gles2_renderer_repaint_output(struct weston_output *output,
|
||||||
pixman_region32_t *output_damage)
|
pixman_region32_t *output_damage)
|
||||||
{
|
{
|
||||||
@@ -674,7 +674,7 @@ gles2_renderer_repaint_output(struct weston_output *output,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
static void
|
||||||
gles2_renderer_flush_damage(struct weston_surface *surface)
|
gles2_renderer_flush_damage(struct weston_surface *surface)
|
||||||
{
|
{
|
||||||
#ifdef GL_UNPACK_ROW_LENGTH
|
#ifdef GL_UNPACK_ROW_LENGTH
|
||||||
@@ -731,7 +731,7 @@ ensure_textures(struct weston_surface *es, int num_textures)
|
|||||||
glBindTexture(es->target, 0);
|
glBindTexture(es->target, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
static void
|
||||||
gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
|
gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
|
||||||
{
|
{
|
||||||
struct weston_compositor *ec = es->compositor;
|
struct weston_compositor *ec = es->compositor;
|
||||||
@@ -1035,12 +1035,21 @@ log_egl_gl_info(EGLDisplay egldpy)
|
|||||||
log_extensions("GL extensions", str ? str : "(null)");
|
log_extensions("GL extensions", str ? str : "(null)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gles2_renderer {
|
||||||
|
struct weston_renderer base;
|
||||||
|
};
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
gles2_renderer_init(struct weston_compositor *ec)
|
gles2_renderer_init(struct weston_compositor *ec)
|
||||||
{
|
{
|
||||||
|
struct gles2_renderer *renderer;
|
||||||
const char *extensions;
|
const char *extensions;
|
||||||
int has_egl_image_external = 0;
|
int has_egl_image_external = 0;
|
||||||
|
|
||||||
|
renderer = malloc(sizeof *renderer);
|
||||||
|
if (renderer == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
log_egl_gl_info(ec->egl_display);
|
log_egl_gl_info(ec->egl_display);
|
||||||
|
|
||||||
ec->image_target_texture_2d =
|
ec->image_target_texture_2d =
|
||||||
@@ -1115,5 +1124,10 @@ gles2_renderer_init(struct weston_compositor *ec)
|
|||||||
vertex_shader, solid_fragment_shader) < 0)
|
vertex_shader, solid_fragment_shader) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
renderer->base.repaint_output = gles2_renderer_repaint_output;
|
||||||
|
renderer->base.flush_damage = gles2_renderer_flush_damage;
|
||||||
|
renderer->base.attach = gles2_renderer_attach;
|
||||||
|
ec->renderer = &renderer->base;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user