143 BrushPainter *painter = MEM_cnew<BrushPainter>(__func__);
145 painter->
brush = brush;
147 painter->
paint = paint;
169 cache->
ibuf =
nullptr;
203 texco[0] = mapping->xmin + x * mapping->xmax;
204 texco[1] = mapping->ymin + y * mapping->ymax;
223 for (y = 0; y <
size; y++) {
224 for (x = 0; x <
size; x++, m++) {
228 *m =
ushort(65535.0f * res);
238 const ushort *tex_mask_old,
254 bool use_texture_old = (tex_mask_old !=
nullptr);
262 for (y = origy; y < h; y++) {
263 for (x = origx; x <
w; x++) {
268 ushort *
b = tex_mask + (y * diameter +
x);
269 ushort *t = tex_mask_cur + (y * diameter +
x);
271 if (!use_texture_old) {
277 if (use_texture_old) {
278 res = *(tex_mask_old + ((y - origy + yt) * cache->
tex_mask_old_w + (x - origx + xt)));
301 int destx, desty, srcx, srcy,
w, h, x1, y1, x2, y2;
317 maskibuf.
x = diameter;
318 maskibuf.
y = diameter;
329 IMB_rectclip(&maskibuf, &maskibuf_old, &destx, &desty, &srcx, &srcy, &
w, &h);
337 x1 =
min_ii(destx, diameter);
338 y1 =
min_ii(desty, diameter);
339 x2 =
min_ii(destx +
w, diameter);
340 y2 =
min_ii(desty + h, diameter);
343 if ((x1 < x2) && (y1 < y2)) {
345 painter,
tile, tex_mask_old, x1, y1, x2, y2, srcx, srcy, diameter);
353 if ((0 < x1) && (0 < diameter)) {
356 if ((x2 < diameter) && (0 < diameter)) {
358 painter,
tile,
nullptr, x2, 0, diameter, diameter, 0, 0, diameter);
360 if ((x1 < x2) && (0 < y1)) {
363 if ((x1 < x2) && (y2 < diameter)) {
381 const char *display_device = scene->display_settings.display_device;
402 use_color_correction,
416 for (y = 0; y <
size; y++) {
417 for (x = 0; x <
size; x++) {
419 float texco[3], rgba[4];
472 const char *display_device = scene->display_settings.display_device;
481 bool use_texture_old = (oldtexibuf !=
nullptr);
492 scene, paint, brush, use_color_correction, cache->
invert, 0.0f, 1.0f, display, brush_rgb);
501 for (y = origy; y < h; y++) {
502 for (x = origx; x <
w; x++) {
504 float texco[3], rgba[4];
506 if (!use_texture_old) {
528 if (use_texture_old) {
530 ((y - origy + yt) * oldtexibuf->
x + (x - origx + xt)) * 4;
549 if (use_texture_old) {
551 ((y - origy + yt) * oldtexibuf->
x + (x - origx + xt)) * 4;
586 ImBuf *oldtexibuf, *ibuf;
587 int imbflag, destx, desty, srcx, srcy,
w, h, x1, y1, x2, y2;
618 y2 =
min_ii(desty + h, ibuf->
y);
621 if ((x1 < x2) && (y1 < y2)) {
630 if ((0 < x1) && (0 < ibuf->
y)) {
633 if ((x2 < ibuf->x) && (0 < ibuf->
y)) {
636 if ((x1 < x2) && (0 < y1)) {
639 if ((x1 < x2) && (y2 < ibuf->y)) {
648 const float mouse[2],
657 start[0] =
pos[0] - diameter / 2.0f;
658 start[1] =
pos[1] - diameter / 2.0f;
662 float xmin, ymin, xmax, ymax;
665 s->v2d, (start[0] + diameter) * invw, (start[1] + diameter) * invh, &xmax, &ymax);
668 r_mapping->
xmax = (xmax - xmin) /
float(diameter);
669 r_mapping->
ymax = (ymax - ymin) /
float(diameter);
670 r_mapping->
xmin = xmin + (
tile->uv_origin[0] *
tile->size[0] * r_mapping->
xmax);
671 r_mapping->
ymin = ymin + (
tile->uv_origin[1] *
tile->size[1] * r_mapping->
ymax);
675 r_mapping->
xmin = 2.0f * (start[0] * invw - 0.5f);
676 r_mapping->
ymin = 2.0f * (start[1] * invh - 0.5f);
677 r_mapping->
xmax = 2.0f * invw;
678 r_mapping->
ymax = 2.0f * invh;
682 r_mapping->
xmin = mouse[0] - diameter * 0.5f + 0.5f;
683 r_mapping->
ymin = mouse[1] - diameter * 0.5f + 0.5f;
684 r_mapping->
xmax = 1.0f;
685 r_mapping->
ymax = 1.0f;
692 r_mapping->
xmax = 1.0f;
693 r_mapping->
ymax = 1.0f;
701 const float mouse[2],
711 const int diameter = std::max(1,
int(size * 2)) + 4;
713 bool do_random =
false;
714 bool do_partial_update =
false;
719 float tex_rotation = -brush->
mtex.
rot;
733 do_partial_update =
true;
741 bool renew_maxmask =
false;
742 bool do_partial_update_mask =
false;
748 renew_maxmask =
true;
751 do_partial_update_mask =
true;
752 renew_maxmask =
true;
756 do_partial_update_mask =
false;
757 renew_maxmask =
true;
768 if (do_partial_update_mask) {
787 cache->
ibuf =
nullptr;
790 if (do_partial_update) {
803 else if (do_partial_update) {
808 if ((dx != 0) || (dy != 0)) {
814 painter->
pool =
nullptr;
822 if (i >= s->num_tiles) {
833 s->tiles[i].cache.lastdiameter = -1;
836 if (ibuf !=
nullptr) {
840 else if ((s->tiles[0].canvas->byte_buffer.data && !ibuf->
byte_buffer.
data) ||
846 s->tiles[i].size[0] = ibuf->
x;
847 s->tiles[i].size[1] = ibuf->
y;
848 s->tiles[i].radius_fac =
sqrtf((
float(ibuf->
x) *
float(ibuf->
y)) /
849 (s->tiles[0].size[0] * s->tiles[0].size[1]));
862 s->tiles[i].canvas = ibuf;
879 ImBuf *ibuf,
int x,
int y,
const bool is_torus,
const float rgb[4])
894 float map_alpha = (rgb[3] == 0.0f) ? rrgbf[3] : rrgbf[3] / rgb[3];
904 rrgb[0] = straight[0];
905 rrgb[1] = straight[1];
906 rrgb[2] = straight[2];
907 rrgb[3] = straight[3];
928 ImBuf *ibuf,
int x,
int y,
float *outrgb,
short paint_tile,
float w)
955 const short paint_tile)
957 bool sharpen = (
tile->cache.invert ^ ((s->brush->flag &
BRUSH_DIR_IN) != 0));
958 float threshold = s->brush->sharp_threshold;
959 int x,
y, xi, yi, xo, yo, xk, yk;
961 int out_off[2], in_off[2], dim[2];
971 out_off[0] = out_off[1] = 0;
974 IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], &out_off[1], &dim[0], &dim[1]);
976 if ((dim[0] == 0) || (dim[1] == 0)) {
984 for (y = 0; y < dim[1]; y++) {
985 for (x = 0; x < dim[0]; x++) {
993 if (xi < ibuf->x && xi >= 0 && yi < ibuf->y && yi >= 0) {
1006 for (yk = 0; yk < kernel->
side; yk++) {
1007 for (xk = 0; xk < kernel->
side; xk++) {
1027 if (
fabsf(outrgb[0]) > threshold) {
1029 float alpha = rgba[3];
1030 rgba[3] = outrgb[3] =
mask;
1045 xo = out_off[0] +
x;
1046 yo = out_off[1] +
y;
1053 ImagePaintRegion *region,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height)
1055 region->destx = destx;
1056 region->desty = desty;
1057 region->srcx = srcx;
1058 region->srcy = srcy;
1059 region->width = width;
1060 region->height = height;
1068 int destx = region->destx;
1069 int desty = region->desty;
1070 int srcx = region->srcx;
1071 int srcy = region->srcy;
1072 int width = region->width;
1073 int height = region->height;
1074 int origw, origh,
w, h, tot = 0;
1078 destx = destx % dbuf->
x;
1082 srcx = srcx % sbuf->
x;
1088 desty = desty % dbuf->
y;
1092 srcy = srcy % sbuf->
y;
1099 origw =
w = (width > dbuf->
x) ? dbuf->
x : width;
1100 origh = h = (height > dbuf->
y) ? dbuf->
y : height;
1103 IMB_rectclip(dbuf, sbuf, &destx, &desty, &srcx, &srcy, &
w, &h);
1109 ®ion[tot++], (destx +
w) % dbuf->
x, desty, (srcx +
w) % sbuf->
x, srcy, origw -
w, h);
1113 ®ion[tot++], destx, (desty + h) % dbuf->
y, srcx, (srcy + h) % sbuf->
y,
w, origh - h);
1117 (destx +
w) % dbuf->
x,
1118 (desty + h) % dbuf->
y,
1119 (srcx +
w) % sbuf->
x,
1120 (srcy + h) % sbuf->
y,
1136 for (a = 0; a < tot; a++) {
1161 int w = ibufb->
x, h = ibufb->
y, destx = 0, desty = 0, srcx =
pos[0], srcy =
pos[1];
1164 IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &
w, &h);
1225 for (
int ty = tiley; ty <= tileh; ty++) {
1226 for (
int tx = tilex; tx <= tilew; tx++) {
1232 if (
tile->canvas->float_buffer.data) {
1236 undo_tiles, s->image,
tile->canvas, &
tile->iuser, tx, ty, &mask,
false)),
1243 undo_tiles, s->image,
tile->canvas, &
tile->iuser, tx, ty, &mask,
false)),
1251 tile->cache.curve_mask_cache.curve_mask,
1252 tile->cache.tex_mask,
1298 const float lastpos[2],
1302 ImBuf *clonebuf =
nullptr, *frombuf;
1307 short blend = s->blend;
1308 const float *offset = s->brush->clone.offset;
1311 int bpos[2], blastpos[2], bliftpos[2];
1322 if (lastpos[0] ==
pos[0] && lastpos[1] ==
pos[1]) {
1331 liftpos[0] =
pos[0] - offset[0] * canvas->
x;
1332 liftpos[1] =
pos[1] - offset[1] * canvas->
y;
1338 frombuf = (clonebuf) ? clonebuf : ibufb;
1350 for (a = 0; a < tot; a++) {
1360 if (s->do_masking) {
1362 int tilex, tiley, tilew, tileh;
1374 if (tiley == tileh) {
1376 s,
tile, ®ion[a], frombuf, mask_max,
blend, tilex, tiley, tilew, tileh);
1382 data.region = ®ion[a];
1383 data.frombuf = frombuf;
1384 data.mask_max = mask_max;
1400 tile->cache.curve_mask_cache.curve_mask,
1401 tile->cache.tex_mask,
1427 Image *ima = s->brush->clone.image;
1435 s->clonecanvas = ibuf;
1438 if (s->tiles[0].canvas->float_buffer.data && !s->clonecanvas->float_buffer.data) {
1441 else if (!s->tiles[0].canvas->float_buffer.data && !s->clonecanvas->byte_buffer.data) {
1454 for (
int i = 0; i < s->num_tiles; i++) {
1459 if (s->blurkernel) {
1461 MEM_delete(s->blurkernel);
1472 return (
pos[0] >= -brush[0]) && (
pos[0] < size[0] + brush[0]) && (
pos[1] >= -brush[1]) &&
1473 (
pos[1] < size[1] + brush[1]);
1478 coord[0] = (uv[0] -
tile->uv_origin[0]) *
tile->size[0];
1479 coord[1] = (uv[1] -
tile->uv_origin[1]) *
tile->size[1];
1483 const float prev_mval[2],
1484 const float mval[2],
1490 float new_uv[2], old_uv[2];
1504 float last_uv[2], start_uv[2];
1514 const float uv_brush_size[2] = {
1518 for (
int i = 0; i < s->num_tiles; i++) {
1522 const int uv_size[2] = {1, 1};
1523 float local_new_uv[2], local_old_uv[2];
1537 float size = base_size *
tile->radius_fac;
1539 float new_coord[2], old_coord[2];
1570 tile->need_redraw =
true;
1593 s->blend = brush->
blend;
1595 s->image = s->sima->image;
1596 s->symmetry = settings->imapaint.paint.symmetry_flags;
1598 if (s->image ==
nullptr) {
1609 s->tiles = MEM_cnew_array<ImagePaintTile>(s->num_tiles, __func__);
1610 for (
int i = 0; i < s->num_tiles; i++) {
1611 s->tiles[i].iuser = sima->
iuser;
1614 zero_v2(s->tiles[0].uv_origin);
1617 if (ibuf ==
nullptr) {
1631 s->tiles[0].size[0] = ibuf->
x;
1632 s->tiles[0].size[1] = ibuf->
y;
1633 s->tiles[0].radius_fac = 1.0f;
1635 s->tiles[0].canvas = ibuf;
1644 s->tiles[tile_idx].iuser.tile =
tile->tile_number;
1645 s->tiles[tile_idx].uv_origin[0] = ((
tile->tile_number - 1001) % 10);
1646 s->tiles[tile_idx].uv_origin[1] = ((
tile->tile_number - 1001) / 10);
1672 bool had_redraw =
false;
1673 for (
int i = 0; i < s->num_tiles; i++) {
1674 if (s->tiles[i].need_redraw) {
1681 s->tiles[i].need_redraw =
false;
1688 if (s->sima ==
nullptr || !s->sima->lock) {
1697 if (s->image && !(s->sima && s->sima->lock)) {
1712 for (
int i = 0; i < s->num_tiles; i++) {
1727 const float color[4],
1732 if (x_px >= ibuf->
x || x_px < 0 || y_px >= ibuf->
y || y_px < 0) {
1736 coordinate = size_t(y_px) * ibuf->
x + x_px;
1756 const float color[4],
1761 if (x_px >= ibuf->
x || x_px < 0 || y_px >= ibuf->
y || y_px < 0) {
1765 coordinate = size_t(y_px) * ibuf->
x + x_px;
1778 for (
int i = 0; i < s->num_tiles; i++) {
1779 if (s->tiles[i].iuser.tile == tile_number) {
1783 iuser = &s->tiles[i].iuser;
1792 const float color[3],
1794 const float mouse_init[2],
1795 const float mouse_final[2],
1825 if (iuser ==
nullptr) {
1830 iuser = &local_iuser;
1832 iuser->
tile = tile_number;
1846 *(((
char *)&color_b) + 3) = strength * 255;
1850 color_f[3] = strength;
1853 if (!mouse_final || !br) {
1858 for (x_px = 0; x_px < ibuf->
x; x_px++) {
1859 for (y_px = 0; y_px < ibuf->
y; y_px++) {
1867 for (x_px = 0; x_px < ibuf->
x; x_px++) {
1868 for (y_px = 0; y_px < ibuf->
y; y_px++) {
1882 int width = ibuf->
x;
1883 int minx = ibuf->
x, miny = ibuf->
y, maxx = 0, maxy = 0;
1884 float pixel_color[4];
1892 if (x_px >= ibuf->
x || x_px < 0 || y_px > ibuf->
y || y_px < 0) {
1903 coordinate = (size_t(y_px) * ibuf->
x + x_px);
1927 x_px = coordinate % width;
1928 y_px = coordinate / width;
1931 x_px - 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1933 x_px - 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
1935 x_px - 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
1937 x_px, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
1939 x_px, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1941 x_px + 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1943 x_px + 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
1945 x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
1971 x_px = coordinate % width;
1972 y_px = coordinate / width;
1975 x_px - 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1977 x_px - 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
1979 x_px - 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
1981 x_px, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
1983 x_px, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1985 x_px + 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
1987 x_px + 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
1989 x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2019 const bContext *C,
Brush *br,
const float mouse_init[2],
const float mouse_final[2],
void *ps)
2031 float line_len_sq_inv, line_len;
2036 if (ima ==
nullptr) {
2048 if (ibuf ==
nullptr) {
2057 image_final[0] *= ibuf->
x;
2058 image_final[1] *= ibuf->
y;
2066 line_len_sq_inv = 1.0f / line_len;
2067 line_len =
sqrtf(line_len);
2075 for (x_px = 0; x_px < ibuf->
x; x_px++) {
2076 for (y_px = 0; y_px < ibuf->
y; y_px++) {
2082 f =
dot_v2v2(p, tangent) * line_len_sq_inv;
2087 f =
len_v2(p) / line_len;
2094 color_f[3] *= brush_alpha;
2103 for (x_px = 0; x_px < ibuf->
x; x_px++) {
2104 for (y_px = 0; y_px < ibuf->
y; y_px++) {
2110 f =
dot_v2v2(p, tangent) * line_len_sq_inv;
2115 f =
len_v2(p) / line_len;
2123 ((
uchar *)&color_b)[3] *= brush_alpha;
float BKE_brush_sample_tex_3d(const Scene *scene, const Brush *br, const MTex *mtex, const float point[3], float rgba[4], int thread, ImagePool *pool)
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
float BKE_brush_sample_masktex(const Scene *scene, Brush *br, const float point[2], int thread, ImagePool *pool)
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
SpaceImage * CTX_wm_space_image(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
void BKE_image_pool_free(ImagePool *pool)
void BKE_imageuser_default(ImageUser *iuser)
void BKE_image_free_gputextures(Image *ima)
bool BKE_image_has_packedfile(const Image *image)
ImagePool * BKE_image_pool_new(void)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void straight_to_premul_v4(float color[4])
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void sub_v2_v2v2_int(int r[2], const int a[2], const int b[2])
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
MINLINE float len_squared_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v2(float r[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
void BLI_stack_pop(BLI_Stack *stack, void *dst) ATTR_NONNULL()
void BLI_stack_push(BLI_Stack *stack, const void *src) ATTR_NONNULL()
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_stack_free(BLI_Stack *stack) ATTR_NONNULL()
#define BLI_stack_new(esize, descr)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
@ IMAGE_PAINT_BRUSH_TYPE_SOFTEN
@ IMAGE_PAINT_BRUSH_TYPE_SMEAR
@ BRUSH_GRADIENT_SPACING_CLAMP
@ BRUSH_GRADIENT_SPACING_REPEAT
Object is a sort of wrapper for general info.
void * ED_image_paint_tile_find(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool validate)
void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h, bool find_old)
#define ED_IMAGE_UNDO_TILE_SIZE
PaintTileMap * ED_image_paint_tile_map_get()
void ED_imapaint_clear_partial_redraw()
void ED_region_tag_redraw(ARegion *region)
ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
void IMB_rect_from_float(ImBuf *ibuf)
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)
void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
void IMB_blend_color_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
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)
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
bool IMB_initImBuf(ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership)
void IMB_float_from_rect(ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
@ IMB_COLORMANAGE_IS_DATA
@ IB_DO_NOT_TAKE_OWNERSHIP
Read Guarded memory(de)allocation.
void UI_view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
struct ImBuf * IMB_allocImBuf(unsigned int, unsigned int, unsigned char, unsigned int)
void IMB_freeImBuf(ImBuf *)
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_global const KernelWorkTile * tile
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
#define unit_float_to_uchar_clamp(val)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
void paint_delete_blur_kernel(BlurKernel *kernel)
void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint)
void paint_brush_init_tex(Brush *brush)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
bool paint_use_opacity_masking(Brush *brush)
void paint_brush_color_get(Scene *scene, const Paint *paint, Brush *br, bool color_correction, bool invert, float distance, float pressure, ColorManagedDisplay *display, float r_color[3])
void paint_brush_exit_tex(Brush *brush)
void imapaint_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
static ushort * brush_painter_mask_ibuf_new(BrushPainter *painter, const int size)
static int paint_2d_torus_split_region(ImagePaintRegion region[4], ImBuf *dbuf, ImBuf *sbuf, short paint_tile)
static void brush_painter_mask_imbuf_update(BrushPainter *painter, ImagePaintTile *tile, const ushort *tex_mask_old, int origx, int origy, int w, int h, int xt, int yt, const int diameter)
static void paint_2d_fill_add_pixel_float(const int x_px, const int y_px, ImBuf *ibuf, BLI_Stack *stack, BLI_bitmap *touched, const float color[4], float threshold_sq)
static float paint_2d_ibuf_add_if(ImBuf *ibuf, int x, int y, float *outrgb, short paint_tile, float w)
static void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[2])
@ PAINT2D_TILE_UNINITIALIZED
static void paint_2d_canvas_free(ImagePaintState *s)
static ImBuf * paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos)
static void brush_painter_cache_2d_free(BrushPainterCache *cache)
static int paint_2d_op(void *state, ImagePaintTile *tile, const float lastpos[2], const float pos[2])
static void paint_2d_lift_soften(ImagePaintState *s, ImagePaintTile *tile, ImBuf *ibuf, ImBuf *ibufb, const int *pos, const short paint_tile)
static void paint_2d_do_making_brush(ImagePaintState *s, ImagePaintTile *tile, ImagePaintRegion *region, ImBuf *frombuf, float mask_max, short blend, int tilex, int tiley, int tilew, int tileh)
void * paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
void paint_2d_bucket_fill(const bContext *C, const float color[3], Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
void paint_2d_gradient_fill(const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
static void brush_painter_imbuf_partial_update(BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
void paint_2d_stroke_done(void *ps)
static void paint_2d_op_foreach_do(void *__restrict data_v, const int iter, const TaskParallelTLS *__restrict)
static void paint_2d_ibuf_rgb_set(ImBuf *ibuf, int x, int y, const bool is_torus, const float rgb[4])
static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
static void paint_2d_transform_mouse(View2D *v2d, const float in[2], float out[2])
static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short paint_tile)
static ImBuf * brush_painter_imbuf_new(BrushPainter *painter, ImagePaintTile *tile, const int size, float pressure, float distance)
void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], const bool eraser, float pressure, float distance, float base_size)
static void paint_2d_uv_to_coord(ImagePaintTile *tile, const float uv[2], float coord[2])
static void paint_2d_ibuf_rgb_get(ImBuf *ibuf, int x, int y, float r_rgb[4])
static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
static void brush_painter_2d_require_imbuf(Brush *brush, ImagePaintTile *tile, bool use_float, bool use_color_correction, bool invert)
static void paint_2d_set_region(ImagePaintRegion *region, int destx, int desty, int srcx, int srcy, int width, int height)
static ImageUser * paint_2d_get_tile_iuser(ImagePaintState *s, int tile_number)
static int paint_2d_canvas_set(ImagePaintState *s)
static void brush_imbuf_tex_co(const rctf *mapping, int x, int y, float texco[3])
static void paint_2d_ibuf_tile_convert(ImBuf *ibuf, int *x, int *y, short paint_tile)
static BrushPainter * brush_painter_2d_new(Scene *scene, const Paint *paint, Brush *brush, bool invert)
static void brush_painter_2d_tex_mapping(ImagePaintState *s, ImagePaintTile *tile, const int diameter, const float pos[2], const float mouse[2], int mapmode, rctf *r_mapping)
void paint_2d_redraw(const bContext *C, void *ps, bool final)
static bool is_inside_tile(const int size[2], const float pos[2], const float brush[2])
static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const float mouse[2], float pressure, float distance, float size)
static void brush_painter_imbuf_update(BrushPainter *painter, ImagePaintTile *tile, ImBuf *oldtexibuf, int origx, int origy, int w, int h, int xt, int yt)
static void paint_2d_fill_add_pixel_byte(const int x_px, const int y_px, ImBuf *ibuf, BLI_Stack *stack, BLI_bitmap *touched, const float color[4], float threshold_sq)
void paint_curve_mask_cache_free_data(CurveMaskCache *curve_mask_cache)
void paint_curve_mask_cache_update(CurveMaskCache *curve_mask_cache, const Brush *brush, const int diameter, const float radius, const float cursor_position[2])
static void image_init(Image *ima, short source, short type)
CurveMaskCache curve_mask_cache
bool use_color_correction
struct ColorBand * gradient
char gradient_stroke_mode
Caching structure for curve mask.
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
ImagePaintTileState state
ImagePaintRegion * region
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)