mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 17:50:10 +00:00
Use the surface colorstate in begin_frame
begin_frame is the place where we make decisions about the format, depth and colorstate for our rendering. Make these calls take the surface color state into account. In particular, if the surface colorstate is suitable for GL_SRGB, and we don't need high depth, set things up for that.
This commit is contained in:
parent
52d2975af3
commit
53d99f5521
@ -617,27 +617,33 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
|||||||
{
|
{
|
||||||
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
||||||
G_GNUC_UNUSED GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
G_GNUC_UNUSED GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
GdkSurface *surface;
|
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||||
|
GdkColorState *color_state;
|
||||||
cairo_region_t *damage;
|
cairo_region_t *damage;
|
||||||
double scale;
|
double scale;
|
||||||
int ww, wh;
|
int ww, wh;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
surface = gdk_draw_context_get_surface (draw_context);
|
color_state = gdk_surface_get_color_state (surface);
|
||||||
scale = gdk_gl_context_get_scale (context);
|
scale = gdk_gl_context_get_scale (context);
|
||||||
|
|
||||||
|
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_depth (color_state));
|
||||||
|
|
||||||
|
g_assert (depth != GDK_MEMORY_U8_SRGB || gdk_color_state_get_no_srgb_tf (color_state) != NULL);
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
if (priv->egl_context)
|
if (priv->egl_context)
|
||||||
*out_depth = gdk_surface_ensure_egl_surface (surface, depth);
|
*out_depth = gdk_surface_ensure_egl_surface (surface, depth);
|
||||||
else
|
else
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
*out_depth = GDK_MEMORY_U8;
|
||||||
|
|
||||||
if (*out_depth == GDK_MEMORY_U8_SRGB)
|
if (*out_depth == GDK_MEMORY_U8_SRGB)
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
*out_color_state = gdk_color_state_get_no_srgb_tf (color_state);
|
||||||
else
|
else
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
*out_color_state = color_state;
|
||||||
#else
|
#else
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
*out_color_state = gdk_color_state_get_srgb ();
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
*out_depth = GDK_MEMORY_U8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
||||||
|
@ -642,9 +642,16 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
{
|
{
|
||||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||||
|
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||||
|
GdkColorState *color_state;
|
||||||
VkResult acquire_result;
|
VkResult acquire_result;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
color_state = gdk_surface_get_color_state (surface);
|
||||||
|
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_depth (color_state));
|
||||||
|
|
||||||
|
g_assert (depth != GDK_MEMORY_U8_SRGB || gdk_color_state_get_no_srgb_tf (color_state) != NULL);
|
||||||
|
|
||||||
if (depth != priv->current_depth && depth != GDK_MEMORY_NONE)
|
if (depth != priv->current_depth && depth != GDK_MEMORY_NONE)
|
||||||
{
|
{
|
||||||
if (priv->formats[depth].vk_format.format != priv->formats[priv->current_depth].vk_format.format ||
|
if (priv->formats[depth].vk_format.format != priv->formats[priv->current_depth].vk_format.format ||
|
||||||
@ -695,9 +702,9 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
cairo_region_union (region, priv->regions[priv->draw_index]);
|
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||||
|
|
||||||
if (priv->current_depth == GDK_MEMORY_U8_SRGB)
|
if (priv->current_depth == GDK_MEMORY_U8_SRGB)
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
|
*out_color_state = gdk_color_state_get_no_srgb_tf (color_state);
|
||||||
else
|
else
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
*out_color_state = color_state;
|
||||||
*out_depth = priv->current_depth;
|
*out_depth = priv->current_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
const cairo_region_t *surface_region;
|
const cairo_region_t *surface_region;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||||
|
|
||||||
if (self->cached_surface)
|
if (self->cached_surface)
|
||||||
self->paint_surface = g_steal_pointer (&self->cached_surface);
|
self->paint_surface = g_steal_pointer (&self->cached_surface);
|
||||||
@ -176,8 +177,8 @@ gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
*out_color_state = GDK_COLOR_STATE_SRGB;
|
*out_color_state = gdk_surface_get_color_state (surface);
|
||||||
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB);
|
*out_depth = GDK_MEMORY_U8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user