155 BrushPainter *painter = MEM_new<BrushPainter>(__func__);
158 painter->
scene = scene;
189 cache->
ibuf =
nullptr;
225 texco[0] = mapping->
xmin +
x * mapping->
xmax;
226 texco[1] = mapping->
ymin +
y * mapping->
ymax;
244 for (
y = 0;
y < size;
y++) {
245 for (
x = 0;
x < size;
x++, m++) {
249 *m =
ushort(65535.0f * res);
259 const ushort *tex_mask_old,
274 bool use_texture_old = (tex_mask_old !=
nullptr);
282 for (
y = origy;
y < h;
y++) {
283 for (
x = origx;
x <
w;
x++) {
288 ushort *
b = tex_mask + (
y * diameter +
x);
289 ushort *t = tex_mask_cur + (
y * diameter +
x);
291 if (!use_texture_old) {
298 if (use_texture_old) {
299 res = *(tex_mask_old + ((
y - origy + yt) * cache->
tex_mask_old_w + (
x - origx + xt)));
322 int destx, desty, srcx, srcy,
w, h, x1, y1, x2, y2;
336 maskibuf.
x = diameter;
337 maskibuf.
y = diameter;
344 destx = int(
floorf(
tile->last_paintpos[0])) - int(
floorf(pos[0])) + (diameter / 2 -
w / 2);
345 desty = int(
floorf(
tile->last_paintpos[1])) - int(
floorf(pos[1])) + (diameter / 2 - h / 2);
348 IMB_rectclip(&maskibuf, &maskibuf_old, &destx, &desty, &srcx, &srcy, &
w, &h);
356 x1 =
min_ii(destx, diameter);
357 y1 =
min_ii(desty, diameter);
358 x2 =
min_ii(destx +
w, diameter);
359 y2 =
min_ii(desty + h, diameter);
362 if ((x1 < x2) && (y1 < y2)) {
364 painter,
tile, tex_mask_old, x1, y1, x2, y2, srcx, srcy, diameter);
368 MEM_delete(tex_mask_old);
372 if ((0 < x1) && (0 < diameter)) {
375 if ((x2 < diameter) && (0 < diameter)) {
377 painter,
tile,
nullptr, x2, 0, diameter, diameter, 0, 0, diameter);
379 if ((x1 < x2) && (0 < y1)) {
382 if ((x1 < x2) && (y2 < diameter)) {
402 const bool is_float = cache->
is_float;
433 for (
y = 0;
y < size;
y++) {
434 for (
x = 0;
x < size;
x++) {
459 float *dstf = float_data + (
y * size +
x) * 4;
465 uchar *dst = byte_data + (
y * size +
x) * 4;
495 const bool is_float = cache->
is_float;
497 const bool use_texture_old = (oldtexibuf !=
nullptr);
528 const uchar *oldtexibuf_byte_data = (oldtexibuf) ? oldtexibuf->
byte_data() :
nullptr;
529 const float *oldtexibuf_float_data = (oldtexibuf) ? oldtexibuf->
float_data() :
nullptr;
530 for (
y = origy;
y < h;
y++) {
531 for (
x = origx;
x <
w;
x++) {
536 if (!use_texture_old) {
557 float *bf = ibuf_float_data + (
y * ibuf->
x +
x) * 4;
558 float *tf = texibuf_float_data + (
y * texibuf->
x +
x) * 4;
561 if (use_texture_old) {
562 const float *otf = oldtexibuf_float_data +
563 ((
y - origy + yt) * oldtexibuf->
x + (
x - origx + xt)) * 4;
578 uchar *
b = ibuf_byte_data + (
y * ibuf->
x +
x) * 4;
579 uchar *t = texibuf_byte_data + (
y * texibuf->
x +
x) * 4;
582 if (use_texture_old) {
583 const uchar *ot = oldtexibuf_byte_data +
584 ((
y - origy + yt) * oldtexibuf->
x + (
x - origx + xt)) * 4;
619 ImBuf *oldtexibuf, *ibuf;
620 int destx, desty, srcx, srcy,
w, h, x1, y1, x2, y2;
637 destx = int(
floorf(
tile->last_paintpos[0])) - int(
floorf(pos[0])) + (diameter / 2 -
w / 2);
638 desty = int(
floorf(
tile->last_paintpos[1])) - int(
floorf(pos[1])) + (diameter / 2 - h / 2);
651 y2 =
min_ii(desty + h, ibuf->
y);
654 if ((x1 < x2) && (y1 < y2)) {
663 if ((0 < x1) && (0 < ibuf->
y)) {
666 if ((x2 < ibuf->
x) && (0 < ibuf->
y)) {
669 if ((x1 < x2) && (0 < y1)) {
672 if ((x1 < x2) && (y2 < ibuf->
y)) {
681 const float mouse[2],
685 float invw = 1.0f /
float(
tile->canvas->x);
686 float invh = 1.0f /
float(
tile->canvas->y);
690 start[0] = pos[0] - diameter / 2.0f;
691 start[1] = pos[1] - diameter / 2.0f;
695 float xmin, ymin, xmax, ymax;
698 s->
v2d, (start[0] + diameter) * invw, (start[1] + diameter) * invh, &xmax, &ymax);
701 r_mapping->
xmax = (xmax - xmin) /
float(diameter);
702 r_mapping->
ymax = (ymax - ymin) /
float(diameter);
703 r_mapping->
xmin = xmin + (
tile->uv_origin[0] *
tile->size[0] * r_mapping->
xmax);
704 r_mapping->
ymin = ymin + (
tile->uv_origin[1] *
tile->size[1] * r_mapping->
ymax);
708 r_mapping->
xmin = 2.0f * (start[0] * invw - 0.5f);
709 r_mapping->
ymin = 2.0f * (start[1] * invh - 0.5f);
710 r_mapping->
xmax = 2.0f * invw;
711 r_mapping->
ymax = 2.0f * invh;
715 r_mapping->
xmin = mouse[0] - diameter * 0.5f + 0.5f;
716 r_mapping->
ymin = mouse[1] - diameter * 0.5f + 0.5f;
717 r_mapping->
xmax = 1.0f;
718 r_mapping->
ymax = 1.0f;
721 r_mapping->
xmin = int(-diameter * 0.5) + int(
floorf(pos[0])) -
723 r_mapping->
ymin = int(-diameter * 0.5) + int(
floorf(pos[1])) -
725 r_mapping->
xmax = 1.0f;
726 r_mapping->
ymax = 1.0f;
734 const float mouse[2],
743 const int diameter = std::max(1,
int(size * 2)) + 4;
745 bool do_random =
false;
746 bool do_partial_update =
false;
753 float tex_rotation = -
brush->mtex.rot;
754 float mask_rotation = -
brush->mask_mtex.rot;
767 do_partial_update =
true;
775 bool renew_maxmask =
false;
776 bool do_partial_update_mask =
false;
782 renew_maxmask =
true;
785 do_partial_update_mask =
true;
786 renew_maxmask =
true;
789 if (
brush->mask_pressure) {
790 do_partial_update_mask =
false;
791 renew_maxmask =
true;
802 if (do_partial_update_mask) {
821 cache->
ibuf =
nullptr;
824 if (do_partial_update) {
837 else if (do_partial_update) {
842 if ((dx != 0) || (dy != 0)) {
848 painter->
pool =
nullptr;
870 if (ibuf !=
nullptr) {
904 const float *rrgbf = ibuf->
float_data() + (ibuf->
x *
y +
x) * 4;
913 ImBuf *ibuf,
int x,
int y,
const bool is_torus,
const float rgb[4])
927 float *rrgbf = float_data + (ibuf->
x *
y +
x) * 4;
928 float map_alpha = (rgb[3] == 0.0f) ? rrgbf[3] : rrgbf[3] / rgb[3];
938 rrgb[0] = straight[0];
939 rrgb[1] = straight[1];
940 rrgb[2] = straight[2];
941 rrgb[3] = straight[3];
962 ImBuf *ibuf,
int x,
int y,
float *outrgb,
short paint_tile,
float w)
989 const short paint_tile)
993 int x,
y, xi, yi, xo, yo, xk, yk;
995 int out_off[2], in_off[2], dim[2];
1005 out_off[0] = out_off[1] = 0;
1008 IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], &out_off[1], &dim[0], &dim[1]);
1010 if ((dim[0] == 0) || (dim[1] == 0)) {
1018 for (
y = 0;
y < dim[1];
y++) {
1019 for (
x = 0;
x < dim[0];
x++) {
1027 if (xi < ibuf->
x && xi >= 0 && yi < ibuf->
y && yi >= 0) {
1040 for (yk = 0; yk < kernel->
side; yk++) {
1041 for (xk = 0; xk < kernel->
side; xk++) {
1061 if (
fabsf(outrgb[0]) > threshold) {
1063 float alpha = rgba[3];
1064 rgba[3] = outrgb[3] =
mask;
1079 xo = out_off[0] +
x;
1080 yo = out_off[1] +
y;
1087 ImagePaintRegion *region,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height)
1089 region->
destx = destx;
1090 region->
desty = desty;
1091 region->
srcx = srcx;
1092 region->
srcy = srcy;
1093 region->
width = width;
1102 int destx = region->
destx;
1103 int desty = region->
desty;
1104 int srcx = region->
srcx;
1105 int srcy = region->
srcy;
1106 int width = region->
width;
1107 int height = region->
height;
1108 int origw, origh,
w, h, tot = 0;
1112 destx = destx % dbuf->
x;
1116 srcx = srcx % sbuf->
x;
1122 desty = desty % dbuf->
y;
1126 srcy = srcy % sbuf->
y;
1133 origw =
w = (width > dbuf->
x) ? dbuf->
x : width;
1134 origh = h = (height > dbuf->
y) ? dbuf->
y : height;
1137 IMB_rectclip(dbuf, sbuf, &destx, &desty, &srcx, &srcy, &
w, &h);
1143 ®ion[tot++], (destx +
w) % dbuf->
x, desty, (srcx +
w) % sbuf->
x, srcy, origw -
w, h);
1147 ®ion[tot++], destx, (desty + h) % dbuf->
y, srcx, (srcy + h) % sbuf->
y,
w, origh - h);
1151 (destx +
w) % dbuf->
x,
1152 (desty + h) % dbuf->
y,
1153 (srcx +
w) % sbuf->
x,
1154 (srcy + h) % sbuf->
y,
1170 for (a = 0; a < tot; a++) {
1173 int2(region[a].srcx, region[a].srcy),
1174 int2(region[a].destx, region[a].desty),
1175 int2(region[a].width, region[a].height));
1183 int w = ibufb->
x, h = ibufb->
y, destx = 0, desty = 0, srcx = pos[0], srcy = pos[1];
1194 IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &
w, &h);
1201 clonebuf_float_data,
1220 clonebuf_float_data,
1243 ipos[0] = int(
floorf(pos[0] - ibufb->
x / 2));
1244 ipos[1] = int(
floorf(pos[1] - ibufb->
y / 2));
1251 float *canvas_float_data,
1265 for (
int ty = tiley; ty <= tileh; ty++) {
1266 for (
int tx = tilex; tx <= tilew; tx++) {
1274 if (
data ==
nullptr) {
1277 if (
tile->canvas->float_data()) {
1290 tile->cache.curve_mask_cache.curve_mask,
1291 tile->cache.tex_mask,
1328 data->canvas_byte_data,
1329 data->canvas_float_data,
1341 const float lastpos[2],
1346 ImBuf *clonebuf =
nullptr, *frombuf;
1351 short blend = s->
blend;
1352 const float *offset = image_paint_settings.
clone_offset;
1355 int bpos[2], blastpos[2], bliftpos[2];
1366 if (lastpos[0] == pos[0] && lastpos[1] == pos[1]) {
1375 liftpos[0] = pos[0] - offset[0] *
canvas->x;
1376 liftpos[1] = pos[1] - offset[1] *
canvas->y;
1382 frombuf = (clonebuf) ? clonebuf : ibufb;
1394 for (a = 0; a < tot; a++) {
1405 int tilex, tiley, tilew, tileh;
1419 float *canvas_float_data =
canvas->float_data_for_write();
1421 if (tiley == tileh) {
1439 data.region = ®ion[a];
1440 data.canvas_byte_data = canvas_byte_data;
1441 data.canvas_float_data = canvas_float_data;
1442 data.frombuf = frombuf;
1443 data.mask_max = mask_max;
1459 tile->cache.curve_mask_cache.curve_mask,
1460 tile->cache.tex_mask,
1514 for (
int i = 0; i < s->
num_tiles; i++) {
1533 return (pos[0] >= -
brush[0]) && (pos[0] < size[0] +
brush[0]) && (pos[1] >= -
brush[1]) &&
1534 (pos[1] < size[1] +
brush[1]);
1539 coord[0] = (uv[0] -
tile->uv_origin[0]) *
tile->size[0];
1540 coord[1] = (uv[1] -
tile->uv_origin[1]) *
tile->size[1];
1544 const float prev_mval[2],
1545 const float mval[2],
1551 float new_uv[2], old_uv[2];
1563 float last_uv[2], start_uv[2];
1573 const float uv_brush_size[2] = {
1577 for (
int i = 0; i < s->
num_tiles; i++) {
1581 const int uv_size[2] = {1, 1};
1582 float local_new_uv[2], local_old_uv[2];
1596 float size = base_size *
tile->radius_fac;
1598 float new_coord[2], old_coord[2];
1618 const bool is_float = (ibuf->
float_data() !=
nullptr);
1619 const ColorSpace *byte_colorspace = (is_float || is_data) ?
nullptr :
1621 const bool is_srgb = (is_float || is_data) ?
1639 tile->need_redraw =
true;
1668 if (s->
image ==
nullptr) {
1679 s->
tiles = MEM_new_array<ImagePaintTile>(s->
num_tiles, __func__);
1680 for (
int i = 0; i < s->
num_tiles; i++) {
1687 if (ibuf ==
nullptr) {
1688 MEM_delete(s->
tiles);
1696 MEM_delete(s->
tiles);
1718 MEM_delete(s->
tiles);
1740 bool had_redraw =
false;
1741 for (
int i = 0; i < s->
num_tiles; i++) {
1787 for (
int i = 0; i < s->
num_tiles; i++) {
1791 MEM_delete(s->
tiles);
1803 const float color[4],
1808 if (x_px >= ibuf->
x || x_px < 0 || y_px >= ibuf->
y || y_px < 0) {
1812 coordinate = size_t(y_px) * ibuf->
x + x_px;
1832 const float color[4],
1837 if (x_px >= ibuf->
x || x_px < 0 || y_px >= ibuf->
y || y_px < 0) {
1841 coordinate = size_t(y_px) * ibuf->
x + x_px;
1854 for (
int i = 0; i < s->
num_tiles; i++) {
1868 const float color[3],
1870 const float mouse_init[2],
1871 const float mouse_final[2],
1902 if (iuser ==
nullptr) {
1907 iuser = &local_iuser;
1909 iuser->
tile = tile_number;
1924 *((
reinterpret_cast<char *
>(&color_b)) + 3) = strength * 255;
1928 color_f[3] = strength;
1931 if (!mouse_final || !br) {
1937 for (x_px = 0; x_px < ibuf->
x; x_px++) {
1938 for (y_px = 0; y_px < ibuf->
y; y_px++) {
1940 float_data + 4 * (
size_t(y_px) * ibuf->
x + x_px),
1947 for (x_px = 0; x_px < ibuf->
x; x_px++) {
1948 for (y_px = 0; y_px < ibuf->
y; y_px++) {
1950 byte_data + 4 * (
size_t(y_px) * ibuf->
x + x_px),
1951 reinterpret_cast<uchar *
>(&color_b));
1962 int width = ibuf->
x;
1963 float pixel_color[4];
1971 if (x_px >= ibuf->
x || x_px < 0 || y_px > ibuf->
y || y_px < 0) {
1982 coordinate = (size_t(y_px) * ibuf->
x + x_px);
2006 x_px = coordinate % width;
2007 y_px = coordinate / width;
2010 x_px - 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2012 x_px - 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
2014 x_px - 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2016 x_px, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2018 x_px, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2020 x_px + 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2022 x_px + 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
2024 x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2033 reinterpret_cast<uchar *
>(&color_b),
2037 x_px = coordinate % width;
2038 y_px = coordinate / width;
2041 x_px - 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2043 x_px - 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
2045 x_px - 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2047 x_px, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2049 x_px, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2051 x_px + 1, y_px - 1, ibuf, stack, touched, pixel_color, threshold_sq);
2053 x_px + 1, y_px, ibuf, stack, touched, pixel_color, threshold_sq);
2055 x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
2059 MEM_delete(touched);
2072 const bContext *
C,
Brush *br,
const float mouse_init[2],
const float mouse_final[2],
void *ps)
2084 float line_len_sq_inv, line_len;
2089 if (ima ==
nullptr) {
2101 if (ibuf ==
nullptr) {
2110 image_final[0] *= ibuf->
x;
2111 image_final[1] *= ibuf->
y;
2119 line_len_sq_inv = 1.0f / line_len;
2120 line_len =
sqrtf(line_len);
2129 for (x_px = 0; x_px < ibuf->
x; x_px++) {
2130 for (y_px = 0; y_px < ibuf->
y; y_px++) {
2136 f =
dot_v2v2(p, tangent) * line_len_sq_inv;
2141 f =
len_v2(p) / line_len;
2148 color_f[3] *= brush_alpha;
2150 float_data + 4 * (
size_t(y_px) * ibuf->
x + x_px),
2158 for (x_px = 0; x_px < ibuf->
x; x_px++) {
2159 for (y_px = 0; y_px < ibuf->
y; y_px++) {
2165 f =
dot_v2v2(p, tangent) * line_len_sq_inv;
2170 f =
len_v2(p) / line_len;
2178 (
reinterpret_cast<uchar *
>(&color_b))[3] *= brush_alpha;
2180 byte_data + 4 * (
size_t(y_px) * ibuf->
x + x_px),
2181 reinterpret_cast<uchar *
>(&color_b),
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
#define IMAGEPAINT_MODE_IMAGE
#define ED_IMAGE_UNDO_TILE_SIZE
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
float distance(float, float) RET
float2x2 invert(float2x2 mat)
const ccl_global KernelWorkTile * tile
void view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
static int paint_2d_op(void *state, ImagePaintTile *tile, const float lastpos[2], const float pos[2])
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
static bool is_inside_tile(const int size[2], const float pos[2], const float brush[2])
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
MINLINE float len_squared_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static void paint_2d_ibuf_rgb_get(ImBuf *ibuf, int x, int y, float r_rgb[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void brush_imbuf_tex_co(const rctf *mapping, int x, int y, float texco[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
float BKE_brush_sample_tex_3d(const Paint *paint, const Brush *br, const MTex *mtex, const float3 &point, float4 &rgba, int thread, ImagePool *pool)
void ED_imapaint_clear_partial_redraw()
static float paint_2d_ibuf_add_if(ImBuf *ibuf, int x, int y, float *outrgb, short paint_tile, float w)
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 BLI_stack_free(BLI_Stack *stack) ATTR_NONNULL()
static ImageUser * paint_2d_get_tile_iuser(ImagePaintState *s, int tile_number)
bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace)
@ BRUSH_GRADIENT_SPACING_CLAMP
@ BRUSH_GRADIENT_SPACING_REPEAT
float BKE_brush_sample_masktex(const Paint *paint, Brush *br, const float2 &point, int thread, ImagePool *pool)
void * paint_2d_new_stroke(bContext *C, wmOperator *op, const BrushStrokeMode mode)
MINLINE void copy_v2_v2(float r[2], const float a[2])
static void paint_2d_canvas_free(ImagePaintState *s)
void BLI_stack_pop(BLI_Stack *stack, void *dst) ATTR_NONNULL()
static void paint_2d_ibuf_tile_convert(ImBuf *ibuf, int *x, int *y, short paint_tile)
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
static int paint_2d_torus_split_region(ImagePaintRegion region[4], ImBuf *dbuf, const ImBuf *sbuf, short paint_tile)
static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
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)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void imapaint_image_update(ImBuf *ibuf)
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
MINLINE void sub_v2_v2v2_int(int r[2], const int a[2], const int b[2])
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 void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[2])
bool IMB_initImBuf(ImBuf *ibuf, unsigned int x, unsigned int y, ImBufFlags flags)
void paint_2d_stroke_done(void *ps, wmPaintCursor *cursor)
static void image_init(Image *ima, eImageSource source, eImageType type)
MINLINE void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
void ED_region_tag_redraw(ARegion *region)
static void paint_2d_ibuf_rgb_set(ImBuf *ibuf, int x, int y, const bool is_torus, const float rgb[4])
PaintTileMap * ED_image_paint_tile_map_get()
MINLINE void mul_v3_fl(float r[3], float f)
VecBase< float, 4 > float4
static BrushPainter * brush_painter_2d_new(Scene *scene, const Paint *paint, Brush *brush, bool invert)
MINLINE void zero_v4(float r[4])
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 IMB_float_from_byte(ImBuf *ibuf)
static void paint_2d_lift_soften(ImagePaintState *s, ImagePaintTile *tile, ImBuf *ibuf, ImBuf *ibufb, const int *pos, const short paint_tile)
void IMB_rectblend(ImBuf *dbuf, uint8_t *dbuf_byte_data, float *dbuf_float_data, const ImBuf *obuf, const ImBuf *sbuf, unsigned short *dmask, const unsigned short *curvemask, const unsigned short *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
void paint_curve_mask_cache_free_data(CurveMaskCache *curve_mask_cache)
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
void IMB_freeImBuf(ImBuf *ibuf)
VecBase< int32_t, 2 > int2
MINLINE void mul_v3_v3(float r[3], const float a[3])
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void paint_brush_color_get(const Paint *paint, Brush *br, std::optional< float3 > &initial_hsv_jitter, bool invert, float distance, float pressure, float r_color[3])
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
static void paint_2d_set_region(ImagePaintRegion *region, int destx, int desty, int srcx, int srcy, int width, int height)
MINLINE void add_v4_v4(float r[4], const float a[4])
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void paint_2d_redraw(const bContext *C, void *ps, bool final)
float3 BKE_paint_seed_hsv_jitter()
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 paint_2d_op_foreach_do(void *__restrict data_v, const int iter, const TaskParallelTLS *__restrict)
void paint_2d_gradient_fill(const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
@ IMAGE_PAINT_BRUSH_TYPE_SOFTEN
@ IMAGE_PAINT_BRUSH_TYPE_SMEAR
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
static void paint_2d_do_making_brush(ImagePaintState *s, ImagePaintTile *tile, ImagePaintRegion *region, uint8_t *canvas_byte_data, float *canvas_float_data, ImBuf *frombuf, float mask_max, short blend, int tilex, int tiley, int tilew, int tileh)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
static void paint_2d_transform_mouse(View2D *v2d, const float in[2], float out[2])
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
void paint_brush_exit_tex(Brush *brush)
static ImBuf * paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos)
void BKE_image_pool_free(ImagePool *pool)
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush)
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void imapaint_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
const ImBuf * 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)
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)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, ImBufFlags flags)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h)
static void brush_painter_imbuf_partial_update(BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
SpaceImage * CTX_wm_space_image(const bContext *C)
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void IMB_byte_from_float(ImBuf *ibuf)
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)
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)
Paint * BKE_paint_get_active_from_context(const bContext *C)
static int paint_2d_canvas_set(ImagePaintState *s, const Paint *paint)
static void paint_2d_lift_smear(const ImBuf *ibuf, ImBuf *ibufb, int *pos, short paint_tile)
void paint_delete_blur_kernel(BlurKernel *kernel)
static void brush_painter_2d_require_imbuf(Brush *brush, ImagePaintTile *tile, bool is_float, bool is_data, bool is_srgb, const ColorSpace *byte_colorspace, bool invert)
static ushort * brush_painter_mask_ibuf_new(BrushPainter *painter, const int size)
std::optional< BrushColorJitterSettings > BKE_brush_color_jitter_get_settings(const Paint *paint, const Brush *brush)
Brush * BKE_paint_brush(Paint *paint)
static void brush_painter_cache_2d_free(BrushPainterCache *cache)
void BLI_stack_push(BLI_Stack *stack, const void *src) ATTR_NONNULL()
Scene * CTX_data_scene(const bContext *C)
void IMB_blend_color_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void sub_v2_v2(float r[2], const float a[2])
ImagePool * BKE_image_pool_new()
static void brush_painter_imbuf_update(BrushPainter *painter, ImagePaintTile *tile, ImBuf *oldtexibuf, int origx, int origy, int w, int h, int xt, int yt)
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v4_fl(float r[4], float f)
VecBase< float, 3 > float3
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
static void paint_2d_uv_to_coord(ImagePaintTile *tile, const float uv[2], float coord[2])
bool BKE_image_has_packedfile(const Image *image)
static ImBuf * brush_painter_imbuf_new(BrushPainter *painter, ImagePaintTile *tile, const int size, float pressure, float distance)
void BKE_imageuser_default(ImageUser *iuser)
BLI_Stack * BLI_stack_new(size_t elem_size, const char *description) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MINLINE int min_ii(int a, int b)
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
Object * CTX_data_active_object(const bContext *C)
MINLINE void zero_v2(float r[2])
ARegion * CTX_wm_region(const bContext *C)
MINLINE void straight_to_premul_v4(float color[4])
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
ocio::ColorSpace ColorSpace
void paint_brush_init_tex(Brush *brush)
void IMB_copy_rect(float *dst, const int2 &dst_size, const float *src, const int2 &src_size, int channels, const int2 &src_rect_pos, const int2 &dst_rect_pos, const int2 &rect_size)
void paint_curve_mask_cache_update(CurveMaskCache *curve_mask_cache, const Brush *brush, const int diameter, const float radius, const float cursor_position[2])
@ PAINT2D_TILE_UNINITIALIZED
bool WM_paint_cursor_end(wmPaintCursor *handle)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const ColorSpace * byte_colorspace
CurveMaskCache curve_mask_cache
std::optional< float3 > initial_hsv_jitter
struct ColorBand * gradient
eBrushGradientSourceFill gradient_fill_mode
Caching structure for curve mask.
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
bool colorspace_is_data() const
const float * float_data() const
float * float_data_for_write()
ImagePaintTileState state
uint8_t * canvas_byte_data
ImagePaintRegion * region
float * canvas_float_data
bke::PaintRuntime * runtime
ePaintSymmetryFlags symmetry_flags
struct ToolSettings * toolsettings
struct ReportList * reports