Blender V5.3
rectop.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <cstdlib>
11
12#include "BLI_math_base_c.hh"
14#include "BLI_math_vector_c.hh"
15#include "BLI_rect.hh"
16#include "BLI_task.hh"
17#include "BLI_utildefines.hh"
18
19#include "IMB_imbuf.hh"
20#include "IMB_imbuf_types.hh"
21
23
24#include "MEM_guardedalloc.h"
25
26#include <cstring>
27
28namespace blender {
29
31 const uchar src1[4],
32 const uchar src2[4],
33 IMB_BlendMode mode)
34{
35 switch (mode) {
36 case IMB_BLEND_MIX:
37 blend_color_mix_byte(dst, src1, src2);
38 break;
39 case IMB_BLEND_ADD:
40 blend_color_add_byte(dst, src1, src2);
41 break;
42 case IMB_BLEND_SUB:
43 blend_color_sub_byte(dst, src1, src2);
44 break;
45 case IMB_BLEND_MUL:
46 blend_color_mul_byte(dst, src1, src2);
47 break;
49 blend_color_lighten_byte(dst, src1, src2);
50 break;
52 blend_color_darken_byte(dst, src1, src2);
53 break;
55 blend_color_erase_alpha_byte(dst, src1, src2);
56 break;
58 blend_color_add_alpha_byte(dst, src1, src2);
59 break;
61 blend_color_overlay_byte(dst, src1, src2);
62 break;
64 blend_color_hardlight_byte(dst, src1, src2);
65 break;
67 blend_color_burn_byte(dst, src1, src2);
68 break;
70 blend_color_linearburn_byte(dst, src1, src2);
71 break;
73 blend_color_dodge_byte(dst, src1, src2);
74 break;
76 blend_color_screen_byte(dst, src1, src2);
77 break;
79 blend_color_softlight_byte(dst, src1, src2);
80 break;
82 blend_color_pinlight_byte(dst, src1, src2);
83 break;
85 blend_color_linearlight_byte(dst, src1, src2);
86 break;
88 blend_color_vividlight_byte(dst, src1, src2);
89 break;
91 blend_color_difference_byte(dst, src1, src2);
92 break;
94 blend_color_exclusion_byte(dst, src1, src2);
95 break;
96 case IMB_BLEND_COLOR:
97 blend_color_color_byte(dst, src1, src2);
98 break;
99 case IMB_BLEND_HUE:
100 blend_color_hue_byte(dst, src1, src2);
101 break;
103 blend_color_saturation_byte(dst, src1, src2);
104 break;
106 blend_color_luminosity_byte(dst, src1, src2);
107 break;
108
109 default:
110 dst[0] = src1[0];
111 dst[1] = src1[1];
112 dst[2] = src1[2];
113 dst[3] = src1[3];
114 break;
115 }
116}
117
118void IMB_blend_color_float(float dst[4],
119 const float src1[4],
120 const float src2[4],
121 IMB_BlendMode mode)
122{
123 switch (mode) {
124 case IMB_BLEND_MIX:
125 blend_color_mix_float(dst, src1, src2);
126 break;
127 case IMB_BLEND_ADD:
128 blend_color_add_float(dst, src1, src2);
129 break;
130 case IMB_BLEND_SUB:
131 blend_color_sub_float(dst, src1, src2);
132 break;
133 case IMB_BLEND_MUL:
134 blend_color_mul_float(dst, src1, src2);
135 break;
137 blend_color_lighten_float(dst, src1, src2);
138 break;
139 case IMB_BLEND_DARKEN:
140 blend_color_darken_float(dst, src1, src2);
141 break;
143 blend_color_erase_alpha_float(dst, src1, src2);
144 break;
146 blend_color_add_alpha_float(dst, src1, src2);
147 break;
149 blend_color_overlay_float(dst, src1, src2);
150 break;
152 blend_color_hardlight_float(dst, src1, src2);
153 break;
155 blend_color_burn_float(dst, src1, src2);
156 break;
158 blend_color_linearburn_float(dst, src1, src2);
159 break;
161 blend_color_dodge_float(dst, src1, src2);
162 break;
163 case IMB_BLEND_SCREEN:
164 blend_color_screen_float(dst, src1, src2);
165 break;
167 blend_color_softlight_float(dst, src1, src2);
168 break;
170 blend_color_pinlight_float(dst, src1, src2);
171 break;
173 blend_color_linearlight_float(dst, src1, src2);
174 break;
176 blend_color_vividlight_float(dst, src1, src2);
177 break;
179 blend_color_difference_float(dst, src1, src2);
180 break;
182 blend_color_exclusion_float(dst, src1, src2);
183 break;
184 case IMB_BLEND_COLOR:
185 blend_color_color_float(dst, src1, src2);
186 break;
187 case IMB_BLEND_HUE:
188 blend_color_hue_float(dst, src1, src2);
189 break;
191 blend_color_saturation_float(dst, src1, src2);
192 break;
194 blend_color_luminosity_float(dst, src1, src2);
195 break;
196 default:
197 dst[0] = src1[0];
198 dst[1] = src1[1];
199 dst[2] = src1[2];
200 dst[3] = src1[3];
201 break;
202 }
203}
204
206 const Span<float4> src1,
207 const Span<float4> src2,
208 const IMB_BlendMode mode)
209{
210 BLI_assert(dst.size() == src1.size());
211 BLI_assert(dst.size() == src2.size());
212
213 switch (mode) {
214 case IMB_BLEND_MIX:
215 for (const int i : dst.index_range()) {
216 blend_color_mix_float(dst[i], src1[i], src2[i]);
217 }
218 break;
219 case IMB_BLEND_ADD:
220 for (const int i : dst.index_range()) {
221 blend_color_add_float(dst[i], src1[i], src2[i]);
222 }
223 break;
224 case IMB_BLEND_SUB:
225 for (const int i : dst.index_range()) {
226 blend_color_sub_float(dst[i], src1[i], src2[i]);
227 }
228 break;
229 case IMB_BLEND_MUL:
230 for (const int i : dst.index_range()) {
231 blend_color_mul_float(dst[i], src1[i], src2[i]);
232 }
233 break;
235 for (const int i : dst.index_range()) {
236 blend_color_lighten_float(dst[i], src1[i], src2[i]);
237 }
238 break;
239 case IMB_BLEND_DARKEN:
240 for (const int i : dst.index_range()) {
241 blend_color_darken_float(dst[i], src1[i], src2[i]);
242 }
243 break;
245 for (const int i : dst.index_range()) {
246 blend_color_erase_alpha_float(dst[i], src1[i], src2[i]);
247 }
248 break;
250 for (const int i : dst.index_range()) {
251 blend_color_add_alpha_float(dst[i], src1[i], src2[i]);
252 }
253 break;
255 for (const int i : dst.index_range()) {
256 blend_color_overlay_float(dst[i], src1[i], src2[i]);
257 }
258 break;
260 for (const int i : dst.index_range()) {
261 blend_color_hardlight_float(dst[i], src1[i], src2[i]);
262 }
263 break;
265 for (const int i : dst.index_range()) {
266 blend_color_burn_float(dst[i], src1[i], src2[i]);
267 }
268 break;
270 for (const int i : dst.index_range()) {
271 blend_color_linearburn_float(dst[i], src1[i], src2[i]);
272 }
273 break;
275 for (const int i : dst.index_range()) {
276 blend_color_dodge_float(dst[i], src1[i], src2[i]);
277 }
278 break;
279 case IMB_BLEND_SCREEN:
280 for (const int i : dst.index_range()) {
281 blend_color_screen_float(dst[i], src1[i], src2[i]);
282 }
283 break;
285 for (const int i : dst.index_range()) {
286 blend_color_softlight_float(dst[i], src1[i], src2[i]);
287 }
288 break;
290 for (const int i : dst.index_range()) {
291 blend_color_pinlight_float(dst[i], src1[i], src2[i]);
292 }
293 break;
295 for (const int i : dst.index_range()) {
296 blend_color_linearlight_float(dst[i], src1[i], src2[i]);
297 }
298 break;
300 for (const int i : dst.index_range()) {
301 blend_color_vividlight_float(dst[i], src1[i], src2[i]);
302 }
303 break;
305 for (const int i : dst.index_range()) {
306 blend_color_difference_float(dst[i], src1[i], src2[i]);
307 }
308 break;
310 for (const int i : dst.index_range()) {
311 blend_color_exclusion_float(dst[i], src1[i], src2[i]);
312 }
313 break;
314 case IMB_BLEND_COLOR:
315 for (const int i : dst.index_range()) {
316 blend_color_color_float(dst[i], src1[i], src2[i]);
317 }
318 break;
319 case IMB_BLEND_HUE:
320 for (const int i : dst.index_range()) {
321 blend_color_hue_float(dst[i], src1[i], src2[i]);
322 }
323 break;
325 for (const int i : dst.index_range()) {
326 blend_color_saturation_float(dst[i], src1[i], src2[i]);
327 }
328 break;
330 for (const int i : dst.index_range()) {
331 blend_color_luminosity_float(dst[i], src1[i], src2[i]);
332 }
333 break;
334 default:
335 for (const int i : dst.index_range()) {
336 dst[i] = src1[i];
337 }
338 break;
339 }
340}
341
342/* -------------------------------------------------------------------- */
345
346static void copy_to_cropped_bufffer(void *dst_void,
347 const int2 &dst_size,
348 const void *src_void,
349 const int2 &src_size,
350 const int stride,
351 const int2 &src_rect_pos,
352 const int2 &dst_rect_pos,
353 const int2 &rect_size)
354{
355 BLI_assert(src_size.x > 0 && src_size.y > 0);
356 BLI_assert(dst_size.x > 0 && dst_size.y > 0);
357 BLI_assert(rect_size.x > 0 && rect_size.y > 0);
358 BLI_assert(src_rect_pos.x >= 0 && src_rect_pos.y >= 0);
359 BLI_assert(dst_rect_pos.x >= 0 && dst_rect_pos.y >= 0);
360 BLI_assert((src_rect_pos.x + rect_size.x) <= src_size.x &&
361 (src_rect_pos.y + rect_size.y) <= src_size.y);
362 BLI_assert((dst_rect_pos.x + rect_size.x) <= dst_size.x &&
363 (dst_rect_pos.y + rect_size.y) <= dst_size.y);
364 auto *dst = static_cast<std::byte *>(dst_void);
365 const auto *src = static_cast<const std::byte *>(src_void);
366 for (const int rect_y : IndexRange(rect_size.y)) {
367 const int src_y = src_rect_pos.y + rect_y;
368 const int dst_y = dst_rect_pos.y + rect_y;
369 const std::byte *row_src = src + size_t(src_size.x) * stride * src_y;
370 std::byte *row_dst = dst + size_t(dst_size.x) * stride * dst_y;
371 std::copy_n(row_src + size_t(src_rect_pos.x) * stride,
372 size_t(rect_size.x) * stride,
373 row_dst + size_t(dst_rect_pos.x) * stride);
374 }
375}
376
377static void *create_cropped_buffer_impl(const void *src_void,
378 const int2 &src_size,
379 const int stride,
380 const int2 &src_rect_pos,
381 const int2 &rect_size)
382{
383 BLI_assert(rect_size.x > 0 && rect_size.y > 0);
384 const size_t dst_buffer_size = size_t(rect_size.x) * size_t(rect_size.y);
385 auto *dst = MEM_new_array_uninitialized<std::byte>(dst_buffer_size * stride, __func__);
387 dst, rect_size, src_void, src_size, stride, src_rect_pos, int2(0, 0), rect_size);
388 return dst;
389}
390
391static float *create_cropped_buffer(const float *src,
392 const int2 &src_size,
393 const int channels,
394 const int2 &src_rect_pos,
395 const int2 &rect_size)
396{
397 /* For some reason channels == 0 means 4-channel default. */
398 const int stride = (channels == 0 ? 4 : channels) * sizeof(float);
399 return static_cast<float *>(
400 create_cropped_buffer_impl(src, src_size, stride, src_rect_pos, rect_size));
401}
402
404 const int2 &src_size,
405 const int2 &src_rect_pos,
406 const int2 &rect_size)
407{
408 /* Byte buffers always have 4 channels. */
409 const int stride = 4 * sizeof(uchar);
410 return static_cast<uchar *>(
411 create_cropped_buffer_impl(src, src_size, stride, src_rect_pos, rect_size));
412}
413
414void IMB_copy_rect(float *dst,
415 const int2 &dst_size,
416 const float *src,
417 const int2 &src_size,
418 const int channels,
419 const int2 &src_rect_pos,
420 const int2 &dst_rect_pos,
421 const int2 &rect_size)
422{
423 /* For some reason channels == 0 means 4-channel default. */
424 const int stride = (channels == 0 ? 4 : channels) * sizeof(float);
426 dst, dst_size, src, src_size, stride, src_rect_pos, dst_rect_pos, rect_size);
427}
428
430 const int2 &dst_size,
431 const uchar *src,
432 const int2 &src_size,
433 const int2 &src_rect_pos,
434 const int2 &dst_rect_pos,
435 const int2 &rect_size)
436{
437 /* Byte buffers always have 4 channels. */
438 const int stride = 4 * sizeof(uchar);
440 dst, dst_size, src, src_size, stride, src_rect_pos, dst_rect_pos, rect_size);
441}
442
444 const ImBuf *src,
445 const int2 &src_rect_pos,
446 const int2 &dst_rect_pos,
447 const int2 &rect_size)
448{
449 if (src->byte_data() && dst->byte_data()) {
451 int2(dst->x, dst->y),
452 src->byte_data(),
453 int2(src->x, src->y),
454 src_rect_pos,
455 dst_rect_pos,
456 rect_size);
457 }
458 if (src->float_data() && dst->float_data()) {
460 int2(dst->x, dst->y),
461 src->float_data(),
462 int2(src->x, src->y),
463 src->channels,
464 src_rect_pos,
465 dst_rect_pos,
466 rect_size);
467 }
468}
469
470void IMB_crop(ImBuf *ibuf, const int2 &rect_pos, const int2 &rect_size)
471{
472 const int2 src_size(ibuf->x, ibuf->y);
473 if (src_size == rect_size) {
474 return;
475 }
476
477 if (const uchar *byte_data = ibuf->byte_data()) {
478 ibuf->assign_byte_data(create_cropped_buffer(byte_data, src_size, rect_pos, rect_size));
479 }
480 if (const float *float_data = ibuf->float_data()) {
481 ibuf->assign_float_data(
482 create_cropped_buffer(float_data, src_size, ibuf->channels, rect_pos, rect_size));
483 }
484
485 ibuf->x = rect_size.x;
486 ibuf->y = rect_size.y;
487}
488
489void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
490{
491 BLI_assert(size[0] > 0 && size[1] > 0);
492 if ((size[0] == ibuf->x) && (size[1] == ibuf->y)) {
493 return;
494 }
495
496 ibuf->x = size[0];
497 ibuf->y = size[1];
498
499 if (ibuf->float_data()) {
500 IMB_alloc_float_pixels(ibuf, ibuf->channels, false);
501 }
502 if (ibuf->byte_data()) {
503 IMB_alloc_byte_pixels(ibuf, false);
504 }
505}
506
508
509/* clipping */
510
512 const ImBuf *sbuf,
513 int *destx,
514 int *desty,
515 int *srcx,
516 int *srcy,
517 int *width,
518 int *height)
519{
520 int tmp;
521
522 if (dbuf == nullptr) {
523 return;
524 }
525
526 if (*destx < 0) {
527 *srcx -= *destx;
528 *width += *destx;
529 *destx = 0;
530 }
531 if (*srcx < 0) {
532 *destx -= *srcx;
533 *width += *srcx;
534 *srcx = 0;
535 }
536 if (*desty < 0) {
537 *srcy -= *desty;
538 *height += *desty;
539 *desty = 0;
540 }
541 if (*srcy < 0) {
542 *desty -= *srcy;
543 *height += *srcy;
544 *srcy = 0;
545 }
546
547 tmp = dbuf->x - *destx;
548 *width = std::min(*width, tmp);
549 tmp = dbuf->y - *desty;
550 *height = std::min(*height, tmp);
551
552 if (sbuf) {
553 tmp = sbuf->x - *srcx;
554 *width = std::min(*width, tmp);
555 tmp = sbuf->y - *srcy;
556 *height = std::min(*height, tmp);
557 }
558
559 if ((*height <= 0) || (*width <= 0)) {
560 *width = 0;
561 *height = 0;
562 }
563}
564
565static void imb_rectclip3(ImBuf *dbuf,
566 const ImBuf *obuf,
567 const ImBuf *sbuf,
568 int *destx,
569 int *desty,
570 int *origx,
571 int *origy,
572 int *srcx,
573 int *srcy,
574 int *width,
575 int *height)
576{
577 int tmp;
578
579 if (dbuf == nullptr) {
580 return;
581 }
582
583 if (*destx < 0) {
584 *srcx -= *destx;
585 *origx -= *destx;
586 *width += *destx;
587 *destx = 0;
588 }
589 if (*origx < 0) {
590 *destx -= *origx;
591 *srcx -= *origx;
592 *width += *origx;
593 *origx = 0;
594 }
595 if (*srcx < 0) {
596 *destx -= *srcx;
597 *origx -= *srcx;
598 *width += *srcx;
599 *srcx = 0;
600 }
601
602 if (*desty < 0) {
603 *srcy -= *desty;
604 *origy -= *desty;
605 *height += *desty;
606 *desty = 0;
607 }
608 if (*origy < 0) {
609 *desty -= *origy;
610 *srcy -= *origy;
611 *height += *origy;
612 *origy = 0;
613 }
614 if (*srcy < 0) {
615 *desty -= *srcy;
616 *origy -= *srcy;
617 *height += *srcy;
618 *srcy = 0;
619 }
620
621 tmp = dbuf->x - *destx;
622 *width = std::min(*width, tmp);
623 tmp = dbuf->y - *desty;
624 *height = std::min(*height, tmp);
625
626 if (obuf) {
627 tmp = obuf->x - *origx;
628 *width = std::min(*width, tmp);
629 tmp = obuf->y - *origy;
630 *height = std::min(*height, tmp);
631 }
632
633 if (sbuf) {
634 tmp = sbuf->x - *srcx;
635 *width = std::min(*width, tmp);
636 tmp = sbuf->y - *srcy;
637 *height = std::min(*height, tmp);
638 }
639
640 if ((*height <= 0) || (*width <= 0)) {
641 *width = 0;
642 *height = 0;
643 }
644}
645
646using IMB_blend_func = void (*)(uchar *dst, const uchar *src1, const uchar *src2);
647using IMB_blend_func_float = void (*)(float *dst, const float *src1, const float *src2);
648
650 uint8_t *dbuf_byte_data,
651 float *dbuf_float_data,
652 const ImBuf *obuf,
653 const ImBuf *sbuf,
654 ushort *dmask,
655 const ushort *curvemask,
656 const ushort *texmask,
657 float mask_max,
658 int destx,
659 int desty,
660 int origx,
661 int origy,
662 int srcx,
663 int srcy,
664 int width,
665 int height,
666 IMB_BlendMode mode,
667 bool accumulate)
668{
669 uint *drect = nullptr;
670 const uint *orect = nullptr;
671 const uint *srect = nullptr;
672 uint *dr;
673 const uint *outr;
674 const uint *sr;
675 float *drectf = nullptr;
676 const float *orectf = nullptr;
677 const float *srectf = nullptr;
678 float *drf;
679 const float *orf;
680 const float *srf;
681 const ushort *cmaskrect = curvemask, *cmr;
682 ushort *dmaskrect = dmask, *dmr;
683 const ushort *texmaskrect = texmask, *tmr;
684 int srcskip, destskip, origskip, x;
685 IMB_blend_func func = nullptr;
686 IMB_blend_func_float func_float = nullptr;
687
688 if (dbuf == nullptr || obuf == nullptr) {
689 return;
690 }
691
692 imb_rectclip3(dbuf, obuf, sbuf, &destx, &desty, &origx, &origy, &srcx, &srcy, &width, &height);
693
694 if (width == 0 || height == 0) {
695 return;
696 }
697 if (sbuf && sbuf->channels != 4) {
698 return;
699 }
700 if (dbuf->channels != 4) {
701 return;
702 }
703
704 const bool do_char = (sbuf && sbuf->byte_data() && dbuf_byte_data && obuf->byte_data());
705 const bool do_float = (sbuf && sbuf->float_data() && dbuf_float_data && obuf->float_data());
706
707 if (do_char) {
708 drect = reinterpret_cast<uint *>(dbuf_byte_data) + size_t(desty) * dbuf->x + destx;
709 orect = reinterpret_cast<const uint *>(obuf->byte_data()) + size_t(origy) * obuf->x + origx;
710 }
711 if (do_float) {
712 drectf = dbuf_float_data + (size_t(desty) * dbuf->x + destx) * 4;
713 orectf = obuf->float_data() + (size_t(origy) * obuf->x + origx) * 4;
714 }
715
716 if (dmaskrect) {
717 dmaskrect += size_t(origy) * obuf->x + origx;
718 }
719
720 destskip = dbuf->x;
721 origskip = obuf->x;
722
723 if (sbuf) {
724 if (do_char) {
725 srect = reinterpret_cast<const uint *>(sbuf->byte_data()) + size_t(srcy) * sbuf->x + srcx;
726 }
727 if (do_float) {
728 srectf = sbuf->float_data() + (size_t(srcy) * sbuf->x + srcx) * 4;
729 }
730 srcskip = sbuf->x;
731
732 if (cmaskrect) {
733 cmaskrect += size_t(srcy) * sbuf->x + srcx;
734 }
735
736 if (texmaskrect) {
737 texmaskrect += size_t(srcy) * sbuf->x + srcx;
738 }
739 }
740 else {
741 srect = drect;
742 srectf = drectf;
743 srcskip = destskip;
744 }
745
746 if (mode == IMB_BLEND_COPY_RGB) {
747 /* copy rgb only */
748 for (; height > 0; height--) {
749 if (do_char) {
750 dr = drect;
751 sr = srect;
752 for (x = width; x > 0; x--, dr++, sr++) {
753 (reinterpret_cast<char *>(dr))[0] = (reinterpret_cast<const char *>(sr))[0];
754 (reinterpret_cast<char *>(dr))[1] = (reinterpret_cast<const char *>(sr))[1];
755 (reinterpret_cast<char *>(dr))[2] = (reinterpret_cast<const char *>(sr))[2];
756 }
757 drect += destskip;
758 srect += srcskip;
759 }
760
761 if (do_float) {
762 drf = drectf;
763 srf = srectf;
764 for (x = width; x > 0; x--, drf += 4, srf += 4) {
765 float map_alpha = (srf[3] == 0.0f) ? drf[3] : drf[3] / srf[3];
766
767 drf[0] = srf[0] * map_alpha;
768 drf[1] = srf[1] * map_alpha;
769 drf[2] = srf[2] * map_alpha;
770 }
771 drectf += destskip * 4;
772 srectf += srcskip * 4;
773 }
774 }
775 }
776 else if (mode == IMB_BLEND_COPY_ALPHA) {
777 /* copy alpha only */
778 for (; height > 0; height--) {
779 if (do_char) {
780 dr = drect;
781 sr = srect;
782 for (x = width; x > 0; x--, dr++, sr++) {
783 (reinterpret_cast<char *>(dr))[3] = (reinterpret_cast<const char *>(sr))[3];
784 }
785 drect += destskip;
786 srect += srcskip;
787 }
788
789 if (do_float) {
790 drf = drectf;
791 srf = srectf;
792 for (x = width; x > 0; x--, drf += 4, srf += 4) {
793 drf[3] = srf[3];
794 }
795 drectf += destskip * 4;
796 srectf += srcskip * 4;
797 }
798 }
799 }
800 else {
801 switch (mode) {
802 case IMB_BLEND_MIX:
805 func_float = blend_color_mix_float;
806 break;
807 case IMB_BLEND_ADD:
809 func_float = blend_color_add_float;
810 break;
811 case IMB_BLEND_SUB:
813 func_float = blend_color_sub_float;
814 break;
815 case IMB_BLEND_MUL:
817 func_float = blend_color_mul_float;
818 break;
821 func_float = blend_color_lighten_float;
822 break;
823 case IMB_BLEND_DARKEN:
825 func_float = blend_color_darken_float;
826 break;
830 break;
833 func_float = blend_color_add_alpha_float;
834 break;
837 func_float = blend_color_overlay_float;
838 break;
841 func_float = blend_color_hardlight_float;
842 break;
845 func_float = blend_color_burn_float;
846 break;
849 func_float = blend_color_linearburn_float;
850 break;
853 func_float = blend_color_dodge_float;
854 break;
855 case IMB_BLEND_SCREEN:
857 func_float = blend_color_screen_float;
858 break;
861 func_float = blend_color_softlight_float;
862 break;
865 func_float = blend_color_pinlight_float;
866 break;
870 break;
873 func_float = blend_color_vividlight_float;
874 break;
877 func_float = blend_color_difference_float;
878 break;
881 func_float = blend_color_exclusion_float;
882 break;
883 case IMB_BLEND_COLOR:
885 func_float = blend_color_color_float;
886 break;
887 case IMB_BLEND_HUE:
889 func_float = blend_color_hue_float;
890 break;
893 func_float = blend_color_saturation_float;
894 break;
897 func_float = blend_color_luminosity_float;
898 break;
899 default:
900 break;
901 }
902
903 /* blend */
904 for (; height > 0; height--) {
905 if (do_char) {
906 dr = drect;
907 outr = orect;
908 sr = srect;
909
910 if (cmaskrect) {
911 /* mask accumulation for painting */
912 cmr = cmaskrect;
913 tmr = texmaskrect;
914
915 /* destination mask present, do max alpha masking */
916 if (dmaskrect) {
917 dmr = dmaskrect;
918 for (x = width; x > 0; x--, dr++, outr++, sr++, dmr++, cmr++) {
919 const uchar *src = reinterpret_cast<const uchar *>(sr);
920 float mask_lim = mask_max * (*cmr);
921
922 if (texmaskrect) {
923 mask_lim *= ((*tmr++) / 65535.0f);
924 }
925
926 if (src[3] && mask_lim) {
927 float mask;
928
929 if (accumulate) {
930 mask = *dmr + mask_lim;
931 }
932 else {
933 mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
934 }
935
936 mask = min_ff(mask, 65535.0);
937
938 if (mask > *dmr) {
939 uchar mask_src[4];
940
941 *dmr = mask;
942
943 mask_src[0] = src[0];
944 mask_src[1] = src[1];
945 mask_src[2] = src[2];
946
947 if (mode == IMB_BLEND_INTERPOLATE) {
948 mask_src[3] = src[3];
949 blend_color_interpolate_byte(reinterpret_cast<uchar *>(dr),
950 reinterpret_cast<const uchar *>(outr),
951 mask_src,
952 mask / 65535.0f);
953 }
954 else {
955 mask_src[3] = divide_round_i(src[3] * mask, 65535);
956 func(reinterpret_cast<uchar *>(dr),
957 reinterpret_cast<const uchar *>(outr),
958 mask_src);
959 }
960 }
961 }
962 }
963 dmaskrect += origskip;
964 }
965 /* No destination mask buffer, do regular blend with mask-texture if present. */
966 else {
967 for (x = width; x > 0; x--, dr++, outr++, sr++, cmr++) {
968 const uchar *src = reinterpret_cast<const uchar *>(sr);
969 float mask = mask_max * float(*cmr);
970
971 if (texmaskrect) {
972 mask *= (float(*tmr++) / 65535.0f);
973 }
974
975 mask = min_ff(mask, 65535.0);
976
977 if (src[3] && (mask > 0.0f)) {
978 uchar mask_src[4];
979
980 mask_src[0] = src[0];
981 mask_src[1] = src[1];
982 mask_src[2] = src[2];
983
984 if (mode == IMB_BLEND_INTERPOLATE) {
985 mask_src[3] = src[3];
986 blend_color_interpolate_byte(reinterpret_cast<uchar *>(dr),
987 reinterpret_cast<const uchar *>(outr),
988 mask_src,
989 mask / 65535.0f);
990 }
991 else {
992 mask_src[3] = divide_round_i(src[3] * mask, 65535);
993 func(reinterpret_cast<uchar *>(dr),
994 reinterpret_cast<const uchar *>(outr),
995 mask_src);
996 }
997 }
998 }
999 }
1000
1001 cmaskrect += srcskip;
1002 if (texmaskrect) {
1003 texmaskrect += srcskip;
1004 }
1005 }
1006 else {
1007 /* regular blending */
1008 for (x = width; x > 0; x--, dr++, outr++, sr++) {
1009 if ((reinterpret_cast<const uchar *>(sr))[3]) {
1010 func(reinterpret_cast<uchar *>(dr),
1011 reinterpret_cast<const uchar *>(outr),
1012 reinterpret_cast<const uchar *>(sr));
1013 }
1014 }
1015 }
1016
1017 drect += destskip;
1018 orect += origskip;
1019 srect += srcskip;
1020 }
1021
1022 if (do_float) {
1023 drf = drectf;
1024 orf = orectf;
1025 srf = srectf;
1026
1027 if (cmaskrect) {
1028 /* mask accumulation for painting */
1029 cmr = cmaskrect;
1030 tmr = texmaskrect;
1031
1032 /* destination mask present, do max alpha masking */
1033 if (dmaskrect) {
1034 dmr = dmaskrect;
1035 for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, dmr++, cmr++) {
1036 float mask_lim = mask_max * (*cmr);
1037
1038 if (texmaskrect) {
1039 mask_lim *= ((*tmr++) / 65535.0f);
1040 }
1041
1042 if (srf[3] && mask_lim) {
1043 float mask;
1044
1045 if (accumulate) {
1046 mask = min_ff(*dmr + mask_lim, 65535.0);
1047 }
1048 else {
1049 mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
1050 }
1051
1052 mask = min_ff(mask, 65535.0);
1053
1054 if (mask > *dmr) {
1055 *dmr = mask;
1056
1057 if (mode == IMB_BLEND_INTERPOLATE) {
1058 blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
1059 }
1060 else {
1061 float mask_srf[4];
1062 mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
1063 func_float(drf, orf, mask_srf);
1064 }
1065 }
1066 }
1067 }
1068 dmaskrect += origskip;
1069 }
1070 /* No destination mask buffer, do regular blend with mask-texture if present. */
1071 else {
1072 for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, cmr++) {
1073 float mask = mask_max * float(*cmr);
1074
1075 if (texmaskrect) {
1076 mask *= (float(*tmr++) / 65535.0f);
1077 }
1078
1079 mask = min_ff(mask, 65535.0);
1080
1081 if (srf[3] && (mask > 0.0f)) {
1082 if (mode == IMB_BLEND_INTERPOLATE) {
1083 blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
1084 }
1085 else {
1086 float mask_srf[4];
1087 mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
1088 func_float(drf, orf, mask_srf);
1089 }
1090 }
1091 }
1092 }
1093
1094 cmaskrect += srcskip;
1095 if (texmaskrect) {
1096 texmaskrect += srcskip;
1097 }
1098 }
1099 else {
1100 /* regular blending */
1101 for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4) {
1102 if (srf[3] != 0) {
1103 func_float(drf, orf, srf);
1104 }
1105 }
1106 }
1107
1108 drectf += destskip * 4;
1109 orectf += origskip * 4;
1110 srectf += srcskip * 4;
1111 }
1112 }
1113 }
1114}
1115
1117 const ImBuf *obuf,
1118 const ImBuf *sbuf,
1119 ushort *dmask,
1120 const ushort *curvemask,
1121 const ushort *texmask,
1122 float mask_max,
1123 int destx,
1124 int desty,
1125 int origx,
1126 int origy,
1127 int srcx,
1128 int srcy,
1129 int width,
1130 int height,
1131 IMB_BlendMode mode,
1132 bool accumulate)
1133{
1134 if (dbuf == nullptr || obuf == nullptr) {
1135 return;
1136 }
1137
1138 /* Acquire mutable data pointers outside of parallel loop. */
1139 uint8_t *dbuf_byte_data = dbuf->byte_data_for_write();
1140 float *dbuf_float_data = dbuf->float_data_for_write();
1141
1142 threading::parallel_for(IndexRange(height), 16, [&](const IndexRange y_range) {
1143 IMB_rectblend(dbuf,
1144 dbuf_byte_data,
1145 dbuf_float_data,
1146 obuf,
1147 sbuf,
1148 dmask,
1149 curvemask,
1150 texmask,
1151 mask_max,
1152 destx,
1153 desty + y_range.first(),
1154 origx,
1155 origy + y_range.first(),
1156 srcx,
1157 srcy + y_range.first(),
1158 width,
1159 y_range.size(),
1160 mode,
1161 accumulate);
1162 });
1163}
1164
1165void IMB_rectfill(ImBuf *drect, const float col[4])
1166{
1167 size_t num;
1168
1169 if (drect->byte_data()) {
1170 uint *rrect = reinterpret_cast<uint *>(drect->byte_data_for_write());
1171
1172 char ccol[4];
1174
1175 num = IMB_get_pixel_count(drect);
1176 for (; num > 0; num--) {
1177 *rrect++ = *(reinterpret_cast<uint *>(ccol));
1178 }
1179 }
1180
1181 if (drect->float_data()) {
1182 float *rrectf = drect->float_data_for_write();
1183
1184 num = IMB_get_pixel_count(drect);
1185 for (; num > 0; num--) {
1186 *rrectf++ = col[0];
1187 *rrectf++ = col[1];
1188 *rrectf++ = col[2];
1189 *rrectf++ = col[3];
1190 }
1191 }
1192}
1193
1195 ImBuf *ibuf, const float scene_linear_color[4], int x1, int y1, int x2, int y2)
1196{
1197 if (!ibuf) {
1198 return;
1199 }
1200
1201 uchar *rect = ibuf->byte_data_for_write();
1202 float *rectf = ibuf->float_data_for_write();
1203 const int width = ibuf->x;
1204 const int height = ibuf->y;
1205
1206 if ((!rect && !rectf) || scene_linear_color[3] == 0.0f) {
1207 return;
1208 }
1209
1210 /* sanity checks for coords */
1211 CLAMP(x1, 0, width);
1212 CLAMP(x2, 0, width);
1213 CLAMP(y1, 0, height);
1214 CLAMP(y2, 0, height);
1215
1216 if (x1 > x2) {
1217 std::swap(x1, x2);
1218 }
1219 if (y1 > y2) {
1220 std::swap(y1, y2);
1221 }
1222 if (x1 == x2 || y1 == y2) {
1223 return;
1224 }
1225 const int x_span = x2 - x1;
1226 const int y_span = y2 - y1;
1227
1228 /* Alpha. */
1229 const float a = scene_linear_color[3];
1230 /* Alpha inverted. */
1231 const float ai = 1 - a;
1232 /* Alpha, inverted, ai/255.0 - Convert char to float at the same time. */
1233 const float aich = ai / 255.0f;
1234
1235 if (rect) {
1236 uchar *pixel;
1237 uchar chr = 0, chg = 0, chb = 0;
1238 float fr = 0, fg = 0, fb = 0;
1239
1240 const int alphaint = unit_float_to_uchar_clamp(a);
1241
1242 float col[3];
1243 copy_v3_v3(col, scene_linear_color);
1244 if (ibuf->byte_buffer.colorspace) {
1246 }
1247 else {
1248 IMB_colormanagement_scene_linear_to_srgb_v3(col, scene_linear_color);
1249 }
1250
1251 if (a == 1.0f) {
1252 chr = unit_float_to_uchar_clamp(col[0]);
1253 chg = unit_float_to_uchar_clamp(col[1]);
1254 chb = unit_float_to_uchar_clamp(col[2]);
1255 }
1256 else {
1257 fr = col[0] * a;
1258 fg = col[1] * a;
1259 fb = col[2] * a;
1260 }
1261 for (int j = 0; j < y_span; j++) {
1262 pixel = rect + (4 * (((size_t(y1) + size_t(j)) * size_t(width)) + size_t(x1)));
1263 for (int i = 0; i < x_span; i++) {
1264 BLI_assert(pixel >= rect && pixel < rect + (4 * (size_t(width) * size_t(height))));
1265 if (a == 1.0f) {
1266 pixel[0] = chr;
1267 pixel[1] = chg;
1268 pixel[2] = chb;
1269 pixel[3] = 255;
1270 }
1271 else {
1272 int alphatest;
1273 pixel[0] = char((fr + (float(pixel[0]) * aich)) * 255.0f);
1274 pixel[1] = char((fg + (float(pixel[1]) * aich)) * 255.0f);
1275 pixel[2] = char((fb + (float(pixel[2]) * aich)) * 255.0f);
1276 pixel[3] = char((alphatest = (int(pixel[3]) + alphaint)) < 255 ? alphatest : 255);
1277 }
1278 pixel += 4;
1279 }
1280 }
1281 }
1282
1283 if (rectf) {
1284 float *pixel;
1285
1286 for (int j = 0; j < y_span; j++) {
1287 pixel = rectf + (4 * (((size_t(y1) + j) * size_t(width)) + size_t(x1)));
1288 for (int i = 0; i < x_span; i++) {
1289 BLI_assert(pixel >= rectf && pixel < rectf + (4 * (size_t(width) * size_t(height))));
1290 if (a == 1.0f) {
1291 pixel[0] = scene_linear_color[0];
1292 pixel[1] = scene_linear_color[1];
1293 pixel[2] = scene_linear_color[2];
1294 pixel[3] = 1.0f;
1295 }
1296 else {
1297 float alphatest;
1298 pixel[0] = (scene_linear_color[0] * a) + (pixel[0] * ai);
1299 pixel[1] = (scene_linear_color[1] * a) + (pixel[1] * ai);
1300 pixel[2] = (scene_linear_color[2] * a) + (pixel[2] * ai);
1301 pixel[3] = (alphatest = (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
1302 }
1303 pixel += 4;
1304 }
1305 }
1306 }
1307}
1308
1309void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
1310{
1311 size_t i;
1312
1313 if (ibuf->float_data() && (ibuf->channels == 4)) {
1314 float *fbuf = ibuf->float_data_for_write() + 3;
1315 for (i = IMB_get_pixel_count(ibuf); i > 0; i--, fbuf += 4) {
1316 *fbuf = value;
1317 }
1318 }
1319
1320 if (uchar *byte_data = ibuf->byte_data_for_write()) {
1321 const uchar cvalue = value * 255;
1322 uchar *cbuf = byte_data + 3;
1323 for (i = IMB_get_pixel_count(ibuf); i > 0; i--, cbuf += 4) {
1324 *cbuf = cvalue;
1325 }
1326 }
1327}
1328
1329} // namespace blender
Read Blender memory allocation and freeing.
#define CLAMP(a, b, c)
constexpr int64_t first() const
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr int64_t size() const
Definition BLI_span.hh:499
constexpr IndexRange index_range() const
Definition BLI_span.hh:676
constexpr int64_t size() const
Definition BLI_span.hh:256
#define unit_float_to_uchar_clamp_v4(v1, v2)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BMesh Iterators.
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static float * create_cropped_buffer(const float *src, const int2 &src_size, const int channels, const int2 &src_rect_pos, const int2 &rect_size)
Definition rectop.cc:391
MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_luminosity_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
void IMB_rectfill_alpha(ImBuf *ibuf, float value)
Definition rectop.cc:1309
MINLINE void blend_color_linearburn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_linearlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
static void imb_rectclip3(ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, int *destx, int *desty, int *origx, int *origy, int *srcx, int *srcy, int *width, int *height)
Definition rectop.cc:565
MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], const float src2[4])
BLI_INLINE float fb(float length, float L)
static void * create_cropped_buffer_impl(const void *src_void, const int2 &src_size, const int stride, const int2 &src_rect_pos, const int2 &rect_size)
Definition rectop.cc:377
size_t IMB_get_pixel_count(const ImBuf *ibuf)
Get the length of the data of the given image buffer in pixels.
MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
bool IMB_alloc_byte_pixels(ImBuf *ibuf, bool initialize_pixels=true)
void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
Definition rectop.cc:489
MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
@ IMB_BLEND_COLOR
Definition IMB_imbuf.hh:227
@ IMB_BLEND_HARDLIGHT
Definition IMB_imbuf.hh:213
@ IMB_BLEND_COPY_RGB
Definition IMB_imbuf.hh:230
@ IMB_BLEND_COLORBURN
Definition IMB_imbuf.hh:214
@ IMB_BLEND_SOFTLIGHT
Definition IMB_imbuf.hh:218
@ IMB_BLEND_COPY_ALPHA
Definition IMB_imbuf.hh:231
@ IMB_BLEND_SCREEN
Definition IMB_imbuf.hh:217
@ IMB_BLEND_VIVIDLIGHT
Definition IMB_imbuf.hh:220
@ IMB_BLEND_DARKEN
Definition IMB_imbuf.hh:209
@ IMB_BLEND_ADD_ALPHA
Definition IMB_imbuf.hh:211
@ IMB_BLEND_PINLIGHT
Definition IMB_imbuf.hh:219
@ IMB_BLEND_INTERPOLATE
Definition IMB_imbuf.hh:228
@ IMB_BLEND_MUL
Definition IMB_imbuf.hh:207
@ IMB_BLEND_LINEARBURN
Definition IMB_imbuf.hh:215
@ IMB_BLEND_COLORDODGE
Definition IMB_imbuf.hh:216
@ IMB_BLEND_DIFFERENCE
Definition IMB_imbuf.hh:222
@ IMB_BLEND_HUE
Definition IMB_imbuf.hh:224
@ IMB_BLEND_SUB
Definition IMB_imbuf.hh:206
@ IMB_BLEND_OVERLAY
Definition IMB_imbuf.hh:212
@ IMB_BLEND_LINEARLIGHT
Definition IMB_imbuf.hh:221
@ IMB_BLEND_SATURATION
Definition IMB_imbuf.hh:225
@ IMB_BLEND_EXCLUSION
Definition IMB_imbuf.hh:223
@ IMB_BLEND_MIX
Definition IMB_imbuf.hh:204
@ IMB_BLEND_ERASE_ALPHA
Definition IMB_imbuf.hh:210
@ IMB_BLEND_LIGHTEN
Definition IMB_imbuf.hh:208
@ IMB_BLEND_LUMINOSITY
Definition IMB_imbuf.hh:226
@ IMB_BLEND_ADD
Definition IMB_imbuf.hh:205
void IMB_rectfill(ImBuf *drect, const float col[4])
Definition rectop.cc:1165
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
unsigned short ushort
Definition BKE_text.h:56
MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_darken_float(float dst[4], const float src1[4], const float src2[4])
void(*)(uchar *dst, const uchar *src1, const uchar *src2) IMB_blend_func
Definition rectop.cc:646
void IMB_rectfill_area(ImBuf *ibuf, const float scene_linear_color[4], int x1, int y1, int x2, int y2)
Definition rectop.cc:1194
MINLINE void blend_color_exclusion_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
void IMB_crop(ImBuf *ibuf, const int2 &rect_pos, const int2 &rect_size)
Definition rectop.cc:470
MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_difference_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_luminosity_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_color_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_difference_float(float dst[4], const float src1[4], const float src2[4])
void IMB_rectblend(ImBuf *dbuf, uint8_t *dbuf_byte_data, float *dbuf_float_data, const ImBuf *obuf, const ImBuf *sbuf, unsigned short *dmask, const unsigned short *curvemask, const unsigned short *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
Definition rectop.cc:649
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4])
MINLINE int divide_round_i(int a, int b)
VecBase< int32_t, 2 > int2
MINLINE void blend_color_overlay_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
unsigned char uchar
Definition BKE_text.h:58
MINLINE void blend_color_hardlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_screen_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
unsigned char uint8_t
Definition BKE_text.h:79
static void copy_to_cropped_bufffer(void *dst_void, const int2 &dst_size, const void *src_void, const int2 &src_size, const int stride, const int2 &src_rect_pos, const int2 &dst_rect_pos, const int2 &rect_size)
Definition rectop.cc:346
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
Definition rectop.cc:511
MINLINE void blend_color_saturation_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_dodge_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
Definition rectop.cc:118
ATTR_WARN_UNUSED_RESULT const size_t num
MINLINE void blend_color_hue_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4])
void IMB_rectblend_threaded(ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, unsigned short *dmask, const unsigned short *curvemask, const unsigned short *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
Definition rectop.cc:1116
MINLINE void blend_color_burn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_lighten_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_vividlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
void IMB_blend_color_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
Definition rectop.cc:30
MINLINE void blend_color_lighten_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4])
bool IMB_alloc_float_pixels(ImBuf *ibuf, unsigned int channels, bool initialize_pixels=true)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], const float src2[4])
void(*)(float *dst, const float *src1, const float *src2) IMB_blend_func_float
Definition rectop.cc:647
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
MINLINE void blend_color_pinlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], const float src2[4])
void IMB_copy_rect(float *dst, const int2 &dst_size, const float *src, const int2 &src_size, int channels, const int2 &src_rect_pos, const int2 &dst_rect_pos, const int2 &rect_size)
Definition rectop.cc:414
MINLINE void blend_color_softlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4])
ccl_device_inline int rect_size(const int4 rect)
Definition rect.h:56
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
Definition allocimbuf.cc:60
const float * float_data() const
void assign_byte_data(uint8_t *data)
float * float_data_for_write()
Definition allocimbuf.cc:79
void assign_float_data(float *data)