54 gboolean found =
FALSE;
68 for(
const GList *node = g_list_first(pipe->
nodes); node; node = g_list_next(node))
90 int32_t raw_width = 0;
91 int32_t raw_height = 0;
93 if(raw_width <= 0 || raw_height <= 0)
return FALSE;
119 int canvas_width = 0;
120 int canvas_height = 0;
148 int *frame_width,
int *frame_height)
184 int frame_height = 0;
187 for(
int i = 0;
i < count;
i++)
189 pts[2 *
i] = (float)placement.
offset_x + pts[2 *
i] * (
float)frame_width;
190 pts[2 *
i + 1] = (float)placement.
offset_y + pts[2 *
i + 1] * (
float)frame_height;
202 int frame_height = 0;
205 for(
int i = 0;
i < count;
i++)
207 pts[2 *
i] = (pts[2 *
i] - (float)placement.
offset_x) / (float)frame_width;
208 pts[2 *
i + 1] = (pts[2 *
i + 1] - (float)placement.
offset_y) / (float)frame_height;
223 float *lx,
float *ly)
227 float pt[2] = { (float)wx, (
float)wy };
236 float *wx,
float *wy)
240 float pt[2] = {
x, y };
248 const float x1,
const float y1,
249 float *left,
float *
top,
250 float *right,
float *bottom)
253 x0, y0, x1, y0, x0, y1, x1, y1,
258 float min_x = pts[0];
259 float max_x = pts[0];
260 float min_y = pts[1];
261 float max_y = pts[1];
262 for(
int i = 1;
i < 4;
i++)
264 min_x = fminf(min_x, pts[2 *
i]);
265 max_x = fmaxf(max_x, pts[2 *
i]);
266 min_y = fminf(min_y, pts[2 *
i + 1]);
267 max_y = fmaxf(max_y, pts[2 *
i + 1]);
278 const float fallback)
288 const float rx = hypotf(pts[2] - pts[0], pts[3] - pts[1]);
289 const float ry = hypotf(pts[4] - pts[0], pts[5] - pts[1]);
290 const float radius = 0.5f * (rx + ry);
291 return fmaxf(0.5f, isfinite(radius) ? radius : fallback);
301 return ceilf(dab.
radius + 1.0f);
309 int layer_height = 0;
316 if(widget_w <= 0.0f || widget_h <= 0.0f || preview_w <= 0.0f || preview_h <= 0.0f)
return FALSE;
320 const float roi_w = fminf(widget_w, preview_w * zoom_scale);
321 const float roi_h = fminf(widget_h, preview_h * zoom_scale);
322 const float rec_x = fmaxf(border, 0.5f * (widget_w - roi_w));
323 const float rec_y = fmaxf(border, 0.5f * (widget_h - roi_h));
324 const float rec_w = fminf(widget_w - 2.0f * border, roi_w);
325 const float rec_h = fminf(widget_h - 2.0f * border, roi_h);
326 if(rec_w <= 0.0f || rec_h <= 0.0f)
return FALSE;
329 rec_x, rec_y, rec_x + rec_w, rec_y, rec_x, rec_y + rec_h, rec_x + rec_w, rec_y + rec_h,
333 float min_x = pts[0];
334 float max_x = pts[0];
335 float min_y = pts[1];
336 float max_y = pts[1];
337 for(
int i = 1;
i < 4;
i++)
339 min_x = fminf(min_x, pts[2 *
i]);
340 max_x = fmaxf(max_x, pts[2 *
i]);
341 min_y = fminf(min_y, pts[2 *
i + 1]);
342 max_y = fmaxf(max_y, pts[2 *
i + 1]);
345 view->layer_x0 = min_x;
346 view->layer_y0 = min_y;
347 view->layer_x1 = max_x;
348 view->layer_y1 = max_y;
350 view->patch.x =
MAX(0, (
int)floorf(min_x - padding));
351 view->patch.y =
MAX(0, (
int)floorf(min_y - padding));
352 const int right =
MIN(layer_width, (
int)ceilf(max_x + padding));
353 const int bottom =
MIN(layer_height, (
int)ceilf(max_y + padding));
355 view->patch.height =
MAX(0, bottom -
view->patch.y);
356 return view->patch.width > 0 &&
view->patch.height > 0;
const dt_colormatrix_t dt_aligned_pixel_t out
gboolean dt_drawlayer_compute_view_patch(dt_iop_module_t *self, const float padding, drawlayer_view_patch_info_t *view)
gboolean dt_drawlayer_layer_canvas_for_pipe(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, int *width, int *height)
gboolean dt_drawlayer_widget_points_to_layer_coords(dt_iop_module_t *self, float *pts, const int count)
gboolean dt_drawlayer_raw_placement_gui(dt_iop_module_t *self, dt_drawlayer_raw_placement_t *placement, int *frame_width, int *frame_height)
The placement against this module's frame, as the GUI sees it.
static gboolean _virtual_piece_layer_geometry(dt_iop_module_t *self, int *layer_width, int *layer_height)
gboolean dt_drawlayer_raw_placement_for_frame(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_iop_roi_t *const frame, dt_drawlayer_raw_placement_t *placement)
float dt_drawlayer_widget_brush_radius(dt_iop_module_t *self, const dt_drawlayer_brush_dab_t *dab, const float fallback)
gboolean dt_drawlayer_layer_points_to_widget_coords(dt_iop_module_t *self, float *pts, const int count)
gboolean dt_drawlayer_layer_bounds_to_widget_bounds(dt_iop_module_t *self, const float x0, const float y0, const float x1, const float y1, float *left, float *top, float *right, float *bottom)
float dt_drawlayer_current_live_padding(dt_iop_module_t *self)
gboolean dt_drawlayer_layer_canvas(dt_iop_module_t *self, int *width, int *height)
dt_drawlayer_layer_canvas_for_pipe for a GUI caller.
gboolean dt_drawlayer_widget_to_layer_coords(dt_iop_module_t *self, const double wx, const double wy, float *lx, float *ly)
static gboolean _flip_swaps_axes(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe)
Does the orientation flip.c settled on swap the axes?
gboolean dt_drawlayer_layer_to_widget_coords(dt_iop_module_t *self, const float x, const float y, float *wx, float *wy)
Shared coordinate transforms and geometry computations for drawlayer.
gboolean dt_dev_geometry_get_raw_size(const dt_develop_t *dev, int32_t *width, int32_t *height)
int32_t dt_dev_roi_request_preview_height(const dt_develop_t *dev)
int32_t dt_dev_roi_request_preview_width(const dt_develop_t *dev)
int32_t dt_dev_viewport_border_size(const dt_develop_t *dev)
int32_t dt_dev_viewport_widget_height(const dt_develop_t *dev)
int32_t dt_dev_viewport_widget_width(const dt_develop_t *dev)
void dt_dev_coordinates_preview_abs_to_image_norm(dt_develop_t *dev, float *points, size_t num_points)
int dt_dev_distort_backtransform_gui(dt_develop_t *dev, const double iop_order, const int transf_direction, float *points, size_t points_count)
The inverse of dt_dev_distort_transform_gui(), same rules.
float dt_dev_get_overlay_scale(dt_develop_t *dev)
Get the overlay scale factor in GUI logical coordinates.
void dt_dev_coordinates_image_norm_to_preview_abs(dt_develop_t *dev, float *points, size_t num_points)
void dt_dev_coordinates_image_norm_to_widget(dt_develop_t *dev, float *points, size_t num_points)
gboolean dt_dev_module_geometry_gui(dt_develop_t *dev, dt_iop_module_t *module, dt_iop_roi_t *in, dt_iop_roi_t *out)
One module's own input and output rectangles at full resolution, from the geometry service.
int dt_dev_distort_transform_gui(dt_develop_t *dev, const double iop_order, const int transf_direction, float *points, size_t points_count)
The GUI's bounded transform folds, composed by the geometry service.
void dt_dev_coordinates_widget_to_image_norm(dt_develop_t *dev, float *points, size_t num_points)
Coordinate conversion helpers between widget, normalized image, and absolute image spaces.
@ DT_DEV_TRANSFORM_DIR_FORW_EXCL
GtkWidget * view
the tree view
const dt_geometry_record_t * dt_geometry_chain_find(const dt_geometry_chain_t *chain, const char *op, const int instance)
One module instance's record, or NULL. Use it for that module's own in/out dims.
Where things are on the image, answered without a pipeline.
static float _conf_hardness(void)
Derive hardness as complementary value of softness.
static float _conf_size(void)
Read and clamp configured brush size (px).
static dt_iop_drawlayer_brush_shape_t _conf_brush_shape(void)
Read and clamp configured brush shape.
static void swap(float *x, float *y)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
struct dt_iop_module_t *void * data
struct dt_geometry_chain_t * geometry_chain
Fully resolved input dab descriptor.
Where the raw-anchored layer canvas sits in this module's own frame.
One module instance's contribution, as data.
struct dt_develop_t * dev
Region of interest passed through the pixelpipe.