aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-06-13 19:38:10 +0100
committeremersion <contact@emersion.fr>2018-06-13 19:38:10 +0100
commit0378d143d9517c7508b64b81e9267a29ab1951aa (patch)
treec34ebe66d720c4c47278a0b39dd74332890b2588 /include
parentd643361c48231305b8d8a4d93772d1e2c14382a7 (diff)
surface: remove wlr_surface.texture
The texture is managed by the surface's wlr_buffer now. In particular, the buffer can destroy the texture early if it becomes invalid.
Diffstat (limited to 'include')
-rw-r--r--include/wlr/types/wlr_buffer.h11
-rw-r--r--include/wlr/types/wlr_surface.h14
2 files changed, 22 insertions, 3 deletions
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h
index fc348a1c..eabc8b51 100644
--- a/include/wlr/types/wlr_buffer.h
+++ b/include/wlr/types/wlr_buffer.h
@@ -8,8 +8,15 @@
* A client buffer.
*/
struct wlr_buffer {
- struct wl_resource *resource; // can be NULL
- struct wlr_texture *texture; // can be NULL
+ /**
+ * The buffer resource, if any. Will be NULL if the client destroys it.
+ */
+ struct wl_resource *resource;
+ /**
+ * 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;
bool released;
size_t n_refs;
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 64503e78..8517934a 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -69,8 +69,13 @@ struct wlr_subsurface {
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer;
+ /**
+ * The surface's buffer, 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.
+ */
struct wlr_buffer *buffer;
- struct wlr_texture *texture;
struct wlr_surface_state *current, *pending;
const char *role; // the lifetime-bound role or null
@@ -126,6 +131,13 @@ int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
bool wlr_surface_has_buffer(struct wlr_surface *surface);
/**
+ * Get the texture of the buffer currently attached to this surface. Returns
+ * NULL if no buffer is currently attached or if something went wrong with
+ * uploading the buffer.
+ */
+struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);
+
+/**
* Create a new subsurface resource with the provided new ID. If `resource_list`
* is non-NULL, adds the subsurface's resource to the list.
*/