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