2 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
18 * The Original Code is Copyright (C) 2012 by Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): Xavier Thomas,
27 * ***** END GPL LICENSE BLOCK *****
31 #ifndef IMB_COLORMANAGEMENT_H
32 #define IMB_COLORMANAGEMENT_H
34 #define BCM_CONFIG_FILE "config.ocio"
37 struct ColorManagedColorspaceSettings;
38 struct ColorManagedDisplaySettings;
39 struct ColorManagedViewSettings;
40 struct ColormanageProcessor;
41 struct EnumPropertyItem;
45 struct PartialBufferUpdateContext;
48 struct ImageFormatData;
51 struct ColorManagedDisplay;
53 /* ** Generic functions ** */
55 void IMB_colormanagement_check_file_config(struct Main *bmain);
57 void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *display_settings,
58 struct ColorManagedViewSettings *view_settings);
60 const char *IMB_colormanagement_role_colorspace_name_get(int role);
61 void IMB_colormanagement_check_is_data(struct ImBuf *ibuf, const char *name);
62 void IMB_colormanagement_assign_float_colorspace(struct ImBuf *ibuf, const char *name);
63 void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name);
65 /* ** Color space transformation functions ** */
66 void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
67 const char *from_colorspace, const char *to_colorspace, int predivide);
68 void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels,
69 const char *from_colorspace, const char *to_colorspace, int predivide);
70 void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace);
72 void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace);
73 void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], struct ColorSpace *colorspace);
75 void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide);
77 void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display);
78 void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display);
80 void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], const struct ColorManagedViewSettings *view_settings,
81 const struct ColorManagedDisplaySettings *display_settings);
83 void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const struct ColorManagedViewSettings *view_settings,
84 const struct ColorManagedDisplaySettings *display_settings);
86 void IMB_colormanagement_imbuf_make_display_space(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
87 const struct ColorManagedDisplaySettings *display_settings);
89 struct ImBuf *IMB_colormanagement_imbuf_for_write(struct ImBuf *ibuf, int save_as_render, int allocate_result,
90 const struct ColorManagedViewSettings *view_settings,
91 const struct ColorManagedDisplaySettings *display_settings,
92 struct ImageFormatData *image_format_data);
94 /* ** Public display buffers interfaces ** */
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);
100 void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,
101 int channels, const struct ColorManagedViewSettings *view_settings,
102 const struct ColorManagedDisplaySettings *display_settings, int predivide);
104 void IMB_display_buffer_release(void *cache_handle);
106 /* ** Display funcrions ** */
107 int IMB_colormanagement_display_get_named_index(const char *name);
108 const char *IMB_colormanagement_display_get_indexed_name(int index);
109 const char *IMB_colormanagement_display_get_default_name(void);
110 struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name);
111 const char *IMB_colormanagement_display_get_none_name(void);
113 /* ** View funcrions ** */
114 int IMB_colormanagement_view_get_named_index(const char *name);
115 const char *IMB_colormanagement_view_get_indexed_name(int index);
117 /* ** Color space functions ** */
118 int IMB_colormanagement_colorspace_get_named_index(const char *name);
119 const char *IMB_colormanagement_colorspace_get_indexed_name(int index);
120 const char *IMB_colormanagement_view_get_default_name(const char *display_name);
122 void IMB_colormanagment_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);
124 /* ** RNA helper functions ** */
125 void IMB_colormanagement_display_items_add(struct EnumPropertyItem **items, int *totitem);
126 void IMB_colormanagement_view_items_add(struct EnumPropertyItem **items, int *totitem, const char *display_name);
127 void IMB_colormanagement_colorspace_items_add(struct EnumPropertyItem **items, int *totitem);
129 /* ** Tile-based buffer management ** */
130 void IMB_partial_display_buffer_update(struct ImBuf *ibuf, const float *linear_buffer, const unsigned char *buffer_byte,
131 int stride, int offset_x, int offset_y, const struct ColorManagedViewSettings *view_settings,
132 const struct ColorManagedDisplaySettings *display_settings,
133 int xmin, int ymin, int xmax, int ymax,
134 int update_orig_byte_buffer);
136 /* ** Pixel processor functions ** */
137 struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings,
138 const struct ColorManagedDisplaySettings *display_settings);
139 struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace);
140 void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]);
141 void IMB_colormanagement_processor_apply_v4_predivide(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);
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,
157 #endif /* IMB_COLORMANAGEMENT_H */