Add wlr_output.needs_swap

This commit is contained in:
emersion 2017-11-01 20:08:15 +01:00
parent 697a24137b
commit e18460c981
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 16 additions and 6 deletions

View File

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_WLR_OUTPUT_H #ifndef WLR_TYPES_WLR_OUTPUT_H
#define WLR_TYPES_WLR_OUTPUT_H #define WLR_TYPES_WLR_OUTPUT_H
#include <stdbool.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <stdbool.h>
struct wlr_output_mode { struct wlr_output_mode {
uint32_t flags; // enum wl_output_mode uint32_t flags; // enum wl_output_mode
@ -44,8 +44,9 @@ struct wlr_output {
uint32_t scale; uint32_t scale;
int32_t width, height; int32_t width, height;
int32_t phys_width, phys_height; // mm int32_t phys_width, phys_height; // mm
int32_t subpixel; // enum wl_output_subpixel enum wl_output_subpixel subpixel;
int32_t transform; // enum wl_output_transform enum wl_output_transform transform;
bool needs_swap;
float transform_matrix[16]; float transform_matrix[16];

View File

@ -291,6 +291,8 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) {
} }
void wlr_output_swap_buffers(struct wlr_output *output) { void wlr_output_swap_buffers(struct wlr_output *output) {
wl_signal_emit(&output->events.swap_buffers, &output);
struct wlr_output_cursor *cursor; struct wlr_output_cursor *cursor;
wl_list_for_each(cursor, &output->cursors, link) { wl_list_for_each(cursor, &output->cursors, link) {
if (output->hardware_cursor == cursor) { if (output->hardware_cursor == cursor) {
@ -299,9 +301,8 @@ void wlr_output_swap_buffers(struct wlr_output *output) {
output_cursor_render(cursor); output_cursor_render(cursor);
} }
wl_signal_emit(&output->events.swap_buffers, &output);
output->impl->swap_buffers(output); output->impl->swap_buffers(output);
output->needs_swap = false;
} }
void wlr_output_set_gamma(struct wlr_output *output, void wlr_output_set_gamma(struct wlr_output *output,
@ -319,6 +320,9 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) {
} }
static void output_cursor_reset(struct wlr_output_cursor *cursor) { static void output_cursor_reset(struct wlr_output_cursor *cursor) {
if (cursor->output->hardware_cursor != cursor) {
cursor->output->needs_swap = true;
}
if (cursor->surface != NULL) { if (cursor->surface != NULL) {
wl_list_remove(&cursor->surface_commit.link); wl_list_remove(&cursor->surface_commit.link);
wl_list_remove(&cursor->surface_destroy.link); wl_list_remove(&cursor->surface_destroy.link);
@ -347,6 +351,7 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
} }
wlr_log(L_INFO, "Falling back to software cursor"); wlr_log(L_INFO, "Falling back to software cursor");
cursor->output->needs_swap = true;
if (cursor->renderer == NULL) { if (cursor->renderer == NULL) {
cursor->renderer = wlr_gles2_renderer_create(cursor->output->backend); cursor->renderer = wlr_gles2_renderer_create(cursor->output->backend);
@ -370,7 +375,11 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) {
cursor->width = cursor->surface->current->width; cursor->width = cursor->surface->current->width;
cursor->height = cursor->surface->current->height; cursor->height = cursor->surface->current->height;
// TODO: if hardware cursor, upload pixels if (cursor->output->hardware_cursor != cursor) {
cursor->output->needs_swap = true;
} else {
// TODO: upload pixels
}
} }
static inline int64_t timespec_to_msec(const struct timespec *a) { static inline int64_t timespec_to_msec(const struct timespec *a) {