Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
borders.c File Reference
#include "widgets/bauhaus.h"
#include "system/openmp.h"
#include "system/target_clones.h"
#include "system/mem_alloc.h"
#include "system/simd.h"
#include "common/logging.h"
#include "common/module_versioning.h"
#include "common/imagebuf.h"
#include "common/opencl.h"
#include "develop/develop.h"
#include "develop/geometry/geometry.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "gui/color_picker_proxy.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for borders.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_borders_params_t
 
struct  dt_iop_borders_gui_data_t
 
struct  dt_iop_borders_global_data_t
 
struct  border_positions_t
 

Macros

#define DT_IOP_BORDERS_ASPECT_COUNT   12
 
#define DT_IOP_BORDERS_ASPECT_IMAGE_IDX   0
 
#define DT_IOP_BORDERS_ASPECT_CONSTANT_IDX   11
 
#define DT_IOP_BORDERS_ASPECT_IMAGE_VALUE   0.0f
 
#define DT_IOP_BORDERS_ASPECT_CONSTANT_VALUE   -1.0f
 
#define DT_IOP_BORDERS_ASPECT_ORIENTATION_AUTO   0
 
#define DT_IOP_BORDERS_ASPECT_ORIENTATION_PORTRAIT   1
 
#define DT_IOP_BORDERS_ASPECT_ORIENTATION_LANDSCAPE   2
 
#define DT_IOP_BORDERS_POSITION_H_COUNT   5
 
#define DT_IOP_BORDERS_POSITION_V_COUNT   5
 

Typedefs

typedef struct dt_iop_borders_params_t dt_iop_borders_params_t
 
typedef struct dt_iop_borders_gui_data_t dt_iop_borders_gui_data_t
 
typedef struct dt_iop_borders_global_data_t dt_iop_borders_global_data_t
 
typedef struct dt_iop_borders_params_t dt_iop_borders_data_t
 

Functions

int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
 
const char * name ()
 
const char ** description (struct dt_iop_module_t *self)
 
int default_group ()
 
int operation_tags ()
 
int flags ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
static void _borders_offset (const dt_iop_borders_data_t *const d, const dt_iop_roi_t *const in, const dt_iop_roi_t *const out, int *left, int *top)
 The translation the border applies, from the two rects it sits between.
 
int distort_transform (dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
 
int distort_backtransform (dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
 
void distort_mask (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const float *const in, float *const out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
static void _borders_map_size (const dt_iop_borders_data_t *const d, const dt_iop_roi_t *const roi_in, dt_iop_roi_t *roi_out)
 Input rect -> output rect. THE size evaluator: modify_roi_out() below and the geometry record both call it, so the frame the pipe renders and the frame the GUI measures are the same frame.
 
void modify_roi_out (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, dt_iop_roi_t *roi_out, const dt_iop_roi_t *roi_in)
 
void modify_roi_in (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi_out, dt_iop_roi_t *roi_in)
 
static void set_pixels (float *buf, const dt_aligned_pixel_t color, const int npixels)
 
static void copy_pixels (float *out, const float *const in, const int npixels)
 
__DT_CLONE_TARGETS__ void copy_image_with_border (float *out, const float *const in, const struct border_positions_t *binfo)
 
int process (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
 
int process_cl (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
static void _borders_geometry_map_size (const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
 
static int _borders_geometry_transform (const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
 
static int _borders_geometry_backtransform (const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
 
gboolean geometry_record (dt_iop_module_t *self, const void *params, dt_geometry_record_t *record)
 
void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void init_presets (dt_iop_module_so_t *self)
 
void color_picker_apply (dt_iop_module_t *self, GtkWidget *picker, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static void aspect_changed (GtkWidget *combo, dt_iop_module_t *self)
 
static void position_h_changed (GtkWidget *combo, dt_iop_module_t *self)
 
static void position_v_changed (GtkWidget *combo, dt_iop_module_t *self)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
static void colorpick_color_set (GtkColorButton *widget, dt_iop_module_t *self)
 
static void frame_colorpick_color_set (GtkColorButton *widget, dt_iop_module_t *self)
 
void gui_update (struct dt_iop_module_t *self)
 
static void gui_init_aspect (struct dt_iop_module_t *self)
 
static void gui_init_positions (struct dt_iop_module_t *self)
 
void gui_init (struct dt_iop_module_t *self)
 
void init (dt_iop_module_t *self)
 

Variables

static const dt_geometry_vtable_t _borders_geometry_vtable
 

Macro Definition Documentation

◆ DT_IOP_BORDERS_ASPECT_CONSTANT_IDX

#define DT_IOP_BORDERS_ASPECT_CONSTANT_IDX   11

Definition at line 84 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_CONSTANT_VALUE

#define DT_IOP_BORDERS_ASPECT_CONSTANT_VALUE   -1.0f

Definition at line 86 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_COUNT

#define DT_IOP_BORDERS_ASPECT_COUNT   12

Definition at line 82 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_IMAGE_IDX

#define DT_IOP_BORDERS_ASPECT_IMAGE_IDX   0

Definition at line 83 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_IMAGE_VALUE

#define DT_IOP_BORDERS_ASPECT_IMAGE_VALUE   0.0f

Definition at line 85 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_ORIENTATION_AUTO

#define DT_IOP_BORDERS_ASPECT_ORIENTATION_AUTO   0

Definition at line 87 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_ORIENTATION_LANDSCAPE

#define DT_IOP_BORDERS_ASPECT_ORIENTATION_LANDSCAPE   2

Definition at line 89 of file borders.c.

◆ DT_IOP_BORDERS_ASPECT_ORIENTATION_PORTRAIT

#define DT_IOP_BORDERS_ASPECT_ORIENTATION_PORTRAIT   1

Definition at line 88 of file borders.c.

◆ DT_IOP_BORDERS_POSITION_H_COUNT

#define DT_IOP_BORDERS_POSITION_H_COUNT   5

Definition at line 90 of file borders.c.

◆ DT_IOP_BORDERS_POSITION_V_COUNT

#define DT_IOP_BORDERS_POSITION_V_COUNT   5

Definition at line 91 of file borders.c.

Typedef Documentation

◆ dt_iop_borders_data_t

Definition at line 205 of file borders.c.

◆ dt_iop_borders_global_data_t

◆ dt_iop_borders_gui_data_t

◆ dt_iop_borders_params_t

Function Documentation

◆ _borders_geometry_backtransform()

static int _borders_geometry_backtransform ( const void data,
const dt_geometry_record_t *const  record,
dt_geometry_chain_t chain,
float *  points,
size_t  points_count 
)
static

Definition at line 742 of file borders.c.

References _borders_offset(), i, dt_geometry_record_t::in, dt_geometry_record_t::out, and top.

◆ _borders_geometry_map_size()

static void _borders_geometry_map_size ( const void data,
const dt_iop_roi_t *const  in,
dt_iop_roi_t out 
)
static

Definition at line 723 of file borders.c.

References _borders_map_size(), and out.

◆ _borders_geometry_transform()

static int _borders_geometry_transform ( const void data,
const dt_geometry_record_t *const  record,
dt_geometry_chain_t chain,
float *  points,
size_t  points_count 
)
static

Definition at line 728 of file borders.c.

References _borders_offset(), i, dt_geometry_record_t::in, dt_geometry_record_t::out, and top.

◆ _borders_map_size()

static void _borders_map_size ( const dt_iop_borders_data_t *const  d,
const dt_iop_roi_t *const  roi_in,
dt_iop_roi_t roi_out 
)
static

Input rect -> output rect. THE size evaluator: modify_roi_out() below and the geometry record both call it, so the frame the pipe renders and the frame the GUI measures are the same frame.

Definition at line 330 of file borders.c.

References dt_iop_borders_params_t::aspect, d, DT_IOP_BORDERS_ASPECT_CONSTANT_VALUE, DT_IOP_BORDERS_ASPECT_IMAGE_VALUE, DT_IOP_BORDERS_ASPECT_ORIENTATION_AUTO, DT_IOP_BORDERS_ASPECT_ORIENTATION_LANDSCAPE, DT_IOP_BORDERS_ASPECT_ORIENTATION_PORTRAIT, dt_iop_roi_t::height, size, and dt_iop_roi_t::width.

Referenced by _borders_geometry_map_size(), and modify_roi_out().

◆ _borders_offset()

static void _borders_offset ( const dt_iop_borders_data_t *const  d,
const dt_iop_roi_t *const  in,
const dt_iop_roi_t *const  out,
int *  left,
int *  top 
)
static

The translation the border applies, from the two rects it sits between.

Definition at line 252 of file borders.c.

References d, dt_iop_roi_t::height, out, top, and dt_iop_roi_t::width.

Referenced by _borders_geometry_backtransform(), _borders_geometry_transform(), distort_backtransform(), and distort_transform().

◆ aspect_changed()

◆ cleanup_global()

◆ cleanup_pipe()

void cleanup_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

Definition at line 790 of file borders.c.

References dt_dev_pixelpipe_iop_t::data, and dt_free_align.

◆ color_picker_apply()

void color_picker_apply ( dt_iop_module_t self,
GtkWidget picker,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ colorpick_color_set()

static void colorpick_color_set ( GtkColorButton *  widget,
dt_iop_module_t self 
)
static

◆ commit_params()

void commit_params ( struct dt_iop_module_t self,
dt_iop_params_t p1,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

Definition at line 776 of file borders.c.

References d, dt_dev_pixelpipe_iop_t::data, and p.

◆ copy_image_with_border()

◆ copy_pixels()

static void copy_pixels ( float *  out,
const float *const  in,
const int  npixels 
)
inlinestatic

Definition at line 451 of file borders.c.

References __OMP_SIMD__, i, and out.

Referenced by copy_image_with_border().

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece 
)

Definition at line 238 of file borders.c.

References IOP_CS_RGB.

◆ default_group()

int default_group ( )

Definition at line 223 of file borders.c.

References IOP_GROUP_EFFECTS.

◆ description()

const char ** description ( struct dt_iop_module_t self)

Definition at line 213 of file borders.c.

References dt_iop_set_description().

◆ distort_backtransform()

int distort_backtransform ( dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
float *const restrict  points,
size_t  points_count 
)

◆ distort_mask()

void distort_mask ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
const float *const  in,
float *const  out,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out 
)

◆ distort_transform()

int distort_transform ( dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
float *const restrict  points,
size_t  points_count 
)

◆ flags()

int flags ( )

Definition at line 233 of file borders.c.

References IOP_FLAGS_ALLOW_TILING, and IOP_FLAGS_TILING_FULL_ROI.

◆ frame_colorpick_color_set()

static void frame_colorpick_color_set ( GtkColorButton *  widget,
dt_iop_module_t self 
)
static

◆ geometry_record()

gboolean geometry_record ( dt_iop_module_t self,
const void params,
dt_geometry_record_t record 
)

◆ gui_changed()

◆ gui_init()

◆ gui_init_aspect()

◆ gui_init_positions()

static void gui_init_positions ( struct dt_iop_module_t self)
static

Definition at line 1076 of file borders.c.

References dt_bauhaus_combobox_add(), dt_iop_gui_data(), g, and i.

Referenced by gui_init().

◆ gui_update()

◆ init()

◆ init_global()

void init_global ( dt_iop_module_so_t module)

◆ init_pipe()

void init_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ init_presets()

void init_presets ( dt_iop_module_so_t self)

Definition at line 796 of file borders.c.

References dt_gui_presets_add_generic(), dt_iop_module_so_t::op, p, and TRUE.

◆ legacy_params()

int legacy_params ( dt_iop_module_t self,
const void *const  old_params,
const int  old_version,
void new_params,
const int  new_version 
)

◆ modify_roi_in()

void modify_roi_in ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
const dt_iop_roi_t roi_out,
dt_iop_roi_t roi_in 
)
Todo:
: clamping to 1 leads to a one-pixel visual glitch if the right/bottom border completely fills the
Todo:
Todo:
: viewport, but changing it to 0 breaks all of the tiling_callback functions with a division by zero

Definition at line 388 of file borders.c.

References dt_dev_pixelpipe_iop_t::buf_in, dt_dev_pixelpipe_iop_t::buf_out, d, dt_dev_pixelpipe_iop_t::data, 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.

◆ modify_roi_out()

void modify_roi_out ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
dt_iop_roi_t roi_out,
const dt_iop_roi_t roi_in 
)

Definition at line 380 of file borders.c.

References _borders_map_size(), and dt_dev_pixelpipe_iop_t::data.

◆ name()

const char * name ( )

Definition at line 208 of file borders.c.

◆ operation_tags()

int operation_tags ( )

Definition at line 228 of file borders.c.

References IOP_TAG_DECORATION, and IOP_TAG_DISTORT.

◆ position_h_changed()

◆ position_v_changed()

◆ process()

◆ process_cl()

◆ set_pixels()

static void set_pixels ( float *  buf,
const dt_aligned_pixel_t  color,
const int  npixels 
)
inlinestatic

Definition at line 438 of file borders.c.

References __OMP_SIMD__, color, and i.

Referenced by copy_image_with_border().

Variable Documentation

◆ _borders_geometry_vtable

const dt_geometry_vtable_t _borders_geometry_vtable
static
Initial value:
= {
}
static int _borders_geometry_transform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
Definition borders.c:728
static int _borders_geometry_backtransform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
Definition borders.c:742
static void _borders_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
Definition borders.c:723

Definition at line 756 of file borders.c.

Referenced by geometry_record().