compositor: Consolidate output repaint logic
We move the EGL and GLES2 output repaint code into a new gles2-render.c file. The eglMakeCurrent, glViewPort, surface loop etc was duplicated across all backends, but this patch moves it to a new file.
This commit is contained in:
@@ -33,6 +33,7 @@ weston_SOURCES = \
|
|||||||
util.c \
|
util.c \
|
||||||
matrix.c \
|
matrix.c \
|
||||||
matrix.h \
|
matrix.h \
|
||||||
|
gles2-renderer.c \
|
||||||
weston-launch.h \
|
weston-launch.h \
|
||||||
weston-egl-ext.h
|
weston-egl-ext.h
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ struct android_output {
|
|||||||
|
|
||||||
struct weston_mode mode;
|
struct weston_mode mode;
|
||||||
struct android_framebuffer *fb;
|
struct android_framebuffer *fb;
|
||||||
EGLSurface egl_surface;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct android_seat {
|
struct android_seat {
|
||||||
@@ -122,8 +121,10 @@ android_output_make_current(struct android_output *output)
|
|||||||
EGLBoolean ret;
|
EGLBoolean ret;
|
||||||
static int errored;
|
static int errored;
|
||||||
|
|
||||||
ret = eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
|
ret = eglMakeCurrent(compositor->base.egl_display,
|
||||||
output->egl_surface, compositor->base.egl_context);
|
output->base.egl_surface,
|
||||||
|
output->base.egl_surface,
|
||||||
|
compositor->base.egl_context);
|
||||||
if (ret == EGL_FALSE) {
|
if (ret == EGL_FALSE) {
|
||||||
if (errored)
|
if (errored)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -146,33 +147,13 @@ android_finish_frame(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
android_output_repaint(struct weston_output *base, pixman_region32_t *damage,
|
android_output_repaint(struct weston_output *base, pixman_region32_t *damage)
|
||||||
int flip)
|
|
||||||
{
|
{
|
||||||
struct android_output *output = to_android_output(base);
|
struct android_output *output = to_android_output(base);
|
||||||
struct android_compositor *compositor = output->compositor;
|
struct android_compositor *compositor = output->compositor;
|
||||||
struct weston_surface *surface;
|
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
EGLBoolean ret;
|
|
||||||
static int errored;
|
|
||||||
|
|
||||||
if (android_output_make_current(output) < 0)
|
gles2_renderer_repaint_output(&output->base, damage);
|
||||||
return;
|
|
||||||
|
|
||||||
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
|
|
||||||
weston_surface_draw(surface, &output->base, damage);
|
|
||||||
|
|
||||||
if (!flip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_signal_emit(&output->base.frame_signal, output);
|
|
||||||
|
|
||||||
ret = eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
|
|
||||||
if (ret == EGL_FALSE && !errored) {
|
|
||||||
errored = 1;
|
|
||||||
weston_log("Failed in eglSwapBuffers.\n");
|
|
||||||
print_egl_error_state();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
||||||
@@ -470,12 +451,12 @@ android_init_egl(struct android_compositor *compositor,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->egl_surface =
|
output->base.egl_surface =
|
||||||
eglCreateWindowSurface(compositor->base.egl_display,
|
eglCreateWindowSurface(compositor->base.egl_display,
|
||||||
compositor->base.egl_config,
|
compositor->base.egl_config,
|
||||||
output->fb->native_window,
|
output->fb->native_window,
|
||||||
NULL);
|
NULL);
|
||||||
if (output->egl_surface == EGL_NO_SURFACE) {
|
if (output->base.egl_surface == EGL_NO_SURFACE) {
|
||||||
weston_log("Failed to create FB EGLSurface.\n");
|
weston_log("Failed to create FB EGLSurface.\n");
|
||||||
print_egl_error_state();
|
print_egl_error_state();
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
+9
-30
@@ -140,7 +140,6 @@ struct drm_output {
|
|||||||
struct weston_plane fb_plane;
|
struct weston_plane fb_plane;
|
||||||
struct weston_surface *cursor_surface;
|
struct weston_surface *cursor_surface;
|
||||||
int current_cursor;
|
int current_cursor;
|
||||||
EGLSurface egl_surface;
|
|
||||||
struct drm_fb *current, *next;
|
struct drm_fb *current, *next;
|
||||||
struct backlight *backlight;
|
struct backlight *backlight;
|
||||||
};
|
};
|
||||||
@@ -322,30 +321,12 @@ drm_output_prepare_scanout_surface(struct weston_output *_output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drm_output_render(struct drm_output *output, pixman_region32_t *damage, int flip)
|
drm_output_render(struct drm_output *output, pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
struct drm_compositor *compositor =
|
|
||||||
(struct drm_compositor *) output->base.compositor;
|
|
||||||
struct weston_surface *surface;
|
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
|
|
||||||
if (!eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
|
gles2_renderer_repaint_output(&output->base, damage);
|
||||||
output->egl_surface,
|
|
||||||
compositor->base.egl_context)) {
|
|
||||||
weston_log("failed to make current\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
|
|
||||||
if (surface->plane == &compositor->base.primary_plane)
|
|
||||||
weston_surface_draw(surface, &output->base, damage);
|
|
||||||
|
|
||||||
if (!flip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_signal_emit(&output->base.frame_signal, output);
|
|
||||||
|
|
||||||
eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
|
|
||||||
bo = gbm_surface_lock_front_buffer(output->surface);
|
bo = gbm_surface_lock_front_buffer(output->surface);
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
weston_log("failed to lock front buffer: %m\n");
|
weston_log("failed to lock front buffer: %m\n");
|
||||||
@@ -362,7 +343,7 @@ drm_output_render(struct drm_output *output, pixman_region32_t *damage, int flip
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
drm_output_repaint(struct weston_output *output_base,
|
drm_output_repaint(struct weston_output *output_base,
|
||||||
pixman_region32_t *damage, int flip)
|
pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
struct drm_output *output = (struct drm_output *) output_base;
|
struct drm_output *output = (struct drm_output *) output_base;
|
||||||
struct drm_compositor *compositor =
|
struct drm_compositor *compositor =
|
||||||
@@ -372,11 +353,9 @@ drm_output_repaint(struct weston_output *output_base,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!output->next)
|
if (!output->next)
|
||||||
drm_output_render(output, damage, flip);
|
drm_output_render(output, damage);
|
||||||
if (!output->next)
|
if (!output->next)
|
||||||
return;
|
return;
|
||||||
if (!flip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mode = container_of(output->base.current, struct drm_mode, base);
|
mode = container_of(output->base.current, struct drm_mode, base);
|
||||||
if (!output->current) {
|
if (!output->current) {
|
||||||
@@ -885,7 +864,7 @@ drm_output_destroy(struct weston_output *output_base)
|
|||||||
c->crtc_allocator &= ~(1 << output->crtc_id);
|
c->crtc_allocator &= ~(1 << output->crtc_id);
|
||||||
c->connector_allocator &= ~(1 << output->connector_id);
|
c->connector_allocator &= ~(1 << output->connector_id);
|
||||||
|
|
||||||
eglDestroySurface(c->base.egl_display, output->egl_surface);
|
eglDestroySurface(c->base.egl_display, output->base.egl_surface);
|
||||||
gbm_surface_destroy(output->surface);
|
gbm_surface_destroy(output->surface);
|
||||||
|
|
||||||
weston_plane_release(&output->fb_plane);
|
weston_plane_release(&output->fb_plane);
|
||||||
@@ -1029,9 +1008,9 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo
|
|||||||
}
|
}
|
||||||
output->next = NULL;
|
output->next = NULL;
|
||||||
|
|
||||||
eglDestroySurface(ec->base.egl_display, output->egl_surface);
|
eglDestroySurface(ec->base.egl_display, output->base.egl_surface);
|
||||||
gbm_surface_destroy(output->surface);
|
gbm_surface_destroy(output->surface);
|
||||||
output->egl_surface = egl_surface;
|
output->base.egl_surface = egl_surface;
|
||||||
output->surface = surface;
|
output->surface = surface;
|
||||||
|
|
||||||
/*update output*/
|
/*update output*/
|
||||||
@@ -1511,12 +1490,12 @@ create_output_for_connector(struct drm_compositor *ec,
|
|||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->egl_surface =
|
output->base.egl_surface =
|
||||||
eglCreateWindowSurface(ec->base.egl_display,
|
eglCreateWindowSurface(ec->base.egl_display,
|
||||||
ec->base.egl_config,
|
ec->base.egl_config,
|
||||||
output->surface,
|
output->surface,
|
||||||
NULL);
|
NULL);
|
||||||
if (output->egl_surface == EGL_NO_SURFACE) {
|
if (output->base.egl_surface == EGL_NO_SURFACE) {
|
||||||
weston_log("failed to create egl surface\n");
|
weston_log("failed to create egl surface\n");
|
||||||
goto err_surface;
|
goto err_surface;
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-30
@@ -74,13 +74,12 @@ struct wayland_compositor {
|
|||||||
|
|
||||||
struct wayland_output {
|
struct wayland_output {
|
||||||
struct weston_output base;
|
struct weston_output base;
|
||||||
|
struct wl_listener frame_listener;
|
||||||
struct {
|
struct {
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct wl_shell_surface *shell_surface;
|
struct wl_shell_surface *shell_surface;
|
||||||
struct wl_egl_window *egl_window;
|
struct wl_egl_window *egl_window;
|
||||||
} parent;
|
} parent;
|
||||||
EGLSurface egl_surface;
|
|
||||||
struct weston_mode mode;
|
struct weston_mode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -329,33 +328,24 @@ static const struct wl_callback_listener frame_listener = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wayland_output_repaint(struct weston_output *output_base,
|
wayland_output_frame_notify(struct wl_listener *listener, void *data)
|
||||||
pixman_region32_t *damage, int flip)
|
|
||||||
{
|
{
|
||||||
struct wayland_output *output = (struct wayland_output *) output_base;
|
struct wayland_output *output =
|
||||||
struct wayland_compositor *compositor =
|
container_of(listener,
|
||||||
(struct wayland_compositor *) output->base.compositor;
|
struct wayland_output, frame_listener);
|
||||||
struct wl_callback *callback;
|
|
||||||
struct weston_surface *surface;
|
|
||||||
|
|
||||||
if (!eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
|
|
||||||
output->egl_surface,
|
|
||||||
compositor->base.egl_context)) {
|
|
||||||
weston_log("failed to make current\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
|
|
||||||
weston_surface_draw(surface, &output->base, damage);
|
|
||||||
|
|
||||||
if (!flip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
draw_border(output);
|
draw_border(output);
|
||||||
|
}
|
||||||
|
|
||||||
wl_signal_emit(&output->base.frame_signal, output);
|
static void
|
||||||
|
wayland_output_repaint(struct weston_output *output_base,
|
||||||
|
pixman_region32_t *damage)
|
||||||
|
{
|
||||||
|
struct wayland_output *output = (struct wayland_output *) output_base;
|
||||||
|
struct wl_callback *callback;
|
||||||
|
|
||||||
|
gles2_renderer_repaint_output(output_base, damage);
|
||||||
|
|
||||||
eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -368,7 +358,7 @@ wayland_output_destroy(struct weston_output *output_base)
|
|||||||
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 weston_compositor *ec = output->base.compositor;
|
||||||
|
|
||||||
eglDestroySurface(ec->egl_display, output->egl_surface);
|
eglDestroySurface(ec->egl_display, output->base.egl_surface);
|
||||||
wl_egl_window_destroy(output->parent.egl_window);
|
wl_egl_window_destroy(output->parent.egl_window);
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
@@ -422,16 +412,16 @@ wayland_compositor_create_output(struct wayland_compositor *c,
|
|||||||
goto cleanup_output;
|
goto cleanup_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->egl_surface =
|
output->base.egl_surface =
|
||||||
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
|
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
|
||||||
output->parent.egl_window, NULL);
|
output->parent.egl_window, NULL);
|
||||||
if (!output->egl_surface) {
|
if (!output->base.egl_surface) {
|
||||||
weston_log("failed to create window surface\n");
|
weston_log("failed to create window surface\n");
|
||||||
goto cleanup_window;
|
goto cleanup_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglMakeCurrent(c->base.egl_display, output->egl_surface,
|
if (!eglMakeCurrent(c->base.egl_display, output->base.egl_surface,
|
||||||
output->egl_surface, c->base.egl_context)) {
|
output->base.egl_surface, c->base.egl_context)) {
|
||||||
weston_log("failed to make surface current\n");
|
weston_log("failed to make surface current\n");
|
||||||
goto cleanup_surface;
|
goto cleanup_surface;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -454,10 +444,13 @@ wayland_compositor_create_output(struct wayland_compositor *c,
|
|||||||
|
|
||||||
wl_list_insert(c->base.output_list.prev, &output->base.link);
|
wl_list_insert(c->base.output_list.prev, &output->base.link);
|
||||||
|
|
||||||
|
output->frame_listener.notify = wayland_output_frame_notify;
|
||||||
|
wl_signal_add(&output->base.frame_signal, &output->frame_listener);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup_surface:
|
cleanup_surface:
|
||||||
eglDestroySurface(c->base.egl_display, output->egl_surface);
|
eglDestroySurface(c->base.egl_display, output->base.egl_surface);
|
||||||
cleanup_window:
|
cleanup_window:
|
||||||
wl_egl_window_destroy(output->parent.egl_window);
|
wl_egl_window_destroy(output->parent.egl_window);
|
||||||
cleanup_output:
|
cleanup_output:
|
||||||
|
|||||||
+8
-26
@@ -105,7 +105,6 @@ struct x11_output {
|
|||||||
struct weston_output base;
|
struct weston_output base;
|
||||||
|
|
||||||
xcb_window_t window;
|
xcb_window_t window;
|
||||||
EGLSurface egl_surface;
|
|
||||||
struct weston_mode mode;
|
struct weston_mode mode;
|
||||||
struct wl_event_source *finish_frame_timer;
|
struct wl_event_source *finish_frame_timer;
|
||||||
};
|
};
|
||||||
@@ -322,29 +321,11 @@ x11_compositor_fini_egl(struct x11_compositor *compositor)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
x11_output_repaint(struct weston_output *output_base,
|
x11_output_repaint(struct weston_output *output_base,
|
||||||
pixman_region32_t *damage, int flip)
|
pixman_region32_t *damage)
|
||||||
{
|
{
|
||||||
struct x11_output *output = (struct x11_output *)output_base;
|
struct x11_output *output = (struct x11_output *)output_base;
|
||||||
struct x11_compositor *compositor =
|
|
||||||
(struct x11_compositor *)output->base.compositor;
|
|
||||||
struct weston_surface *surface;
|
|
||||||
|
|
||||||
if (!eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
|
gles2_renderer_repaint_output(output_base, damage);
|
||||||
output->egl_surface,
|
|
||||||
compositor->base.egl_context)) {
|
|
||||||
weston_log("failed to make current\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
|
|
||||||
weston_surface_draw(surface, &output->base, damage);
|
|
||||||
|
|
||||||
if (!flip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_signal_emit(&output->base.frame_signal, output);
|
|
||||||
|
|
||||||
eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
|
|
||||||
|
|
||||||
wl_event_source_timer_update(output->finish_frame_timer, 10);
|
wl_event_source_timer_update(output->finish_frame_timer, 10);
|
||||||
}
|
}
|
||||||
@@ -373,7 +354,8 @@ x11_output_destroy(struct weston_output *output_base)
|
|||||||
wl_list_remove(&output->base.link);
|
wl_list_remove(&output->base.link);
|
||||||
wl_event_source_remove(output->finish_frame_timer);
|
wl_event_source_remove(output->finish_frame_timer);
|
||||||
|
|
||||||
eglDestroySurface(compositor->base.egl_display, output->egl_surface);
|
eglDestroySurface(compositor->base.egl_display,
|
||||||
|
output->base.egl_surface);
|
||||||
|
|
||||||
xcb_destroy_window(compositor->conn, output->window);
|
xcb_destroy_window(compositor->conn, output->window);
|
||||||
|
|
||||||
@@ -579,15 +561,15 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
|
|||||||
x11_output_change_state(output, 1,
|
x11_output_change_state(output, 1,
|
||||||
c->atom.net_wm_state_fullscreen);
|
c->atom.net_wm_state_fullscreen);
|
||||||
|
|
||||||
output->egl_surface =
|
output->base.egl_surface =
|
||||||
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
|
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
|
||||||
output->window, NULL);
|
output->window, NULL);
|
||||||
if (!output->egl_surface) {
|
if (!output->base.egl_surface) {
|
||||||
weston_log("failed to create window surface\n");
|
weston_log("failed to create window surface\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!eglMakeCurrent(c->base.egl_display, output->egl_surface,
|
if (!eglMakeCurrent(c->base.egl_display, output->base.egl_surface,
|
||||||
output->egl_surface, c->base.egl_context)) {
|
output->base.egl_surface, c->base.egl_context)) {
|
||||||
weston_log("failed to make surface current\n");
|
weston_log("failed to make surface current\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-23
@@ -1559,17 +1559,9 @@ weston_output_repaint(struct weston_output *output, uint32_t msecs)
|
|||||||
struct weston_frame_callback *cb, *cnext;
|
struct weston_frame_callback *cb, *cnext;
|
||||||
struct wl_list frame_callback_list;
|
struct wl_list frame_callback_list;
|
||||||
pixman_region32_t opaque, output_damage, new_damage;
|
pixman_region32_t opaque, output_damage, new_damage;
|
||||||
int32_t width, height;
|
|
||||||
|
|
||||||
weston_compositor_update_drag_surfaces(ec);
|
weston_compositor_update_drag_surfaces(ec);
|
||||||
|
|
||||||
width = output->current->width +
|
|
||||||
output->border.left + output->border.right;
|
|
||||||
height = output->current->height +
|
|
||||||
output->border.top + output->border.bottom;
|
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
|
|
||||||
/* Rebuild the surface list and update surface transforms up front. */
|
/* Rebuild the surface list and update surface transforms up front. */
|
||||||
wl_list_init(&ec->surface_list);
|
wl_list_init(&ec->surface_list);
|
||||||
wl_list_init(&frame_callback_list);
|
wl_list_init(&frame_callback_list);
|
||||||
@@ -1618,21 +1610,7 @@ weston_output_repaint(struct weston_output *output, uint32_t msecs)
|
|||||||
if (output->dirty)
|
if (output->dirty)
|
||||||
weston_output_update_matrix(output);
|
weston_output_update_matrix(output);
|
||||||
|
|
||||||
/* if debugging, redraw everything outside the damage to clean up
|
output->repaint(output, &output_damage);
|
||||||
* debug lines from the previous draw on this buffer:
|
|
||||||
*/
|
|
||||||
if (ec->fan_debug) {
|
|
||||||
pixman_region32_t undamaged;
|
|
||||||
pixman_region32_init(&undamaged);
|
|
||||||
pixman_region32_subtract(&undamaged, &output->region,
|
|
||||||
&output_damage);
|
|
||||||
ec->fan_debug = 0;
|
|
||||||
output->repaint(output, &undamaged, 0);
|
|
||||||
ec->fan_debug = 1;
|
|
||||||
pixman_region32_fini(&undamaged);
|
|
||||||
}
|
|
||||||
|
|
||||||
output->repaint(output, &output_damage, 1);
|
|
||||||
|
|
||||||
pixman_region32_fini(&output_damage);
|
pixman_region32_fini(&output_damage);
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -149,6 +149,7 @@ enum dpms_enum {
|
|||||||
struct weston_output {
|
struct weston_output {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
|
EGLSurface egl_surface;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list resource_list;
|
struct wl_list resource_list;
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
@@ -177,7 +178,7 @@ struct weston_output {
|
|||||||
struct wl_list mode_list;
|
struct wl_list mode_list;
|
||||||
|
|
||||||
void (*repaint)(struct weston_output *output,
|
void (*repaint)(struct weston_output *output,
|
||||||
pixman_region32_t *damage, int flip);
|
pixman_region32_t *damage);
|
||||||
void (*destroy)(struct weston_output *output);
|
void (*destroy)(struct weston_output *output);
|
||||||
void (*assign_planes)(struct weston_output *output);
|
void (*assign_planes)(struct weston_output *output);
|
||||||
int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
|
int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
|
||||||
@@ -794,4 +795,8 @@ backend_init(struct wl_display *display, int argc, char *argv[],
|
|||||||
int
|
int
|
||||||
weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
|
weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
|
||||||
|
|
||||||
|
void
|
||||||
|
gles2_renderer_repaint_output(struct weston_output *output,
|
||||||
|
pixman_region32_t *output_damage);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2012 Intel Corporation
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that the above copyright notice appear in all copies and that both that
|
||||||
|
* copyright notice and this permission notice appear in supporting
|
||||||
|
* documentation, and that the name of the copyright holders not be used in
|
||||||
|
* advertising or publicity pertaining to distribution of the software
|
||||||
|
* without specific, written prior permission. The copyright holders make
|
||||||
|
* no representations about the suitability of this software for any
|
||||||
|
* purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||||
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||||
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||||
|
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "compositor.h"
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
egl_error_string(EGLint code)
|
||||||
|
{
|
||||||
|
#define MYERRCODE(x) case x: return #x;
|
||||||
|
switch (code) {
|
||||||
|
MYERRCODE(EGL_SUCCESS)
|
||||||
|
MYERRCODE(EGL_NOT_INITIALIZED)
|
||||||
|
MYERRCODE(EGL_BAD_ACCESS)
|
||||||
|
MYERRCODE(EGL_BAD_ALLOC)
|
||||||
|
MYERRCODE(EGL_BAD_ATTRIBUTE)
|
||||||
|
MYERRCODE(EGL_BAD_CONTEXT)
|
||||||
|
MYERRCODE(EGL_BAD_CONFIG)
|
||||||
|
MYERRCODE(EGL_BAD_CURRENT_SURFACE)
|
||||||
|
MYERRCODE(EGL_BAD_DISPLAY)
|
||||||
|
MYERRCODE(EGL_BAD_SURFACE)
|
||||||
|
MYERRCODE(EGL_BAD_MATCH)
|
||||||
|
MYERRCODE(EGL_BAD_PARAMETER)
|
||||||
|
MYERRCODE(EGL_BAD_NATIVE_PIXMAP)
|
||||||
|
MYERRCODE(EGL_BAD_NATIVE_WINDOW)
|
||||||
|
MYERRCODE(EGL_CONTEXT_LOST)
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
#undef MYERRCODE
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_egl_error_state(void)
|
||||||
|
{
|
||||||
|
EGLint code;
|
||||||
|
|
||||||
|
code = eglGetError();
|
||||||
|
weston_log("EGL error state: %s (0x%04lx)\n",
|
||||||
|
egl_error_string(code), (long)code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
repaint_surfaces(struct weston_output *output, pixman_region32_t *damage)
|
||||||
|
{
|
||||||
|
struct weston_compositor *compositor = output->compositor;
|
||||||
|
struct weston_surface *surface;
|
||||||
|
|
||||||
|
wl_list_for_each_reverse(surface, &compositor->surface_list, link)
|
||||||
|
if (surface->plane == &compositor->primary_plane)
|
||||||
|
weston_surface_draw(surface, output, damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
gles2_renderer_repaint_output(struct weston_output *output,
|
||||||
|
pixman_region32_t *output_damage)
|
||||||
|
{
|
||||||
|
struct weston_compositor *compositor = output->compositor;
|
||||||
|
EGLBoolean ret;
|
||||||
|
static int errored;
|
||||||
|
int32_t width, height;
|
||||||
|
|
||||||
|
width = output->current->width +
|
||||||
|
output->border.left + output->border.right;
|
||||||
|
height = output->current->height +
|
||||||
|
output->border.top + output->border.bottom;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
ret = eglMakeCurrent(compositor->egl_display, output->egl_surface,
|
||||||
|
output->egl_surface, compositor->egl_context);
|
||||||
|
if (ret == EGL_FALSE) {
|
||||||
|
if (errored)
|
||||||
|
return;
|
||||||
|
errored = 1;
|
||||||
|
weston_log("Failed to make EGL context current.\n");
|
||||||
|
print_egl_error_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if debugging, redraw everything outside the damage to clean up
|
||||||
|
* debug lines from the previous draw on this buffer:
|
||||||
|
*/
|
||||||
|
if (compositor->fan_debug) {
|
||||||
|
pixman_region32_t undamaged;
|
||||||
|
pixman_region32_init(&undamaged);
|
||||||
|
pixman_region32_subtract(&undamaged, &output->region,
|
||||||
|
output_damage);
|
||||||
|
compositor->fan_debug = 0;
|
||||||
|
repaint_surfaces(output, &undamaged);
|
||||||
|
compositor->fan_debug = 1;
|
||||||
|
pixman_region32_fini(&undamaged);
|
||||||
|
}
|
||||||
|
|
||||||
|
repaint_surfaces(output, output_damage);
|
||||||
|
|
||||||
|
wl_signal_emit(&output->frame_signal, output);
|
||||||
|
|
||||||
|
ret = eglSwapBuffers(compositor->egl_display, output->egl_surface);
|
||||||
|
if (ret == EGL_FALSE && !errored) {
|
||||||
|
errored = 1;
|
||||||
|
weston_log("Failed in eglSwapBuffers.\n");
|
||||||
|
print_egl_error_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user