![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
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 | |
| void * | dt_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. | |
Patch/cache helpers for drawlayer process and preview buffers.
| typedef struct dt_drawlayer_cache_patch_t dt_drawlayer_cache_patch_t |
Generic float RGBA patch stored either in malloc memory or pixel cache.
| void * dt_drawlayer_cache_alloc_temp_buffer | ( | const size_t | bytes, |
| const char * | name | ||
| ) |
Allocate a temporary RGBA scratch buffer.
Allocate a temporary RGBA scratch buffer.
References darktable, DT_DEV_PIXELPIPE_NONE, dt_pixelpipe_cache_alloc_align_cache_impl(), name, and darktable_t::pixelpipe_cache.
Referenced by _ensure_external_patch_buffer(), dt_drawlayer_cache_ensure_process_patch_buffer(), dt_drawlayer_cache_ensure_scratch_buffer(), and dt_drawlayer_io_background_layer_job_run().
| 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().
| 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().
| 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().
| 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().
| 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 its stroke mask buffers are allocated.
Ensure process patch and its stroke mask buffers are allocated.
References dt_drawlayer_cache_patch_t::cache_entry, dt_drawlayer_cache_patch_t::cache_hash, darktable, dt_dev_pixelpipe_cache_ref_entry_for_host_ptr(), dt_drawlayer_cache_alloc_temp_buffer(), dt_drawlayer_cache_patch_clear(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_drawlayer_cache_patch_t::external_alloc, FALSE, dt_pixel_cache_entry_t::hash, height, dt_drawlayer_cache_patch_t::height, darktable_t::pixelpipe_cache, dt_drawlayer_cache_patch_t::pixels, TRUE, width, dt_drawlayer_cache_patch_t::width, dt_drawlayer_cache_patch_t::x, and dt_drawlayer_cache_patch_t::y.
Referenced by dt_drawlayer_build_process_patch_from_base().
| 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().
| 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.
Flush dirty process-patch region back into base patch.
References darktable, dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_drawlayer_cache_ensure_scratch_buffer(), dt_drawlayer_cache_patch_wrlock(), dt_drawlayer_cache_patch_wrunlock(), dt_drawlayer_paint_runtime_state_reset(), dt_iop_clip_and_zoom(), FALSE, dt_drawlayer_cache_patch_t::height, MAX, MIN, dt_drawlayer_damaged_rect_t::nw, darktable_t::pixelpipe_cache, dt_drawlayer_cache_patch_t::pixels, dt_iop_roi_t::scale, dt_drawlayer_damaged_rect_t::se, TRUE, dt_drawlayer_damaged_rect_t::valid, dt_drawlayer_cache_patch_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.
Referenced by _flush_process_patch_to_base_locked().
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().
| 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().
| 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/reuse shared patch storage from pixel cache.
Allocate/reuse shared patch storage from pixel cache.
References dt_drawlayer_cache_patch_t::cache_entry, dt_drawlayer_cache_patch_t::cache_hash, dt_iop_buffer_dsc_t::channels, dt_iop_buffer_dsc_t::cst, darktable, dt_iop_buffer_dsc_t::datatype, dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_wrlock_entry(), DT_DEV_PIXELPIPE_NONE, dt_drawlayer_cache_patch_clear(), dt_drawlayer_cache_patch_t::external_alloc, FALSE, height, dt_drawlayer_cache_patch_t::height, IOP_CS_RGB, name, darktable_t::pixelpipe_cache, dt_drawlayer_cache_patch_t::pixels, TRUE, TYPE_FLOAT, width, dt_drawlayer_cache_patch_t::width, dt_drawlayer_cache_patch_t::x, and dt_drawlayer_cache_patch_t::y.
Referenced by _refresh_piece_base_cache(), _rekey_shared_base_patch(), and dt_drawlayer_ensure_layer_cache().
| void dt_drawlayer_cache_patch_clear | ( | dt_drawlayer_cache_patch_t * | patch, |
| const char * | external_alloc_name | ||
| ) |
Drop patch storage and clear metadata.
Drop patch storage and clear metadata.
References dt_drawlayer_cache_patch_t::cache_entry, dt_drawlayer_cache_patch_t::cache_hash, darktable, dt_dev_pixelpipe_cache_ref_count_entry(), dt_free, dt_pixelpipe_cache_free_align_cache(), dt_drawlayer_cache_patch_t::external_alloc, FALSE, darktable_t::pixelpipe_cache, and dt_drawlayer_cache_patch_t::pixels.
Referenced by _delete_current_layer(), _ensure_external_patch_buffer(), _refresh_piece_base_cache(), _rekey_shared_base_patch(), dt_drawlayer_cache_ensure_process_patch_buffer(), dt_drawlayer_cache_patch_alloc_shared(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_process_state_cleanup(), and dt_drawlayer_runtime_manager_update().
| void dt_drawlayer_cache_patch_rdlock | ( | const dt_drawlayer_cache_patch_t * | patch | ) |
Acquire read lock on shared patch cache entry.
References dt_drawlayer_cache_patch_t::cache_entry, darktable, dt_dev_pixelpipe_cache_rdlock_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, darktable_t::pixelpipe_cache, and TRUE.
Referenced by _rekey_shared_base_patch(), _update_runtime_state(), dt_drawlayer_build_process_patch_from_base(), dt_drawlayer_cache_populate_process_patch_from_base(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_flush_layer_cache(), dt_drawlayer_prime_live_process_patch_before_stroke(), dt_drawlayer_process_state_publish_locked(), dt_drawlayer_worker_replay_finished_stroke_to_base_patch(), and process().
| void dt_drawlayer_cache_patch_rdunlock | ( | const dt_drawlayer_cache_patch_t * | patch | ) |
Release read lock on shared patch cache entry.
References dt_drawlayer_cache_patch_t::cache_entry, darktable, dt_dev_pixelpipe_cache_rdlock_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, FALSE, and darktable_t::pixelpipe_cache.
Referenced by _rekey_shared_base_patch(), _release_runtime_source(), dt_drawlayer_build_process_patch_from_base(), dt_drawlayer_cache_populate_process_patch_from_base(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_flush_layer_cache(), dt_drawlayer_prime_live_process_patch_before_stroke(), dt_drawlayer_process_state_publish_locked(), dt_drawlayer_worker_replay_finished_stroke_to_base_patch(), and process().
| void dt_drawlayer_cache_patch_wrlock | ( | const dt_drawlayer_cache_patch_t * | patch | ) |
Acquire write lock on shared patch cache entry.
References dt_drawlayer_cache_patch_t::cache_entry, darktable, dt_dev_pixelpipe_cache_wrlock_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, darktable_t::pixelpipe_cache, and TRUE.
Referenced by _clear_current_layer(), _fill_current_layer(), _rasterize_pending_dab_batch(), _refresh_piece_base_cache(), dt_drawlayer_build_process_patch_from_base(), dt_drawlayer_cache_flush_process_patch_to_base(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_flush_process_patch_to_base(), dt_drawlayer_process_state_invalidate(), dt_drawlayer_process_state_publish_locked(), dt_drawlayer_process_state_reset_stroke(), dt_drawlayer_runtime_manager_update(), and dt_drawlayer_worker_replay_finished_stroke_to_base_patch().
| void dt_drawlayer_cache_patch_wrunlock | ( | const dt_drawlayer_cache_patch_t * | patch | ) |
Release write lock on shared patch cache entry.
References dt_drawlayer_cache_patch_t::cache_entry, darktable, dt_dev_pixelpipe_cache_wrlock_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, FALSE, and darktable_t::pixelpipe_cache.
Referenced by _clear_current_layer(), _fill_current_layer(), _rasterize_pending_dab_batch(), _refresh_piece_base_cache(), dt_drawlayer_build_process_patch_from_base(), dt_drawlayer_cache_flush_process_patch_to_base(), dt_drawlayer_ensure_layer_cache(), dt_drawlayer_flush_process_patch_to_base(), dt_drawlayer_process_state_invalidate(), dt_drawlayer_process_state_publish_locked(), dt_drawlayer_process_state_reset_stroke(), dt_drawlayer_runtime_manager_update(), and dt_drawlayer_worker_replay_finished_stroke_to_base_patch().
| 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 with crop/scale and synchronized stroke mask.
Populate process patch from base patch with crop/scale and synchronized stroke mask.
References darktable, dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_drawlayer_cache_patch_rdlock(), dt_drawlayer_cache_patch_rdunlock(), dt_drawlayer_paint_runtime_state_reset(), dt_iop_clip_and_zoom(), FALSE, dt_iop_roi_t::height, dt_drawlayer_cache_patch_t::height, MAX, MIN, darktable_t::pixelpipe_cache, dt_drawlayer_cache_patch_t::pixels, dt_iop_roi_t::scale, TRUE, dt_iop_roi_t::width, dt_drawlayer_cache_patch_t::width, x, dt_iop_roi_t::x, dt_drawlayer_cache_patch_t::x, dt_iop_roi_t::y, and dt_drawlayer_cache_patch_t::y.
Referenced by dt_drawlayer_build_process_patch_from_base().
| 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.
| 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().