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#ifndef DT_IOP_DRAWLAYER_CACHE_H
20#define DT_IOP_DRAWLAYER_CACHE_H
21
22#include "develop/imageop.h"
24#include "iop/drawlayer/paint.h"
25
26#include <glib.h>
27#include <stddef.h>
28#include <stdint.h>
29
48
50void *dt_drawlayer_cache_alloc_temp_buffer(size_t bytes, const char *name);
52void dt_drawlayer_cache_free_temp_buffer(void **buffer, const char *name);
54float *dt_drawlayer_cache_ensure_scratch_buffer(float **buffer, size_t *capacity_pixels, size_t needed_pixels,
55 const char *name);
56
58void dt_drawlayer_cache_clear_transparent_float(float *pixels, size_t pixel_count);
59
61void dt_drawlayer_cache_patch_clear(dt_drawlayer_cache_patch_t *patch, const char *external_alloc_name);
63gboolean dt_drawlayer_cache_patch_alloc_shared(dt_drawlayer_cache_patch_t *patch, uint64_t hash, size_t pixel_count,
64 int width, int height, const char *name, int *created_out);
67 const char *name);
76
78void dt_drawlayer_cache_invalidate_process_patch_state(gboolean *process_patch_valid, gboolean *process_patch_dirty,
79 dt_drawlayer_damaged_rect_t *process_dirty_rect,
80 int *process_patch_padding,
81 dt_iop_roi_t *process_combined_roi);
82
85 dt_drawlayer_cache_patch_t *process_stroke_mask,
86 int width, int height,
87 const char *patch_buffer_name,
88 const char *mask_buffer_name);
89
92 int current_full_w, int current_full_h, int src_w, int src_h,
93 int module_origin_x, int module_origin_y,
94 dt_iop_roi_t *combined_roi);
97 const dt_iop_roi_t *process_roi,
98 int current_full_w, int current_full_h,
99 int src_w, int src_h,
100 dt_iop_roi_t *combined_roi);
103 int current_full_w, int current_full_h,
104 int *module_origin_x, int *module_origin_y);
105
108 int process_patch_padding, const dt_iop_roi_t *roi_out,
109 dt_iop_roi_t *blend_target_roi,
110 dt_iop_roi_t *source_process_roi,
111 gboolean *direct_copy);
112
115 int process_patch_padding,
116 const dt_iop_roi_t *roi_out,
117 float *layerbuf, int layerbuf_width);
118
121 const dt_drawlayer_cache_patch_t *base_stroke_mask,
122 dt_drawlayer_cache_patch_t *process_patch,
123 dt_drawlayer_cache_patch_t *process_stroke_mask,
124 const dt_iop_roi_t *combined_roi, int process_pad,
125 int patch_width, int patch_height,
126 gboolean *process_patch_valid,
127 gboolean *process_patch_dirty,
128 dt_drawlayer_damaged_rect_t *process_dirty_rect,
129 int *process_patch_padding,
130 dt_iop_roi_t *process_combined_roi,
131 const char *patch_buffer_name,
132 const char *mask_buffer_name);
133
136 dt_drawlayer_cache_patch_t *base_stroke_mask,
137 const dt_iop_roi_t *process_combined_roi,
138 dt_drawlayer_cache_patch_t *process_patch,
139 dt_drawlayer_cache_patch_t *process_stroke_mask,
140 float **process_update_pixels,
141 size_t *process_update_capacity_pixels,
142 gboolean *cache_dirty, gboolean *process_patch_dirty,
143 dt_drawlayer_damaged_rect_t *process_dirty_rect,
144 const char *update_buffer_name);
145#endif // DT_IOP_DRAWLAYER_CACHE_H
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.
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.
void dt_drawlayer_cache_patch_wrunlock(const dt_drawlayer_cache_patch_t *patch)
Release write lock on shared patch cache entry.
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.
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.
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.
void dt_drawlayer_cache_patch_wrlock(const dt_drawlayer_cache_patch_t *patch)
Acquire write lock on shared patch cache entry.
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.
void dt_drawlayer_cache_patch_clear(dt_drawlayer_cache_patch_t *patch, const char *external_alloc_name)
Drop patch storage and clear metadata.
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.
void * dt_drawlayer_cache_alloc_temp_buffer(size_t bytes, const char *name)
Allocate a temporary RGBA scratch buffer.
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.
void dt_drawlayer_cache_clear_transparent_float(float *pixels, size_t pixel_count)
Fill RGBA float buffer with transparent black.
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.
void dt_drawlayer_cache_free_temp_buffer(void **buffer, const char *name)
Release temporary scratch buffer allocated by cache helpers.
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.
void dt_drawlayer_cache_patch_rdlock(const dt_drawlayer_cache_patch_t *patch)
Acquire read lock on shared patch cache entry.
gboolean dt_drawlayer_cache_ensure_mask_buffer(dt_drawlayer_cache_patch_t *mask, int width, int height, const char *name)
Ensure a float stroke-mask buffer exists for the requested size.
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.
void dt_drawlayer_cache_patch_rdunlock(const dt_drawlayer_cache_patch_t *patch)
Release read lock on shared patch cache entry.
Stroke-level path sampling and runtime-state API for drawlayer.
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
const char * name
Definition pdf.h:90
Pixelpipe cache for storing intermediate results in the pixelpipe.
unsigned __int64 uint64_t
Definition strptime.c:75
Generic float RGBA patch stored either in malloc memory or pixel cache.
dt_pixel_cache_entry_t * cache_entry
Integer axis-aligned rectangle in buffer coordinates.
Region of interest passed through the pixelpipe.
Definition format.h:49