Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-07-02 19:45:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-02 19:45:26 +0300
commitdbe1b07e058db33a9e806d8e9808463d563d4aa5 (patch)
tree79ba8e3a9adc48cb55f5e7f35f82f1d90bc6e2b5 /source/blender/editors/sculpt_paint/paint_image_2d.c
parent73c577d46a2fd99c519ce7ef0fd9deb3b914099f (diff)
Cleanup: right shift
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_2d.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c172
1 files changed, 97 insertions, 75 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index ec1a6ebf7ed..76190b13b61 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -441,8 +441,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pre
}
/* update rectangular section of the brush image */
-static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
- int origx, int origy, int w, int h, int xt, int yt)
+static void brush_painter_imbuf_update(
+ BrushPainter *painter, ImBuf *oldtexibuf,
+ int origx, int origy, int w, int h, int xt, int yt)
{
Scene *scene = painter->scene;
Brush *brush = painter->brush;
@@ -659,11 +660,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
bool do_random = false;
bool do_partial_update = false;
- bool update_color = (brush->flag & BRUSH_USE_GRADIENT) &&
- ((ELEM(brush->gradient_stroke_mode,
- BRUSH_GRADIENT_SPACING_REPEAT,
- BRUSH_GRADIENT_SPACING_CLAMP)) ||
- (cache->last_pressure != pressure));
+ bool update_color = (
+ (brush->flag & BRUSH_USE_GRADIENT) &&
+ ((ELEM(brush->gradient_stroke_mode,
+ BRUSH_GRADIENT_SPACING_REPEAT,
+ BRUSH_GRADIENT_SPACING_CLAMP)) ||
+ (cache->last_pressure != pressure)));
float tex_rotation = -brush->mtex.rot;
float mask_rotation = -brush->mask_mtex.rot;
@@ -679,8 +681,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
else if (!((brush->flag & BRUSH_ANCHORED) || update_color))
do_partial_update = true;
- brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse,
- brush->mtex.brush_map_mode, &painter->tex_mapping);
+ brush_painter_2d_tex_mapping(
+ s, diameter, painter->startpaintpos, pos, mouse,
+ brush->mtex.brush_map_mode, &painter->tex_mapping);
}
if (painter->cache.is_maskbrush) {
@@ -712,8 +715,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
cache->tex_mask = NULL;
}
- brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse,
- brush->mask_mtex.brush_map_mode, &painter->mask_mapping);
+ brush_painter_2d_tex_mapping(
+ s, diameter, painter->startpaintpos, pos, mouse,
+ brush->mask_mtex.brush_map_mode, &painter->mask_mapping);
if (do_partial_update_mask)
brush_painter_mask_imbuf_partial_update(painter, pos, diameter);
@@ -893,9 +897,10 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImBuf *ibuf, ImBuf *ibufb,
for (yk = 0; yk < kernel->side; yk++) {
for (xk = 0; xk < kernel->side; xk++) {
- count += paint_2d_ibuf_add_if(ibuf, xi + xk - kernel->pixel_len,
- yi + yk - kernel->pixel_len, outrgb, tile,
- kernel->wdata[xk + yk * kernel->side]);
+ count += paint_2d_ibuf_add_if(
+ ibuf, xi + xk - kernel->pixel_len,
+ yi + yk - kernel->pixel_len, outrgb, tile,
+ kernel->wdata[xk + yk * kernel->side]);
}
}
@@ -994,10 +999,11 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
tot = paint_2d_torus_split_region(region, ibufb, ibuf, tile);
for (a = 0; a < tot; a++)
- IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty,
- region[a].destx, region[a].desty,
- region[a].srcx, region[a].srcy,
- region[a].width, region[a].height, IMB_BLEND_COPY, false);
+ IMB_rectblend(
+ ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty,
+ region[a].destx, region[a].desty,
+ region[a].srcx, region[a].srcy,
+ region[a].width, region[a].height, IMB_BLEND_COPY, false);
}
static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
@@ -1008,10 +1014,12 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
ImBuf *clonebuf = IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags);
IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h);
- IMB_rectblend(clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h,
- IMB_BLEND_COPY_ALPHA, false);
- IMB_rectblend(clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h,
- IMB_BLEND_COPY_RGB, false);
+ IMB_rectblend(
+ clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h,
+ IMB_BLEND_COPY_ALPHA, false);
+ IMB_rectblend(
+ clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h,
+ IMB_BLEND_COPY_RGB, false);
return clonebuf;
}
@@ -1022,15 +1030,16 @@ static void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[
ipos[1] = (int)floorf((pos[1] - ibufb->y / 2));
}
-static void paint_2d_do_making_brush(ImagePaintState *s,
- ImagePaintRegion *region,
- unsigned short *curveb,
- unsigned short *texmaskb,
- ImBuf *frombuf,
- float mask_max,
- short blend,
- int tilex, int tiley,
- int tilew, int tileh)
+static void paint_2d_do_making_brush(
+ ImagePaintState *s,
+ ImagePaintRegion *region,
+ unsigned short *curveb,
+ unsigned short *texmaskb,
+ ImBuf *frombuf,
+ float mask_max,
+ short blend,
+ int tilex, int tiley,
+ int tilew, int tileh)
{
ImBuf tmpbuf;
IMB_initImBuf(&tmpbuf, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, 0);
@@ -1049,13 +1058,14 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
else
tmpbuf.rect = image_undo_find_tile(undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
- IMB_rectblend(s->canvas, &tmpbuf, frombuf, mask,
- curveb, texmaskb, mask_max,
- region->destx, region->desty,
- origx, origy,
- region->srcx, region->srcy,
- region->width, region->height,
- blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0));
+ IMB_rectblend(
+ s->canvas, &tmpbuf, frombuf, mask,
+ curveb, texmaskb, mask_max,
+ region->destx, region->desty,
+ origx, origy,
+ region->srcx, region->srcy,
+ region->width, region->height,
+ blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0));
}
}
}
@@ -1078,11 +1088,12 @@ static void paint_2d_op_foreach_do(
const ParallelRangeTLS *__restrict UNUSED(tls))
{
Paint2DForeachData *data = (Paint2DForeachData *)data_v;
- paint_2d_do_making_brush(data->s, data->region, data->curveb,
- data->texmaskb, data->frombuf, data->mask_max,
- data->blend,
- data->tilex, iter,
- data->tilew, iter);
+ paint_2d_do_making_brush(
+ data->s, data->region, data->curveb,
+ data->texmaskb, data->frombuf, data->mask_max,
+ data->blend,
+ data->tilex, iter,
+ data->tilew, iter);
}
static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsigned short *texmaskb, const float lastpos[2], const float pos[2])
@@ -1134,21 +1145,24 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
/* blend into canvas */
for (a = 0; a < tot; a++) {
- ED_imapaint_dirty_region(s->image, s->canvas,
- region[a].destx, region[a].desty,
- region[a].width, region[a].height, true);
+ ED_imapaint_dirty_region(
+ s->image, s->canvas,
+ region[a].destx, region[a].desty,
+ region[a].width, region[a].height, true);
if (s->do_masking) {
/* masking, find original pixels tiles from undo buffer to composite over */
int tilex, tiley, tilew, tileh;
- imapaint_region_tiles(s->canvas, region[a].destx, region[a].desty,
- region[a].width, region[a].height,
- &tilex, &tiley, &tilew, &tileh);
+ imapaint_region_tiles(
+ s->canvas, region[a].destx, region[a].desty,
+ region[a].width, region[a].height,
+ &tilex, &tiley, &tilew, &tileh);
if (tiley == tileh) {
- paint_2d_do_making_brush(s, &region[a], curveb, texmaskb, frombuf,
- mask_max, blend, tilex, tiley, tilew, tileh);
+ paint_2d_do_making_brush(
+ s, &region[a], curveb, texmaskb, frombuf,
+ mask_max, blend, tilex, tiley, tilew, tileh);
}
else {
Paint2DForeachData data;
@@ -1164,19 +1178,21 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
- BLI_task_parallel_range(tiley, tileh + 1, &data,
- paint_2d_op_foreach_do,
- &settings);
+ BLI_task_parallel_range(
+ tiley, tileh + 1, &data,
+ paint_2d_op_foreach_do,
+ &settings);
}
}
else {
/* no masking, composite brush directly onto canvas */
- IMB_rectblend_threaded(s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max,
- region[a].destx, region[a].desty,
- region[a].destx, region[a].desty,
- region[a].srcx, region[a].srcy,
- region[a].width, region[a].height, blend, false);
+ IMB_rectblend_threaded(
+ s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max,
+ region[a].destx, region[a].desty,
+ region[a].destx, region[a].desty,
+ region[a].srcx, region[a].srcy,
+ region[a].width, region[a].height, blend, false);
}
}
@@ -1477,16 +1493,18 @@ void paint_2d_bucket_fill(
if (do_float) {
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
- blend_color_mix_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
- ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f);
+ blend_color_mix_float(
+ ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
+ ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f);
}
}
}
else {
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
- blend_color_mix_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b);
+ blend_color_mix_byte(
+ (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b);
}
}
}
@@ -1537,9 +1555,10 @@ void paint_2d_bucket_fill(
while (!BLI_stack_is_empty(stack)) {
BLI_stack_pop(stack, &coordinate);
- IMB_blend_color_float(ibuf->rect_float + 4 * (coordinate),
- ibuf->rect_float + 4 * (coordinate),
- color_f, br->blend);
+ IMB_blend_color_float(
+ ibuf->rect_float + 4 * (coordinate),
+ ibuf->rect_float + 4 * (coordinate),
+ color_f, br->blend);
/* reconstruct the coordinates here */
x_px = coordinate % width;
@@ -1568,9 +1587,10 @@ void paint_2d_bucket_fill(
while (!BLI_stack_is_empty(stack)) {
BLI_stack_pop(stack, &coordinate);
- IMB_blend_color_byte((unsigned char *)(ibuf->rect + coordinate),
- (unsigned char *)(ibuf->rect + coordinate),
- (unsigned char *)&color_b, br->blend);
+ IMB_blend_color_byte(
+ (unsigned char *)(ibuf->rect + coordinate),
+ (unsigned char *)(ibuf->rect + coordinate),
+ (unsigned char *)&color_b, br->blend);
/* reconstruct the coordinates here */
x_px = coordinate % width;
@@ -1678,9 +1698,10 @@ void paint_2d_gradient_fill(
/* convert to premultiplied */
mul_v3_fl(color_f, color_f[3]);
color_f[3] *= br->alpha;
- IMB_blend_color_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
- ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
- color_f, br->blend);
+ IMB_blend_color_float(
+ ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
+ ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
+ color_f, br->blend);
}
}
}
@@ -1708,9 +1729,10 @@ void paint_2d_gradient_fill(
linearrgb_to_srgb_v3_v3(color_f, color_f);
rgba_float_to_uchar((unsigned char *)&color_b, color_f);
((unsigned char *)&color_b)[3] *= br->alpha;
- IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)&color_b, br->blend);
+ IMB_blend_color_byte(
+ (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (unsigned char *)&color_b, br->blend);
}
}
}