Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
layers.h
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
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
23#ifndef DT_IOP_DRAWLAYER_LAYERS_H
24#define DT_IOP_DRAWLAYER_LAYERS_H
25
26#include "iop/drawlayer/common.h" // dt_iop_drawlayer_gui_data_t
27#include "develop/imageop.h" // dt_iop_module_t
28#include "iop/drawlayer/coordinates.h" // dt_drawlayer_layer_canvas_for_pipe()
29#include "common/hash.h" // dt_hash()
30#include "system/macros.h" // IS_NULL_PTR()
31
43
44/* These two are inline ON PURPOSE, the exception the developer notes allow for a header
45 * whose published interface IS code: drawlayer.c calls each five times on the per-frame
46 * path. A static inline gives both translation units their own copy, so always_inline
47 * still holds without relying on link-time optimisation. This header has exactly two
48 * includers, which is what keeps that trade proportionate. */
51 int *layer_height, int *origin_x, int *origin_y)
52{
57 if(IS_NULL_PTR(self) || IS_NULL_PTR(self->dev)) return FALSE;
58 /* The canvas has the RAW image's dimensions, in this image's own orientation, and is centred
59 * on the module's frame -- the same for every pipe, every zoom and every crop, which is the
60 * point of anchoring to it: a crop changes which window of the canvas a render reads, not
61 * where the paint sits. See iop/drawlayer/coordinates.h.
62 *
63 * It used to be the module's own stage frame, lifted back through roi_out.scale. That size
64 * moves with every crop, and the authored raster was then fitted onto the new frame -- the
65 * paint moved and stretched with the crop.
66 *
67 * Thumbnail and export pipes may start from a downscaled mipmap; that shrinks the module's
68 * frame, not the canvas, and the placement's scale absorbs it. */
72
73 (void)piece;
74
77 return resolved_width > 0 && resolved_height > 0;
78}
79
81 const int layer_width, const int layer_height)
82{
83 /* Internal drawlayer base-cache identity must stay stable across transient
84 * stroke/hash updates. Key only by image + layer identity + working profile,
85 * not by volatile fields (stroke hash, sidecar timestamp...).
86 *
87 * This keeps the shared base patch line hot across interactive drawing ticks
88 * and avoids expensive rekey conflicts/republishing during realtime updates. */
89 uint64_t hash = 5381u;
90 hash = dt_hash(hash, (const char *)&imgid, sizeof(imgid));
91 hash = dt_hash(hash, (const char *)&layer_width, sizeof(layer_width));
92 hash = dt_hash(hash, (const char *)&layer_height, sizeof(layer_height));
94 {
96 hash = dt_hash(hash, (const char *)&params->layer_order, sizeof(params->layer_order));
98 }
99 return hash ? hash : 1u;
100}
101
102void dt_drawlayer_layers_append_error(GString *errors, const char *message);
103
105
107
109
110#endif
#define FALSE
Definition ashift_lsd.c:158
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
gboolean dt_drawlayer_layer_canvas_for_pipe(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, int *width, int *height)
Definition coordinates.c:87
Shared coordinate transforms and geometry computations for drawlayer.
static uint64_t dt_hash(uint64_t hash, const char *str, size_t size)
Definition hash.h:55
int resolved_width
Definition layers.h:69
int resolved_height
Definition layers.h:70
void dt_drawlayer_layers_log_errors(GString *errors)
Definition layers.c:42
static const dt_dev_pixelpipe_t * pipe
Definition layers.h:49
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t * piece
Definition layers.h:50
hash
Definition layers.h:90
void dt_drawlayer_layers_populate_list(dt_iop_module_t *self)
Definition layers.c:48
static const dt_iop_drawlayer_params_t * params
Definition layers.h:80
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t int int int int * origin_y
Definition layers.h:52
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t int int * layer_height
Definition layers.h:51
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t int * layer_width
Definition layers.h:50
void dt_drawlayer_layers_reset_stroke_session(dt_iop_drawlayer_gui_data_t *g)
Definition layers.c:94
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t int int int * origin_x
Definition layers.h:51
void dt_drawlayer_layers_append_error(GString *errors, const char *message)
Definition layers.c:35
#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
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
Definition simd.h:55
Shared drawlayer runtime helpers used across module/runtime files.
#define DRAWLAYER_NAME_SIZE
#define DRAWLAYER_PROFILE_SIZE
unsigned __int64 uint64_t
Definition strptime.c:75
What one sidecar directory scan found about a layer.
Definition layers.h:34
char work_profile[DRAWLAYER_PROFILE_SIZE]
Definition layers.h:41
char name[DRAWLAYER_NAME_SIZE]
Definition layers.h:40
uint32_t height
Definition layers.h:39
struct dt_develop_t * dev
Definition imageop.h:311