mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
wlr_texture: Update wlr_texture_update_from_buffer to use wlr_raster
In the future, these implementations can use compatible texture sources to do fast blit instead.
This commit is contained in:
parent
1e2af8665b
commit
beaede2df0
5 changed files with 23 additions and 23 deletions
|
|
@ -55,8 +55,8 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||||
const struct wlr_renderer_impl *impl);
|
const struct wlr_renderer_impl *impl);
|
||||||
|
|
||||||
struct wlr_texture_impl {
|
struct wlr_texture_impl {
|
||||||
bool (*update_from_buffer)(struct wlr_texture *texture,
|
bool (*update_from_raster)(struct wlr_texture *texture,
|
||||||
struct wlr_buffer *buffer, pixman_region32_t *damage);
|
struct wlr_raster *raster, pixman_region32_t *damage);
|
||||||
void (*destroy)(struct wlr_texture *texture);
|
void (*destroy)(struct wlr_texture *texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/types/wlr_raster.h>
|
#include <wlr/types/wlr_raster.h>
|
||||||
|
|
||||||
struct wlr_buffer;
|
|
||||||
struct wlr_renderer;
|
struct wlr_renderer;
|
||||||
struct wlr_texture_impl;
|
struct wlr_texture_impl;
|
||||||
|
|
||||||
|
|
@ -27,17 +26,17 @@ struct wlr_texture {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a texture with a struct wlr_buffer's contents.
|
* Update a texture with a struct wlr_raster's contents.
|
||||||
*
|
*
|
||||||
* The update might be rejected (in case the texture is immutable, the buffer
|
* The update might be rejected (in case the texture is immutable, the raster
|
||||||
* has an unsupported type/format, etc), so callers must be prepared to fall
|
* doesn't have a compatible source, unsupported type/format, etc), so callers
|
||||||
* back to re-creating the texture from scratch via wlr_texture_from_buffer().
|
* must be prepared to fall back.
|
||||||
*
|
*
|
||||||
* The damage can be used by the renderer as an optimization: only the supplied
|
* The damage can be used by the renderer as an optimization: only the supplied
|
||||||
* region needs to be updated.
|
* region needs to be updated.
|
||||||
*/
|
*/
|
||||||
bool wlr_texture_update_from_buffer(struct wlr_texture *texture,
|
bool wlr_texture_update_from_raster(struct wlr_texture *texture,
|
||||||
struct wlr_buffer *buffer, pixman_region32_t *damage);
|
struct wlr_raster *raster, pixman_region32_t *damage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the texture.
|
* Destroys the texture.
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,10 @@ static bool check_stride(const struct wlr_pixel_format_info *fmt,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gles2_texture_update_from_buffer(struct wlr_texture *wlr_texture,
|
static bool gles2_texture_update_from_raster(struct wlr_texture *wlr_texture,
|
||||||
struct wlr_buffer *buffer, pixman_region32_t *damage) {
|
struct wlr_raster *raster, pixman_region32_t *damage) {
|
||||||
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
|
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
|
||||||
|
struct wlr_buffer *buffer = raster->buffer;
|
||||||
|
|
||||||
if (texture->target != GL_TEXTURE_2D || texture->image != EGL_NO_IMAGE_KHR) {
|
if (texture->target != GL_TEXTURE_2D || texture->image != EGL_NO_IMAGE_KHR) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -178,7 +179,7 @@ static void gles2_texture_unref(struct wlr_texture *wlr_texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wlr_texture_impl texture_impl = {
|
static const struct wlr_texture_impl texture_impl = {
|
||||||
.update_from_buffer = gles2_texture_update_from_buffer,
|
.update_from_raster = gles2_texture_update_from_raster,
|
||||||
.destroy = gles2_texture_unref,
|
.destroy = gles2_texture_unref,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,9 +136,10 @@ static bool write_pixels(struct wlr_texture *wlr_texture,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vulkan_texture_update_from_buffer(struct wlr_texture *wlr_texture,
|
static bool vulkan_texture_update_from_raster(struct wlr_texture *wlr_texture,
|
||||||
struct wlr_buffer *buffer, pixman_region32_t *damage) {
|
struct wlr_raster *raster, pixman_region32_t *damage) {
|
||||||
struct wlr_vk_texture *texture = vulkan_get_texture(wlr_texture);
|
struct wlr_vk_texture *texture = vulkan_get_texture(wlr_texture);
|
||||||
|
struct wlr_buffer *buffer = raster->buffer;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
uint32_t format;
|
uint32_t format;
|
||||||
|
|
@ -224,7 +225,7 @@ static void vulkan_texture_unref(struct wlr_texture *wlr_texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wlr_texture_impl texture_impl = {
|
static const struct wlr_texture_impl texture_impl = {
|
||||||
.update_from_buffer = vulkan_texture_update_from_buffer,
|
.update_from_raster = vulkan_texture_update_from_raster,
|
||||||
.destroy = vulkan_texture_unref,
|
.destroy = vulkan_texture_unref,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,18 @@ void wlr_texture_destroy(struct wlr_texture *texture) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_texture_update_from_buffer(struct wlr_texture *texture,
|
bool wlr_texture_update_from_raster(struct wlr_texture *texture,
|
||||||
struct wlr_buffer *buffer, pixman_region32_t *damage) {
|
struct wlr_raster *raster, pixman_region32_t *damage) {
|
||||||
if (!texture->impl->update_from_buffer) {
|
if (!texture->impl->update_from_raster) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (texture->width != (uint32_t)buffer->width ||
|
if (texture->width != raster->width || texture->height != raster->height) {
|
||||||
texture->height != (uint32_t)buffer->height) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const pixman_box32_t *extents = pixman_region32_extents(damage);
|
const pixman_box32_t *extents = pixman_region32_extents(damage);
|
||||||
if (extents->x1 < 0 || extents->y1 < 0 || extents->x2 > buffer->width ||
|
if (extents->x1 < 0 || extents->y1 < 0 || extents->x2 > (int32_t)raster->width ||
|
||||||
extents->y2 > buffer->height) {
|
extents->y2 > (int32_t)raster->height) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return texture->impl->update_from_buffer(texture, buffer, damage);
|
return texture->impl->update_from_raster(texture, raster, damage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue