Color Management: remove unused functions
[blender.git] / source / blender / imbuf / IMB_colormanagement.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2012 by Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): Xavier Thomas,
24  *                 Lukas Toenne,
25  *                 Sergey Sharybin
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  *
29  */
30
31 #ifndef IMB_COLORMANAGEMENT_H
32 #define IMB_COLORMANAGEMENT_H
33
34 #define BCM_CONFIG_FILE "config.ocio"
35
36 struct bContext;
37 struct ColorManagedColorspaceSettings;
38 struct ColorManagedDisplaySettings;
39 struct ColorManagedViewSettings;
40 struct ColormanageProcessor;
41 struct EnumPropertyItem;
42 struct ImBuf;
43 struct Main;
44 struct rcti;
45 struct PartialBufferUpdateContext;
46 struct wmWindow;
47 struct Scene;
48
49 struct ColorSpace;
50 struct ColorManagedDisplay;
51
52 /* ** Initialization / De-initialization ** */
53
54 void IMB_colormanagement_init(void);
55 void IMB_colormanagement_exit(void);
56
57 /* ** Generic functions ** */
58
59 void IMB_colormanagement_check_file_config(struct Main *bmain);
60
61 void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *display_settings,
62                                            struct ColorManagedViewSettings *view_settings);
63
64 const char *IMB_colormanagement_role_colorspace_name_get(int role);
65 void IMB_colormanagement_imbuf_float_from_rect(struct ImBuf *ibuf);
66
67 /* ** Color space transformation functions ** */
68 void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
69                                    const char *from_colorspace, const char *to_colorspace, int predivide);
70 void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels,
71                                             const char *from_colorspace, const char *to_colorspace, int predivide);
72 void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace);
73
74 void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace);
75 void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], struct ColorSpace *colorspace);
76
77 void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide);
78
79 void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display);
80 void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display);
81
82 void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4],  const struct ColorManagedViewSettings *view_settings,
83                                                    const struct ColorManagedDisplaySettings *display_settings);
84
85 void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3],  const struct ColorManagedViewSettings *view_settings,
86                                                    const struct ColorManagedDisplaySettings *display_settings);
87
88 void IMB_colormanagement_imbuf_assign_spaces(struct ImBuf *ibuf, struct ColorManagedColorspaceSettings *colorspace_settings);
89 void IMB_colormanagement_imbuf_assign_float_space(struct ImBuf *ibuf, struct ColorManagedColorspaceSettings *colorspace_settings);
90
91 void IMB_colormanagement_imbuf_make_display_space(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
92                                                   const struct ColorManagedDisplaySettings *display_settings);
93
94 /* ** Public display buffers interfaces ** */
95
96 unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
97                                           const struct ColorManagedDisplaySettings *display_settings, void **cache_handle);
98 unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle);
99
100 void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
101                                       const struct ColorManagedDisplaySettings *display_settings);
102
103 void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,
104                                         int channels, const struct ColorManagedViewSettings *view_settings,
105                                         const struct ColorManagedDisplaySettings *display_settings, int predivide);
106
107 void IMB_display_buffer_release(void *cache_handle);
108
109 /* ** Display funcrions ** */
110 int IMB_colormanagement_display_get_named_index(const char *name);
111 const char *IMB_colormanagement_display_get_indexed_name(int index);
112 const char *IMB_colormanagement_display_get_default_name(void);
113 struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name);
114
115 /* ** View funcrions ** */
116 int IMB_colormanagement_view_get_named_index(const char *name);
117 const char *IMB_colormanagement_view_get_indexed_name(int index);
118
119 /* ** Color space functions ** */
120 int IMB_colormanagement_colorspace_get_named_index(const char *name);
121 const char *IMB_colormanagement_colorspace_get_indexed_name(int index);
122 const char *IMB_colormanagement_view_get_default_name(const char *display_name);
123
124 void IMB_colormanagment_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);
125
126 /* ** RNA helper functions ** */
127 void IMB_colormanagement_display_items_add(struct EnumPropertyItem **items, int *totitem);
128 void IMB_colormanagement_view_items_add(struct EnumPropertyItem **items, int *totitem, const char *display_name);
129 void IMB_colormanagement_colorspace_items_add(struct EnumPropertyItem **items, int *totitem);
130
131 /* ** Tile-based buffer management ** */
132 void IMB_partial_display_buffer_update(struct ImBuf *ibuf, const float *linear_buffer, const unsigned char *buffer_byte,
133                                        int stride, int offset_x, int offset_y, const struct ColorManagedViewSettings *view_settings,
134                                        const struct ColorManagedDisplaySettings *display_settings,
135                                        int xmin, int ymin, int xmax, int ymax);
136
137 /* ** Pixel processor functions ** */
138 struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings,
139                                                                        const struct ColorManagedDisplaySettings *display_settings);
140 struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace);
141 void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]);
142 void IMB_colormanagement_processor_apply_v3(struct ColormanageProcessor *cm_processor, float pixel[3]);
143 void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height,
144                                          int channels, int predivide);
145 void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor);
146
147 /* Roles */
148 enum {
149         COLOR_ROLE_SCENE_LINEAR = 0,
150         COLOR_ROLE_COLOR_PICKING,
151         COLOR_ROLE_TEXTURE_PAINTING,
152         COLOR_ROLE_DEFAULT_SEQUENCER,
153         COLOR_ROLE_DEFAULT_BYTE,
154         COLOR_ROLE_DEFAULT_FLOAT,
155 };
156
157 #endif  /* IMB_COLORMANAGEMENT_H */