Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
cache.c File Reference
#include "common/darktable.h"
#include "iop/drawlayer/cache.h"
#include "develop/imageop_math.h"
#include <math.h>
#include <string.h>
+ Include dependency graph for iop/drawlayer/cache.c:

Functions

voiddt_drawlayer_cache_alloc_temp_buffer (const size_t bytes, const char *name)
 Allocate temporary aligned cache buffer.
 
void dt_drawlayer_cache_free_temp_buffer (void **buffer, const char *name)
 Free temporary aligned cache buffer.
 
float * dt_drawlayer_cache_ensure_scratch_buffer (float **buffer, size_t *capacity_pixels, const size_t needed_pixels, const char *name)
 Ensure scratch RGBA float capacity in pixels.
 
void dt_drawlayer_cache_clear_transparent_float (float *pixels, const size_t pixel_count)
 Fill float RGBA buffer with transparent black.
 
void dt_drawlayer_cache_patch_clear (dt_drawlayer_cache_patch_t *patch, const char *external_alloc_name)
 Release patch storage and reset patch metadata.
 
gboolean dt_drawlayer_cache_patch_alloc_shared (dt_drawlayer_cache_patch_t *patch, const uint64_t hash, const size_t pixel_count, const int width, const int height, const char *name, int *created_out)
 Allocate patch storage from shared pixel cache entry.
 
void dt_drawlayer_cache_patch_rdlock (const dt_drawlayer_cache_patch_t *patch)
 Acquire read lock on shared patch cache entry.
 
void dt_drawlayer_cache_patch_rdunlock (const dt_drawlayer_cache_patch_t *patch)
 Release read lock on shared patch cache entry.
 
void dt_drawlayer_cache_patch_wrlock (const dt_drawlayer_cache_patch_t *patch)
 Acquire write lock on shared patch cache entry.
 
void dt_drawlayer_cache_patch_wrunlock (const dt_drawlayer_cache_patch_t *patch)
 Release write lock on shared patch cache entry.
 
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 and dirty-state bookkeeping.
 
gboolean dt_drawlayer_cache_ensure_process_patch_buffer (dt_drawlayer_cache_patch_t *process_patch, dt_drawlayer_cache_patch_t *process_stroke_mask, const int width, const int height, const char *patch_buffer_name, const char *mask_buffer_name)
 Ensure process patch and process-stroke-mask backing buffers exist.
 
void dt_drawlayer_cache_build_combined_process_roi (const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *process_roi, const int current_full_w, const int current_full_h, const int src_w, const int src_h, const int module_origin_x, const int module_origin_y, dt_iop_roi_t *combined_roi)
 Build combined ROI mapping process tile coordinates to fitted source image.
 
void dt_drawlayer_cache_resolve_piece_input_origin (const dt_dev_pixelpipe_iop_t *piece, const int current_full_w, const int current_full_h, int *module_origin_x, int *module_origin_y)
 Build combined ROI using module origin heuristics from piece buffers.
 
void dt_drawlayer_cache_build_combined_process_roi_for_piece (const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *process_roi, const int current_full_w, const int current_full_h, const int src_w, const int src_h, dt_iop_roi_t *combined_roi)
 Build combined ROI using module origin heuristics from piece buffers.
 
gboolean dt_drawlayer_cache_build_process_blend_rois (const dt_drawlayer_cache_patch_t *process_patch, const 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)
 Resolve source/target ROIs used when blending process patch to output ROI.
 
gboolean dt_drawlayer_cache_resample_process_patch_to_output (const dt_drawlayer_cache_patch_t *process_patch, const int process_patch_padding, const dt_iop_roi_t *roi_out, float *layerbuf, const int layerbuf_width)
 Copy or resample process patch into output layer buffer.
 
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, const int process_pad, const int patch_width, const 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 using ROI crop/scale rules.
 
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 the base patch.
 

Function Documentation

◆ dt_drawlayer_cache_alloc_temp_buffer()

void * dt_drawlayer_cache_alloc_temp_buffer ( const size_t  bytes,
const char *  name 
)

◆ dt_drawlayer_cache_build_combined_process_roi()

void dt_drawlayer_cache_build_combined_process_roi ( const dt_dev_pixelpipe_iop_t piece,
const dt_iop_roi_t process_roi,
const int  current_full_w,
const int  current_full_h,
const int  src_w,
const int  src_h,
const int  module_origin_x,
const int  module_origin_y,
dt_iop_roi_t combined_roi 
)

Build combined ROI mapping process tile coordinates to fitted source image.

Build process+padding ROI in module-buffer coordinates.

References dt_iop_roi_t::height, MAX, MIN, dt_iop_roi_t::scale, dt_iop_roi_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.

Referenced by dt_drawlayer_cache_build_combined_process_roi_for_piece().

◆ dt_drawlayer_cache_build_combined_process_roi_for_piece()

void dt_drawlayer_cache_build_combined_process_roi_for_piece ( const dt_dev_pixelpipe_iop_t piece,
const dt_iop_roi_t process_roi,
const int  current_full_w,
const int  current_full_h,
const int  src_w,
const int  src_h,
dt_iop_roi_t combined_roi 
)

Build combined ROI using module origin heuristics from piece buffers.

Convenience wrapper using piece ROI offsets as module origin.

References dt_drawlayer_cache_build_combined_process_roi(), and dt_drawlayer_cache_resolve_piece_input_origin().

Referenced by _update_runtime_state(), and dt_drawlayer_compute_process_patch_geometry().

◆ dt_drawlayer_cache_build_process_blend_rois()

gboolean dt_drawlayer_cache_build_process_blend_rois ( const dt_drawlayer_cache_patch_t process_patch,
const 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 
)

Resolve source/target ROIs used when blending process patch to output ROI.

Build blend/source ROIs from process patch and output ROI.

References FALSE, dt_iop_roi_t::height, dt_drawlayer_cache_patch_t::height, MAX, dt_iop_roi_t::scale, TRUE, dt_iop_roi_t::width, dt_drawlayer_cache_patch_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.

Referenced by dt_drawlayer_cache_resample_process_patch_to_output(), and process().

◆ dt_drawlayer_cache_clear_transparent_float()

void dt_drawlayer_cache_clear_transparent_float ( float *  pixels,
const size_t  pixel_count 
)

Fill float RGBA buffer with transparent black.

Fill RGBA float buffer with transparent black.

Referenced by _clear_current_layer(), _refresh_piece_base_cache(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_io_background_layer_job_run(), dt_drawlayer_io_load_flat_rgba(), and dt_drawlayer_io_load_layer().

◆ dt_drawlayer_cache_ensure_process_patch_buffer()

gboolean dt_drawlayer_cache_ensure_process_patch_buffer ( dt_drawlayer_cache_patch_t process_patch,
dt_drawlayer_cache_patch_t process_stroke_mask,
const int  width,
const int  height,
const char *  patch_buffer_name,
const char *  mask_buffer_name 
)

◆ dt_drawlayer_cache_ensure_scratch_buffer()

float * dt_drawlayer_cache_ensure_scratch_buffer ( float **  buffer,
size_t *  capacity_pixels,
const size_t  needed_pixels,
const char *  name 
)

Ensure scratch RGBA float capacity in pixels.

Ensure a float RGBA scratch buffer capacity in pixels.

References dt_drawlayer_cache_alloc_temp_buffer(), dt_drawlayer_cache_free_temp_buffer(), and name.

Referenced by dt_drawlayer_cache_flush_process_patch_to_base(), and process().

◆ dt_drawlayer_cache_flush_process_patch_to_base()

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 
)

◆ dt_drawlayer_cache_free_temp_buffer()

void dt_drawlayer_cache_free_temp_buffer ( void **  buffer,
const char *  name 
)

Free temporary aligned cache buffer.

Release temporary scratch buffer allocated by cache helpers.

References darktable, dt_pixelpipe_cache_free_align_cache(), name, and darktable_t::pixelpipe_cache.

Referenced by _destroy_process_scratch(), dt_drawlayer_cache_ensure_scratch_buffer(), and dt_drawlayer_io_background_layer_job_run().

◆ dt_drawlayer_cache_invalidate_process_patch_state()

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 and dirty-state bookkeeping.

Reset process-patch validity/dirty state bookkeeping.

References dt_drawlayer_paint_runtime_state_reset(), and FALSE.

Referenced by dt_drawlayer_process_state_invalidate().

◆ dt_drawlayer_cache_patch_alloc_shared()

◆ dt_drawlayer_cache_patch_clear()

◆ dt_drawlayer_cache_patch_rdlock()

◆ dt_drawlayer_cache_patch_rdunlock()

◆ dt_drawlayer_cache_patch_wrlock()

◆ dt_drawlayer_cache_patch_wrunlock()

◆ dt_drawlayer_cache_populate_process_patch_from_base()

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,
const int  process_pad,
const int  patch_width,
const 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 
)

◆ dt_drawlayer_cache_resample_process_patch_to_output()

gboolean dt_drawlayer_cache_resample_process_patch_to_output ( const dt_drawlayer_cache_patch_t process_patch,
const int  process_patch_padding,
const dt_iop_roi_t roi_out,
float *  layerbuf,
const int  layerbuf_width 
)

Copy or resample process patch into output layer buffer.

Resample process patch into output layer buffer ROI.

References dt_drawlayer_cache_build_process_blend_rois(), dt_iop_clip_and_zoom(), FALSE, dt_iop_roi_t::height, dt_drawlayer_cache_patch_t::pixels, TRUE, dt_iop_roi_t::width, and dt_drawlayer_cache_patch_t::width.

◆ dt_drawlayer_cache_resolve_piece_input_origin()

void dt_drawlayer_cache_resolve_piece_input_origin ( const dt_dev_pixelpipe_iop_t piece,
const int  current_full_w,
const int  current_full_h,
int *  module_origin_x,
int *  module_origin_y 
)

Build combined ROI using module origin heuristics from piece buffers.

Resolve effective module input origin, including centered-fit fallback.

References dt_dev_pixelpipe_iop_t::buf_in, dt_iop_roi_t::height, MAX, dt_iop_roi_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.

Referenced by _virtual_piece_input_offset(), and dt_drawlayer_cache_build_combined_process_roi_for_piece().