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:
authorPhilipp Oeser <info@graphics-engineer.com>2020-03-04 16:40:21 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-03-10 15:47:33 +0300
commitca717f0489af6854f3f4bedb3c1e82ea0a8dff1c (patch)
tree9d25588ea433fd5242277a3a704283b0130d8799 /source/blender/editors/space_image/image_undo.c
parent212660f467451b0092fcebcb44591c92c09acbc9 (diff)
Fix T74425: Cannot texture paint an images sequence anymore
Caused by the introduction of UDIM (rBc30d6571bb47). We need to make sure the tiles ImageUser is set up correctly [especially the framenr], otherwise BKE_image_acquire_ibuf() and friends will fail to find the correct ImBuf. Also instead of initializing a minimal BKE_imageuser_default, now use an appropriate ImageUser if avaliable and pass this around (instead of just the tile_number). 2D painting can reuse the Image Editor ImageUser, for 3D painting we still rely on a default ImageUser in most places, but at least set the framenr correctly]. This also fixes crashes when doing image operations such as inverting or resizing on images in a sequence in the Image Editor. This also fixes color sampling (S) from the 3DView going wrong for image sequences (would fallback to OpenGL sampling because an ImBuf could not be found). Maniphest Tasks: T74425 Differential Revision: https://developer.blender.org/D7022
Diffstat (limited to 'source/blender/editors/space_image/image_undo.c')
-rw-r--r--source/blender/editors/space_image/image_undo.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index d18eb9a5410..eac330b4ff2 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -107,7 +107,11 @@ typedef struct PaintTile {
struct PaintTile *next, *prev;
Image *image;
ImBuf *ibuf;
- int tile_number;
+ /* For 2D image painting the ImageUser uses most of the values.
+ * Even though views and passes are stored they are currently not supported for painting.
+ * For 3D projection painting this only uses a tile & frame number.
+ * The scene pointer must be cleared (or temporarily set it as needed, but leave cleared). */
+ ImageUser iuser;
union {
float *fp;
uint *uint;
@@ -149,7 +153,7 @@ static void ptile_invalidate_list(ListBase *paint_tiles)
void *ED_image_paint_tile_find(ListBase *paint_tiles,
Image *image,
ImBuf *ibuf,
- int tile_number,
+ ImageUser *iuser,
int x_tile,
int y_tile,
ushort **r_mask,
@@ -157,7 +161,7 @@ void *ED_image_paint_tile_find(ListBase *paint_tiles,
{
for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
if (ptile->x_tile == x_tile && ptile->y_tile == y_tile) {
- if (ptile->image == image && ptile->ibuf == ibuf && ptile->tile_number == tile_number) {
+ if (ptile->image == image && ptile->ibuf == ibuf && ptile->iuser.tile == iuser->tile) {
if (r_mask) {
/* allocate mask if requested. */
if (!ptile->mask) {
@@ -180,7 +184,7 @@ void *ED_image_paint_tile_push(ListBase *paint_tiles,
Image *image,
ImBuf *ibuf,
ImBuf **tmpibuf,
- int tile_number,
+ ImageUser *iuser,
int x_tile,
int y_tile,
ushort **r_mask,
@@ -195,7 +199,7 @@ void *ED_image_paint_tile_push(ListBase *paint_tiles,
/* in projective painting we keep accounting of tiles, so if we need one pushed, just push! */
if (find_prev) {
void *data = ED_image_paint_tile_find(
- paint_tiles, image, ibuf, tile_number, x_tile, y_tile, r_mask, true);
+ paint_tiles, image, ibuf, iuser, x_tile, y_tile, r_mask, true);
if (data) {
return data;
}
@@ -209,7 +213,8 @@ void *ED_image_paint_tile_push(ListBase *paint_tiles,
ptile->image = image;
ptile->ibuf = ibuf;
- ptile->tile_number = tile_number;
+ ptile->iuser = *iuser;
+ ptile->iuser.scene = NULL;
ptile->x_tile = x_tile;
ptile->y_tile = y_tile;
@@ -264,10 +269,7 @@ static void ptile_restore_runtime_list(ListBase *paint_tiles)
for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
Image *image = ptile->image;
- ImageUser iuser;
- BKE_imageuser_default(&iuser);
- iuser.tile = ptile->tile_number;
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL);
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, &ptile->iuser, NULL);
const bool has_float = (ibuf->rect_float != NULL);
if (has_float) {
@@ -659,22 +661,23 @@ static UndoImageHandle *uhandle_lookup(ListBase *undo_handles, const Image *imag
return NULL;
}
-static UndoImageHandle *uhandle_add(ListBase *undo_handles, Image *image, int tile_number)
+static UndoImageHandle *uhandle_add(ListBase *undo_handles, Image *image, ImageUser *iuser)
{
- BLI_assert(uhandle_lookup(undo_handles, image, tile_number) == NULL);
+ BLI_assert(uhandle_lookup(undo_handles, image, iuser->tile) == NULL);
UndoImageHandle *uh = MEM_callocN(sizeof(*uh), __func__);
uh->image_ref.ptr = image;
+ uh->iuser = *iuser;
+ BLI_assert(uh->iuser.scene == NULL);
uh->iuser.ok = 1;
- uh->iuser.tile = tile_number;
BLI_addtail(undo_handles, uh);
return uh;
}
-static UndoImageHandle *uhandle_ensure(ListBase *undo_handles, Image *image, int tile_number)
+static UndoImageHandle *uhandle_ensure(ListBase *undo_handles, Image *image, ImageUser *iuser)
{
- UndoImageHandle *uh = uhandle_lookup(undo_handles, image, tile_number);
+ UndoImageHandle *uh = uhandle_lookup(undo_handles, image, iuser->tile);
if (uh == NULL) {
- uh = uhandle_add(undo_handles, image, tile_number);
+ uh = uhandle_add(undo_handles, image, iuser);
}
return uh;
}
@@ -779,7 +782,7 @@ static bool image_undosys_step_encode(struct bContext *C,
/* Initialize undo tiles from ptiles (if they exist). */
for (PaintTile *ptile = us->paint_tiles.first, *ptile_next; ptile; ptile = ptile_next) {
if (ptile->valid) {
- UndoImageHandle *uh = uhandle_ensure(&us->handles, ptile->image, ptile->tile_number);
+ UndoImageHandle *uh = uhandle_ensure(&us->handles, ptile->image, &ptile->iuser);
UndoImageBuf *ubuf_pre = uhandle_ensure_ubuf(uh, ptile->image, ptile->ibuf);
UndoImageTile *utile = MEM_callocN(sizeof(*utile), "UndoImageTile");
@@ -1047,12 +1050,12 @@ void ED_image_undo_push_begin(const char *name, int paint_mode)
void ED_image_undo_push_begin_with_image(const char *name,
Image *image,
ImBuf *ibuf,
- int tile_number)
+ ImageUser *iuser)
{
ImageUndoStep *us = image_undo_push_begin(name, PAINT_MODE_TEXTURE_2D);
- BLI_assert(BKE_image_get_tile(image, tile_number));
- UndoImageHandle *uh = uhandle_ensure(&us->handles, image, tile_number);
+ BLI_assert(BKE_image_get_tile(image, iuser->tile));
+ UndoImageHandle *uh = uhandle_ensure(&us->handles, image, iuser);
UndoImageBuf *ubuf_pre = uhandle_ensure_ubuf(uh, image, ibuf);
BLI_assert(ubuf_pre->post == NULL);
@@ -1061,7 +1064,7 @@ void ED_image_undo_push_begin_with_image(const char *name,
us_reference = (ImageUndoStep *)us_reference->step.prev;
}
UndoImageBuf *ubuf_reference = (us_reference ? ubuf_lookup_from_reference(
- us_reference, image, tile_number, ubuf_pre) :
+ us_reference, image, iuser->tile, ubuf_pre) :
NULL);
if (ubuf_reference) {