diff options
author | emersion <contact@emersion.fr> | 2017-10-07 12:01:21 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-10-07 16:22:03 +0200 |
commit | d4cc82f11a4917328366926083a703d85e50ddd6 (patch) | |
tree | 636b23bd08c5fa9e9d97ac2785ed36df647fc352 | |
parent | 05096ab45817127f75aecf10d94f082ec1815ee4 (diff) |
Call glReadPixels right before swapping buffers
-rw-r--r-- | backend/drm/drm.c | 10 | ||||
-rw-r--r-- | examples/screenshot.c | 2 | ||||
-rw-r--r-- | include/wlr/interfaces/wlr_output.h | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_output.h | 2 | ||||
-rw-r--r-- | types/wlr_output.c | 12 | ||||
-rw-r--r-- | types/wlr_screenshooter.c | 2 |
6 files changed, 11 insertions, 18 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index d08fa7f4..9e5346a1 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -634,14 +634,6 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output, return drm->iface->crtc_move_cursor(drm, conn->crtc, x, y); } -static void wlr_drm_connector_read_pixels(struct wlr_output *output, - void *out_data) { - int width, height; - wlr_output_effective_resolution(output, &width, &height); - wlr_drm_connector_make_current(output); - glReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, out_data); -} - static void wlr_drm_connector_destroy(struct wlr_output *output) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; wlr_drm_connector_cleanup(conn); @@ -660,7 +652,6 @@ static struct wlr_output_impl output_impl = { .swap_buffers = wlr_drm_connector_swap_buffers, .set_gamma = wlr_drm_connector_set_gamma, .get_gamma_size = wlr_drm_connector_get_gamma_size, - .read_pixels = wlr_drm_connector_read_pixels, }; static int retry_pageflip(void *data) { @@ -845,7 +836,6 @@ static void page_flip_handler(int fd, unsigned seq, if (drm->session->active) { wl_signal_emit(&conn->output.events.frame, &conn->output); - wl_signal_emit(&conn->output.events.post_frame, &conn->output); } } diff --git a/examples/screenshot.c b/examples/screenshot.c index 0f1f1efe..f70b9b56 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -204,7 +204,7 @@ write_png(int width, int height) } surface = cairo_image_surface_create_for_data(data, - CAIRO_FORMAT_ARGB32, + CAIRO_FORMAT_RGB24, width, height, buffer_stride); cairo_surface_write_to_png(surface, "wayland-screenshot.png"); cairo_surface_destroy(surface); diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 2fd306d7..7d2821e0 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -19,7 +19,6 @@ struct wlr_output_impl { void (*set_gamma)(struct wlr_output *output, uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b); uint16_t (*get_gamma_size)(struct wlr_output *output); - void (*read_pixels)(struct wlr_output *_output, void *out_data); }; void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *impl); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index a7ad2dbd..7fab1cf6 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -37,7 +37,7 @@ struct wlr_output { struct { struct wl_signal frame; - struct wl_signal post_frame; + struct wl_signal swap_buffers; struct wl_signal resolution; struct wl_signal destroy; } events; diff --git a/types/wlr_output.c b/types/wlr_output.c index e0220e6b..85357d2a 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -8,6 +8,7 @@ #include <wlr/util/list.h> #include <wlr/util/log.h> #include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> #include <wlr/render/matrix.h> #include <wlr/render/gles2.h> #include <wlr/render.h> @@ -105,7 +106,7 @@ void wlr_output_init(struct wlr_output *output, output->transform = WL_OUTPUT_TRANSFORM_NORMAL; output->scale = 1; wl_signal_init(&output->events.frame); - wl_signal_init(&output->events.post_frame); + wl_signal_init(&output->events.swap_buffers); wl_signal_init(&output->events.resolution); wl_signal_init(&output->events.destroy); } @@ -232,6 +233,8 @@ void wlr_output_swap_buffers(struct wlr_output *output) { wlr_render_with_matrix(output->cursor.renderer, output->cursor.texture, &matrix); } + wl_signal_emit(&output->events.swap_buffers, &output); + output->impl->swap_buffers(output); } @@ -250,7 +253,8 @@ uint16_t wlr_output_get_gamma_size(struct wlr_output *output) { } void wlr_output_read_pixels(struct wlr_output *output, void *out_data) { - if (output->impl->read_pixels) { - output->impl->read_pixels(output, out_data); - } + // TODO: is wlr_output_make_current required? + wlr_output_make_current(output); + glReadPixels(0, 0, output->width, output->height, GL_BGRA_EXT, + GL_UNSIGNED_BYTE, out_data); } diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c index 5f20925c..48db62c0 100644 --- a/types/wlr_screenshooter.c +++ b/types/wlr_screenshooter.c @@ -59,7 +59,7 @@ static void screenshooter_shoot(struct wl_client *client, state->output = output; state->screenshot = screenshot; state->frame_listener.notify = output_frame_notify; - wl_signal_add(&output->events.post_frame, &state->frame_listener); + wl_signal_add(&output->events.swap_buffers, &state->frame_listener); } static struct orbital_screenshooter_interface screenshooter_impl = { |