wlr_texture: Expose owning renderer

This commit is contained in:
Alexander Orzechowski 2022-12-01 04:41:43 -05:00
parent f103dc74d8
commit db0e962368
7 changed files with 14 additions and 6 deletions

View file

@ -59,7 +59,7 @@ struct wlr_texture_impl {
void (*destroy)(struct wlr_texture *texture); void (*destroy)(struct wlr_texture *texture);
}; };
void wlr_texture_init(struct wlr_texture *texture, void wlr_texture_init(struct wlr_texture *texture, struct wlr_renderer *rendener,
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height); const struct wlr_texture_impl *impl, uint32_t width, uint32_t height);
#endif #endif

View file

@ -21,6 +21,8 @@ struct wlr_texture_impl;
struct wlr_texture { struct wlr_texture {
const struct wlr_texture_impl *impl; const struct wlr_texture_impl *impl;
uint32_t width, height; uint32_t width, height;
struct wlr_renderer *renderer;
}; };
/** /**

View file

@ -174,7 +174,8 @@ static struct wlr_gles2_texture *gles2_texture_create(
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;
} }
wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height); wlr_texture_init(&texture->wlr_texture, &renderer->wlr_renderer,
&texture_impl, width, height);
texture->renderer = renderer; texture->renderer = renderer;
wl_list_insert(&renderer->textures, &texture->link); wl_list_insert(&renderer->textures, &texture->link);
return texture; return texture;

View file

@ -354,8 +354,8 @@ static struct wlr_pixman_texture *pixman_texture_create(
return NULL; return NULL;
} }
wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height); wlr_texture_init(&texture->wlr_texture, &renderer->wlr_renderer,
texture->renderer = renderer; &texture_impl, width, height);
texture->format_info = drm_get_pixel_format_info(drm_format); texture->format_info = drm_get_pixel_format_info(drm_format);
if (!texture->format_info) { if (!texture->format_info) {

View file

@ -252,7 +252,8 @@ static struct wlr_vk_texture *vulkan_texture_create(
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;
} }
wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height); wlr_texture_init(&texture->wlr_texture, &renderer->wlr_renderer,
&texture_impl, width, height);
texture->renderer = renderer; texture->renderer = renderer;
wl_list_insert(&renderer->textures, &texture->link); wl_list_insert(&renderer->textures, &texture->link);
return texture; return texture;

View file

@ -153,6 +153,7 @@ bool wlr_render_subtexture_with_matrix(struct wlr_renderer *r,
struct wlr_texture *texture, const struct wlr_fbox *box, struct wlr_texture *texture, const struct wlr_fbox *box,
const float matrix[static 9], float alpha) { const float matrix[static 9], float alpha) {
assert(r->rendering); assert(r->rendering);
assert(texture->renderer == r);
return r->impl->render_subtexture_with_matrix(r, texture, return r->impl->render_subtexture_with_matrix(r, texture,
box, matrix, alpha); box, matrix, alpha);
} }

View file

@ -6,9 +6,12 @@
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include "types/wlr_buffer.h" #include "types/wlr_buffer.h"
void wlr_texture_init(struct wlr_texture *texture, void wlr_texture_init(struct wlr_texture *texture, struct wlr_renderer *renderer,
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) { const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) {
assert(renderer);
memset(texture, 0, sizeof(*texture)); memset(texture, 0, sizeof(*texture));
texture->renderer = renderer;
texture->impl = impl; texture->impl = impl;
texture->width = width; texture->width = width;
texture->height = height; texture->height = height;