mutter/clutter/clutter/clutter-context.h
Jonas Ådahl 4238512764 clutter: Introduce color transform aware pipeline cache
Color aware rendering needs shaders / pipelines that adapt to what
output they render to. For example if we want to render to a linear
BT.2020 intermediate framebuffer on one monitor, and a non-linear sRGB
direct target buffer on another, the shader for the same paint node or
content will depend on where they are going to be presented.

In order to help keeping track of what shader should target what
monitor, without having to regenerate them each time, introduce a
pipeline cache that knows how to handle differentiating between
transforming between different color state.

The cache is meant to handle caches for multiple pipeline users, where
each user might potentially want to keep track of multiple pipelines
itself. Lookup should be O(1), and in order to achieve this, separate
the cache into 3 levels.

The first level is the "pipeline group", where e.g. a ClutterContent
type allocates a group where it can store its pipelines. Each group has
a fixed number of "slots" where it can store a pipeline. Each slot has a
hash table where the key is derived from a color state transform, and
where the value is a CoglPipeline where the thame color state
transformation is expected to be handled.

A content will when painting know about its own color state, and the
target state it should render into, retrieve a cached pipeline for the
correct transform, or if the cache didn't have it, generate it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00

71 lines
2.2 KiB
C

/*
* Copyright (C) 2006 OpenedHand
* Copyright (C) 2023 Red Hat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "clutter-backend.h"
#include "clutter-stage-manager.h"
#include "clutter-settings.h"
#include "cogl-pango/cogl-pango.h"
typedef enum _ClutterContextFlags
{
CLUTTER_CONTEXT_FLAG_NONE = 0,
CLUTTER_CONTEXT_FLAG_NO_A11Y = 1 << 0,
} ClutterContextFlags;
typedef ClutterBackend * (* ClutterBackendConstructor) (gpointer user_data);
#define CLUTTER_TYPE_CONTEXT (clutter_context_get_type ())
CLUTTER_EXPORT
G_DECLARE_FINAL_TYPE (ClutterContext, clutter_context,
CLUTTER, CONTEXT, GObject)
/**
* clutter_context_new: (skip)
*/
ClutterContext * clutter_context_new (ClutterContextFlags flags,
ClutterBackendConstructor backend_constructor,
gpointer user_data,
GError **error);
/**
* clutter_context_destroy: (skip)
*/
CLUTTER_EXPORT
void clutter_context_destroy (ClutterContext *context);
/**
* clutter_context_get_backend:
*
* Returns: (transfer none): The %ClutterBackend
*/
CLUTTER_EXPORT
ClutterBackend * clutter_context_get_backend (ClutterContext *context);
/**
* clutter_context_get_pango_fontmap: (skip)
*/
CoglPangoFontMap * clutter_context_get_pango_fontmap (ClutterContext *context);
ClutterTextDirection clutter_context_get_text_direction (ClutterContext *context);
CLUTTER_EXPORT
ClutterPipelineCache * clutter_context_get_pipeline_cache (ClutterContext *clutter_context);