Blender  V2.93
colorspace.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __COLORSPACE_H__
18 #define __COLORSPACE_H__
19 
20 #include "util/util_map.h"
21 #include "util/util_param.h"
22 
24 
25 extern ustring u_colorspace_auto;
26 extern ustring u_colorspace_raw;
27 extern ustring u_colorspace_srgb;
28 
29 class ColorSpaceProcessor;
30 
32  public:
33  /* Convert used specified colorspace to a colorspace that we are able to
34  * convert to and from. If the colorspace is u_colorspace_auto, we auto
35  * detect a colospace. */
36  static ustring detect_known_colorspace(ustring colorspace,
37  const char *file_format,
38  bool is_float);
39 
40  /* Test if colorspace is for non-color data. */
41  static bool colorspace_is_data(ustring colorspace);
42 
43  /* Convert pixels in the specified colorspace to scene linear color for
44  * rendering. Must be a colorspace returned from detect_known_colorspace. */
45  template<typename T>
46  static void to_scene_linear(ustring colorspace,
47  T *pixels,
48  size_t num_pixels,
49  bool compress_as_srgb);
50 
51  /* Efficiently convert pixels to scene linear colorspace at render time,
52  * for OSL where the image texture cache contains original pixels. The
53  * handle is valid for the lifetime of the application. */
54  static ColorSpaceProcessor *get_processor(ustring colorspace);
55  static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, int channels);
56 
57  /* Clear memory when the application exits. Invalidates all processors. */
58  static void free_memory();
59 
60  private:
61  static void is_builtin_colorspace(ustring colorspace, bool &is_no_op, bool &is_srgb);
62 };
63 
65 
66 #endif /* __COLORSPACE_H__ */
static bool colorspace_is_data(ustring colorspace)
Definition: colorspace.cpp:85
static void free_memory()
Definition: colorspace.cpp:384
static void to_scene_linear(ustring colorspace, T *pixels, size_t num_pixels, bool compress_as_srgb)
Definition: colorspace.cpp:316
static ColorSpaceProcessor * get_processor(ustring colorspace)
Definition: colorspace.cpp:47
static ustring detect_known_colorspace(ustring colorspace, const char *file_format, bool is_float)
Definition: colorspace.cpp:110
ustring u_colorspace_raw
ustring u_colorspace_srgb
CCL_NAMESPACE_BEGIN ustring u_colorspace_auto
Definition: colorspace.cpp:35
#define CCL_NAMESPACE_END
#define T