mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
Call glReadPixels right before swapping buffers
This commit is contained in:
parent
05096ab458
commit
d4cc82f11a
6 changed files with 11 additions and 18 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue