Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_snapshot.h
Go to the documentation of this file.
1/*
2 This file is part of ansel,
3 Copyright (C) 2025-2026 Guillaume STUTIN.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18#pragma once
19
20#include <cairo.h>
21#include <glib.h>
22#include <stdint.h>
23
24struct dt_develop_t;
25
26// A still render of one image's pipeline output, decoupled from any live dt_dev_pixelpipe_t,
27// plus the resampled-crop cache needed to composite it into a darkroom viewport at an arbitrary
28// pan/zoom. Used to show an image other than (or a frozen past state of) the one currently open
29// in darkroom, positioned as if it were the live pipe's own output -- see libs/snapshots.c
30// (compare current edit against a past history state) and libs/duplicate.c (preview another
31// version of the same shot without leaving darkroom).
32typedef struct dt_dev_snapshot_t
33{
34 cairo_surface_t *image; // full-resolution render, owned. NULL if nothing captured.
35 cairo_surface_t *display_image; // Mitchell-resampled viewport crop cache, owned. Rebuilt by
36 // dt_dev_snapshot_draw() as pan/zoom moves; never set directly.
39 float sample_scale; // scale `image` was rendered at (see dt_dev_snapshot_capture)
41
42// Renders imgid's pipeline output into snap->image, replacing any previous content. `scale` is
43// the fraction of the processed image size to render at (1.0 = full size).
44//
45// history_override/iop_order_override, if non-NULL, are used verbatim instead of imgid's own
46// on-disk history -- e.g. to capture a *live*, possibly-uncommitted edit from a dt_develop_t
47// that currently has imgid open. Ownership of both lists transfers to this call (freed
48// internally, win or lose) -- duplicate them first (dt_history_duplicate() /
49// dt_ioppr_iop_order_copy_deep()) if the caller still needs its own copy afterwards. Pass
50// NULL/NULL/-1 to render imgid's own persisted history as-is, with no live override.
51//
52// Returns FALSE on failure, in which case snap is left cleared.
53gboolean dt_dev_snapshot_capture(dt_dev_snapshot_t *snap, int32_t imgid, float scale,
54 GList *history_override, GList *iop_order_override,
55 int32_t history_end_override);
56
57// Frees snap's surfaces and resets it to empty. Safe to call on an already-empty snapshot.
59
60// Paints snap into cri as if it were dev's own pipeline output, matching dev's current pan and
61// zoom (dev->roi, dt_dev_get_zoom_level()), clipped to (clip_x, clip_y, clip_w, clip_h) in widget
62// space. width/height must be the full darkroom center-view widget size -- needed to locate
63// source pixel (0,0) -- independently of how small the clip rect is. No-op if snap holds no
64// image. Rebuilds/reuses snap->display_image as needed; callers must not free it directly.
65void dt_dev_snapshot_draw(dt_dev_snapshot_t *snap, cairo_t *cri, struct dt_develop_t *dev,
66 int32_t width, int32_t height,
67 double clip_x, double clip_y, double clip_w, double clip_h);
68
69// clang-format off
70// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
71// vim: shiftwidth=2 expandtab tabstop=2 cindent
72// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
73// clang-format on
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
void dt_dev_snapshot_draw(dt_dev_snapshot_t *snap, cairo_t *cri, struct dt_develop_t *dev, int32_t width, int32_t height, double clip_x, double clip_y, double clip_w, double clip_h)
void dt_dev_snapshot_clear(dt_dev_snapshot_t *snap)
gboolean dt_dev_snapshot_capture(dt_dev_snapshot_t *snap, int32_t imgid, float scale, GList *history_override, GList *iop_order_override, int32_t history_end_override)
cairo_surface_t * image
cairo_surface_t * display_image