Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
masks_distort.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
47#ifndef DT_DEVELOP_MASKS_MASKS_DISTORT_H
48#define DT_DEVELOP_MASKS_MASKS_DISTORT_H
49
50#include <glib.h>
51#include <stdint.h>
52
53#include "develop/develop.h"
55
79
82{
83 dt_masks_distort_t d = { pipe, dev, 0, 0, 1 };
84 if(!IS_NULL_PTR(pipe))
85 {
86 d.iwidth = pipe->iwidth;
87 d.iheight = pipe->iheight;
88 d.rasterization_step = pipe->mask_rasterization_step;
89 }
90 return d;
91}
92
100
116{
117 dt_masks_distort_t d = { NULL, dev, 0, 0, dt_masks_gui_outline_step(dev) };
118 int32_t raw_width = 0;
119 int32_t raw_height = 0;
120 if(dt_dev_geometry_get_raw_size(dev, &raw_width, &raw_height))
121 {
122 d.iwidth = raw_width;
123 d.iheight = raw_height;
124 }
125 return d;
126}
127
129static inline int dt_masks_distort_transform(const dt_masks_distort_t *const d, const double iop_order,
130 const int transf_direction, float *points,
131 size_t points_count)
132{
133 if(!IS_NULL_PTR(d->pipe))
134 return dt_dev_distort_transform_plus(d->pipe, iop_order, transf_direction, points, points_count);
135 return dt_dev_distort_transform_gui(d->dev, iop_order, transf_direction, points, points_count);
136}
137
139static inline int dt_masks_distort_backtransform(const dt_masks_distort_t *const d, const double iop_order,
140 const int transf_direction, float *points,
141 size_t points_count)
142{
143 if(!IS_NULL_PTR(d->pipe))
144 return dt_dev_distort_backtransform_plus(d->pipe, iop_order, transf_direction, points, points_count);
145 return dt_dev_distort_backtransform_gui(d->dev, iop_order, transf_direction, points, points_count);
146}
147
148#endif // DT_DEVELOP_MASKS_MASKS_DISTORT_H
149
150// clang-format off
151// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
152// vim: shiftwidth=2 expandtab tabstop=2 cindent
153// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
154// clang-format on
gboolean dt_dev_geometry_get_raw_size(const dt_develop_t *dev, int32_t *width, int32_t *height)
int dt_dev_distort_backtransform_gui(dt_develop_t *dev, const double iop_order, const int transf_direction, float *points, size_t points_count)
The inverse of dt_dev_distort_transform_gui(), same rules.
Definition develop.c:1699
int dt_dev_distort_transform_plus(const dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
Definition develop.c:1797
int dt_dev_distort_transform_gui(dt_develop_t *dev, const double iop_order, const int transf_direction, float *points, size_t points_count)
The GUI's bounded transform folds, composed by the geometry service.
Definition develop.c:1691
int dt_dev_distort_backtransform_plus(const dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
Definition develop.c:1826
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:96
static dt_masks_distort_t dt_masks_distort_for_pipe(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
The rendering supplier: compose this pipe, sample as this pipe was told to.
int dt_masks_gui_outline_step(const dt_develop_t *dev)
The density the dev's GUI shows its outlines at, in image pixels between consecutive samples: what th...
Definition masks_gui.c:1908
static dt_masks_distort_t dt_masks_distort_for_gui(dt_develop_t *dev)
The GUI supplier: compose through the geometry service, at full resolution, sampled at the density th...
static int dt_masks_distort_backtransform(const dt_masks_distort_t *const d, const double iop_order, const int transf_direction, float *points, size_t points_count)
Compose backward, same bounds.
static int dt_masks_distort_transform(const dt_masks_distort_t *const d, const double iop_order, const int transf_direction, float *points, size_t points_count)
Compose forward, bounded exactly as dt_dev_distort_transform_plus() is.
int mask_rasterization_step
Rasterisation step for drawn masks, in image pixels. Always >= 1.
Where an outline builder gets its geometry from.
dt_develop_t * dev
dt_dev_pixelpipe_t * pipe