util.c \
matrix.c \
matrix.h \
+ gles2-renderer.c \
weston-launch.h \
weston-egl-ext.h
struct weston_mode mode;
struct android_framebuffer *fb;
- EGLSurface egl_surface;
};
struct android_seat {
EGLBoolean ret;
static int errored;
- ret = eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
- output->egl_surface, compositor->base.egl_context);
+ ret = eglMakeCurrent(compositor->base.egl_display,
+ output->base.egl_surface,
+ output->base.egl_surface,
+ compositor->base.egl_context);
if (ret == EGL_FALSE) {
if (errored)
return -1;
}
static void
-android_output_repaint(struct weston_output *base, pixman_region32_t *damage,
- int flip)
+android_output_repaint(struct weston_output *base, pixman_region32_t *damage)
{
struct android_output *output = to_android_output(base);
- struct android_compositor *compositor = output->compositor;
- struct weston_surface *surface;
+ struct android_compositor *compositor = output->compositor;
struct wl_event_loop *loop;
- EGLBoolean ret;
- static int errored;
-
- if (android_output_make_current(output) < 0)
- 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();
- }
+ gles2_renderer_repaint_output(&output->base, damage);
/* FIXME: does Android have a way to signal page flip done? */
loop = wl_display_get_event_loop(compositor->base.wl_display);
return -1;
}
- output->egl_surface =
+ output->base.egl_surface =
eglCreateWindowSurface(compositor->base.egl_display,
compositor->base.egl_config,
output->fb->native_window,
NULL);
- if (output->egl_surface == EGL_NO_SURFACE) {
+ if (output->base.egl_surface == EGL_NO_SURFACE) {
weston_log("Failed to create FB EGLSurface.\n");
print_egl_error_state();
return -1;
struct weston_plane fb_plane;
struct weston_surface *cursor_surface;
int current_cursor;
- EGLSurface egl_surface;
struct drm_fb *current, *next;
struct backlight *backlight;
};
}
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;
- if (!eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
- output->egl_surface,
- compositor->base.egl_context)) {
- weston_log("failed to make current\n");
- return;
- }
+ gles2_renderer_repaint_output(&output->base, damage);
- 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);
if (!bo) {
weston_log("failed to lock front buffer: %m\n");
static void
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_compositor *compositor =
int ret = 0;
if (!output->next)
- drm_output_render(output, damage, flip);
+ drm_output_render(output, damage);
if (!output->next)
return;
- if (!flip)
- return;
mode = container_of(output->base.current, struct drm_mode, base);
if (!output->current) {
c->crtc_allocator &= ~(1 << output->crtc_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);
weston_plane_release(&output->fb_plane);
}
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);
- output->egl_surface = egl_surface;
+ output->base.egl_surface = egl_surface;
output->surface = surface;
/*update output*/
goto err_free;
}
- output->egl_surface =
+ output->base.egl_surface =
eglCreateWindowSurface(ec->base.egl_display,
ec->base.egl_config,
output->surface,
NULL);
- if (output->egl_surface == EGL_NO_SURFACE) {
+ if (output->base.egl_surface == EGL_NO_SURFACE) {
weston_log("failed to create egl surface\n");
goto err_surface;
}
struct wayland_output {
struct weston_output base;
-
+ struct wl_listener frame_listener;
struct {
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct wl_egl_window *egl_window;
} parent;
- EGLSurface egl_surface;
struct weston_mode mode;
};
};
static void
+wayland_output_frame_notify(struct wl_listener *listener, void *data)
+{
+ struct wayland_output *output =
+ container_of(listener,
+ struct wayland_output, frame_listener);
+
+ draw_border(output);
+}
+
+static void
wayland_output_repaint(struct weston_output *output_base,
- pixman_region32_t *damage, int flip)
+ pixman_region32_t *damage)
{
struct wayland_output *output = (struct wayland_output *) output_base;
- struct wayland_compositor *compositor =
- (struct wayland_compositor *) output->base.compositor;
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;
+ gles2_renderer_repaint_output(output_base, damage);
- draw_border(output);
-
- wl_signal_emit(&output->base.frame_signal, output);
-
- eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
callback = wl_surface_frame(output->parent.surface);
wl_callback_add_listener(callback, &frame_listener, output);
struct wayland_output *output = (struct wayland_output *) output_base;
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);
free(output);
goto cleanup_output;
}
- output->egl_surface =
+ output->base.egl_surface =
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
output->parent.egl_window, NULL);
- if (!output->egl_surface) {
+ if (!output->base.egl_surface) {
weston_log("failed to create window surface\n");
goto cleanup_window;
}
- if (!eglMakeCurrent(c->base.egl_display, output->egl_surface,
- output->egl_surface, c->base.egl_context)) {
+ if (!eglMakeCurrent(c->base.egl_display, output->base.egl_surface,
+ output->base.egl_surface, c->base.egl_context)) {
weston_log("failed to make surface current\n");
goto cleanup_surface;
return -1;
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;
cleanup_surface:
- eglDestroySurface(c->base.egl_display, output->egl_surface);
+ eglDestroySurface(c->base.egl_display, output->base.egl_surface);
cleanup_window:
wl_egl_window_destroy(output->parent.egl_window);
cleanup_output:
struct weston_output base;
xcb_window_t window;
- EGLSurface egl_surface;
struct weston_mode mode;
struct wl_event_source *finish_frame_timer;
};
static void
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_compositor *compositor =
- (struct x11_compositor *)output->base.compositor;
- 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;
-
- wl_signal_emit(&output->base.frame_signal, output);
- eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
+ gles2_renderer_repaint_output(output_base, damage);
wl_event_source_timer_update(output->finish_frame_timer, 10);
}
wl_list_remove(&output->base.link);
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);
x11_output_change_state(output, 1,
c->atom.net_wm_state_fullscreen);
- output->egl_surface =
+ output->base.egl_surface =
eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
output->window, NULL);
- if (!output->egl_surface) {
+ if (!output->base.egl_surface) {
weston_log("failed to create window surface\n");
return NULL;
}
- if (!eglMakeCurrent(c->base.egl_display, output->egl_surface,
- output->egl_surface, c->base.egl_context)) {
+ if (!eglMakeCurrent(c->base.egl_display, output->base.egl_surface,
+ output->base.egl_surface, c->base.egl_context)) {
weston_log("failed to make surface current\n");
return NULL;
}
struct weston_frame_callback *cb, *cnext;
struct wl_list frame_callback_list;
pixman_region32_t opaque, output_damage, new_damage;
- int32_t width, height;
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. */
wl_list_init(&ec->surface_list);
wl_list_init(&frame_callback_list);
if (output->dirty)
weston_output_update_matrix(output);
- /* if debugging, redraw everything outside the damage to clean up
- * 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);
+ output->repaint(output, &output_damage);
pixman_region32_fini(&output_damage);
struct weston_output {
uint32_t id;
+ EGLSurface egl_surface;
struct wl_list link;
struct wl_list resource_list;
struct wl_global *global;
struct wl_list mode_list;
void (*repaint)(struct weston_output *output,
- pixman_region32_t *damage, int flip);
+ pixman_region32_t *damage);
void (*destroy)(struct weston_output *output);
void (*assign_planes)(struct weston_output *output);
int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
int
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
--- /dev/null
+/*
+ * 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();
+ }
+
+}