|
|
@ -47,7 +47,7 @@ struct fullscreen_output {
|
|
|
|
|
|
|
|
|
|
|
|
struct render_data {
|
|
|
|
struct render_data {
|
|
|
|
struct wlr_output *output;
|
|
|
|
struct wlr_output *output;
|
|
|
|
struct wlr_renderer *renderer;
|
|
|
|
struct wlr_render_pass *render_pass;
|
|
|
|
struct timespec *when;
|
|
|
|
struct timespec *when;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -68,13 +68,14 @@ static void render_surface(struct wlr_surface *surface,
|
|
|
|
.height = surface->current.height * output->scale,
|
|
|
|
.height = surface->current.height * output->scale,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
float matrix[9];
|
|
|
|
enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform);
|
|
|
|
enum wl_output_transform transform =
|
|
|
|
transform = wlr_output_transform_compose(transform, output->transform);
|
|
|
|
wlr_output_transform_invert(surface->current.transform);
|
|
|
|
|
|
|
|
wlr_matrix_project_box(matrix, &box, transform, 0,
|
|
|
|
|
|
|
|
output->transform_matrix);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_render_texture_with_matrix(rdata->renderer, texture, matrix, 1);
|
|
|
|
wlr_render_pass_add_texture(rdata->render_pass, &(struct wlr_render_texture_options){
|
|
|
|
|
|
|
|
.texture = texture,
|
|
|
|
|
|
|
|
.dst_box = box,
|
|
|
|
|
|
|
|
.transform = transform,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
wlr_surface_send_frame_done(surface, rdata->when);
|
|
|
|
wlr_surface_send_frame_done(surface, rdata->when);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -82,33 +83,35 @@ static void render_surface(struct wlr_surface *surface,
|
|
|
|
static void output_handle_frame(struct wl_listener *listener, void *data) {
|
|
|
|
static void output_handle_frame(struct wl_listener *listener, void *data) {
|
|
|
|
struct fullscreen_output *output =
|
|
|
|
struct fullscreen_output *output =
|
|
|
|
wl_container_of(listener, output, frame);
|
|
|
|
wl_container_of(listener, output, frame);
|
|
|
|
struct wlr_renderer *renderer = output->server->renderer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct timespec now;
|
|
|
|
struct timespec now;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
int width, height;
|
|
|
|
int width, height;
|
|
|
|
wlr_output_effective_resolution(output->wlr_output, &width, &height);
|
|
|
|
wlr_output_effective_resolution(output->wlr_output, &width, &height);
|
|
|
|
|
|
|
|
|
|
|
|
if (!wlr_output_attach_render(output->wlr_output, NULL)) {
|
|
|
|
struct wlr_output_state state = {0};
|
|
|
|
|
|
|
|
struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->wlr_output, &state, NULL);
|
|
|
|
|
|
|
|
if (pass == NULL) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_renderer_begin(renderer, width, height);
|
|
|
|
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
|
|
|
|
|
|
|
.color = { 0.3, 0.3, 0.3, 1.0 },
|
|
|
|
float color[4] = {0.3, 0.3, 0.3, 1.0};
|
|
|
|
.box = { .width = width, .height = height },
|
|
|
|
wlr_renderer_clear(renderer, color);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (output->surface != NULL) {
|
|
|
|
if (output->surface != NULL) {
|
|
|
|
struct render_data rdata = {
|
|
|
|
struct render_data rdata = {
|
|
|
|
.output = output->wlr_output,
|
|
|
|
.output = output->wlr_output,
|
|
|
|
.renderer = renderer,
|
|
|
|
.render_pass = pass,
|
|
|
|
.when = &now,
|
|
|
|
.when = &now,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
wlr_surface_for_each_surface(output->surface, render_surface, &rdata);
|
|
|
|
wlr_surface_for_each_surface(output->surface, render_surface, &rdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_renderer_end(renderer);
|
|
|
|
wlr_render_pass_submit(pass);
|
|
|
|
wlr_output_commit(output->wlr_output);
|
|
|
|
wlr_output_commit_state(output->wlr_output, &state);
|
|
|
|
|
|
|
|
wlr_output_state_finish(&state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void output_set_surface(struct fullscreen_output *output,
|
|
|
|
static void output_set_surface(struct fullscreen_output *output,
|
|
|
|