mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
wlr_renderer: Switch texture rendering functions to take wlr_raster
Implements automatic texture uploading as both wlr_scene and cursor handling both are simplified as a result.
This commit is contained in:
parent
45ad3d47ad
commit
248a33a026
20 changed files with 142 additions and 166 deletions
|
|
@ -56,9 +56,8 @@ static void render_surface(struct wlr_surface *surface,
|
|||
struct render_data *rdata = data;
|
||||
struct wlr_output *output = rdata->output;
|
||||
|
||||
struct wlr_texture *texture = wlr_texture_from_buffer(output->renderer,
|
||||
surface->current.buffer);
|
||||
if (texture == NULL) {
|
||||
struct wlr_raster *raster = wlr_raster_create(surface->current.buffer);
|
||||
if (raster == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -75,11 +74,11 @@ static void render_surface(struct wlr_surface *surface,
|
|||
wlr_matrix_project_box(matrix, &box, transform, 0,
|
||||
output->transform_matrix);
|
||||
|
||||
wlr_render_texture_with_matrix(rdata->renderer, texture, matrix, 1);
|
||||
wlr_render_raster_with_matrix(rdata->renderer, raster, matrix, 1);
|
||||
|
||||
wlr_surface_send_frame_done(surface, rdata->when);
|
||||
|
||||
wlr_texture_destroy(texture);
|
||||
wlr_raster_unlock(raster);
|
||||
}
|
||||
|
||||
static void output_handle_frame(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ struct sample_state {
|
|||
struct wl_listener new_input;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wlr_raster *cat_raster;
|
||||
struct wlr_output_layout *layout;
|
||||
float x_offs, y_offs;
|
||||
float x_vel, y_vel;
|
||||
|
|
@ -134,7 +134,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_output_layout_output_coords(sample->layout, output->output,
|
||||
&local_x, &local_y);
|
||||
|
||||
wlr_render_texture(sample->renderer, sample->cat_texture,
|
||||
wlr_render_raster(sample->renderer, sample->cat_raster,
|
||||
wlr_output->transform_matrix, local_x, local_y, 1.0f);
|
||||
}
|
||||
|
||||
|
|
@ -279,9 +279,8 @@ int main(int argc, char *argv[]) {
|
|||
state.new_input.notify = new_input_notify;
|
||||
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
state.cat_texture = wlr_texture_from_pixels(state.renderer,
|
||||
DRM_FORMAT_ABGR8888, cat_tex.width * 4, cat_tex.width, cat_tex.height,
|
||||
cat_tex.pixel_data);
|
||||
state.cat_raster = wlr_raster_from_pixels(DRM_FORMAT_ABGR8888,
|
||||
cat_tex.width * 4, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
|
|
@ -292,7 +291,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
wl_display_run(display);
|
||||
|
||||
wlr_texture_destroy(state.cat_texture);
|
||||
wlr_raster_unlock(state.cat_raster);
|
||||
|
||||
wl_display_destroy(state.display);
|
||||
wlr_output_layout_destroy(state.layout);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ struct sample_state {
|
|||
struct timespec last_frame;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wlr_raster *cat_raster;
|
||||
struct wl_list outputs;
|
||||
enum wl_output_transform transform;
|
||||
};
|
||||
|
|
@ -65,7 +65,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
for (int y = -128 + (int)sample_output->y_offs; y < height; y += 128) {
|
||||
for (int x = -128 + (int)sample_output->x_offs; x < width; x += 128) {
|
||||
wlr_render_texture(sample->renderer, sample->cat_texture,
|
||||
wlr_render_raster(sample->renderer, sample->cat_raster,
|
||||
wlr_output->transform_matrix, x, y, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
@ -256,10 +256,9 @@ int main(int argc, char *argv[]) {
|
|||
wlr_backend_destroy(wlr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
state.cat_texture = wlr_texture_from_pixels(state.renderer,
|
||||
DRM_FORMAT_ABGR8888, cat_tex.width * 4, cat_tex.width, cat_tex.height,
|
||||
cat_tex.pixel_data);
|
||||
if (!state.cat_texture) {
|
||||
state.cat_raster = wlr_raster_from_pixels(DRM_FORMAT_ABGR8888,
|
||||
cat_tex.width * 4, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
||||
if (!state.cat_raster) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -273,6 +272,6 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
wl_display_run(display);
|
||||
|
||||
wlr_texture_destroy(state.cat_texture);
|
||||
wlr_raster_unlock(state.cat_raster);
|
||||
wl_display_destroy(display);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct sample_state {
|
|||
struct wl_display *display;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wlr_raster *cat_raster;
|
||||
struct wl_list touch_points;
|
||||
struct timespec last_frame;
|
||||
struct wl_listener new_output;
|
||||
|
|
@ -81,9 +81,9 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct touch_point *p;
|
||||
wl_list_for_each(p, &sample->touch_points, link) {
|
||||
int x = (int)(p->x * width) - sample->cat_texture->width / 2;
|
||||
int y = (int)(p->y * height) - sample->cat_texture->height / 2;
|
||||
wlr_render_texture(sample->renderer, sample->cat_texture,
|
||||
int x = (int)(p->x * width) - sample->cat_raster->width / 2;
|
||||
int y = (int)(p->y * height) - sample->cat_raster->height / 2;
|
||||
wlr_render_raster(sample->renderer, sample->cat_raster,
|
||||
wlr_output->transform_matrix, x, y, 1.0f);
|
||||
}
|
||||
|
||||
|
|
@ -264,10 +264,9 @@ int main(int argc, char *argv[]) {
|
|||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
state.cat_texture = wlr_texture_from_pixels(state.renderer,
|
||||
DRM_FORMAT_ARGB8888, cat_tex.width * 4, cat_tex.width, cat_tex.height,
|
||||
cat_tex.pixel_data);
|
||||
if (!state.cat_texture) {
|
||||
state.cat_raster = wlr_raster_from_pixels(DRM_FORMAT_ARGB8888,
|
||||
cat_tex.width * 4, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
|
||||
if (!state.cat_raster) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -281,6 +280,6 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
wl_display_run(display);
|
||||
|
||||
wlr_texture_destroy(state.cat_texture);
|
||||
wlr_raster_unlock(state.cat_raster);
|
||||
wl_display_destroy(display);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue