mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
wlr_texture: Expose owning renderer
This commit is contained in:
parent
f103dc74d8
commit
db0e962368
7 changed files with 14 additions and 6 deletions
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue