mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
examples: Modeset with a buffer
This means that for most examples, rendering code had to be extracted so that it could be called during modeset and during a regular refresh.
This commit is contained in:
parent
34ec9319d0
commit
9b1bdf7475
10 changed files with 147 additions and 111 deletions
|
|
@ -107,17 +107,11 @@ static void animate_cat(struct sample_state *sample,
|
|||
sample->ts_last = ts;
|
||||
}
|
||||
|
||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||
struct sample_output *output = wl_container_of(listener, output, frame);
|
||||
static void render(struct sample_output *output, struct wlr_output_state *state) {
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->output, state, NULL);
|
||||
struct sample_state *sample = output->sample;
|
||||
struct wlr_output *wlr_output = output->output;
|
||||
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL);
|
||||
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
.box = { .width = wlr_output->width, .height = wlr_output->height },
|
||||
.color = { 0.25, 0.25, 0.25, 1 },
|
||||
});
|
||||
|
||||
|
|
@ -141,7 +135,15 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
wlr_render_pass_submit(pass);
|
||||
wlr_output_commit_state(wlr_output, &output_state);
|
||||
}
|
||||
|
||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||
struct sample_output *output = wl_container_of(listener, output, frame);
|
||||
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
render(output, &output_state);
|
||||
wlr_output_commit_state(output->output, &output_state);
|
||||
wlr_output_state_finish(&output_state);
|
||||
}
|
||||
|
||||
|
|
@ -182,6 +184,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
if (mode != NULL) {
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
}
|
||||
render(sample_output, &state);
|
||||
wlr_output_commit_state(output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue