diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index c8f3551455..cc5538a320 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -44,6 +44,8 @@ #include #include +#include + G_DEFINE_TYPE (GskGLDriver, gsk_gl_driver, G_TYPE_OBJECT) @@ -758,7 +760,15 @@ gsk_gl_driver_load_texture (GskGLDriver *self, return t->texture_id; } - if (GDK_IS_GL_TEXTURE (texture)) + if (GDK_IS_DMABUF_TEXTURE (texture)) + { + texture_id = gdk_gl_context_import_dmabuf (context, + gdk_texture_get_width (texture), + gdk_texture_get_height (texture), + gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture)), + GL_TEXTURE_2D); + } + else if (GDK_IS_GL_TEXTURE (texture)) { GdkGLTexture *gl_texture = (GdkGLTexture *) texture; GdkGLContext *texture_context = gdk_gl_texture_get_context (gl_texture); diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c index 8dbe6df97f..efe6a59850 100644 --- a/gsk/gl/gskglrenderjob.c +++ b/gsk/gl/gskglrenderjob.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include "ninesliceprivate.h" #include "fp16private.h" + #define ORTHO_NEAR_PLANE -10000 #define ORTHO_FAR_PLANE 10000 #define MAX_GRADIENT_STOPS 6 @@ -3630,16 +3632,12 @@ gsk_gl_render_job_upload_texture (GskGLRenderJob *job, gboolean ensure_mipmap, GskGLRenderOffscreen *offscreen) { - GdkGLTexture *gl_texture = NULL; - - if (GDK_IS_GL_TEXTURE (texture)) - gl_texture = GDK_GL_TEXTURE (texture); - + /* Don't put GL or dmabuf textures into icon caches, they are already on the GPU side */ if (!ensure_mipmap && gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons_library, texture->width, texture->height) && - !gl_texture) + !(GDK_IS_GL_TEXTURE (texture) || GDK_IS_DMABUF_TEXTURE (texture))) { const GskGLIconData *icon_data; @@ -3653,16 +3651,18 @@ gsk_gl_render_job_upload_texture (GskGLRenderJob *job, /* Only generate a mipmap if it does not make use reupload * a GL texture which we could otherwise use directly. */ - if (gl_texture && - gdk_gl_context_is_shared (gdk_gl_texture_get_context (gl_texture), job->command_queue->context)) - ensure_mipmap = gdk_gl_texture_has_mipmap (gl_texture); + if (GDK_IS_GL_TEXTURE (texture) && + gdk_gl_context_is_shared (gdk_gl_texture_get_context (GDK_GL_TEXTURE (texture)), + job->command_queue->context)) + ensure_mipmap = gdk_gl_texture_has_mipmap (GDK_GL_TEXTURE (texture)); offscreen->texture_id = gsk_gl_driver_load_texture (job->driver, texture, ensure_mipmap); init_full_texture_region (offscreen); offscreen->has_mipmap = ensure_mipmap; - if (gl_texture && offscreen->texture_id == gdk_gl_texture_get_id (gl_texture)) - offscreen->sync = gdk_gl_texture_get_sync (gl_texture); + if (GDK_IS_GL_TEXTURE (texture) && + offscreen->texture_id == gdk_gl_texture_get_id (GDK_GL_TEXTURE (texture))) + offscreen->sync = gdk_gl_texture_get_sync (GDK_GL_TEXTURE (texture)); } }