~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/develop/pixelpipe_hb.h

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-04-14 23:42:12 UTC
  • Revision ID: james.westby@ubuntu.com-20110414234212-kuffcz5wiu18v6ra
Tags: upstream-0.8
ImportĀ upstreamĀ versionĀ 0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of darktable,
 
3
    copyright (c) 2009--2010 johannes hanika.
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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/>.
 
17
*/
 
18
#ifndef DT_DEV_PIXELPIPE
 
19
#define DT_DEV_PIXELPIPE
 
20
 
 
21
#include "develop/imageop.h"
 
22
#include "develop/develop.h"
 
23
#include "develop/pixelpipe_cache.h"
 
24
 
 
25
/**
 
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.
 
30
 */
 
31
struct dt_iop_module_t;
 
32
struct dt_dev_pixelpipe_t;
 
33
 
 
34
/** region of interest */
 
35
typedef struct dt_iop_roi_t
 
36
{
 
37
  int x, y, width, height;
 
38
  float scale;
 
39
}
 
40
dt_iop_roi_t;
 
41
 
 
42
typedef struct dt_dev_pixelpipe_iop_t
 
43
{
 
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
 
56
}
 
57
dt_dev_pixelpipe_iop_t;
 
58
 
 
59
typedef enum dt_dev_pixelpipe_change_t
 
60
{
 
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
 
66
}
 
67
dt_dev_pixelpipe_change_t;
 
68
 
 
69
typedef enum dt_dev_pixelpipe_type_t
 
70
{
 
71
  DT_DEV_PIXELPIPE_EXPORT,
 
72
  DT_DEV_PIXELPIPE_FULL,
 
73
  DT_DEV_PIXELPIPE_PREVIEW
 
74
}
 
75
dt_dev_pixelpipe_type_t;
 
76
 
 
77
/**
 
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.
 
82
 */
 
83
typedef struct dt_dev_pixelpipe_t
 
84
{
 
85
  // store history/zoom caches
 
86
  dt_dev_pixelpipe_cache_t cache;
 
87
  // input buffer
 
88
  float *input;
 
89
  // width and height of input buffer
 
90
  int iwidth, iheight;
 
91
  // input actually just downscaled buffer? iscale*iwidth = actual width
 
92
  float iscale;
 
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
 
98
  GList *nodes;
 
99
  // event flag
 
100
  dt_dev_pixelpipe_change_t changed;
 
101
  // backbuffer (output)
 
102
  uint8_t *backbuf;
 
103
  int backbuf_size;
 
104
  int backbuf_width, backbuf_height;
 
105
  uint64_t backbuf_hash;
 
106
  dt_pthread_mutex_t backbuf_mutex, busy_mutex;
 
107
  // working?
 
108
  int processing;
 
109
  // shutting down?
 
110
  int shutdown;
 
111
  // input data based on this timestamp:
 
112
  int input_timestamp;
 
113
  dt_dev_pixelpipe_type_t type;
 
114
  // opencl device that has been locked for this pipe.
 
115
  int devid;
 
116
}
 
117
dt_dev_pixelpipe_t;
 
118
 
 
119
struct dt_develop_t;
 
120
 
 
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);
 
129
 
 
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);
 
132
 
 
133
// destroys all allocated data.
 
134
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe);
 
135
 
 
136
// flushes all cached data. usefull if input pixels unexpectedly change.
 
137
void dt_dev_pixelpipe_flush_caches(dt_dev_pixelpipe_t *pipe);
 
138
 
 
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);
 
149
 
 
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);
 
154
 
 
155
 
 
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);
 
161
 
 
162
#endif