mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
render/texture: drop wlr_texture_is_opaque
Whether a texture is opaque or not doesn't depend on the renderer at all, it just depends on the source buffer. Instead of forcing all renderers to implement wlr_texture_impl.is_opaque, let's move this in common code and use the wlr_buffer format to know whether a texture will be opaque.
This commit is contained in:
parent
f28c0e2046
commit
29291cb47c
10 changed files with 42 additions and 35 deletions
|
|
@ -29,11 +29,6 @@ struct wlr_gles2_texture *gles2_get_texture(
|
|||
return (struct wlr_gles2_texture *)wlr_texture;
|
||||
}
|
||||
|
||||
static bool gles2_texture_is_opaque(struct wlr_texture *wlr_texture) {
|
||||
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
|
||||
return !texture->has_alpha;
|
||||
}
|
||||
|
||||
static bool check_stride(const struct wlr_pixel_format_info *fmt,
|
||||
uint32_t stride, uint32_t width) {
|
||||
if (stride % (fmt->bpp / 8) != 0) {
|
||||
|
|
@ -161,7 +156,6 @@ static void gles2_texture_unref(struct wlr_texture *wlr_texture) {
|
|||
}
|
||||
|
||||
static const struct wlr_texture_impl texture_impl = {
|
||||
.is_opaque = gles2_texture_is_opaque,
|
||||
.write_pixels = gles2_texture_write_pixels,
|
||||
.destroy = gles2_texture_unref,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@ static struct wlr_pixman_texture *get_texture(
|
|||
return (struct wlr_pixman_texture *)wlr_texture;
|
||||
}
|
||||
|
||||
static bool texture_is_opaque(struct wlr_texture *wlr_texture) {
|
||||
struct wlr_pixman_texture *texture = get_texture(wlr_texture);
|
||||
return !texture->format_info->has_alpha;
|
||||
}
|
||||
|
||||
static void texture_destroy(struct wlr_texture *wlr_texture) {
|
||||
struct wlr_pixman_texture *texture = get_texture(wlr_texture);
|
||||
wl_list_remove(&texture->link);
|
||||
|
|
@ -61,7 +56,6 @@ static void texture_destroy(struct wlr_texture *wlr_texture) {
|
|||
}
|
||||
|
||||
static const struct wlr_texture_impl texture_impl = {
|
||||
.is_opaque = texture_is_opaque,
|
||||
.destroy = texture_destroy,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -33,14 +33,6 @@ static VkImageAspectFlagBits mem_plane_aspect(unsigned i) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool vulkan_texture_is_opaque(struct wlr_texture *wlr_texture) {
|
||||
struct wlr_vk_texture *texture = vulkan_get_texture(wlr_texture);
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(
|
||||
texture->format->drm_format);
|
||||
assert(format_info);
|
||||
return !format_info->has_alpha;
|
||||
}
|
||||
|
||||
// Will transition the texture to shaderReadOnlyOptimal layout for reading
|
||||
// from fragment shader later on
|
||||
static bool write_pixels(struct wlr_texture *wlr_texture,
|
||||
|
|
@ -199,7 +191,6 @@ static void vulkan_texture_unref(struct wlr_texture *wlr_texture) {
|
|||
}
|
||||
|
||||
static const struct wlr_texture_impl texture_impl = {
|
||||
.is_opaque = vulkan_texture_is_opaque,
|
||||
.write_pixels = vulkan_texture_write_pixels,
|
||||
.destroy = vulkan_texture_unref,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,13 +71,6 @@ struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer,
|
|||
return renderer->impl->texture_from_buffer(renderer, buffer);
|
||||
}
|
||||
|
||||
bool wlr_texture_is_opaque(struct wlr_texture *texture) {
|
||||
if (!texture->impl->is_opaque) {
|
||||
return false;
|
||||
}
|
||||
return texture->impl->is_opaque(texture);
|
||||
}
|
||||
|
||||
bool wlr_texture_write_pixels(struct wlr_texture *texture,
|
||||
uint32_t stride, uint32_t width, uint32_t height,
|
||||
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue