Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
screen_metrics.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DT_GUI_SCREEN_METRICS_H
20#define DT_GUI_SCREEN_METRICS_H
21
23
24#include <cairo.h>
25#include <glib.h>
26
28
29/* How dense the screen is, and how much cairo has to draw per logical pixel.
30 *
31 * These are hardware facts -- the same category as the monitor's ICC profile in
32 * system/display_profile.h -- and they had ended up owned by the GUI (dt_gui_gtk_t) and
33 * mirrored in widgets/widget_settings.c, because that is who resolves them. Anyone below
34 * layer 4 who needed them (the crash reporter, the telemetry payload, the SVG rasteriser)
35 * therefore had to include gui/gtk.h to read three doubles.
36 *
37 * They live here instead, as the single copy. Whoever can interrogate the display pushes
38 * them in once -- dt_gui_gtk_init() does, from GDK -- and everyone else reads.
39 *
40 * This is state, so it is not in src/system: that directory answers "is this stateless?" with
41 * its own name, and one exception would cost every reader the check the arrangement exists to
42 * avoid. The scaling arithmetic these values feed has no state and did stay there, in
43 * system/surface_scaling.h, taking the scale as an argument. The constructors below are those
44 * same functions bound to the current screen.
45 *
46 * It lives in gui/ because the GUI is what resolves these values -- it is the only thing that
47 * can interrogate a display. That makes every reader below layer 4 an upward include, which
48 * is not a regression but the coupling becoming visible: code in common/ that needs to know
49 * the screen's DPI always depended on there being a screen. Callers that know their own scale
50 * should use system/surface_scaling.h directly and depend on nothing.
51 *
52 * Before that push, the getters return neutral values (1.0 scaling, 96 dpi), which is what
53 * makes a headless run and early startup work without a single "is there a GUI?" test.
54 */
55
57double dt_screen_dpi(void);
58void dt_screen_set_dpi(double dpi);
59
61double dt_screen_dpi_factor(void);
63
65double dt_screen_ppd(void);
66void dt_screen_set_ppd(double ppd);
67
74gboolean dt_screen_metrics_probed(void);
75
77double dt_screen_em_size(void);
78void dt_screen_set_em_size(double em);
79
80/* The scaling helpers from system/surface_scaling.h, bound to the current screen. Callers that
81 * already know their scale -- an export at a fixed size, a test -- should use those directly
82 * and stay independent of the display. */
83
88
90 int width, int height, int stride)
91{
93}
94
99
101{
103}
104
106{
108}
109
111
112#endif // DT_GUI_SCREEN_METRICS_H
113
114// clang-format off
115// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
116// vim: shiftwidth=2 expandtab tabstop=2 cindent
117// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
118// clang-format on
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
const float factor
Definition pdf.h:91
void dt_screen_set_ppd(double ppd)
static cairo_surface_t * dt_cairo_image_surface_create_from_png(const char *filename)
static cairo_surface_t * dt_cairo_image_surface_create(cairo_format_t format, int width, int height)
void dt_screen_set_dpi_factor(double factor)
static int dt_cairo_image_surface_get_width(cairo_surface_t *surface)
void dt_screen_set_dpi(double dpi)
void dt_screen_set_em_size(double em)
static cairo_surface_t * dt_cairo_image_surface_create_for_data(unsigned char *data, cairo_format_t format, int width, int height, int stride)
G_BEGIN_DECLS double dt_screen_dpi(void)
double dt_screen_em_size(void)
double dt_screen_dpi_factor(void)
static int dt_cairo_image_surface_get_height(cairo_surface_t *surface)
gboolean dt_screen_metrics_probed(void)
double dt_screen_ppd(void)
static cairo_surface_t * dt_cairo_surface_create_from_png_at_scale(const char *filename, double scale)
static int dt_cairo_surface_logical_width(cairo_surface_t *surface, double scale)
static int dt_cairo_surface_logical_height(cairo_surface_t *surface, double scale)
static cairo_surface_t * dt_cairo_surface_create_for_data_at_scale(unsigned char *data, cairo_format_t format, int width, int height, int stride, double scale)
static G_BEGIN_DECLS cairo_surface_t * dt_cairo_surface_create_at_scale(cairo_format_t format, int width, int height, double scale)