Blender  V2.93
rectop.c
Go to the documentation of this file.
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) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  * allocimbuf.c
19  */
20 
25 #include <stdlib.h>
26 
27 #include "BLI_math_base.h"
28 #include "BLI_math_color.h"
29 #include "BLI_math_color_blend.h"
30 #include "BLI_math_vector.h"
31 #include "BLI_rect.h"
32 #include "BLI_utildefines.h"
33 
34 #include "IMB_imbuf.h"
35 #include "IMB_imbuf_types.h"
36 
37 #include "IMB_colormanagement.h"
38 
39 #include "MEM_guardedalloc.h"
40 
41 void IMB_blend_color_byte(unsigned char dst[4],
42  const unsigned char src1[4],
43  const unsigned char src2[4],
44  IMB_BlendMode mode)
45 {
46  switch (mode) {
47  case IMB_BLEND_MIX:
48  blend_color_mix_byte(dst, src1, src2);
49  break;
50  case IMB_BLEND_ADD:
51  blend_color_add_byte(dst, src1, src2);
52  break;
53  case IMB_BLEND_SUB:
54  blend_color_sub_byte(dst, src1, src2);
55  break;
56  case IMB_BLEND_MUL:
57  blend_color_mul_byte(dst, src1, src2);
58  break;
59  case IMB_BLEND_LIGHTEN:
60  blend_color_lighten_byte(dst, src1, src2);
61  break;
62  case IMB_BLEND_DARKEN:
63  blend_color_darken_byte(dst, src1, src2);
64  break;
66  blend_color_erase_alpha_byte(dst, src1, src2);
67  break;
69  blend_color_add_alpha_byte(dst, src1, src2);
70  break;
71  case IMB_BLEND_OVERLAY:
72  blend_color_overlay_byte(dst, src1, src2);
73  break;
75  blend_color_hardlight_byte(dst, src1, src2);
76  break;
78  blend_color_burn_byte(dst, src1, src2);
79  break;
81  blend_color_linearburn_byte(dst, src1, src2);
82  break;
84  blend_color_dodge_byte(dst, src1, src2);
85  break;
86  case IMB_BLEND_SCREEN:
87  blend_color_screen_byte(dst, src1, src2);
88  break;
90  blend_color_softlight_byte(dst, src1, src2);
91  break;
92  case IMB_BLEND_PINLIGHT:
93  blend_color_pinlight_byte(dst, src1, src2);
94  break;
96  blend_color_linearlight_byte(dst, src1, src2);
97  break;
99  blend_color_vividlight_byte(dst, src1, src2);
100  break;
102  blend_color_difference_byte(dst, src1, src2);
103  break;
104  case IMB_BLEND_EXCLUSION:
105  blend_color_exclusion_byte(dst, src1, src2);
106  break;
107  case IMB_BLEND_COLOR:
108  blend_color_color_byte(dst, src1, src2);
109  break;
110  case IMB_BLEND_HUE:
111  blend_color_hue_byte(dst, src1, src2);
112  break;
114  blend_color_saturation_byte(dst, src1, src2);
115  break;
117  blend_color_luminosity_byte(dst, src1, src2);
118  break;
119 
120  default:
121  dst[0] = src1[0];
122  dst[1] = src1[1];
123  dst[2] = src1[2];
124  dst[3] = src1[3];
125  break;
126  }
127 }
128 
129 void IMB_blend_color_float(float dst[4],
130  const float src1[4],
131  const float src2[4],
132  IMB_BlendMode mode)
133 {
134  switch (mode) {
135  case IMB_BLEND_MIX:
136  blend_color_mix_float(dst, src1, src2);
137  break;
138  case IMB_BLEND_ADD:
139  blend_color_add_float(dst, src1, src2);
140  break;
141  case IMB_BLEND_SUB:
142  blend_color_sub_float(dst, src1, src2);
143  break;
144  case IMB_BLEND_MUL:
145  blend_color_mul_float(dst, src1, src2);
146  break;
147  case IMB_BLEND_LIGHTEN:
148  blend_color_lighten_float(dst, src1, src2);
149  break;
150  case IMB_BLEND_DARKEN:
151  blend_color_darken_float(dst, src1, src2);
152  break;
154  blend_color_erase_alpha_float(dst, src1, src2);
155  break;
156  case IMB_BLEND_ADD_ALPHA:
157  blend_color_add_alpha_float(dst, src1, src2);
158  break;
159  case IMB_BLEND_OVERLAY:
160  blend_color_overlay_float(dst, src1, src2);
161  break;
162  case IMB_BLEND_HARDLIGHT:
163  blend_color_hardlight_float(dst, src1, src2);
164  break;
165  case IMB_BLEND_COLORBURN:
166  blend_color_burn_float(dst, src1, src2);
167  break;
169  blend_color_linearburn_float(dst, src1, src2);
170  break;
172  blend_color_dodge_float(dst, src1, src2);
173  break;
174  case IMB_BLEND_SCREEN:
175  blend_color_screen_float(dst, src1, src2);
176  break;
177  case IMB_BLEND_SOFTLIGHT:
178  blend_color_softlight_float(dst, src1, src2);
179  break;
180  case IMB_BLEND_PINLIGHT:
181  blend_color_pinlight_float(dst, src1, src2);
182  break;
184  blend_color_linearlight_float(dst, src1, src2);
185  break;
187  blend_color_vividlight_float(dst, src1, src2);
188  break;
190  blend_color_difference_float(dst, src1, src2);
191  break;
192  case IMB_BLEND_EXCLUSION:
193  blend_color_exclusion_float(dst, src1, src2);
194  break;
195  case IMB_BLEND_COLOR:
196  blend_color_color_float(dst, src1, src2);
197  break;
198  case IMB_BLEND_HUE:
199  blend_color_hue_float(dst, src1, src2);
200  break;
202  blend_color_saturation_float(dst, src1, src2);
203  break;
205  blend_color_luminosity_float(dst, src1, src2);
206  break;
207  default:
208  dst[0] = src1[0];
209  dst[1] = src1[1];
210  dst[2] = src1[2];
211  dst[3] = src1[3];
212  break;
213  }
214 }
215 
216 /* -------------------------------------------------------------------- */
220 static void rect_crop_4bytes(void **buf_p, const int size_src[2], const rcti *crop)
221 {
222  if (*buf_p == NULL) {
223  return;
224  }
225  const int size_dst[2] = {
226  BLI_rcti_size_x(crop) + 1,
227  BLI_rcti_size_y(crop) + 1,
228  };
229  uint *src = *buf_p;
230  uint *dst = src + crop->ymin * size_src[0] + crop->xmin;
231  for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) {
232  memmove(src, dst, sizeof(uint) * size_dst[0]);
233  }
234  *buf_p = MEM_reallocN(*buf_p, sizeof(uint) * size_dst[0] * size_dst[1]);
235 }
236 
237 static void rect_crop_16bytes(void **buf_p, const int size_src[2], const rcti *crop)
238 {
239  if (*buf_p == NULL) {
240  return;
241  }
242  const int size_dst[2] = {
243  BLI_rcti_size_x(crop) + 1,
244  BLI_rcti_size_y(crop) + 1,
245  };
246  uint(*src)[4] = *buf_p;
247  uint(*dst)[4] = src + crop->ymin * size_src[0] + crop->xmin;
248  for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) {
249  memmove(src, dst, sizeof(uint[4]) * size_dst[0]);
250  }
251  *buf_p = (void *)MEM_reallocN(*buf_p, sizeof(uint[4]) * size_dst[0] * size_dst[1]);
252 }
253 
257 void IMB_rect_crop(ImBuf *ibuf, const rcti *crop)
258 {
259  const int size_src[2] = {
260  ibuf->x,
261  ibuf->y,
262  };
263  const int size_dst[2] = {
264  BLI_rcti_size_x(crop) + 1,
265  BLI_rcti_size_y(crop) + 1,
266  };
267  BLI_assert(size_dst[0] > 0 && size_dst[1] > 0);
268  BLI_assert(crop->xmin >= 0 && crop->ymin >= 0);
269  BLI_assert(crop->xmax < ibuf->x && crop->ymax < ibuf->y);
270 
271  if ((size_dst[0] == ibuf->x) && (size_dst[1] == ibuf->y)) {
272  return;
273  }
274 
275  rect_crop_4bytes((void **)&ibuf->rect, size_src, crop);
276  rect_crop_4bytes((void **)&ibuf->zbuf, size_src, crop);
277  rect_crop_4bytes((void **)&ibuf->zbuf_float, size_src, crop);
278  rect_crop_16bytes((void **)&ibuf->rect_float, size_src, crop);
279 
280  ibuf->x = size_dst[0];
281  ibuf->y = size_dst[1];
282 }
283 
287 static void rect_realloc_4bytes(void **buf_p, const uint size[2])
288 {
289  if (*buf_p == NULL) {
290  return;
291  }
292  MEM_freeN(*buf_p);
293  *buf_p = MEM_mallocN(sizeof(uint) * size[0] * size[1], __func__);
294 }
295 
296 static void rect_realloc_16bytes(void **buf_p, const uint size[2])
297 {
298  if (*buf_p == NULL) {
299  return;
300  }
301  MEM_freeN(*buf_p);
302  *buf_p = MEM_mallocN(sizeof(uint[4]) * size[0] * size[1], __func__);
303 }
304 
308 void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
309 {
310  BLI_assert(size[0] > 0 && size[1] > 0);
311  if ((size[0] == ibuf->x) && (size[1] == ibuf->y)) {
312  return;
313  }
314 
315  rect_realloc_4bytes((void **)&ibuf->rect, size);
316  rect_realloc_4bytes((void **)&ibuf->zbuf, size);
317  rect_realloc_4bytes((void **)&ibuf->zbuf_float, size);
318  rect_realloc_16bytes((void **)&ibuf->rect_float, size);
319 
320  ibuf->x = size[0];
321  ibuf->y = size[1];
322 }
323 
326 /* clipping */
327 
328 void IMB_rectclip(ImBuf *dbuf,
329  const ImBuf *sbuf,
330  int *destx,
331  int *desty,
332  int *srcx,
333  int *srcy,
334  int *width,
335  int *height)
336 {
337  int tmp;
338 
339  if (dbuf == NULL) {
340  return;
341  }
342 
343  if (*destx < 0) {
344  *srcx -= *destx;
345  *width += *destx;
346  *destx = 0;
347  }
348  if (*srcx < 0) {
349  *destx -= *srcx;
350  *width += *srcx;
351  *srcx = 0;
352  }
353  if (*desty < 0) {
354  *srcy -= *desty;
355  *height += *desty;
356  *desty = 0;
357  }
358  if (*srcy < 0) {
359  *desty -= *srcy;
360  *height += *srcy;
361  *srcy = 0;
362  }
363 
364  tmp = dbuf->x - *destx;
365  if (*width > tmp) {
366  *width = tmp;
367  }
368  tmp = dbuf->y - *desty;
369  if (*height > tmp) {
370  *height = tmp;
371  }
372 
373  if (sbuf) {
374  tmp = sbuf->x - *srcx;
375  if (*width > tmp) {
376  *width = tmp;
377  }
378  tmp = sbuf->y - *srcy;
379  if (*height > tmp) {
380  *height = tmp;
381  }
382  }
383 
384  if ((*height <= 0) || (*width <= 0)) {
385  *width = 0;
386  *height = 0;
387  }
388 }
389 
390 static void imb_rectclip3(ImBuf *dbuf,
391  const ImBuf *obuf,
392  const ImBuf *sbuf,
393  int *destx,
394  int *desty,
395  int *origx,
396  int *origy,
397  int *srcx,
398  int *srcy,
399  int *width,
400  int *height)
401 {
402  int tmp;
403 
404  if (dbuf == NULL) {
405  return;
406  }
407 
408  if (*destx < 0) {
409  *srcx -= *destx;
410  *origx -= *destx;
411  *width += *destx;
412  *destx = 0;
413  }
414  if (*origx < 0) {
415  *destx -= *origx;
416  *srcx -= *origx;
417  *width += *origx;
418  *origx = 0;
419  }
420  if (*srcx < 0) {
421  *destx -= *srcx;
422  *origx -= *srcx;
423  *width += *srcx;
424  *srcx = 0;
425  }
426 
427  if (*desty < 0) {
428  *srcy -= *desty;
429  *origy -= *desty;
430  *height += *desty;
431  *desty = 0;
432  }
433  if (*origy < 0) {
434  *desty -= *origy;
435  *srcy -= *origy;
436  *height += *origy;
437  *origy = 0;
438  }
439  if (*srcy < 0) {
440  *desty -= *srcy;
441  *origy -= *srcy;
442  *height += *srcy;
443  *srcy = 0;
444  }
445 
446  tmp = dbuf->x - *destx;
447  if (*width > tmp) {
448  *width = tmp;
449  }
450  tmp = dbuf->y - *desty;
451  if (*height > tmp) {
452  *height = tmp;
453  }
454 
455  if (obuf) {
456  tmp = obuf->x - *origx;
457  if (*width > tmp) {
458  *width = tmp;
459  }
460  tmp = obuf->y - *origy;
461  if (*height > tmp) {
462  *height = tmp;
463  }
464  }
465 
466  if (sbuf) {
467  tmp = sbuf->x - *srcx;
468  if (*width > tmp) {
469  *width = tmp;
470  }
471  tmp = sbuf->y - *srcy;
472  if (*height > tmp) {
473  *height = tmp;
474  }
475  }
476 
477  if ((*height <= 0) || (*width <= 0)) {
478  *width = 0;
479  *height = 0;
480  }
481 }
482 
483 /* copy and blend */
484 
485 void IMB_rectcpy(ImBuf *dbuf,
486  const ImBuf *sbuf,
487  int destx,
488  int desty,
489  int srcx,
490  int srcy,
491  int width,
492  int height)
493 {
494  IMB_rectblend(dbuf,
495  dbuf,
496  sbuf,
497  NULL,
498  NULL,
499  NULL,
500  0,
501  destx,
502  desty,
503  destx,
504  desty,
505  srcx,
506  srcy,
507  width,
508  height,
510  false);
511 }
512 
513 typedef void (*IMB_blend_func)(unsigned char *dst,
514  const unsigned char *src1,
515  const unsigned char *src2);
516 typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2);
517 
518 void IMB_rectblend(ImBuf *dbuf,
519  const ImBuf *obuf,
520  const ImBuf *sbuf,
521  unsigned short *dmask,
522  const unsigned short *curvemask,
523  const unsigned short *texmask,
524  float mask_max,
525  int destx,
526  int desty,
527  int origx,
528  int origy,
529  int srcx,
530  int srcy,
531  int width,
532  int height,
533  IMB_BlendMode mode,
534  bool accumulate)
535 {
536  unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr;
537  float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
538  const unsigned short *cmaskrect = curvemask, *cmr;
539  unsigned short *dmaskrect = dmask, *dmr;
540  const unsigned short *texmaskrect = texmask, *tmr;
541  int do_float, do_char, srcskip, destskip, origskip, x;
542  IMB_blend_func func = NULL;
543  IMB_blend_func_float func_float = NULL;
544 
545  if (dbuf == NULL || obuf == NULL) {
546  return;
547  }
548 
549  imb_rectclip3(dbuf, obuf, sbuf, &destx, &desty, &origx, &origy, &srcx, &srcy, &width, &height);
550 
551  if (width == 0 || height == 0) {
552  return;
553  }
554  if (sbuf && sbuf->channels != 4) {
555  return;
556  }
557  if (dbuf->channels != 4) {
558  return;
559  }
560 
561  do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect);
562  do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float);
563 
564  if (do_char) {
565  drect = dbuf->rect + ((size_t)desty) * dbuf->x + destx;
566  orect = obuf->rect + ((size_t)origy) * obuf->x + origx;
567  }
568  if (do_float) {
569  drectf = dbuf->rect_float + (((size_t)desty) * dbuf->x + destx) * 4;
570  orectf = obuf->rect_float + (((size_t)origy) * obuf->x + origx) * 4;
571  }
572 
573  if (dmaskrect) {
574  dmaskrect += ((size_t)origy) * obuf->x + origx;
575  }
576 
577  destskip = dbuf->x;
578  origskip = obuf->x;
579 
580  if (sbuf) {
581  if (do_char) {
582  srect = sbuf->rect + ((size_t)srcy) * sbuf->x + srcx;
583  }
584  if (do_float) {
585  srectf = sbuf->rect_float + (((size_t)srcy) * sbuf->x + srcx) * 4;
586  }
587  srcskip = sbuf->x;
588 
589  if (cmaskrect) {
590  cmaskrect += ((size_t)srcy) * sbuf->x + srcx;
591  }
592 
593  if (texmaskrect) {
594  texmaskrect += ((size_t)srcy) * sbuf->x + srcx;
595  }
596  }
597  else {
598  srect = drect;
599  srectf = drectf;
600  srcskip = destskip;
601  }
602 
603  if (mode == IMB_BLEND_COPY) {
604  /* copy */
605  for (; height > 0; height--) {
606  if (do_char) {
607  memcpy(drect, srect, width * sizeof(int));
608  drect += destskip;
609  srect += srcskip;
610  }
611 
612  if (do_float) {
613  memcpy(drectf, srectf, sizeof(float[4]) * width);
614  drectf += destskip * 4;
615  srectf += srcskip * 4;
616  }
617  }
618  }
619  else if (mode == IMB_BLEND_COPY_RGB) {
620  /* copy rgb only */
621  for (; height > 0; height--) {
622  if (do_char) {
623  dr = drect;
624  sr = srect;
625  for (x = width; x > 0; x--, dr++, sr++) {
626  ((char *)dr)[0] = ((char *)sr)[0];
627  ((char *)dr)[1] = ((char *)sr)[1];
628  ((char *)dr)[2] = ((char *)sr)[2];
629  }
630  drect += destskip;
631  srect += srcskip;
632  }
633 
634  if (do_float) {
635  drf = drectf;
636  srf = srectf;
637  for (x = width; x > 0; x--, drf += 4, srf += 4) {
638  float map_alpha = (srf[3] == 0.0f) ? drf[3] : drf[3] / srf[3];
639 
640  drf[0] = srf[0] * map_alpha;
641  drf[1] = srf[1] * map_alpha;
642  drf[2] = srf[2] * map_alpha;
643  }
644  drectf += destskip * 4;
645  srectf += srcskip * 4;
646  }
647  }
648  }
649  else if (mode == IMB_BLEND_COPY_ALPHA) {
650  /* copy alpha only */
651  for (; height > 0; height--) {
652  if (do_char) {
653  dr = drect;
654  sr = srect;
655  for (x = width; x > 0; x--, dr++, sr++) {
656  ((char *)dr)[3] = ((char *)sr)[3];
657  }
658  drect += destskip;
659  srect += srcskip;
660  }
661 
662  if (do_float) {
663  drf = drectf;
664  srf = srectf;
665  for (x = width; x > 0; x--, drf += 4, srf += 4) {
666  drf[3] = srf[3];
667  }
668  drectf += destskip * 4;
669  srectf += srcskip * 4;
670  }
671  }
672  }
673  else {
674  switch (mode) {
675  case IMB_BLEND_MIX:
677  func = blend_color_mix_byte;
678  func_float = blend_color_mix_float;
679  break;
680  case IMB_BLEND_ADD:
681  func = blend_color_add_byte;
682  func_float = blend_color_add_float;
683  break;
684  case IMB_BLEND_SUB:
685  func = blend_color_sub_byte;
686  func_float = blend_color_sub_float;
687  break;
688  case IMB_BLEND_MUL:
689  func = blend_color_mul_byte;
690  func_float = blend_color_mul_float;
691  break;
692  case IMB_BLEND_LIGHTEN:
694  func_float = blend_color_lighten_float;
695  break;
696  case IMB_BLEND_DARKEN:
698  func_float = blend_color_darken_float;
699  break;
702  func_float = blend_color_erase_alpha_float;
703  break;
704  case IMB_BLEND_ADD_ALPHA:
706  func_float = blend_color_add_alpha_float;
707  break;
708  case IMB_BLEND_OVERLAY:
710  func_float = blend_color_overlay_float;
711  break;
712  case IMB_BLEND_HARDLIGHT:
714  func_float = blend_color_hardlight_float;
715  break;
716  case IMB_BLEND_COLORBURN:
717  func = blend_color_burn_byte;
718  func_float = blend_color_burn_float;
719  break;
722  func_float = blend_color_linearburn_float;
723  break;
725  func = blend_color_dodge_byte;
726  func_float = blend_color_dodge_float;
727  break;
728  case IMB_BLEND_SCREEN:
730  func_float = blend_color_screen_float;
731  break;
732  case IMB_BLEND_SOFTLIGHT:
734  func_float = blend_color_softlight_float;
735  break;
736  case IMB_BLEND_PINLIGHT:
738  func_float = blend_color_pinlight_float;
739  break;
742  func_float = blend_color_linearlight_float;
743  break;
746  func_float = blend_color_vividlight_float;
747  break;
750  func_float = blend_color_difference_float;
751  break;
752  case IMB_BLEND_EXCLUSION:
754  func_float = blend_color_exclusion_float;
755  break;
756  case IMB_BLEND_COLOR:
757  func = blend_color_color_byte;
758  func_float = blend_color_color_float;
759  break;
760  case IMB_BLEND_HUE:
761  func = blend_color_hue_byte;
762  func_float = blend_color_hue_float;
763  break;
766  func_float = blend_color_saturation_float;
767  break;
770  func_float = blend_color_luminosity_float;
771  break;
772  default:
773  break;
774  }
775 
776  /* blend */
777  for (; height > 0; height--) {
778  if (do_char) {
779  dr = drect;
780  or = orect;
781  sr = srect;
782 
783  if (cmaskrect) {
784  /* mask accumulation for painting */
785  cmr = cmaskrect;
786  tmr = texmaskrect;
787 
788  /* destination mask present, do max alpha masking */
789  if (dmaskrect) {
790  dmr = dmaskrect;
791  for (x = width; x > 0; x--, dr++, or ++, sr++, dmr++, cmr++) {
792  unsigned char *src = (unsigned char *)sr;
793  float mask_lim = mask_max * (*cmr);
794 
795  if (texmaskrect) {
796  mask_lim *= ((*tmr++) / 65535.0f);
797  }
798 
799  if (src[3] && mask_lim) {
800  float mask;
801 
802  if (accumulate) {
803  mask = *dmr + mask_lim;
804  }
805  else {
806  mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
807  }
808 
809  mask = min_ff(mask, 65535.0);
810 
811  if (mask > *dmr) {
812  unsigned char mask_src[4];
813 
814  *dmr = mask;
815 
816  mask_src[0] = src[0];
817  mask_src[1] = src[1];
818  mask_src[2] = src[2];
819 
820  if (mode == IMB_BLEND_INTERPOLATE) {
821  mask_src[3] = src[3];
823  (unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
824  }
825  else {
826  mask_src[3] = divide_round_i(src[3] * mask, 65535);
827  func((unsigned char *)dr, (unsigned char *) or, mask_src);
828  }
829  }
830  }
831  }
832  dmaskrect += origskip;
833  }
834  /* no destination mask buffer, do regular blend with masktexture if present */
835  else {
836  for (x = width; x > 0; x--, dr++, or ++, sr++, cmr++) {
837  unsigned char *src = (unsigned char *)sr;
838  float mask = (float)mask_max * ((float)(*cmr));
839 
840  if (texmaskrect) {
841  mask *= ((float)(*tmr++) / 65535.0f);
842  }
843 
844  mask = min_ff(mask, 65535.0);
845 
846  if (src[3] && (mask > 0.0f)) {
847  unsigned char mask_src[4];
848 
849  mask_src[0] = src[0];
850  mask_src[1] = src[1];
851  mask_src[2] = src[2];
852 
853  if (mode == IMB_BLEND_INTERPOLATE) {
854  mask_src[3] = src[3];
856  (unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
857  }
858  else {
859  mask_src[3] = divide_round_i(src[3] * mask, 65535);
860  func((unsigned char *)dr, (unsigned char *) or, mask_src);
861  }
862  }
863  }
864  }
865 
866  cmaskrect += srcskip;
867  if (texmaskrect) {
868  texmaskrect += srcskip;
869  }
870  }
871  else {
872  /* regular blending */
873  for (x = width; x > 0; x--, dr++, or ++, sr++) {
874  if (((unsigned char *)sr)[3]) {
875  func((unsigned char *)dr, (unsigned char *) or, (unsigned char *)sr);
876  }
877  }
878  }
879 
880  drect += destskip;
881  orect += origskip;
882  srect += srcskip;
883  }
884 
885  if (do_float) {
886  drf = drectf;
887  orf = orectf;
888  srf = srectf;
889 
890  if (cmaskrect) {
891  /* mask accumulation for painting */
892  cmr = cmaskrect;
893  tmr = texmaskrect;
894 
895  /* destination mask present, do max alpha masking */
896  if (dmaskrect) {
897  dmr = dmaskrect;
898  for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, dmr++, cmr++) {
899  float mask_lim = mask_max * (*cmr);
900 
901  if (texmaskrect) {
902  mask_lim *= ((*tmr++) / 65535.0f);
903  }
904 
905  if (srf[3] && mask_lim) {
906  float mask;
907 
908  if (accumulate) {
909  mask = min_ff(*dmr + mask_lim, 65535.0);
910  }
911  else {
912  mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
913  }
914 
915  mask = min_ff(mask, 65535.0);
916 
917  if (mask > *dmr) {
918  *dmr = mask;
919 
920  if (mode == IMB_BLEND_INTERPOLATE) {
921  blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
922  }
923  else {
924  float mask_srf[4];
925  mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
926  func_float(drf, orf, mask_srf);
927  }
928  }
929  }
930  }
931  dmaskrect += origskip;
932  }
933  /* no destination mask buffer, do regular blend with masktexture if present */
934  else {
935  for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, cmr++) {
936  float mask = (float)mask_max * ((float)(*cmr));
937 
938  if (texmaskrect) {
939  mask *= ((float)(*tmr++) / 65535.0f);
940  }
941 
942  mask = min_ff(mask, 65535.0);
943 
944  if (srf[3] && (mask > 0.0f)) {
945  if (mode == IMB_BLEND_INTERPOLATE) {
946  blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
947  }
948  else {
949  float mask_srf[4];
950  mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
951  func_float(drf, orf, mask_srf);
952  }
953  }
954  }
955  }
956 
957  cmaskrect += srcskip;
958  if (texmaskrect) {
959  texmaskrect += srcskip;
960  }
961  }
962  else {
963  /* regular blending */
964  for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4) {
965  if (srf[3] != 0) {
966  func_float(drf, orf, srf);
967  }
968  }
969  }
970 
971  drectf += destskip * 4;
972  orectf += origskip * 4;
973  srectf += srcskip * 4;
974  }
975  }
976  }
977 }
978 
979 typedef struct RectBlendThreadData {
981  const ImBuf *obuf, *sbuf;
982  unsigned short *dmask;
983  const unsigned short *curvemask, *texmask;
984  float mask_max;
986  int srcx, srcy, width;
990 
991 static void rectblend_thread_do(void *data_v, int start_scanline, int num_scanlines)
992 {
994  IMB_rectblend(data->dbuf,
995  data->obuf,
996  data->sbuf,
997  data->dmask,
998  data->curvemask,
999  data->texmask,
1000  data->mask_max,
1001  data->destx,
1002  data->desty + start_scanline,
1003  data->origx,
1004  data->origy + start_scanline,
1005  data->srcx,
1006  data->srcy + start_scanline,
1007  data->width,
1008  num_scanlines,
1009  data->mode,
1010  data->accumulate);
1011 }
1012 
1014  const ImBuf *obuf,
1015  const ImBuf *sbuf,
1016  unsigned short *dmask,
1017  const unsigned short *curvemask,
1018  const unsigned short *texmask,
1019  float mask_max,
1020  int destx,
1021  int desty,
1022  int origx,
1023  int origy,
1024  int srcx,
1025  int srcy,
1026  int width,
1027  int height,
1028  IMB_BlendMode mode,
1029  bool accumulate)
1030 {
1031  if (((size_t)width) * height < 64 * 64) {
1032  IMB_rectblend(dbuf,
1033  obuf,
1034  sbuf,
1035  dmask,
1036  curvemask,
1037  texmask,
1038  mask_max,
1039  destx,
1040  desty,
1041  origx,
1042  origy,
1043  srcx,
1044  srcy,
1045  width,
1046  height,
1047  mode,
1048  accumulate);
1049  }
1050  else {
1052  data.dbuf = dbuf;
1053  data.obuf = obuf;
1054  data.sbuf = sbuf;
1055  data.dmask = dmask;
1056  data.curvemask = curvemask;
1057  data.texmask = texmask;
1058  data.mask_max = mask_max;
1059  data.destx = destx;
1060  data.desty = desty;
1061  data.origx = origx;
1062  data.origy = origy;
1063  data.srcx = srcx;
1064  data.srcy = srcy;
1065  data.width = width;
1066  data.mode = mode;
1067  data.accumulate = accumulate;
1069  }
1070 }
1071 
1077 void IMB_rectfill(ImBuf *drect, const float col[4])
1078 {
1079  int num;
1080 
1081  if (drect->rect) {
1082  unsigned int *rrect = drect->rect;
1083  char ccol[4];
1084 
1085  ccol[0] = (int)(col[0] * 255);
1086  ccol[1] = (int)(col[1] * 255);
1087  ccol[2] = (int)(col[2] * 255);
1088  ccol[3] = (int)(col[3] * 255);
1089 
1090  num = drect->x * drect->y;
1091  for (; num > 0; num--) {
1092  *rrect++ = *((unsigned int *)ccol);
1093  }
1094  }
1095 
1096  if (drect->rect_float) {
1097  float *rrectf = drect->rect_float;
1098 
1099  num = drect->x * drect->y;
1100  for (; num > 0; num--) {
1101  *rrectf++ = col[0];
1102  *rrectf++ = col[1];
1103  *rrectf++ = col[2];
1104  *rrectf++ = col[3];
1105  }
1106  }
1107 }
1108 
1119  const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
1120 {
1121  /* Sanity checks. */
1122  BLI_assert(ibuf->channels == 4);
1123 
1124  if (ibuf->channels != 4) {
1125  return;
1126  }
1127 
1128  int width = ibuf->x;
1129  int height = ibuf->y;
1130  CLAMP(x1, 0, width);
1131  CLAMP(x2, 0, width);
1132  CLAMP(y1, 0, height);
1133  CLAMP(y2, 0, height);
1134 
1135  if (x1 > x2) {
1136  SWAP(int, x1, x2);
1137  }
1138  if (y1 > y2) {
1139  SWAP(int, y1, y2);
1140  }
1141  if (x1 == x2 || y1 == y2) {
1142  return;
1143  }
1144 
1145  unsigned char col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255};
1146 
1147  for (int y = y1; y < y2; y++) {
1148  for (int x = x1; x < x2; x++) {
1149  size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
1150 
1151  if (ibuf->rect) {
1152  unsigned char *rrect = (unsigned char *)ibuf->rect + offset;
1153  memcpy(rrect, &col_char, sizeof(unsigned char) * 4);
1154  }
1155 
1156  if (ibuf->rect_float) {
1157  float *rrectf = ibuf->rect_float + offset;
1158  memcpy(rrectf, &col, sizeof(float) * 4);
1159  }
1160  }
1161  }
1162 }
1163 
1164 void buf_rectfill_area(unsigned char *rect,
1165  float *rectf,
1166  int width,
1167  int height,
1168  const float col[4],
1169  struct ColorManagedDisplay *display,
1170  int x1,
1171  int y1,
1172  int x2,
1173  int y2)
1174 {
1175  int i, j;
1176  float a; /* alpha */
1177  float ai; /* alpha inverted */
1178  float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */
1179  if ((!rect && !rectf) || (!col) || col[3] == 0.0f) {
1180  return;
1181  }
1182 
1183  /* sanity checks for coords */
1184  CLAMP(x1, 0, width);
1185  CLAMP(x2, 0, width);
1186  CLAMP(y1, 0, height);
1187  CLAMP(y2, 0, height);
1188 
1189  if (x1 > x2) {
1190  SWAP(int, x1, x2);
1191  }
1192  if (y1 > y2) {
1193  SWAP(int, y1, y2);
1194  }
1195  if (x1 == x2 || y1 == y2) {
1196  return;
1197  }
1198 
1199  a = col[3];
1200  ai = 1 - a;
1201  aich = ai / 255.0f;
1202 
1203  if (rect) {
1204  unsigned char *pixel;
1205  unsigned char chr = 0, chg = 0, chb = 0;
1206  float fr = 0, fg = 0, fb = 0;
1207 
1208  const int alphaint = unit_float_to_uchar_clamp(a);
1209 
1210  if (a == 1.0f) {
1211  chr = unit_float_to_uchar_clamp(col[0]);
1212  chg = unit_float_to_uchar_clamp(col[1]);
1213  chb = unit_float_to_uchar_clamp(col[2]);
1214  }
1215  else {
1216  fr = col[0] * a;
1217  fg = col[1] * a;
1218  fb = col[2] * a;
1219  }
1220  for (j = 0; j < y2 - y1; j++) {
1221  for (i = 0; i < x2 - x1; i++) {
1222  pixel = rect + 4 * (((y1 + j) * width) + (x1 + i));
1223  if (pixel >= rect && pixel < rect + (4 * (width * height))) {
1224  if (a == 1.0f) {
1225  pixel[0] = chr;
1226  pixel[1] = chg;
1227  pixel[2] = chb;
1228  pixel[3] = 255;
1229  }
1230  else {
1231  int alphatest;
1232  pixel[0] = (char)((fr + ((float)pixel[0] * aich)) * 255.0f);
1233  pixel[1] = (char)((fg + ((float)pixel[1] * aich)) * 255.0f);
1234  pixel[2] = (char)((fb + ((float)pixel[2] * aich)) * 255.0f);
1235  pixel[3] = (char)((alphatest = ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255);
1236  }
1237  }
1238  }
1239  }
1240  }
1241 
1242  if (rectf) {
1243  float col_conv[4];
1244  float *pixel;
1245 
1246  if (display) {
1247  copy_v4_v4(col_conv, col);
1249  }
1250  else {
1251  srgb_to_linearrgb_v4(col_conv, col);
1252  }
1253 
1254  for (j = 0; j < y2 - y1; j++) {
1255  for (i = 0; i < x2 - x1; i++) {
1256  pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i));
1257  if (a == 1.0f) {
1258  pixel[0] = col_conv[0];
1259  pixel[1] = col_conv[1];
1260  pixel[2] = col_conv[2];
1261  pixel[3] = 1.0f;
1262  }
1263  else {
1264  float alphatest;
1265  pixel[0] = (col_conv[0] * a) + (pixel[0] * ai);
1266  pixel[1] = (col_conv[1] * a) + (pixel[1] * ai);
1267  pixel[2] = (col_conv[2] * a) + (pixel[2] * ai);
1268  pixel[3] = (alphatest = (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
1269  }
1270  }
1271  }
1272  }
1273 }
1274 
1291  const float col[4],
1292  int x1,
1293  int y1,
1294  int x2,
1295  int y2,
1296  struct ColorManagedDisplay *display)
1297 {
1298  if (!ibuf) {
1299  return;
1300  }
1301  buf_rectfill_area((unsigned char *)ibuf->rect,
1302  ibuf->rect_float,
1303  ibuf->x,
1304  ibuf->y,
1305  col,
1306  display,
1307  x1,
1308  y1,
1309  x2,
1310  y2);
1311 }
1312 
1313 void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
1314 {
1315  int i;
1316 
1317  if (ibuf->rect_float && (ibuf->channels == 4)) {
1318  float *fbuf = ibuf->rect_float + 3;
1319  for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) {
1320  *fbuf = value;
1321  }
1322  }
1323 
1324  if (ibuf->rect) {
1325  const unsigned char cvalue = value * 255;
1326  unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3;
1327  for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) {
1328  *cbuf = cvalue;
1329  }
1330  }
1331 }
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:58
MINLINE float min_ff(float a, float b)
MINLINE int divide_round_i(int a, int b)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearburn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_saturation_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float t)
MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_sub_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])
MINLINE void blend_color_hue_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])
MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_luminosity_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_pinlight_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])
MINLINE void blend_color_pinlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_screen_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])
MINLINE void blend_color_add_alpha_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])
MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float 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_vividlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_mix_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_difference_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_burn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_color_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_overlay_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])
MINLINE void blend_color_hardlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_sub_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])
MINLINE void blend_color_softlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_hue_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_lighten_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_exclusion_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearlight_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_softlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
MINLINE void mul_v4_v4fl(float r[3], const float a[4], float f)
MINLINE void copy_v4_v4(float r[4], const float a[4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
unsigned int uint
Definition: BLI_sys_types.h:83
#define SWAP(type, a, b)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display)
void IMB_processor_apply_threaded_scanlines(int total_scanlines, ScanlineThreadFunc do_thread, void *custom_data)
Definition: imageprocess.c:424
IMB_BlendMode
Definition: IMB_imbuf.h:197
@ IMB_BLEND_EXCLUSION
Definition: IMB_imbuf.h:217
@ IMB_BLEND_DIFFERENCE
Definition: IMB_imbuf.h:216
@ IMB_BLEND_HARDLIGHT
Definition: IMB_imbuf.h:207
@ IMB_BLEND_COLORBURN
Definition: IMB_imbuf.h:208
@ IMB_BLEND_COLORDODGE
Definition: IMB_imbuf.h:210
@ IMB_BLEND_ERASE_ALPHA
Definition: IMB_imbuf.h:204
@ IMB_BLEND_SCREEN
Definition: IMB_imbuf.h:211
@ IMB_BLEND_HUE
Definition: IMB_imbuf.h:218
@ IMB_BLEND_MUL
Definition: IMB_imbuf.h:201
@ IMB_BLEND_ADD_ALPHA
Definition: IMB_imbuf.h:205
@ IMB_BLEND_DARKEN
Definition: IMB_imbuf.h:203
@ IMB_BLEND_OVERLAY
Definition: IMB_imbuf.h:206
@ IMB_BLEND_SATURATION
Definition: IMB_imbuf.h:219
@ IMB_BLEND_VIVIDLIGHT
Definition: IMB_imbuf.h:214
@ IMB_BLEND_LUMINOSITY
Definition: IMB_imbuf.h:220
@ IMB_BLEND_LIGHTEN
Definition: IMB_imbuf.h:202
@ IMB_BLEND_SOFTLIGHT
Definition: IMB_imbuf.h:212
@ IMB_BLEND_COPY_RGB
Definition: IMB_imbuf.h:225
@ IMB_BLEND_COLOR
Definition: IMB_imbuf.h:221
@ IMB_BLEND_LINEARLIGHT
Definition: IMB_imbuf.h:215
@ IMB_BLEND_COPY_ALPHA
Definition: IMB_imbuf.h:226
@ IMB_BLEND_PINLIGHT
Definition: IMB_imbuf.h:213
@ IMB_BLEND_MIX
Definition: IMB_imbuf.h:198
@ IMB_BLEND_COPY
Definition: IMB_imbuf.h:224
@ IMB_BLEND_INTERPOLATE
Definition: IMB_imbuf.h:222
@ IMB_BLEND_ADD
Definition: IMB_imbuf.h:199
@ IMB_BLEND_SUB
Definition: IMB_imbuf.h:200
@ IMB_BLEND_LINEARBURN
Definition: IMB_imbuf.h:209
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
Group RGB to Bright Vector Camera CLAMP
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
uint col
BLI_INLINE float fb(float length, float L)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
static unsigned a[3]
Definition: RandGen.cpp:92
static void rect_realloc_16bytes(void **buf_p, const uint size[2])
Definition: rectop.c:296
void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
Definition: rectop.c:1313
static void rect_crop_4bytes(void **buf_p, const int size_src[2], const rcti *crop)
Definition: rectop.c:220
static void rectblend_thread_do(void *data_v, int start_scanline, int num_scanlines)
Definition: rectop.c:991
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.c:1013
static void rect_crop_16bytes(void **buf_p, const int size_src[2], const rcti *crop)
Definition: rectop.c:237
void IMB_rectfill_area_replace(const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
Definition: rectop.c:1118
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], struct ColorManagedDisplay *display, int x1, int y1, int x2, int y2)
Definition: rectop.c:1164
void IMB_blend_color_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
Definition: rectop.c:41
struct RectBlendThreadData RectBlendThreadData
void IMB_rect_crop(ImBuf *ibuf, const rcti *crop)
Definition: rectop.c:257
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
Definition: rectop.c:328
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.c:390
void IMB_rectblend(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.c:518
void(* IMB_blend_func_float)(float *dst, const float *src1, const float *src2)
Definition: rectop.c:516
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
Definition: rectop.c:129
void IMB_rectfill(ImBuf *drect, const float col[4])
Definition: rectop.c:1077
void(* IMB_blend_func)(unsigned char *dst, const unsigned char *src1, const unsigned char *src2)
Definition: rectop.c:513
void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
Definition: rectop.c:308
static void rect_realloc_4bytes(void **buf_p, const uint size[2])
Definition: rectop.c:287
void IMB_rectcpy(ImBuf *dbuf, const ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height)
Definition: rectop.c:485
void IMB_rectfill_area(ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display)
Definition: rectop.c:1290
float * zbuf_float
int channels
unsigned int * rect
float * rect_float
int * zbuf
const ImBuf * sbuf
Definition: rectop.c:981
const unsigned short * texmask
Definition: rectop.c:983
IMB_BlendMode mode
Definition: rectop.c:987
unsigned short * dmask
Definition: rectop.c:982
const unsigned short * curvemask
Definition: rectop.c:983
const ImBuf * obuf
Definition: rectop.c:981
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)