From b9460ab724fb8df18d22cb0e10cf6e07646fc1cf Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 25 Dec 2020 12:21:29 +0100 Subject: [PATCH] Stop using wlr_texture_get_size Just use wlr_texture.{width,height} directly. --- backend/drm/drm.c | 6 ++---- backend/wayland/output.c | 6 ++---- examples/touch.c | 7 ++----- render/wlr_renderer.c | 8 ++++++-- types/wlr_buffer.c | 5 ++--- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 26cf99df..06a58d50 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -915,10 +915,8 @@ static bool drm_connector_set_cursor(struct wlr_output *output, plane->cursor_enabled = false; if (texture != NULL) { - int width, height; - wlr_texture_get_size(texture, &width, &height); - width = width * output->scale / scale; - height = height * output->scale / scale; + int width = texture->width * output->scale / scale; + int height = texture->height * output->scale / scale; if (width > (int)plane->surf.width || height > (int)plane->surf.height) { wlr_drm_conn_log(conn, WLR_ERROR, "Cursor too large (max %dx%d)", diff --git a/backend/wayland/output.c b/backend/wayland/output.c index db9056d5..6bc84dcb 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -402,10 +402,8 @@ static bool output_set_cursor(struct wlr_output *wlr_output, struct wl_surface *surface = output->cursor.surface; if (texture != NULL) { - int width, height; - wlr_texture_get_size(texture, &width, &height); - width = width * wlr_output->scale / scale; - height = height * wlr_output->scale / scale; + int width = texture->width * wlr_output->scale / scale; + int height = texture->height * wlr_output->scale / scale; if (output->cursor.swapchain == NULL || output->cursor.swapchain->width != width || diff --git a/examples/touch.c b/examples/touch.c index 3d18dfd0..7f8980e1 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -78,13 +78,10 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height); wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1}); - int tex_width, tex_height; - wlr_texture_get_size(sample->cat_texture, &tex_width, &tex_height); - struct touch_point *p; wl_list_for_each(p, &sample->touch_points, link) { - int x = (int)(p->x * width) - tex_width / 2; - int y = (int)(p->y * height) - tex_height / 2; + 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, wlr_output->transform_matrix, x, y, 1.0f); } diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index b8374be9..fc224467 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -76,8 +76,12 @@ void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) { bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture, const float projection[static 9], int x, int y, float alpha) { - struct wlr_box box = { .x = x, .y = y }; - wlr_texture_get_size(texture, &box.width, &box.height); + struct wlr_box box = { + .x = x, + .y = y, + .width = texture->width, + .height = texture->height, + }; float matrix[9]; wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c index 0878c302..0ead9e09 100644 --- a/types/wlr_buffer.c +++ b/types/wlr_buffer.c @@ -277,9 +277,8 @@ struct wlr_client_buffer *wlr_client_buffer_apply_damage( int32_t width = wl_shm_buffer_get_width(shm_buf); int32_t height = wl_shm_buffer_get_height(shm_buf); - int32_t texture_width, texture_height; - wlr_texture_get_size(buffer->texture, &texture_width, &texture_height); - if (width != texture_width || height != texture_height) { + if ((uint32_t)width != buffer->texture->width || + (uint32_t)height != buffer->texture->height) { return NULL; }