Fix Boundary Brush symmetry with no constant falloff
[blender.git] / source / blender / blenkernel / BKE_colortools.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2006 Blender Foundation.
17  * All rights reserved.
18  */
19 #pragma once
20
21 /** \file
22  * \ingroup bke
23  */
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 struct ColorManagedColorspaceSettings;
30 struct ColorManagedDisplaySettings;
31 struct ColorManagedViewSettings;
32 struct CurveMap;
33 struct CurveMapPoint;
34 struct CurveMapping;
35 struct Histogram;
36 struct ImBuf;
37 struct Scopes;
38 struct rctf;
39 struct BlendWriter;
40 struct BlendDataReader;
41
42 void BKE_curvemapping_set_defaults(
43     struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy);
44 struct CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy);
45 void BKE_curvemapping_free_data(struct CurveMapping *cumap);
46 void BKE_curvemapping_free(struct CurveMapping *cumap);
47 void BKE_curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap);
48 struct CurveMapping *BKE_curvemapping_copy(const struct CurveMapping *cumap);
49 void BKE_curvemapping_set_black_white_ex(const float black[3],
50                                          const float white[3],
51                                          float r_bwmul[3]);
52 void BKE_curvemapping_set_black_white(struct CurveMapping *cumap,
53                                       const float black[3],
54                                       const float white[3]);
55
56 enum {
57   CURVEMAP_SLOPE_NEGATIVE = 0,
58   CURVEMAP_SLOPE_POSITIVE = 1,
59   CURVEMAP_SLOPE_POS_NEG = 2,
60 };
61
62 void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope);
63 void BKE_curvemap_remove(struct CurveMap *cuma, const short flag);
64 bool BKE_curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
65 struct CurveMapPoint *BKE_curvemap_insert(struct CurveMap *cuma, float x, float y);
66 void BKE_curvemap_handle_set(struct CurveMap *cuma, int type);
67
68 void BKE_curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles);
69 void BKE_curvemapping_changed_all(struct CurveMapping *cumap);
70
71 /* call before _all_ evaluation functions */
72 void BKE_curvemapping_init(struct CurveMapping *cumap);
73
74 /* keep these (const CurveMap) - to help with thread safety */
75 /* single curve, no table check */
76 float BKE_curvemap_evaluateF(const struct CurveMapping *cumap,
77                              const struct CurveMap *cuma,
78                              float value);
79 /* single curve, with table check */
80 float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value);
81 void BKE_curvemapping_evaluate3F(const struct CurveMapping *cumap,
82                                  float vecout[3],
83                                  const float vecin[3]);
84 void BKE_curvemapping_evaluateRGBF(const struct CurveMapping *cumap,
85                                    float vecout[3],
86                                    const float vecin[3]);
87 void BKE_curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap,
88                                          unsigned char vecout_byte[3],
89                                          const unsigned char vecin_byte[3]);
90 void BKE_curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap,
91                                              float vecout[3],
92                                              const float vecin[3],
93                                              const float black[3],
94                                              const float bwmul[3]);
95 void BKE_curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap,
96                                           float vecout[3],
97                                           const float vecin[3]);
98 int BKE_curvemapping_RGBA_does_something(const struct CurveMapping *cumap);
99 void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size);
100
101 /* non-const, these modify the curve */
102 void BKE_curvemapping_premultiply(struct CurveMapping *cumap, int restore);
103
104 void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap);
105 void BKE_curvemapping_curves_blend_write(struct BlendWriter *writer,
106                                          const struct CurveMapping *cumap);
107 void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap);
108
109 void BKE_histogram_update_sample_line(struct Histogram *hist,
110                                       struct ImBuf *ibuf,
111                                       const struct ColorManagedViewSettings *view_settings,
112                                       const struct ColorManagedDisplaySettings *display_settings);
113 void BKE_scopes_update(struct Scopes *scopes,
114                        struct ImBuf *ibuf,
115                        const struct ColorManagedViewSettings *view_settings,
116                        const struct ColorManagedDisplaySettings *display_settings);
117 void BKE_scopes_free(struct Scopes *scopes);
118 void BKE_scopes_new(struct Scopes *scopes);
119
120 void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings);
121 void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings,
122                                              const struct ColorManagedDisplaySettings *settings);
123
124 /* Initialize view settings to be best suitable for render type of viewing.
125  * This will use default view transform from the OCIO configuration if none
126  * is specified. */
127 void BKE_color_managed_view_settings_init_render(
128     struct ColorManagedViewSettings *settings,
129     const struct ColorManagedDisplaySettings *display_settings,
130     const char *view_transform);
131
132 /* Initialize view settings which are best suitable for viewing non-render
133  * images. For example,s movie clips while tracking. */
134 void BKE_color_managed_view_settings_init_default(
135     struct ColorManagedViewSettings *settings,
136     const struct ColorManagedDisplaySettings *display_settings);
137
138 void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings,
139                                           const struct ColorManagedViewSettings *settings);
140 void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
141
142 void BKE_color_managed_colorspace_settings_init(
143     struct ColorManagedColorspaceSettings *colorspace_settings);
144 void BKE_color_managed_colorspace_settings_copy(
145     struct ColorManagedColorspaceSettings *colorspace_settings,
146     const struct ColorManagedColorspaceSettings *settings);
147 bool BKE_color_managed_colorspace_settings_equals(
148     const struct ColorManagedColorspaceSettings *settings1,
149     const struct ColorManagedColorspaceSettings *settings2);
150
151 #ifdef __cplusplus
152 }
153 #endif