Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
cache.h File Reference

Patch/cache helpers for drawlayer process and preview buffers. More...

#include "develop/imageop.h"
#include "develop/pixelpipe_cache.h"
#include "iop/drawlayer/paint.h"
#include <glib.h>
#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for iop/drawlayer/cache.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_drawlayer_cache_patch_t
 Generic float RGBA patch stored either in malloc memory or pixel cache. More...
 

Typedefs

typedef struct dt_drawlayer_cache_patch_t dt_drawlayer_cache_patch_t
 Generic float RGBA patch stored either in malloc memory or pixel cache.
 

Functions

voiddt_drawlayer_cache_alloc_temp_buffer (size_t bytes, const char *name)
 Allocate a temporary RGBA scratch buffer.
 
void dt_drawlayer_cache_free_temp_buffer (void **buffer, const char *name)
 Release temporary scratch buffer allocated by cache helpers.
 
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_clear_transparent_float (float *pixels, size_t pixel_count)
 Fill RGBA float buffer with transparent black.
 
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_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_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/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, int width, int height, const char *patch_buffer_name, const char *mask_buffer_name)
 Ensure process patch and its stroke mask buffers are allocated.
 
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_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_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.
 
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.
 
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.
 
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.
 
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.
 

Detailed Description

Patch/cache helpers for drawlayer process and preview buffers.

Typedef Documentation

◆ dt_drawlayer_cache_patch_t

Generic float RGBA patch stored either in malloc memory or pixel cache.

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 process+padding ROI in module-buffer coordinates.

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 
)

Convenience wrapper using piece ROI offsets as module origin.

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 
)

Build blend/source ROIs from process patch and 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 RGBA float 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 a float RGBA scratch buffer 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 
)

Release temporary scratch buffer allocated by cache helpers.

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/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 
)

Resample process patch into output layer buffer ROI.

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 
)

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

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().