Merge branch 'surface-texture-v2' into 'master'

Replace wlr_client_buffer with wlr_surface_texture, take 2

See merge request wlroots/wlroots!4437
This commit is contained in:
Simon Ser 2024-03-14 11:40:18 +00:00
commit 8fa5b78f66
13 changed files with 209 additions and 225 deletions

View file

@ -24,6 +24,10 @@ struct wlr_texture {
uint32_t width, height;
struct wlr_renderer *renderer;
struct {
struct wl_signal destroy;
} events;
};
struct wlr_texture_read_pixels_options {

View file

@ -132,33 +132,4 @@ bool wlr_buffer_begin_data_ptr_access(struct wlr_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride);
void wlr_buffer_end_data_ptr_access(struct wlr_buffer *buffer);
/**
* A client buffer.
*/
struct wlr_client_buffer {
struct wlr_buffer base;
/**
* The buffer's texture, if any. A buffer will not have a texture if the
* client destroys the buffer before it has been released.
*/
struct wlr_texture *texture;
/**
* The buffer this client buffer was created from. NULL if destroyed.
*/
struct wlr_buffer *source;
// private state
struct wl_listener source_destroy;
size_t n_ignore_locks;
};
/**
* Get a client buffer from a generic buffer. If the buffer isn't a client
* buffer, returns NULL.
*/
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer);
#endif

View file

@ -119,16 +119,29 @@ struct wlr_surface_output {
struct wl_listener destroy;
};
struct wlr_surface_texture {
struct wlr_texture *texture;
// The buffer this surface texture was created from. NULL if released.
struct wlr_buffer *buffer;
// True if the texture won't be mutated by client surface commits.
bool locked;
// private state
struct wl_listener buffer_release;
bool dropped;
};
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer; // may be NULL
/**
* The surface's buffer, if any. A surface has an attached buffer when it
* The surface's texture, if any. A surface has an attached buffer when it
* commits with a non-null buffer in its pending state. A surface will not
* have a buffer if it has never committed one, has committed a null buffer,
* or something went wrong with uploading the buffer.
* have a texture if it has never committed one, has committed a null
* buffer, or something went wrong with uploading the buffer.
*/
struct wlr_client_buffer *buffer;
struct wlr_surface_texture *texture;
/**
* The last commit's buffer damage, in buffer-local coordinates. This
* contains both the damage accumulated by the client via
@ -257,6 +270,9 @@ struct wlr_compositor {
typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
int sx, int sy, void *data);
void wlr_surface_texture_lock(struct wlr_surface_texture *surf_tex);
void wlr_surface_texture_unlock(struct wlr_surface_texture *surf_tex);
/**
* Set the lifetime role for this surface.
*

View file

@ -184,6 +184,7 @@ struct wlr_scene_buffer {
uint64_t active_outputs;
struct wlr_texture *texture;
bool own_texture;
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
bool own_buffer;
@ -191,6 +192,7 @@ struct wlr_scene_buffer {
bool buffer_is_opaque;
struct wl_listener buffer_release;
struct wl_listener texture_destroy;
};
/** A viewport for an output in the scene-graph */
@ -399,6 +401,12 @@ void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer, const pixman_region32_t *region);
/**
* Sets the buffer's backing texture.
*/
void wlr_scene_buffer_set_texture(struct wlr_scene_buffer *scene_buffer,
struct wlr_texture *texture);
/**
* Sets the buffer's opaque region. This is an optimization hint used to
* determine if buffers which reside under this one need to be rendered or not.