colorstate: Add gdk_color_state_get_rendering_color_state()

Returns the linear color state that renderers should render in when
this is the target color state.

We disable this function unless linear compositing is enabled and just
return @self by default.
This commit is contained in:
Benjamin Otte
2024-06-28 17:28:02 +02:00
parent 7f9031eae8
commit bdb6b10be8
2 changed files with 14 additions and 2 deletions

View File

@@ -20,8 +20,6 @@
#include "gdkcolorstateprivate.h"
#include "gdkdebugprivate.h"
/**
* GdkColorState:
*
@@ -165,6 +163,7 @@ GdkDefaultColorState gdk_default_color_states[] = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_U8,
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
},
.name = "srgb",
.no_srgb = GDK_COLOR_STATE_SRGB_LINEAR,
@@ -174,6 +173,7 @@ GdkDefaultColorState gdk_default_color_states[] = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_U8,
.rendering_color_state = GDK_COLOR_STATE_SRGB_LINEAR,
},
.name = "srgb-linear",
.no_srgb = NULL,

View File

@@ -1,6 +1,8 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkdebugprivate.h"
#include "gdkmemoryformatprivate.h"
typedef enum
@@ -19,6 +21,7 @@ struct _GdkColorState
gatomicrefcount ref_count;
GdkMemoryDepth depth;
GdkColorState *rendering_color_state;
};
struct _GdkColorStateClass
@@ -52,6 +55,15 @@ extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
const char * gdk_color_state_get_name (GdkColorState *color_state);
GdkColorState * gdk_color_state_get_no_srgb_tf (GdkColorState *self);
static inline GdkColorState *
gdk_color_state_get_rendering_color_state (GdkColorState *self)
{
if (!GDK_DEBUG_CHECK (LINEAR))
return self;
return self->rendering_color_state;
}
static inline GdkMemoryDepth
gdk_color_state_get_depth (GdkColorState *self)
{