diff options
| author | Simon Ser <contact@emersion.fr> | 2023-04-17 19:44:33 +0200 | 
|---|---|---|
| committer | Alexander Orzechowski <alex@ozal.ski> | 2023-05-30 16:18:19 +0000 | 
| commit | 8e81b4bb4237fe846e3f9eb997404aef2c396da5 (patch) | |
| tree | 3ba24eebe3531a62b14194d3c51730b4b35a9ee0 /examples/fullscreen-shell.c | |
| parent | 8fe29e6bd113044d35efaa538546663538196421 (diff) | |
| download | wlroots-8e81b4bb4237fe846e3f9eb997404aef2c396da5.tar.xz | |
examples: convert to new rendering API
Left out multi-pointer (will be removed) and quads (requires
arbitrary rotation).
Diffstat (limited to 'examples/fullscreen-shell.c')
| -rw-r--r-- | examples/fullscreen-shell.c | 35 | 
1 files changed, 19 insertions, 16 deletions
| diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c index ff8f60c1..f75256f2 100644 --- a/examples/fullscreen-shell.c +++ b/examples/fullscreen-shell.c @@ -47,7 +47,7 @@ struct fullscreen_output {  struct render_data {  	struct wlr_output *output; -	struct wlr_renderer *renderer; +	struct wlr_render_pass *render_pass;  	struct timespec *when;  }; @@ -68,13 +68,14 @@ static void render_surface(struct wlr_surface *surface,  		.height = surface->current.height * output->scale,  	}; -	float matrix[9]; -	enum wl_output_transform transform = -		wlr_output_transform_invert(surface->current.transform); -	wlr_matrix_project_box(matrix, &box, transform, 0, -		output->transform_matrix); +	enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform); +	transform = wlr_output_transform_compose(transform, output->transform); -	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);  } @@ -82,33 +83,35 @@ static void render_surface(struct wlr_surface *surface,  static void output_handle_frame(struct wl_listener *listener, void *data) {  	struct fullscreen_output *output =  		wl_container_of(listener, output, frame); -	struct wlr_renderer *renderer = output->server->renderer;  	struct timespec now;  	clock_gettime(CLOCK_MONOTONIC, &now);  	int 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;  	} -	wlr_renderer_begin(renderer, width, height); - -	float color[4] = {0.3, 0.3, 0.3, 1.0}; -	wlr_renderer_clear(renderer, color); +	wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ +		.color = { 0.3, 0.3, 0.3, 1.0 }, +		.box = { .width = width, .height = height }, +	});  	if (output->surface != NULL) {  		struct render_data rdata = {  			.output = output->wlr_output, -			.renderer = renderer, +			.render_pass = pass,  			.when = &now,  		};  		wlr_surface_for_each_surface(output->surface, render_surface, &rdata);  	} -	wlr_renderer_end(renderer); -	wlr_output_commit(output->wlr_output); +	wlr_render_pass_submit(pass); +	wlr_output_commit_state(output->wlr_output, &state); +	wlr_output_state_finish(&state);  }  static void output_set_surface(struct fullscreen_output *output, | 
