54#include <gdk/gdkkeysyms.h>
87static void get_corner(
const int32_t *aabb,
const int i, int32_t *
p)
89 for(
int k = 0;
k < 2;
k++)
p[
k] = aabb[2 * ((
i >>
k) & 1) +
k];
94 aabb[0] =
MIN(aabb[0],
p[0]);
95 aabb[1] =
MIN(aabb[1],
p[1]);
96 aabb[2] =
MAX(aabb[2],
p[0]);
97 aabb[3] =
MAX(aabb[3],
p[1]);
102 return _(
"orientation");
107 return _(
"rotation|flip");
133 _(
"linear, RGB, scene-referred"), _(
"geometric, RGB"),
134 _(
"linear, RGB, scene-referred"));
151 return raw_orientation ^ user_orientation;
164 corrected |= (raw_flip_y << 1) | (raw_flip_x >> 1);
170 return corrected ^ user_orientation;
174 void *new_params,
const int new_version)
176 if(old_version == 1 && new_version == 2)
178 typedef struct dt_iop_flip_params_v1_t
181 } dt_iop_flip_params_v1_t;
183 const dt_iop_flip_params_v1_t *old = (dt_iop_flip_params_v1_t *)old_params;
210 const int32_t tmp = iw;
221 o[0] = iw - o[0] - 1;
225 o[1] = ih - o[1] - 1;
246 return p->orientation;
264 float *
const restrict points,
size_t points_count)
270 if (
d->orientation == 0)
return 1;
272 for(
size_t i = 0;
i < points_count * 2;
i += 2)
275 float y = points[
i + 1];
291 float *
const restrict points,
size_t points_count)
297 if (
d->orientation == 0)
return 1;
299 for(
size_t i = 0;
i < points_count * 2;
i += 2)
323 const float *
const in,
float *
const out,
const dt_iop_roi_t *
const roi_in,
329 const int bpp =
sizeof(float);
330 const int stride =
bpp * roi_in->
width;
357 int32_t aabb[4] = { roi_out->
x, roi_out->
y, roi_out->
x + roi_out->
width - 1, roi_out->
y + roi_out->
height - 1 };
358 int32_t aabb_in[4] = { INT_MAX, INT_MAX, INT_MIN, INT_MIN };
359 for(
int c = 0; c < 4; c++)
371 roi_in->
x = aabb_in[0];
372 roi_in->
y = aabb_in[1];
374 roi_in->
width = aabb_in[2] - aabb_in[0] + 1;
375 roi_in->
height = aabb_in[3] - aabb_in[1] + 1;
380 roi_in->
x = CLAMP(roi_in->
x, 0, (
int)floorf(w));
381 roi_in->
y = CLAMP(roi_in->
y, 0, (
int)floorf(h));
382 roi_in->
width = CLAMP(roi_in->
width, 1, (
int)ceilf(w) - roi_in->
x);
383 roi_in->
height = CLAMP(roi_in->
height, 1, (
int)ceilf(h) - roi_in->
y);
395 const int stride =
bpp * roi_in->
width;
410 const int devid = pipe->
devid;
424 if(err != CL_SUCCESS)
goto error;
435 const int program = 2;
475 for(
size_t i = 0;
i < points_count * 2;
i += 2)
478 float y = points[
i + 1];
497 for(
size_t i = 0;
i < points_count * 2;
i += 2)
500 float y = points[
i + 1];
561 self->version(), &
p,
sizeof(
p), 1);
566 self->version(), &
p,
sizeof(
p), 1);
570 self->version(), &
p,
sizeof(
p), 1);
574 self->version(), &
p,
sizeof(
p), 1);
578 self->version(), &
p,
sizeof(
p), 1);
582 self->version(), &
p,
sizeof(
p), 1);
586 self->version(), &
p,
sizeof(
p), 1);
636 p->orientation = orientation;
static void error(char *msg)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
const dt_colormatrix_t dt_aligned_pixel_t out
#define dt_database_start_transaction()
#define dt_database_release_transaction()
#define dt_dev_add_history_item(dev, module, enable, redraw)
static void _flip_h(GtkWidget *widget, dt_iop_module_t *self)
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 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)
const char ** description(struct dt_iop_module_t *self)
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)
static int _flip_geometry_backtransform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
static void _flip_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
static void _flip_map_size(const dt_image_orientation_t orientation, const dt_iop_roi_t *const roi_in, dt_iop_roi_t *roi_out)
Input rect -> output rect: a swap, or nothing.
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)
static dt_image_orientation_t merge_two_orientations(dt_image_orientation_t raw_orientation, dt_image_orientation_t user_orientation)
static void rotate_cw(GtkWidget *widget, dt_iop_module_t *self)
static void adjust_aabb(const int32_t *p, int32_t *aabb)
static int _flip_geometry_transform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static const dt_geometry_vtable_t _flip_geometry_vtable
gboolean geometry_record(dt_iop_module_t *self, const void *params, dt_geometry_record_t *record)
static void rotate_ccw(GtkWidget *widget, dt_iop_module_t *self)
void cleanup_global(dt_iop_module_so_t *self)
void gui_init(struct dt_iop_module_t *self)
static void _flip_v(GtkWidget *widget, dt_iop_module_t *self)
static dt_image_orientation_t _flip_resolve(dt_iop_module_t *self, const dt_iop_flip_params_t *const p)
The orientation this module will actually apply.
void reload_defaults(dt_iop_module_t *self)
static void get_corner(const int32_t *aabb, const int i, int32_t *p)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void gui_cleanup(struct dt_iop_module_t *self)
void init_presets(dt_iop_module_so_t *self)
static void backtransform(const int32_t *x, int32_t *o, const dt_image_orientation_t orientation, int32_t iw, int32_t ih)
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)
void cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
struct dt_iop_flip_params_t dt_iop_flip_data_t
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 *self)
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)
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)
int legacy_params(dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
static void do_rotate(dt_iop_module_t *self, uint32_t cw)
Where things are on the image, answered without a pipeline.
void dt_gui_presets_add_generic(const char *name, dt_dev_operation_t op, const int32_t version, const void *params, const int32_t params_size, const int32_t enabled)
void dt_gui_presets_update_autoapply(const char *name, dt_dev_operation_t op, const int32_t version, const int autoapply)
gboolean dt_history_repository_module_exists(const int32_t imgid, const char *operation)
@ ORIENTATION_ROTATE_CCW_90_DEG
@ ORIENTATION_ROTATE_CW_90_DEG
@ ORIENTATION_ROTATE_180_DEG
@ ORIENTATION_FLIP_VERTICALLY
@ ORIENTATION_FLIP_HORIZONTALLY
static dt_image_orientation_t dt_image_orientation(const dt_image_t *img)
__DT_CLONE_TARGETS__ void dt_imageio_flip_buffers(char *out, const char *in, const size_t bpp, const int wd, const int ht, const int fwd, const int fht, const int stride, const dt_image_orientation_t orientation)
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
@ IOP_FLAGS_TILING_FULL_ROI
GtkWidget * dt_iop_button_new(dt_iop_module_t *self, const gchar *label, GCallback callback, gboolean local, guint accel_key, GdkModifierType mods, DTGTKCairoPaintIconFunc paint, gint paintflags, GtkWidget *box)
GtkWidget * dt_iop_gui_reset_label_new(const gchar *label, dt_iop_module_t *module, void *param, int param_size)
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void * dt_calloc_align(size_t size)
dt_alloc_align() followed by a zero fill.
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
DT_MODULE() for a module whose params struct is introspected.
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
int dt_opencl_create_kernel(const int prog, const char *name)
void dt_opencl_free_kernel(const int kernel)
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
#define __OMP_PARALLEL_FOR__(...)
dt_iop_buffer_dsc_t dsc_in
struct dt_iop_module_t *void * data
One module instance's contribution, as data.
const dt_geometry_vtable_t * vtable
void(* free_data)(void *data)
A module's geometry, evaluated. Pure functions of the record's own data.
void(* map_size)(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
Full-resolution input rect -> output rect. Mirrors modify_roi_out() at scale 1.
dt_image_raw_parameters_t legacy_flip
dt_image_orientation_t orientation
dt_image_orientation_t orientation
dt_iop_gui_data_t * gui_data
dt_iop_global_data_t * data
dt_iop_params_t * default_params
struct dt_iop_module_gui_t * gui
struct dt_develop_t * dev
dt_iop_global_data_t * global_data
Region of interest passed through the pixelpipe.