Move weston_output EGL state into gles2-renderer.
This introduces callbacks for output creation and destruction for the
gles2-renderer. This enables the gles2-renderer to have per-output
state. EGL surface creation is now done by the output_create callback
and the EGL surface is stored in the new per-output gles2-renderer
state. On the first output_create call, the gles2-renderer will setup
it's GL context. This is because EGL requires a EGL surface to be able
to use the GL context.
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 9d922b5..cbb2482 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -390,8 +390,7 @@
wl_list_remove(&output->base.link);
wl_event_source_remove(output->finish_frame_timer);
- eglDestroySurface(compositor->base.egl_display,
- output->base.egl_surface);
+ gles2_renderer_output_destroy(output_base);
xcb_destroy_window(compositor->conn, output->window);
@@ -607,18 +606,6 @@
x11_output_wait_for_map(c, output);
- output->base.egl_surface =
- eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
- output->window, NULL);
- if (!output->base.egl_surface) {
- weston_log("failed to create window surface\n");
- return NULL;
- }
-
- loop = wl_display_get_event_loop(c->base.wl_display);
- output->finish_frame_timer =
- wl_event_loop_add_timer(loop, finish_frame_handler, output);
-
output->base.origin = output->base.current;
output->base.repaint = x11_output_repaint;
output->base.destroy = x11_output_destroy;
@@ -632,6 +619,13 @@
weston_output_init(&output->base, &c->base,
x, y, width, height, transform);
+ if (gles2_renderer_output_create(&output->base, output->window) < 0)
+ return NULL;
+
+ loop = wl_display_get_event_loop(c->base.wl_display);
+ output->finish_frame_timer =
+ wl_event_loop_add_timer(loop, finish_frame_handler, output);
+
wl_list_insert(c->base.output_list.prev, &output->base.link);
weston_log("x11 output %dx%d, window id %d\n",
@@ -1247,9 +1241,6 @@
x = pixman_region32_extents(&output->base.region)->x2;
}
- if (gles2_renderer_init(&c->base) < 0)
- goto err_egl;
-
c->xcb_source =
wl_event_loop_add_fd(c->base.input_loop,
xcb_get_file_descriptor(c->conn),