mirror of
https://gitlab.gnome.org/GNOME/libmks.git
synced 2024-12-22 13:45:21 +00:00
Merge branch 'bilelmoussaoui/dmabuf-fix' into 'main'
dmabuf: Only create a new texture when needed See merge request GNOME/libmks!33
This commit is contained in:
commit
91ed701bd6
@ -48,6 +48,7 @@ struct _MksDmabufPaintable
|
|||||||
GdkGLTextureBuilder *builder;
|
GdkGLTextureBuilder *builder;
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
|
guint dmabuf_updated : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static MksDmabufTextureData *
|
static MksDmabufTextureData *
|
||||||
@ -115,9 +116,17 @@ mks_dmabuf_paintable_snapshot (GdkPaintable *paintable,
|
|||||||
g_assert (MKS_IS_DMABUF_PAINTABLE (self));
|
g_assert (MKS_IS_DMABUF_PAINTABLE (self));
|
||||||
g_assert (GDK_IS_SNAPSHOT (snapshot));
|
g_assert (GDK_IS_SNAPSHOT (snapshot));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the widget gets resized, snapshot would be called even
|
||||||
|
* if we didn't receive a new DMABufUpdate call.
|
||||||
|
* So only create a new GLTexture when that happens
|
||||||
|
*/
|
||||||
|
if (self->dmabuf_updated)
|
||||||
|
{
|
||||||
texture_id = gdk_gl_texture_builder_get_id (self->builder);
|
texture_id = gdk_gl_texture_builder_get_id (self->builder);
|
||||||
gl_context = gdk_gl_texture_builder_get_context (self->builder);
|
gl_context = gdk_gl_texture_builder_get_context (self->builder);
|
||||||
|
|
||||||
|
|
||||||
gdk_gl_texture_builder_set_update_texture (self->builder, self->texture);
|
gdk_gl_texture_builder_set_update_texture (self->builder, self->texture);
|
||||||
texture = gdk_gl_texture_builder_build (self->builder,
|
texture = gdk_gl_texture_builder_build (self->builder,
|
||||||
mks_dmabuf_texture_data_free,
|
mks_dmabuf_texture_data_free,
|
||||||
@ -126,6 +135,8 @@ mks_dmabuf_paintable_snapshot (GdkPaintable *paintable,
|
|||||||
// Clear up the update region to not union it with the next UpdateDMABuf call
|
// Clear up the update region to not union it with the next UpdateDMABuf call
|
||||||
gdk_gl_texture_builder_set_update_region (self->builder, NULL);
|
gdk_gl_texture_builder_set_update_region (self->builder, NULL);
|
||||||
g_set_object (&self->texture, texture);
|
g_set_object (&self->texture, texture);
|
||||||
|
self->dmabuf_updated = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
area = GRAPHENE_RECT_INIT (0, 0, width, height);
|
area = GRAPHENE_RECT_INIT (0, 0, width, height);
|
||||||
gtk_snapshot_append_texture (snapshot, self->texture, &area);
|
gtk_snapshot_append_texture (snapshot, self->texture, &area);
|
||||||
@ -246,6 +257,7 @@ mks_dmabuf_paintable_import (MksDmabufPaintable *self,
|
|||||||
accumulated_damages);
|
accumulated_damages);
|
||||||
|
|
||||||
g_clear_pointer (&accumulated_damages, cairo_region_destroy);
|
g_clear_pointer (&accumulated_damages, cairo_region_destroy);
|
||||||
|
self->dmabuf_updated = TRUE;
|
||||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -257,6 +269,7 @@ mks_dmabuf_paintable_new (void)
|
|||||||
g_autoptr(MksDmabufPaintable) self = NULL;
|
g_autoptr(MksDmabufPaintable) self = NULL;
|
||||||
|
|
||||||
self = g_object_new (MKS_TYPE_DMABUF_PAINTABLE, NULL);
|
self = g_object_new (MKS_TYPE_DMABUF_PAINTABLE, NULL);
|
||||||
|
self->dmabuf_updated = FALSE;
|
||||||
self->width = 0;
|
self->width = 0;
|
||||||
self->height = 0;
|
self->height = 0;
|
||||||
return g_steal_pointer (&self);
|
return g_steal_pointer (&self);
|
||||||
|
Loading…
Reference in New Issue
Block a user