ngl: Mark backbuffers as srgb

When the surface tells us that a surface is using an sRGB backbuffer,
set the corresponding flag on the backbuffer.
This commit is contained in:
Matthias Clasen 2024-06-17 13:46:13 -04:00 committed by Benjamin Otte
parent dfd181d7d5
commit db3b3c62bb
4 changed files with 17 additions and 2 deletions

View File

@ -72,6 +72,7 @@ GskGpuImage *
gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context,
GdkMemoryFormat format,
gboolean is_srgb,
gsize width,
gsize height)
{
@ -94,7 +95,18 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
&self->gl_type,
swizzle);
self->gl_internal_format = gl_internal_format;
if (is_srgb)
{
if (gl_internal_srgb_format != -1)
self->gl_internal_format = gl_internal_srgb_format;
else /* FIXME: Happens when the driver uses formats that it does not expose */
self->gl_internal_format = gl_internal_format;
flags |= GSK_GPU_IMAGE_SRGB;
}
else
{
self->gl_internal_format = gl_internal_format;
}
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, format, width, height);

View File

@ -13,6 +13,7 @@ G_DECLARE_FINAL_TYPE (GskGLImage, gsk_gl_image, GSK, GL_IMAGE, GskGpuImage)
GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context,
GdkMemoryFormat format,
gboolean is_srgb,
gsize width,
gsize height);
GskGpuImage * gsk_gl_image_new (GskGLDevice *device,

View File

@ -114,7 +114,7 @@ gsk_gpu_image_toggle_ref_texture (GskGpuImage *self,
g_object_add_toggle_ref (G_OBJECT (self), gsk_gpu_image_texture_toggle_ref_cb, texture);
g_object_unref (self);
}
GdkMemoryFormat
gsk_gpu_image_get_format (GskGpuImage *self)
{

View File

@ -103,6 +103,7 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
scale = gsk_gpu_renderer_get_scale (renderer);
if (self->backbuffer == NULL ||
!!(gsk_gpu_image_get_flags (self->backbuffer) & GSK_GPU_IMAGE_SRGB) != gdk_surface_get_gl_is_srgb (surface) ||
gsk_gpu_image_get_width (self->backbuffer) != ceil (gdk_surface_get_width (surface) * scale) ||
gsk_gpu_image_get_height (self->backbuffer) != ceil (gdk_surface_get_height (surface) * scale))
{
@ -110,6 +111,7 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
self->backbuffer = gsk_gl_image_new_backbuffer (GSK_GL_DEVICE (gsk_gpu_renderer_get_device (renderer)),
GDK_GL_CONTEXT (context),
GDK_MEMORY_DEFAULT /* FIXME */,
gdk_surface_get_gl_is_srgb (surface),
ceil (gdk_surface_get_width (surface) * scale),
ceil (gdk_surface_get_height (surface) * scale));
}