7#if defined(WITH_OPENCOLORIO)
17LibOCIOCPUProcessor::LibOCIOCPUProcessor(
18 const OCIO_NAMESPACE::ConstCPUProcessorRcPtr &ocio_cpu_processor)
19 : ocio_cpu_processor_(ocio_cpu_processor)
24void LibOCIOCPUProcessor::apply_rgb(
float rgb[3])
const
26 ocio_cpu_processor_->applyRGB(rgb);
29void LibOCIOCPUProcessor::apply_rgba(
float rgba[4])
const
31 ocio_cpu_processor_->applyRGBA(rgba);
34void LibOCIOCPUProcessor::apply_rgba_predivide(
float rgba[4])
const
36 if (
ELEM(rgba[3], 1.0f, 0.0f)) {
41 const float alpha = rgba[3];
42 const float inv_alpha = 1.0f / alpha;
55void LibOCIOCPUProcessor::apply(
const PackedImage &image)
const
58 if (image.get_bit_depth() != BitDepth::BIT_DEPTH_F32) {
63 ocio_cpu_processor_->apply(image);
65 catch (OCIO_NAMESPACE::Exception &exception) {
66 report_exception(exception);
70void LibOCIOCPUProcessor::apply_predivide(
const PackedImage &image)
const
73 if (image.get_bit_depth() != BitDepth::BIT_DEPTH_F32) {
77 if (image.get_num_channels() == 4) {
79 float *pixel =
reinterpret_cast<float *
>(image.get_data());
80 const size_t pixel_count = image.get_width() * image.get_height();
81 for (
size_t i = 0;
i < pixel_count;
i++, pixel += 4) {
82 const float alpha = pixel[3];
83 if (!
ELEM(alpha, 0.0f, 1.0f)) {
84 const float inv_alpha = 1.0f / alpha;
85 pixel[0] *= inv_alpha;
86 pixel[1] *= inv_alpha;
87 pixel[2] *= inv_alpha;
94 if (image.get_num_channels() == 4) {
96 float *pixel =
reinterpret_cast<float *
>(image.get_data());
97 const size_t pixel_count = image.get_width() * image.get_height();
98 for (
size_t i = 0;
i < pixel_count;
i++, pixel += 4) {
99 const float alpha = pixel[3];
100 if (!
ELEM(alpha, 0.0f, 1.0f)) {
void apply(bContext &C, GestureData &gesture_data, wmOperator &op)