Added software cursor fallback
This commit is contained in:
parent
f252c5a792
commit
0cd94f0cf0
|
@ -92,13 +92,13 @@ static uint32_t get_fb_for_bo(int fd, struct gbm_bo *bo) {
|
||||||
return *id;
|
return *id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_drm_output_begin(struct wlr_output_state *output) {
|
static void wlr_drm_output_make_current(struct wlr_output_state *output) {
|
||||||
struct wlr_drm_renderer *renderer = output->renderer;
|
struct wlr_drm_renderer *renderer = output->renderer;
|
||||||
eglMakeCurrent(renderer->egl.display, output->egl,
|
eglMakeCurrent(renderer->egl.display, output->egl,
|
||||||
output->egl, renderer->egl.context);
|
output->egl, renderer->egl.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_drm_output_end(struct wlr_output_state *output) {
|
static void wlr_drm_output_swap_buffers(struct wlr_output_state *output) {
|
||||||
struct wlr_drm_renderer *renderer = output->renderer;
|
struct wlr_drm_renderer *renderer = output->renderer;
|
||||||
|
|
||||||
if (!eglSwapBuffers(renderer->egl.display, output->egl)) {
|
if (!eglSwapBuffers(renderer->egl.display, output->egl)) {
|
||||||
|
@ -207,10 +207,10 @@ static void wlr_drm_output_enable(struct wlr_output_state *output, bool enable)
|
||||||
DRM_MODE_DPMS_ON);
|
DRM_MODE_DPMS_ON);
|
||||||
|
|
||||||
// Start rendering loop again by drawing a black frame
|
// Start rendering loop again by drawing a black frame
|
||||||
wlr_drm_output_begin(output);
|
wlr_drm_output_make_current(output);
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
wlr_drm_output_end(output);
|
wlr_drm_output_swap_buffers(output);
|
||||||
} else {
|
} else {
|
||||||
drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms,
|
drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms,
|
||||||
DRM_MODE_DPMS_STANDBY);
|
DRM_MODE_DPMS_STANDBY);
|
||||||
|
@ -342,8 +342,13 @@ static bool wlr_drm_output_set_cursor(struct wlr_output_state *output,
|
||||||
wlr_log(L_ERROR, "Failed to write cursor to bo");
|
wlr_log(L_ERROR, "Failed to write cursor to bo");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !drmModeSetCursor(state->fd, output->crtc,
|
|
||||||
gbm_bo_get_handle(bo).s32, width, height);
|
if (drmModeSetCursor(state->fd, output->crtc, gbm_bo_get_handle(bo).u32, width, height)) {
|
||||||
|
wlr_log_errno(L_INFO, "Failed to set hardware cursor");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wlr_drm_output_move_cursor(struct wlr_output_state *output,
|
static bool wlr_drm_output_move_cursor(struct wlr_output_state *output,
|
||||||
|
@ -365,6 +370,8 @@ static struct wlr_output_impl output_impl = {
|
||||||
.set_cursor = wlr_drm_output_set_cursor,
|
.set_cursor = wlr_drm_output_set_cursor,
|
||||||
.move_cursor = wlr_drm_output_move_cursor,
|
.move_cursor = wlr_drm_output_move_cursor,
|
||||||
.destroy = wlr_drm_output_destroy,
|
.destroy = wlr_drm_output_destroy,
|
||||||
|
.make_current = wlr_drm_output_make_current,
|
||||||
|
.swap_buffers = wlr_drm_output_swap_buffers,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t calculate_refresh_rate(drmModeModeInfo *mode) {
|
static int32_t calculate_refresh_rate(drmModeModeInfo *mode) {
|
||||||
|
@ -625,9 +632,7 @@ static void page_flip_handler(int fd, unsigned seq,
|
||||||
|
|
||||||
output->pageflip_pending = false;
|
output->pageflip_pending = false;
|
||||||
if (output->state == DRM_OUTPUT_CONNECTED && state->session->active) {
|
if (output->state == DRM_OUTPUT_CONNECTED && state->session->active) {
|
||||||
wlr_drm_output_begin(output);
|
|
||||||
wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output);
|
wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output);
|
||||||
wlr_drm_output_end(output);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
#include "cat.h"
|
#include "cat.h"
|
||||||
|
|
||||||
struct sample_state {
|
struct sample_state {
|
||||||
struct wlr_renderer *renderer;
|
double cur_x, cur_y;
|
||||||
struct wlr_surface *cat_texture;
|
|
||||||
int cur_x, cur_y;
|
|
||||||
float default_color[4];
|
float default_color[4];
|
||||||
float clear_color[4];
|
float clear_color[4];
|
||||||
};
|
};
|
||||||
|
@ -33,18 +31,13 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
struct sample_state *sample = state->data;
|
struct sample_state *sample = state->data;
|
||||||
struct wlr_output *wlr_output = output->output;
|
struct wlr_output *wlr_output = output->output;
|
||||||
|
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_output_make_current(wlr_output);
|
||||||
|
|
||||||
glClearColor(sample->clear_color[0], sample->clear_color[1],
|
glClearColor(sample->clear_color[0], sample->clear_color[1],
|
||||||
sample->clear_color[2], sample->clear_color[3]);
|
sample->clear_color[2], sample->clear_color[3]);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
float matrix[16];
|
wlr_output_swap_buffers(wlr_output);
|
||||||
wlr_surface_get_matrix(sample->cat_texture, &matrix,
|
|
||||||
&wlr_output->transform_matrix, sample->cur_x, sample->cur_y);
|
|
||||||
wlr_render_with_matrix(sample->renderer,
|
|
||||||
sample->cat_texture, &matrix);
|
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_pointer_motion(struct pointer_state *pstate,
|
static void handle_pointer_motion(struct pointer_state *pstate,
|
||||||
|
@ -52,6 +45,11 @@ static void handle_pointer_motion(struct pointer_state *pstate,
|
||||||
struct sample_state *state = pstate->compositor->data;
|
struct sample_state *state = pstate->compositor->data;
|
||||||
state->cur_x += d_x;
|
state->cur_x += d_x;
|
||||||
state->cur_y += d_y;
|
state->cur_y += d_y;
|
||||||
|
|
||||||
|
struct output_state *output;
|
||||||
|
wl_list_for_each(output, &pstate->compositor->outputs, link) {
|
||||||
|
wlr_output_move_cursor(output->output, state->cur_x, state->cur_y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_pointer_motion_absolute(struct pointer_state *pstate,
|
static void handle_pointer_motion_absolute(struct pointer_state *pstate,
|
||||||
|
@ -59,6 +57,11 @@ static void handle_pointer_motion_absolute(struct pointer_state *pstate,
|
||||||
struct sample_state *state = pstate->compositor->data;
|
struct sample_state *state = pstate->compositor->data;
|
||||||
state->cur_x = x;
|
state->cur_x = x;
|
||||||
state->cur_y = y;
|
state->cur_y = y;
|
||||||
|
|
||||||
|
struct output_state *output;
|
||||||
|
wl_list_for_each(output, &pstate->compositor->outputs, link) {
|
||||||
|
wlr_output_move_cursor(output->output, state->cur_x, state->cur_y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_pointer_button(struct pointer_state *pstate,
|
static void handle_pointer_button(struct pointer_state *pstate,
|
||||||
|
@ -95,9 +98,8 @@ static void handle_pointer_axis(struct pointer_state *pstate,
|
||||||
|
|
||||||
static void handle_output_add(struct output_state *ostate) {
|
static void handle_output_add(struct output_state *ostate) {
|
||||||
struct wlr_output *wlr_output = ostate->output;
|
struct wlr_output *wlr_output = ostate->output;
|
||||||
int width = 16, height = 16;
|
|
||||||
if (!wlr_output_set_cursor(wlr_output, cat_tex.pixel_data,
|
if (!wlr_output_set_cursor(wlr_output, cat_tex.pixel_data,
|
||||||
width * 4, width, height)) {
|
cat_tex.width, cat_tex.width, cat_tex.height)) {
|
||||||
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -121,13 +123,5 @@ int main(int argc, char *argv[]) {
|
||||||
compositor.pointer_axis_cb = handle_pointer_axis;
|
compositor.pointer_axis_cb = handle_pointer_axis;
|
||||||
compositor_init(&compositor);
|
compositor_init(&compositor);
|
||||||
|
|
||||||
state.renderer = wlr_gles2_renderer_init();
|
|
||||||
state.cat_texture = wlr_render_surface_init(state.renderer);
|
|
||||||
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
|
|
||||||
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
|
||||||
|
|
||||||
compositor_run(&compositor);
|
compositor_run(&compositor);
|
||||||
|
|
||||||
wlr_surface_destroy(state.cat_texture);
|
|
||||||
wlr_renderer_destroy(state.renderer);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||||
|
|
||||||
|
wlr_output_make_current(wlr_output);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
|
@ -59,6 +60,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
wlr_output_swap_buffers(wlr_output);
|
||||||
|
|
||||||
long ms = (ts->tv_sec - output->last_frame.tv_sec) * 1000 +
|
long ms = (ts->tv_sec - output->last_frame.tv_sec) * 1000 +
|
||||||
(ts->tv_nsec - output->last_frame.tv_nsec) / 1000000;
|
(ts->tv_nsec - output->last_frame.tv_nsec) / 1000000;
|
||||||
|
@ -205,7 +207,7 @@ int main(int argc, char *argv[]) {
|
||||||
state.renderer = wlr_gles2_renderer_init();
|
state.renderer = wlr_gles2_renderer_init();
|
||||||
state.cat_texture = wlr_render_surface_init(state.renderer);
|
state.cat_texture = wlr_render_surface_init(state.renderer);
|
||||||
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
|
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
|
||||||
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
||||||
|
|
||||||
compositor_run(&compositor);
|
compositor_run(&compositor);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,12 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) {
|
||||||
sample->dec = inc;
|
sample->dec = inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_output_make_current(output->output);
|
||||||
|
|
||||||
glClearColor(sample->color[0], sample->color[1], sample->color[2], 1.0);
|
glClearColor(sample->color[0], sample->color[1], sample->color[2], 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
wlr_output_swap_buffers(output->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
@ -41,6 +41,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||||
|
|
||||||
|
wlr_output_make_current(wlr_output);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
|
|
||||||
float matrix[16], view[16];
|
float matrix[16], view[16];
|
||||||
|
@ -74,6 +75,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
wlr_output_swap_buffers(wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tool_axis(struct tablet_tool_state *tstate,
|
static void handle_tool_axis(struct tablet_tool_state *tstate,
|
||||||
|
|
|
@ -38,6 +38,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
|
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||||
|
|
||||||
|
wlr_output_make_current(wlr_output);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
|
|
||||||
float matrix[16];
|
float matrix[16];
|
||||||
|
@ -52,6 +54,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
wlr_output_swap_buffers(wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_touch_down(struct touch_state *tstate, int32_t slot,
|
static void handle_touch_down(struct touch_state *tstate, int32_t slot,
|
||||||
|
@ -104,7 +107,7 @@ int main(int argc, char *argv[]) {
|
||||||
state.renderer = wlr_gles2_renderer_init();
|
state.renderer = wlr_gles2_renderer_init();
|
||||||
state.cat_texture = wlr_render_surface_init(state.renderer);
|
state.cat_texture = wlr_render_surface_init(state.renderer);
|
||||||
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
|
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
|
||||||
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
||||||
|
|
||||||
compositor_run(&compositor);
|
compositor_run(&compositor);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ struct wlr_output_impl {
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height);
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height);
|
||||||
bool (*move_cursor)(struct wlr_output_state *state, int x, int y);
|
bool (*move_cursor)(struct wlr_output_state *state, int x, int y);
|
||||||
void (*destroy)(struct wlr_output_state *state);
|
void (*destroy)(struct wlr_output_state *state);
|
||||||
|
void (*make_current)(struct wlr_output_state *state);
|
||||||
|
void (*swap_buffers)(struct wlr_output_state *state);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
|
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct wlr_surface {
|
||||||
* calling this function.
|
* calling this function.
|
||||||
*/
|
*/
|
||||||
bool wlr_surface_attach_pixels(struct wlr_surface *surf, uint32_t format,
|
bool wlr_surface_attach_pixels(struct wlr_surface *surf, uint32_t format,
|
||||||
int width, int height, const unsigned char *pixels);
|
int stride, int width, int height, const unsigned char *pixels);
|
||||||
/**
|
/**
|
||||||
* Attaches pixels from a wl_shm_buffer to this surface. The shm buffer may be
|
* Attaches pixels from a wl_shm_buffer to this surface. The shm buffer may be
|
||||||
* invalidated after calling this function.
|
* invalidated after calling this function.
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct wlr_renderer *wlr_renderer_init(struct wlr_renderer_state *state,
|
||||||
|
|
||||||
struct wlr_surface_impl {
|
struct wlr_surface_impl {
|
||||||
bool (*attach_pixels)(struct wlr_surface_state *state, uint32_t format,
|
bool (*attach_pixels)(struct wlr_surface_state *state, uint32_t format,
|
||||||
int width, int height, const unsigned char *pixels);
|
int stride, int width, int height, const unsigned char *pixels);
|
||||||
bool (*attach_shm)(struct wlr_surface_state *state, uint32_t format,
|
bool (*attach_shm)(struct wlr_surface_state *state, uint32_t format,
|
||||||
struct wl_shm_buffer *shm);
|
struct wl_shm_buffer *shm);
|
||||||
// TODO: egl
|
// TODO: egl
|
||||||
|
|
|
@ -42,6 +42,14 @@ struct wlr_output {
|
||||||
struct wl_signal frame;
|
struct wl_signal frame;
|
||||||
struct wl_signal resolution;
|
struct wl_signal resolution;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool is_sw;
|
||||||
|
int32_t x, y;
|
||||||
|
uint32_t width, height;
|
||||||
|
struct wlr_renderer *renderer;
|
||||||
|
struct wlr_surface *texture;
|
||||||
|
} cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_output_enable(struct wlr_output *output, bool enable);
|
void wlr_output_enable(struct wlr_output *output, bool enable);
|
||||||
|
@ -55,5 +63,7 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y);
|
||||||
void wlr_output_destroy(struct wlr_output *output);
|
void wlr_output_destroy(struct wlr_output *output);
|
||||||
void wlr_output_effective_resolution(struct wlr_output *output,
|
void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
int *width, int *height);
|
int *width, int *height);
|
||||||
|
void wlr_output_make_current(struct wlr_output *output);
|
||||||
|
void wlr_output_swap_buffers(struct wlr_output *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
add_library(wlr-render STATIC
|
add_library(wlr-render
|
||||||
matrix.c
|
matrix.c
|
||||||
wlr_renderer.c
|
wlr_renderer.c
|
||||||
wlr_surface.c
|
wlr_surface.c
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
#include <wayland-util.h>
|
#include <wayland-util.h>
|
||||||
#include <wayland-server-protocol.h>
|
#include <wayland-server-protocol.h>
|
||||||
#include <wlr/render.h>
|
#include <wlr/render.h>
|
||||||
|
@ -10,15 +11,17 @@
|
||||||
#include "render/gles2.h"
|
#include "render/gles2.h"
|
||||||
|
|
||||||
static bool gles2_surface_attach_pixels(struct wlr_surface_state *surface,
|
static bool gles2_surface_attach_pixels(struct wlr_surface_state *surface,
|
||||||
uint32_t format, int width, int height, const unsigned char *pixels) {
|
uint32_t format, int stride, int width, int height, const unsigned char *pixels) {
|
||||||
assert(surface);
|
assert(surface);
|
||||||
surface->wlr_surface->width = width;
|
surface->wlr_surface->width = width;
|
||||||
surface->wlr_surface->height = height;
|
surface->wlr_surface->height = height;
|
||||||
surface->wlr_surface->format = format;
|
surface->wlr_surface->format = format;
|
||||||
GL_CALL(glGenTextures(1, &surface->tex_id));
|
GL_CALL(glGenTextures(1, &surface->tex_id));
|
||||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, surface->tex_id));
|
GL_CALL(glBindTexture(GL_TEXTURE_2D, surface->tex_id));
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride));
|
||||||
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0,
|
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0,
|
||||||
format, GL_UNSIGNED_BYTE, pixels));
|
format, GL_UNSIGNED_BYTE, pixels));
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0));
|
||||||
surface->wlr_surface->valid = true;
|
surface->wlr_surface->valid = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ void wlr_surface_bind(struct wlr_surface *surface) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_surface_attach_pixels(struct wlr_surface *surface, uint32_t format,
|
bool wlr_surface_attach_pixels(struct wlr_surface *surface, uint32_t format,
|
||||||
int width, int height, const unsigned char *pixels) {
|
int stride, int width, int height, const unsigned char *pixels) {
|
||||||
return surface->impl->attach_pixels(surface->state,
|
return surface->impl->attach_pixels(surface->state,
|
||||||
format, width, height, pixels);
|
format, stride, width, height, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_surface_attach_shm(struct wlr_surface *surface, uint32_t format,
|
bool wlr_surface_attach_shm(struct wlr_surface *surface, uint32_t format,
|
||||||
|
|
|
@ -15,5 +15,6 @@ add_library(wlr-types
|
||||||
|
|
||||||
target_link_libraries(wlr-types
|
target_link_libraries(wlr-types
|
||||||
wlr-util
|
wlr-util
|
||||||
|
wlr-render
|
||||||
${WAYLAND_LIBRARIES}
|
${WAYLAND_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
#include <wlr/interfaces/wlr_output.h>
|
#include <wlr/interfaces/wlr_output.h>
|
||||||
#include <wlr/util/list.h>
|
#include <wlr/util/list.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include <wlr/render/matrix.h>
|
||||||
|
#include <wlr/render/gles2.h>
|
||||||
|
#include <wlr/render.h>
|
||||||
|
|
||||||
static void wl_output_send_to_resource(struct wl_resource *resource) {
|
static void wl_output_send_to_resource(struct wl_resource *resource) {
|
||||||
assert(resource);
|
assert(resource);
|
||||||
|
@ -182,16 +186,44 @@ void wlr_output_transform(struct wlr_output *output,
|
||||||
|
|
||||||
bool wlr_output_set_cursor(struct wlr_output *output,
|
bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
||||||
if (!output->impl || !output->impl->set_cursor) {
|
if (output->impl->set_cursor && output->impl->set_cursor(output->state, buf,
|
||||||
return false;
|
stride, width, height)) {
|
||||||
|
output->cursor.is_sw = false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return output->impl->set_cursor(output->state, buf, stride, width, height);
|
|
||||||
|
wlr_log(L_INFO, "Falling back to software cursor");
|
||||||
|
|
||||||
|
output->cursor.is_sw = true;
|
||||||
|
output->cursor.width = width;
|
||||||
|
output->cursor.height = height;
|
||||||
|
|
||||||
|
if (!output->cursor.renderer) {
|
||||||
|
output->cursor.renderer = wlr_gles2_renderer_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output->cursor.texture) {
|
||||||
|
output->cursor.texture = wlr_render_surface_init(output->cursor.renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_surface_attach_pixels(output->cursor.texture, GL_RGBA,
|
||||||
|
stride, width, height, buf);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
||||||
if (!output->impl || !output->impl->move_cursor) {
|
output->cursor.x = x;
|
||||||
|
output->cursor.y = y;
|
||||||
|
|
||||||
|
if (output->cursor.is_sw) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output->impl->move_cursor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output->impl->move_cursor(output->state, x, y);
|
return output->impl->move_cursor(output->state, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,3 +248,18 @@ void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
*height = output->height;
|
*height = output->height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_make_current(struct wlr_output *output) {
|
||||||
|
output->impl->make_current(output->state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_output_swap_buffers(struct wlr_output *output) {
|
||||||
|
if (output->cursor.is_sw) {
|
||||||
|
float matrix[16];
|
||||||
|
wlr_surface_get_matrix(output->cursor.texture, &matrix, &output->transform_matrix,
|
||||||
|
output->cursor.x, output->cursor.y);
|
||||||
|
wlr_render_with_matrix(output->cursor.renderer, output->cursor.texture, &matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->impl->swap_buffers(output->state);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue