2
This file is part of darktable,
3
copyright (c) 2009--2010 johannes hanika.
5
darktable 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.
10
darktable 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.
15
You should have received a copy of the GNU General Public License
16
along with darktable. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef DT_DEV_PIXELPIPE
19
#define DT_DEV_PIXELPIPE
21
#include "develop/imageop.h"
22
#include "develop/develop.h"
23
#include "develop/pixelpipe_cache.h"
26
* struct used by iop modules to connect to pixelpipe.
27
* input and output nodes will be connected to gegl graph.
28
* data can be used to store whatever private data and
29
* will be freed at the end.
31
struct dt_iop_module_t;
32
struct dt_dev_pixelpipe_t;
34
/** region of interest */
35
typedef struct dt_iop_roi_t
37
int x, y, width, height;
42
typedef struct dt_dev_pixelpipe_iop_t
44
struct dt_iop_module_t *module; // the module in the dev operation stack
45
struct dt_dev_pixelpipe_t *pipe; // the pipe this piece belongs to
46
void *data; // to be used by the module to store stuff per pipe piece
47
int enabled; // used to disable parts of the pipe for export, independent on module itself.
48
float iscale; // input actually just downscaled buffer? iscale*iwidth = actual width
49
int iwidth, iheight; // width and height of input buffer
50
uint64_t hash; // hash of params and enabled.
51
int bpc; // bits per channel, 32 means flat
52
int colors; // how many colors per pixel
53
dt_iop_roi_t buf_in, buf_out; // theoretical full buffer regions of interest, as passed through modify_roi_out
54
int process_cl_ready; // set this to 0 in commit_params to temporarily disable the use of process_cl
55
float processed_maximum[3]; // sensor saturation after this iop, used internally for caching
57
dt_dev_pixelpipe_iop_t;
59
typedef enum dt_dev_pixelpipe_change_t
61
DT_DEV_PIPE_UNCHANGED = 0, // no event
62
DT_DEV_PIPE_TOP_CHANGED = 1, // only params of top element changed
63
DT_DEV_PIPE_REMOVE = 2, // possibly elements of the pipe have to be removed
64
DT_DEV_PIPE_SYNCH = 4, // all nodes up to end need to be synched, but no removal of module pieces is necessary
65
DT_DEV_PIPE_ZOOMED = 8 // zoom event, preview pipe does not need changes
67
dt_dev_pixelpipe_change_t;
69
typedef enum dt_dev_pixelpipe_type_t
71
DT_DEV_PIXELPIPE_EXPORT,
72
DT_DEV_PIXELPIPE_FULL,
73
DT_DEV_PIXELPIPE_PREVIEW
75
dt_dev_pixelpipe_type_t;
78
* this encapsulates the gegl pixel pipeline.
79
* a develop module will need several of these:
80
* for previews and full blits to cairo and for
81
* the export function.
83
typedef struct dt_dev_pixelpipe_t
85
// store history/zoom caches
86
dt_dev_pixelpipe_cache_t cache;
89
// width and height of input buffer
91
// input actually just downscaled buffer? iscale*iwidth = actual width
93
// dimensions of processed buffer
94
int processed_width, processed_height;
95
// sensor saturation, propagated through the operations:
96
float processed_maximum[3];
97
// gegl instances of pixel pipeline, stored in GList of dt_dev_pixelpipe_iop_t
100
dt_dev_pixelpipe_change_t changed;
101
// backbuffer (output)
104
int backbuf_width, backbuf_height;
105
uint64_t backbuf_hash;
106
dt_pthread_mutex_t backbuf_mutex, busy_mutex;
111
// input data based on this timestamp:
113
dt_dev_pixelpipe_type_t type;
114
// opencl device that has been locked for this pipe.
121
// inits the pixelpipe with plain passthrough input/output and empty input and default caching settings.
122
void dt_dev_pixelpipe_init(dt_dev_pixelpipe_t *pipe);
123
// inits the pixelpipe with settings optimized for full-image export (no history stack cache)
124
void dt_dev_pixelpipe_init_export(dt_dev_pixelpipe_t *pipe, int32_t width, int32_t height);
125
// inits the pixelpipe with given cacheline size and number of entries.
126
void dt_dev_pixelpipe_init_cached(dt_dev_pixelpipe_t *pipe, int32_t size, int32_t entries);
127
// constructs a new input gegl_buffer from given RGB float array.
128
void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, float *input, int width, int height, float iscale);
130
// returns the dimensions of the full image after processing.
131
void dt_dev_pixelpipe_get_dimensions(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int width_in, int height_in, int *width, int *height);
133
// destroys all allocated data.
134
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe);
136
// flushes all cached data. usefull if input pixels unexpectedly change.
137
void dt_dev_pixelpipe_flush_caches(dt_dev_pixelpipe_t *pipe);
139
// wrapper for cleanup_nodes, create_nodes, synch_all and synch_top, decides upon changed event which one to take on. also locks dev->history_mutex.
140
void dt_dev_pixelpipe_change(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev);
141
// cleanup all gegl nodes except clean input/output
142
void dt_dev_pixelpipe_cleanup_nodes(dt_dev_pixelpipe_t *pipe);
143
// sync with develop_t history stack from scratch (new node added, have to pop old ones)
144
void dt_dev_pixelpipe_create_nodes(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev);
145
// sync with develop_t history stack by just copying the top item params (same op, new params on top)
146
void dt_dev_pixelpipe_synch_all(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev);
147
// adjust gegl:nop output node according to history stack (history pop event)
148
void dt_dev_pixelpipe_synch_top(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev);
150
// process region of interest of pixels. returns 1 if pipe was altered during processing.
151
int dt_dev_pixelpipe_process(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int x, int y, int width, int height, float scale);
152
// convenience method that does not gamma-compress the image.
153
int dt_dev_pixelpipe_process_no_gamma(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int x, int y, int width, int height, float scale);
156
// TODO: future application: remove/add modules from list, load from disk, user programmable etc
157
// TODO: add n-th module in dev list to gegl pipeline
158
void dt_dev_pixelpipe_add_node(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int n);
159
// TODO: remove n-th module from gegl pipeline
160
void dt_dev_pixelpipe_remove_node(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int n);