Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
iop/drawlayer/cache.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
19#pragma once
20
21#include "develop/imageop.h"
23#include "iop/drawlayer/paint.h"
24
25#include <glib.h>
26#include <stddef.h>
27#include <stdint.h>
28
47
49void *dt_drawlayer_cache_alloc_temp_buffer(size_t bytes, const char *name);
51void dt_drawlayer_cache_free_temp_buffer(void **buffer, const char *name);
53float *dt_drawlayer_cache_ensure_scratch_buffer(float **buffer, size_t *capacity_pixels, size_t needed_pixels,
54 const char *name);
55
57void dt_drawlayer_cache_clear_transparent_float(float *pixels, size_t pixel_count);
58
60void dt_drawlayer_cache_patch_clear(dt_drawlayer_cache_patch_t *patch, const char *external_alloc_name);
62gboolean dt_drawlayer_cache_patch_alloc_shared(dt_drawlayer_cache_patch_t *patch, uint64_t hash, size_t pixel_count,
63 int width, int height, const char *name, int *created_out);
72
74void dt_drawlayer_cache_invalidate_process_patch_state(gboolean *process_patch_valid, gboolean *process_patch_dirty,
75 dt_drawlayer_damaged_rect_t *process_dirty_rect,
76 int *process_patch_padding,
77 dt_iop_roi_t *process_combined_roi);
78
81 dt_drawlayer_cache_patch_t *process_stroke_mask,
82 int width, int height,
83 const char *patch_buffer_name,
84 const char *mask_buffer_name);
85
88 int current_full_w, int current_full_h, int src_w, int src_h,
89 int module_origin_x, int module_origin_y,
90 dt_iop_roi_t *combined_roi);
93 const dt_iop_roi_t *process_roi,
94 int current_full_w, int current_full_h,
95 int src_w, int src_h,
96 dt_iop_roi_t *combined_roi);
99 int current_full_w, int current_full_h,
100 int *module_origin_x, int *module_origin_y);
101
104 int process_patch_padding, const dt_iop_roi_t *roi_out,
105 dt_iop_roi_t *blend_target_roi,
106 dt_iop_roi_t *source_process_roi,
107 gboolean *direct_copy);
108
111 int process_patch_padding,
112 const dt_iop_roi_t *roi_out,
113 float *layerbuf, int layerbuf_width);
114
117 const dt_drawlayer_cache_patch_t *base_stroke_mask,
118 dt_drawlayer_cache_patch_t *process_patch,
119 dt_drawlayer_cache_patch_t *process_stroke_mask,
120 const dt_iop_roi_t *combined_roi, int process_pad,
121 int patch_width, int patch_height,
122 gboolean *process_patch_valid,
123 gboolean *process_patch_dirty,
124 dt_drawlayer_damaged_rect_t *process_dirty_rect,
125 int *process_patch_padding,
126 dt_iop_roi_t *process_combined_roi,
127 const char *patch_buffer_name,
128 const char *mask_buffer_name);
129
132 dt_drawlayer_cache_patch_t *base_stroke_mask,
133 const dt_iop_roi_t *process_combined_roi,
134 dt_drawlayer_cache_patch_t *process_patch,
135 dt_drawlayer_cache_patch_t *process_stroke_mask,
136 float **process_update_pixels,
137 size_t *process_update_capacity_pixels,
138 gboolean *cache_dirty, gboolean *process_patch_dirty,
139 dt_drawlayer_damaged_rect_t *process_dirty_rect,
140 const char *update_buffer_name);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
char * name
Definition common/metadata.c:61
gboolean dt_drawlayer_cache_patch_alloc_shared(dt_drawlayer_cache_patch_t *patch, uint64_t hash, size_t pixel_count, int width, int height, const char *name, int *created_out)
Allocate/reuse shared patch storage from pixel cache.
Definition iop/drawlayer/cache.c:87
void dt_drawlayer_cache_invalidate_process_patch_state(gboolean *process_patch_valid, gboolean *process_patch_dirty, dt_drawlayer_damaged_rect_t *process_dirty_rect, int *process_patch_padding, dt_iop_roi_t *process_combined_roi)
Reset process-patch validity/dirty state bookkeeping.
Definition iop/drawlayer/cache.c:161
void dt_drawlayer_cache_patch_wrunlock(const dt_drawlayer_cache_patch_t *patch)
Release write lock on shared patch cache entry.
Definition iop/drawlayer/cache.c:153
gboolean dt_drawlayer_cache_ensure_process_patch_buffer(dt_drawlayer_cache_patch_t *process_patch, dt_drawlayer_cache_patch_t *process_stroke_mask, int width, int height, const char *patch_buffer_name, const char *mask_buffer_name)
Ensure process patch and its stroke mask buffers are allocated.
Definition iop/drawlayer/cache.c:174
gboolean dt_drawlayer_cache_flush_process_patch_to_base(dt_drawlayer_cache_patch_t *base_patch, dt_drawlayer_cache_patch_t *base_stroke_mask, const dt_iop_roi_t *process_combined_roi, dt_drawlayer_cache_patch_t *process_patch, dt_drawlayer_cache_patch_t *process_stroke_mask, float **process_update_pixels, size_t *process_update_capacity_pixels, gboolean *cache_dirty, gboolean *process_patch_dirty, dt_drawlayer_damaged_rect_t *process_dirty_rect, const char *update_buffer_name)
Flush dirty process-patch region back into base patch.
Definition iop/drawlayer/cache.c:519
void dt_drawlayer_cache_build_combined_process_roi(const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *process_roi, int current_full_w, int current_full_h, int src_w, int src_h, int module_origin_x, int module_origin_y, dt_iop_roi_t *combined_roi)
Build process+padding ROI in module-buffer coordinates.
Definition iop/drawlayer/cache.c:237
void dt_drawlayer_cache_patch_wrlock(const dt_drawlayer_cache_patch_t *patch)
Acquire write lock on shared patch cache entry.
Definition iop/drawlayer/cache.c:145
gboolean dt_drawlayer_cache_build_process_blend_rois(const dt_drawlayer_cache_patch_t *process_patch, int process_patch_padding, const dt_iop_roi_t *roi_out, dt_iop_roi_t *blend_target_roi, dt_iop_roi_t *source_process_roi, gboolean *direct_copy)
Build blend/source ROIs from process patch and output ROI.
Definition iop/drawlayer/cache.c:315
void dt_drawlayer_cache_patch_clear(dt_drawlayer_cache_patch_t *patch, const char *external_alloc_name)
Drop patch storage and clear metadata.
Definition iop/drawlayer/cache.c:65
gboolean dt_drawlayer_cache_populate_process_patch_from_base(const dt_drawlayer_cache_patch_t *base_patch, const dt_drawlayer_cache_patch_t *base_stroke_mask, dt_drawlayer_cache_patch_t *process_patch, dt_drawlayer_cache_patch_t *process_stroke_mask, const dt_iop_roi_t *combined_roi, int process_pad, int patch_width, int patch_height, gboolean *process_patch_valid, gboolean *process_patch_dirty, dt_drawlayer_damaged_rect_t *process_dirty_rect, int *process_patch_padding, dt_iop_roi_t *process_combined_roi, const char *patch_buffer_name, const char *mask_buffer_name)
Populate process patch from base patch with crop/scale and synchronized stroke mask.
Definition iop/drawlayer/cache.c:377
void * dt_drawlayer_cache_alloc_temp_buffer(size_t bytes, const char *name)
Allocate a temporary RGBA scratch buffer.
Definition iop/drawlayer/cache.c:28
gboolean dt_drawlayer_cache_resample_process_patch_to_output(const dt_drawlayer_cache_patch_t *process_patch, int process_patch_padding, const dt_iop_roi_t *roi_out, float *layerbuf, int layerbuf_width)
Resample process patch into output layer buffer ROI.
Definition iop/drawlayer/cache.c:350
void dt_drawlayer_cache_clear_transparent_float(float *pixels, size_t pixel_count)
Fill RGBA float buffer with transparent black.
Definition iop/drawlayer/cache.c:58
float * dt_drawlayer_cache_ensure_scratch_buffer(float **buffer, size_t *capacity_pixels, size_t needed_pixels, const char *name)
Ensure a float RGBA scratch buffer capacity in pixels.
Definition iop/drawlayer/cache.c:42
void dt_drawlayer_cache_free_temp_buffer(void **buffer, const char *name)
Release temporary scratch buffer allocated by cache helpers.
Definition iop/drawlayer/cache.c:35
void dt_drawlayer_cache_build_combined_process_roi_for_piece(const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *process_roi, int current_full_w, int current_full_h, int src_w, int src_h, dt_iop_roi_t *combined_roi)
Convenience wrapper using piece ROI offsets as module origin.
Definition iop/drawlayer/cache.c:291
void dt_drawlayer_cache_patch_rdlock(const dt_drawlayer_cache_patch_t *patch)
Acquire read lock on shared patch cache entry.
Definition iop/drawlayer/cache.c:129
void dt_drawlayer_cache_resolve_piece_input_origin(const dt_dev_pixelpipe_iop_t *piece, int current_full_w, int current_full_h, int *module_origin_x, int *module_origin_y)
Resolve effective module input origin, including centered-fit fallback.
Definition iop/drawlayer/cache.c:268
void dt_drawlayer_cache_patch_rdunlock(const dt_drawlayer_cache_patch_t *patch)
Release read lock on shared patch cache entry.
Definition iop/drawlayer/cache.c:137
Stroke-level path sampling and runtime-state API for drawlayer.
Pixelpipe cache for storing intermediate results in the pixelpipe.
unsigned __int64 uint64_t
Definition strptime.c:74
Definition pixelpipe_hb.h:58
Generic float RGBA patch stored either in malloc memory or pixel cache.
Definition iop/drawlayer/cache.h:37
int y
Definition iop/drawlayer/cache.h:39
int x
Definition iop/drawlayer/cache.h:38
int height
Definition iop/drawlayer/cache.h:41
float * pixels
Definition iop/drawlayer/cache.h:42
int width
Definition iop/drawlayer/cache.h:40
dt_pixel_cache_entry_t * cache_entry
Definition iop/drawlayer/cache.h:43
gboolean external_alloc
Definition iop/drawlayer/cache.h:45
uint64_t cache_hash
Definition iop/drawlayer/cache.h:44
Integer axis-aligned rectangle in buffer coordinates.
Definition iop/drawlayer/paint.h:87
Definition imageop.h:67
Definition pixelpipe_cache.h:78