xwayland: Drop the separate refcount for the xwl_pixmap
Instead, bump the pixmap's refcount at the bottom of post_damage to reflect the compositor's hold on the buffer, and "destroy" the pixmap in the buffer release callback (which will dec the pixmap's refcount and free if necessary). Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
4e670f1281
commit
affc474525
|
@ -84,10 +84,6 @@ struct xwl_pixmap {
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
struct xwl_screen *xwl_screen;
|
struct xwl_screen *xwl_screen;
|
||||||
|
|
||||||
/* The stream and associated resources have their own lifetime separate
|
|
||||||
* from the pixmap's */
|
|
||||||
int refcount;
|
|
||||||
|
|
||||||
EGLStreamKHR stream;
|
EGLStreamKHR stream;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
};
|
};
|
||||||
|
@ -281,9 +277,6 @@ xwl_eglstream_unref_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
|
||||||
{
|
{
|
||||||
struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
|
struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
|
||||||
|
|
||||||
if (--xwl_pixmap->refcount >= 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* If we're using this stream in the current egl context, unbind it so the
|
/* If we're using this stream in the current egl context, unbind it so the
|
||||||
* driver doesn't keep it around until the next eglMakeCurrent()
|
* driver doesn't keep it around until the next eglMakeCurrent()
|
||||||
* don't have to keep it around until something else changes the surface
|
* don't have to keep it around until something else changes the surface
|
||||||
|
@ -341,13 +334,6 @@ xwl_eglstream_set_window_pixmap(WindowPtr window, PixmapPtr pixmap)
|
||||||
* useless
|
* useless
|
||||||
*/
|
*/
|
||||||
pending->is_valid = FALSE;
|
pending->is_valid = FALSE;
|
||||||
|
|
||||||
/* The compositor may still be using the stream, so we can't destroy
|
|
||||||
* it yet. We'll only have a guarantee that the stream is safe to
|
|
||||||
* destroy once we receive the pending wl_display_sync() for this
|
|
||||||
* stream
|
|
||||||
*/
|
|
||||||
pending->xwl_pixmap->refcount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xwl_screen->screen->SetWindowPixmap = xwl_eglstream->SetWindowPixmap;
|
xwl_screen->screen->SetWindowPixmap = xwl_eglstream->SetWindowPixmap;
|
||||||
|
@ -481,10 +467,8 @@ xwl_eglstream_queue_pending_stream(struct xwl_screen *xwl_screen,
|
||||||
static void
|
static void
|
||||||
xwl_eglstream_buffer_release_callback(void *data, struct wl_buffer *wl_buffer)
|
xwl_eglstream_buffer_release_callback(void *data, struct wl_buffer *wl_buffer)
|
||||||
{
|
{
|
||||||
struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(data);
|
/* drop the reference we took in post_damage, freeing if necessary */
|
||||||
|
dixDestroyPixmap(data, 0);
|
||||||
xwl_pixmap_buffer_release_cb(data, wl_buffer);
|
|
||||||
xwl_eglstream_unref_pixmap_stream(xwl_pixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_buffer_listener xwl_eglstream_buffer_release_listener = {
|
static const struct wl_buffer_listener xwl_eglstream_buffer_release_listener = {
|
||||||
|
@ -510,7 +494,6 @@ xwl_eglstream_create_pending_stream(struct xwl_screen *xwl_screen,
|
||||||
xwl_glamor_egl_make_current(xwl_screen);
|
xwl_glamor_egl_make_current(xwl_screen);
|
||||||
|
|
||||||
xwl_pixmap->xwl_screen = xwl_screen;
|
xwl_pixmap->xwl_screen = xwl_screen;
|
||||||
xwl_pixmap->refcount = 1;
|
|
||||||
xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
|
xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
|
||||||
stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
|
stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
|
||||||
xwl_pixmap->stream);
|
xwl_pixmap->stream);
|
||||||
|
@ -624,9 +607,8 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
|
||||||
glBindVertexArray(saved_vao);
|
glBindVertexArray(saved_vao);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
/* After this we will hand off the eglstream's wl_buffer to the
|
/* hang onto the pixmap until the compositor has released it */
|
||||||
* compositor, which will own it until it sends a release() event. */
|
pixmap->refcnt++;
|
||||||
xwl_pixmap->refcount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue