Commit: 37c89eb3da12c8370b9dd3f0083f8c77d476be8b
Author: Lukas Stockner
Date:   Wed Jun 13 16:38:18 2018 +0200
Branches: temp-udim-images
https://developer.blender.org/rB37c89eb3da12c8370b9dd3f0083f8c77d476be8b

Support live redrawing for secondary tiles during texture painting

===================================================================

M       source/blender/editors/sculpt_paint/paint_image.c
M       source/blender/editors/sculpt_paint/paint_image_2d.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/sculpt_paint/paint_intern.h

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image.c 
b/source/blender/editors/sculpt_paint/paint_image.c
index 52d4802fd19..599d74379aa 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -161,7 +161,7 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int 
x, int y, int w, int
                IMB_freeImBuf(tmpibuf);
 }
 
-void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short 
texpaint)
+void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, 
ImageUser *iuser, short texpaint)
 {
        if (imapaintpartial.x1 != imapaintpartial.x2 &&
            imapaintpartial.y1 != imapaintpartial.y2)
@@ -179,7 +179,7 @@ void imapaint_image_update(SpaceImage *sima, Image *image, 
ImBuf *ibuf, short te
                int h = imapaintpartial.y2 - imapaintpartial.y1;
                if (w && h) {
                        /* Testing with partial update in uv editor too */
-                       GPU_paint_update_image(image, (sima ? &sima->iuser : 
NULL), imapaintpartial.x1, imapaintpartial.y1, w, h);
+                       GPU_paint_update_image(image, iuser, 
imapaintpartial.x1, imapaintpartial.y1, w, h);
                }
        }
 }
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c 
b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 3c5e57de8f9..55fa96f281e 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -1366,7 +1366,7 @@ void paint_2d_redraw(const bContext *C, void *ps, bool 
final)
        if (s->need_redraw) {
                ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->iuser, NULL);
 
-               imapaint_image_update(s->sima, s->image, ibuf, false);
+               imapaint_image_update(s->sima, s->image, ibuf, &s->iuser, 
false);
                ED_imapaint_clear_partial_redraw();
 
                BKE_image_release_ibuf(s->image, ibuf, NULL);
@@ -1616,7 +1616,7 @@ void paint_2d_bucket_fill(
                BLI_stack_free(stack);
        }
 
-       imapaint_image_update(sima, ima, ibuf, false);
+       imapaint_image_update(sima, ima, ibuf, &s->iuser, false);
        ED_imapaint_clear_partial_redraw();
 
        BKE_image_release_ibuf(ima, ibuf, NULL);
@@ -1731,7 +1731,7 @@ void paint_2d_gradient_fill(
                }
        }
 
-       imapaint_image_update(sima, ima, ibuf, false);
+       imapaint_image_update(sima, ima, ibuf, &s->iuser, false);
        ED_imapaint_clear_partial_redraw();
 
        BKE_image_release_ibuf(ima, ibuf, NULL);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 4ffd9cf8025..c4135edee15 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -194,6 +194,7 @@ BLI_INLINE unsigned char f_to_char(const float val)
 typedef struct ProjPaintImage {
        Image *ima;
        ImBuf *ibuf;
+       ImageUser iuser;
        ImagePaintPartialRedraw *partRedrawRect;
        volatile void **undoRect; /* only used to build undo tiles during 
painting */
        unsigned short **maskRect; /* the mask accumulation must happen on 
canvas, not on space screen bucket.
@@ -3684,14 +3685,13 @@ static void project_paint_build_proj_ima(
 
        for (node = image_LinkList, i = 0; node; node = node->next, i++, 
projIma++) {
                float local_uv[2];
-               ImageUser iuser = {NULL};
-               iuser.ok = true;
-               iuser.tile = BKE_image_get_tile_from_pos(node->link, uv, 
local_uv, projIma->uv_ofs);
-
+               memset(&projIma->iuser, 0, sizeof(projIma->iuser));
+               projIma->iuser.ok = true;
+               projIma->iuser.tile = BKE_image_get_tile_from_pos(node->link, 
uv, local_uv, projIma->uv_ofs);
                int size;
                projIma->ima = node->link;
                projIma->touch = 0;
-               projIma->ibuf = BKE_image_acquire_ibuf(projIma->ima, &iuser, 
NULL);
+               projIma->ibuf = BKE_image_acquire_ibuf(projIma->ima, 
&projIma->iuser, NULL);
                size = sizeof(void **) * IMAPAINT_TILE_NUMBER(projIma->ibuf->x) 
* IMAPAINT_TILE_NUMBER(projIma->ibuf->y);
                projIma->partRedrawRect =  BLI_memarena_alloc(arena, 
sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
                partial_redraw_array_init(projIma->partRedrawRect);
@@ -4105,7 +4105,7 @@ static bool project_image_refresh_tagged(ProjPaintState 
*ps)
                                pr = &(projIma->partRedrawRect[i]);
                                if (pr->x2 != -1) { /* TODO - use 'enabled' ? */
                                        set_imapaintpartial(pr);
-                                       imapaint_image_update(NULL, 
projIma->ima, projIma->ibuf, true);
+                                       imapaint_image_update(NULL, 
projIma->ima, projIma->ibuf, &projIma->iuser, true);
                                        redraw = 1;
                                }
 
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h 
b/source/blender/editors/sculpt_paint/paint_intern.h
index 6f9e5eeb751..28c5e264cc0 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -180,7 +180,7 @@ typedef struct ImagePaintPartialRedraw {
 #define IMAPAINT_TILE_NUMBER(size)  (((size) + IMAPAINT_TILE_SIZE - 1) >> 
IMAPAINT_TILE_BITS)
 
 int image_texture_paint_poll(struct bContext *C);
-void imapaint_image_update(struct SpaceImage *sima, struct Image *image, 
struct ImBuf *ibuf, short texpaint);
+void imapaint_image_update(struct SpaceImage *sima, struct Image *image, 
struct ImBuf *ibuf, struct ImageUser *iuser, short texpaint);
 struct ImagePaintPartialRedraw *get_imapaintpartial(void);
 void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr);
 void imapaint_region_tiles(struct ImBuf *ibuf, int x, int y, int w, int h, int 
*tx, int *ty, int *tw, int *th);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to