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:
authorJacques Lucke <jacques@blender.org>2021-11-02 13:15:05 +0300
committerJacques Lucke <jacques@blender.org>2021-11-02 13:17:12 +0300
commit0c3b215e7d5456878b155d13440864f49ad1f230 (patch)
tree1a405cfe6fbf632442d6ce03821e1828d581bcf4 /source/blender/editors
parent2b3becf2be27286d68a49328a13c327d2fa94aeb (diff)
Images: refactor how failed image load attempts are remembered
Previously, `ImageTile->ok` and `ImageUser->ok` were used to indicate whether an image failed to load. There were three possible values which (probably) had the following meanings: * `0`: There was an error while loading the image. Don't try to load again. * `1`: Default value. Try to load the image. * `2`: The image was loaded successfully. This image-wide flag did not make sense unfortunately, because loading may work for some frames of an image sequence but not for others. Remember than an image data block can also contain a movie. The purpose of the `->ok` flag was to serve as an optimization to avoid trying to load a file over and over again when there is an error (e.g. the file does not exist or is invalid). To get the optimization back, the patch is changing `MovieCache` so that it can also cache failed load attempts. As a consequence, `ibuf` is allowed to be `NULL` in a few more places. I added the appropriate null checks. This also solves issues when image sequences are used with the Image Texture node in Geometry nodes (also see D12827). Differential Revision: https://developer.blender.org/D12957
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/object/object_bake_api.c7
-rw-r--r--source/blender/editors/render/render_internal.c1
-rw-r--r--source/blender/editors/render/render_opengl.c1
-rw-r--r--source/blender/editors/render/render_preview.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c3
-rw-r--r--source/blender/editors/space_image/image_buttons.c4
-rw-r--r--source/blender/editors/space_image/image_ops.c4
-rw-r--r--source/blender/editors/space_image/image_undo.c1
8 files changed, 5 insertions, 24 deletions
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 98f85823bb3..0de34e21462 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -314,11 +314,8 @@ static void bake_targets_refresh(BakeTargets *targets)
if (ima) {
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
- if (tile->ok == IMA_OK_LOADED) {
- BKE_image_free_gputextures(ima);
- DEG_id_tag_update(&ima->id, 0);
- break;
- }
+ BKE_image_free_gputextures(ima);
+ DEG_id_tag_update(&ima->id, 0);
}
}
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 2ff47edabf4..49e7ebf6340 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -976,7 +976,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->anim = is_animation;
rj->write_still = is_write_still && !is_animation;
rj->iuser.scene = scene;
- rj->iuser.ok = 1;
rj->reports = op->reports;
rj->orig_layer = 0;
rj->last_layer = 0;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 4c539bdea90..1e1a95f2965 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -836,7 +836,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
BKE_image_backup_render(oglrender->scene, oglrender->ima, true);
oglrender->iuser.scene = scene;
- oglrender->iuser.ok = 1;
/* create render result */
RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, NULL, sizex, sizey, NULL);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 6f49b03f07f..4bf250b9d4f 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -1476,14 +1476,8 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
return;
}
- ImageTile *tile = BKE_image_get_tile(ima, 0);
- /* tile->ok is zero when Image cannot load */
- if (tile->ok == 0) {
- return;
- }
-
/* setup dummy image user */
- iuser.ok = iuser.framenr = 1;
+ iuser.framenr = 1;
iuser.scene = sp->scene;
/* elubie: this needs to be changed: here image is always loaded if not
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index a35e248a78c..63f61b6c5c1 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -916,8 +916,6 @@ static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i)
s->tiles[i].cache.lastdiameter = -1;
- s->tiles[i].iuser.ok = true;
-
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, &s->tiles[i].iuser, NULL);
if (ibuf != NULL) {
if (ibuf->channels != 4) {
@@ -1683,7 +1681,6 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
for (int i = 0; i < s->num_tiles; i++) {
s->tiles[i].iuser = sima->iuser;
}
- s->tiles[0].iuser.ok = true;
zero_v2(s->tiles[0].uv_origin);
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 86349a64681..5b83f681d17 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -729,10 +729,6 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
{
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
- /* ideally this would be done by RNA itself, but there we have
- * no image user available, so we just update this flag here */
- cb->iuser->ok = 1;
-
/* we call update here on the pointer property, this way the
* owner of the image pointer can still define its own update
* and notifier */
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index ae56238d73f..478e484924a 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2227,7 +2227,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
iter = IMB_moviecacheIter_new(image->cache);
while (!IMB_moviecacheIter_done(iter)) {
ibuf = IMB_moviecacheIter_getImBuf(iter);
- if (ibuf->userflags & IB_BITMAPDIRTY) {
+ if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
if (first_ibuf == NULL) {
first_ibuf = ibuf;
}
@@ -2251,7 +2251,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
while (!IMB_moviecacheIter_done(iter)) {
ibuf = IMB_moviecacheIter_getImBuf(iter);
- if (ibuf->userflags & IB_BITMAPDIRTY) {
+ if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
char name[FILE_MAX];
BLI_strncpy(name, ibuf->name, sizeof(name));
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index cc6effd0f71..3fbcc8348c8 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -668,7 +668,6 @@ static UndoImageHandle *uhandle_add(ListBase *undo_handles, Image *image, ImageU
uh->image_ref.ptr = image;
uh->iuser = *iuser;
uh->iuser.scene = NULL;
- uh->iuser.ok = 1;
BLI_addtail(undo_handles, uh);
return uh;
}