diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index 32897a6b73..ce53e568fb 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -151,7 +151,8 @@ gdk_gl_texture_find_format (GdkGLContext *context, for (format = 0; format < GDK_MEMORY_N_FORMATS; format++) { - GLenum q_internal_format, q_format, q_type; + GLint q_internal_format; + GLenum q_format, q_type; GLint q_swizzle[4]; if (gdk_memory_format_alpha (format) != alpha) @@ -181,7 +182,8 @@ gdk_gl_texture_do_download (GdkGLTexture *self, GdkMemoryFormat format; gsize expected_stride; Download *download = download_; - GLenum gl_internal_format, gl_format, gl_type; + GLint gl_internal_format; + GLenum gl_format, gl_type; GLint gl_swizzle[4]; format = gdk_texture_get_format (texture), @@ -230,7 +232,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self, else { GdkMemoryFormat actual_format; - GLint gl_read_format, gl_read_type; + GLenum gl_read_format, gl_read_type; GLuint fbo; glGenFramebuffers (1, &fbo); @@ -238,9 +240,15 @@ gdk_gl_texture_do_download (GdkGLTexture *self, glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0); if (gdk_gl_context_check_version (context, "4.3", "3.1")) { - glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format); - glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type); - if (!gdk_gl_texture_find_format (context, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format)) + GLint read_format, read_type; + glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &read_format); + glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &read_type); + if (gdk_gl_texture_find_format (context, gdk_memory_format_alpha (format), read_format, read_type, &actual_format)) + { + gl_read_format = read_format; + gl_read_type = read_type; + } + else { actual_format = gdk_memory_depth_get_format (gdk_memory_format_get_depth (format)); if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT) diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c index eb6fafe297..92b5f3c3a5 100644 --- a/gdk/gdkmemoryformat.c +++ b/gdk/gdkmemoryformat.c @@ -333,9 +333,9 @@ struct _GdkMemoryFormatDescription GdkMemoryDepth depth; const GdkMemoryFormat *fallbacks; struct { - guint internal_format; - guint format; - guint type; + GLint internal_format; + GLenum format; + GLenum type; GLint swizzle[4]; /* -1 if none exists, ie the format is already RGBA * or the format doesn't have 4 channels */ @@ -1255,9 +1255,9 @@ gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth) void gdk_memory_format_gl_format (GdkMemoryFormat format, - guint *out_internal_format, - guint *out_format, - guint *out_type, + GLint *out_internal_format, + GLenum *out_format, + GLenum *out_type, GLint out_swizzle[4]) { *out_internal_format = memory_formats[format].gl.internal_format; @@ -1287,9 +1287,9 @@ gdk_memory_format_gl_format (GdkMemoryFormat format, gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat format, GdkMemoryFormat *out_actual_format, - guint *out_internal_format, - guint *out_format, - guint *out_type, + GLint *out_internal_format, + GLenum *out_format, + GLenum *out_type, GLint out_swizzle[4]) { GdkMemoryFormat actual = memory_formats[format].gl.rgba_format; diff --git a/gdk/gdkmemoryformatprivate.h b/gdk/gdkmemoryformatprivate.h index 94764a3ee5..9d241de3f0 100644 --- a/gdk/gdkmemoryformatprivate.h +++ b/gdk/gdkmemoryformatprivate.h @@ -51,15 +51,15 @@ GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth GdkMemoryFormat gdk_memory_depth_get_format (GdkMemoryDepth depth) G_GNUC_CONST; GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth) G_GNUC_CONST; void gdk_memory_format_gl_format (GdkMemoryFormat format, - guint *out_internal_format, - guint *out_format, - guint *out_type, + GLint *out_internal_format, + GLenum *out_format, + GLenum *out_type, GLint out_swizzle[4]); gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat format, GdkMemoryFormat *out_actual_format, - guint *out_internal_format, - guint *out_format, - guint *out_type, + GLint *out_internal_format, + GLenum *out_format, + GLenum *out_type, GLint out_swizzle[4]); void gdk_memory_convert (guchar *dest_data, diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index aef0380dca..42b492785e 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -1477,9 +1477,9 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self) static GdkMemoryFormat memory_format_gl_format (GskGLCommandQueue *self, GdkMemoryFormat data_format, - guint *gl_internalformat, - guint *gl_format, - guint *gl_type, + GLint *gl_internalformat, + GLenum *gl_format, + GLenum *gl_type, GLint gl_swizzle[4]) { GdkGLMemoryFlags flags; @@ -1561,7 +1561,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self, GdkTextureDownloader downloader; GdkMemoryFormat data_format; int width, height; - GLenum gl_internalformat; + GLint gl_internalformat; GLenum gl_format; GLenum gl_type; GLint gl_swizzle[4]; @@ -1659,7 +1659,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self, G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME; int width, height; GdkMemoryFormat data_format; - GLenum gl_internalformat; + GLint gl_internalformat; GLenum gl_format; GLenum gl_type; GLint gl_swizzle[4];