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
This commit is contained in:
parent
2b3becf2be
commit
0c3b215e7d
Notes:
blender-bot
2023-02-14 08:40:26 +01:00
Referenced by commitb02ac2d8be
, Fix T93092: incomplete animation rendering of multi-layer exr composition Referenced by commit45bd98d4cf
, Fix T92934: crash rendering with wrong image path Referenced by commitb1bf884889
, Images: fix error in previous refactor Referenced by issue #93310, Compositor: Crash due to broken image paths Referenced by issue #93092, Incomplete Animation Rendering of MultiLayer EXR composition
|
@ -153,10 +153,6 @@ struct RenderData;
|
|||
struct RenderPass;
|
||||
struct RenderResult;
|
||||
|
||||
/* ima->ok */
|
||||
#define IMA_OK 1
|
||||
#define IMA_OK_LOADED 2
|
||||
|
||||
/* signals */
|
||||
/* reload only frees, doesn't read until image_get_ibuf() called */
|
||||
#define IMA_SIGNAL_RELOAD 0
|
||||
|
|
|
@ -140,7 +140,6 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLO_read_list(reader, &ca->bg_images);
|
||||
|
||||
LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
|
||||
bgpic->iuser.ok = 1;
|
||||
bgpic->iuser.scene = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1128,7 +1127,6 @@ CameraBGImage *BKE_camera_background_image_new(Camera *cam)
|
|||
|
||||
bgpic->scale = 1.0f;
|
||||
bgpic->alpha = 0.5f;
|
||||
bgpic->iuser.ok = 1;
|
||||
bgpic->iuser.flag |= IMA_ANIM_ALWAYS;
|
||||
bgpic->flag |= CAM_BGIMG_FLAG_EXPANDED;
|
||||
|
||||
|
|
|
@ -321,9 +321,7 @@ static void image_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLO_read_data_address(reader, &ima->preview);
|
||||
BKE_previewimg_blend_read(reader, ima->preview);
|
||||
BLO_read_data_address(reader, &ima->stereo3d_format);
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
tile->ok = IMA_OK;
|
||||
}
|
||||
|
||||
ima->lastused = 0;
|
||||
ima->gpuflag = 0;
|
||||
BLI_listbase_clear(&ima->gpu_refresh_areas);
|
||||
|
@ -443,12 +441,12 @@ static void imagecache_remove(Image *image, int index)
|
|||
IMB_moviecache_remove(image->cache, &key);
|
||||
}
|
||||
|
||||
static struct ImBuf *imagecache_get(Image *image, int index)
|
||||
static struct ImBuf *imagecache_get(Image *image, int index, bool *r_is_cached_empty)
|
||||
{
|
||||
if (image->cache) {
|
||||
ImageCacheKey key;
|
||||
key.index = index;
|
||||
return IMB_moviecache_get(image->cache, &key);
|
||||
return IMB_moviecache_get(image->cache, &key, r_is_cached_empty);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -529,10 +527,6 @@ void BKE_image_free_buffers_ex(Image *ima, bool do_lock)
|
|||
|
||||
BKE_image_free_gputextures(ima);
|
||||
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
tile->ok = IMA_OK;
|
||||
}
|
||||
|
||||
if (do_lock) {
|
||||
BLI_mutex_unlock(image_mutex);
|
||||
}
|
||||
|
@ -564,7 +558,6 @@ static void image_init(Image *ima, short source, short type)
|
|||
}
|
||||
|
||||
ImageTile *tile = MEM_callocN(sizeof(ImageTile), "Image Tiles");
|
||||
tile->ok = IMA_OK;
|
||||
tile->tile_number = 1001;
|
||||
BLI_addtail(&ima->tiles, tile);
|
||||
|
||||
|
@ -597,25 +590,25 @@ static Image *image_alloc(Main *bmain, const char *name, short source, short typ
|
|||
* call IMB_freeImBuf to de-reference the image buffer after
|
||||
* it's done handling it.
|
||||
*/
|
||||
static ImBuf *image_get_cached_ibuf_for_index_entry(Image *ima, int index, int entry)
|
||||
static ImBuf *image_get_cached_ibuf_for_index_entry(Image *ima,
|
||||
int index,
|
||||
int entry,
|
||||
bool *r_is_cached_empty)
|
||||
{
|
||||
if (index != IMA_NO_INDEX) {
|
||||
index = IMA_MAKE_INDEX(entry, index);
|
||||
}
|
||||
|
||||
return imagecache_get(ima, index);
|
||||
return imagecache_get(ima, index, r_is_cached_empty);
|
||||
}
|
||||
|
||||
/* no ima->ibuf anymore, but listbase */
|
||||
static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int entry)
|
||||
{
|
||||
if (ibuf) {
|
||||
if (index != IMA_NO_INDEX) {
|
||||
index = IMA_MAKE_INDEX(entry, index);
|
||||
}
|
||||
|
||||
imagecache_put(ima, index, ibuf);
|
||||
if (index != IMA_NO_INDEX) {
|
||||
index = IMA_MAKE_INDEX(entry, index);
|
||||
}
|
||||
|
||||
imagecache_put(ima, index, ibuf);
|
||||
}
|
||||
|
||||
static void image_remove_ibuf(Image *ima, int index, int entry)
|
||||
|
@ -888,11 +881,6 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
|
|||
if (BLI_path_cmp(strtest, str) == 0) {
|
||||
if ((BKE_image_has_anim(ima) == false) || (ima->id.us == 0)) {
|
||||
id_us_plus(&ima->id); /* officially should not, it doesn't link here! */
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
if (tile->ok == 0) {
|
||||
tile->ok = IMA_OK;
|
||||
}
|
||||
}
|
||||
if (r_exists) {
|
||||
*r_exists = true;
|
||||
}
|
||||
|
@ -1080,9 +1068,6 @@ Image *BKE_image_add_generated(Main *bmain,
|
|||
image_add_view(ima, names[view_id], "");
|
||||
}
|
||||
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
|
||||
return ima;
|
||||
}
|
||||
|
||||
|
@ -1105,8 +1090,6 @@ Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
|
|||
if (ima) {
|
||||
STRNCPY(ima->filepath, ibuf->name);
|
||||
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
}
|
||||
|
||||
return ima;
|
||||
|
@ -1157,7 +1140,7 @@ bool BKE_image_memorypack(Image *ima)
|
|||
int i;
|
||||
|
||||
for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, i, 0);
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, i, 0, NULL);
|
||||
|
||||
if (!ibuf) {
|
||||
ok = false;
|
||||
|
@ -1177,7 +1160,7 @@ bool BKE_image_memorypack(Image *ima)
|
|||
ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
|
||||
}
|
||||
else {
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0, NULL);
|
||||
|
||||
if (ibuf) {
|
||||
ok = ok && image_memorypack_imbuf(ima, ibuf, ibuf->name);
|
||||
|
@ -1266,6 +1249,10 @@ static uintptr_t image_mem_size(Image *image)
|
|||
|
||||
while (!IMB_moviecacheIter_done(iter)) {
|
||||
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||
IMB_moviecacheIter_step(iter);
|
||||
if (ibuf == NULL) {
|
||||
continue;
|
||||
}
|
||||
ImBuf *ibufm;
|
||||
int level;
|
||||
|
||||
|
@ -1287,8 +1274,6 @@ static uintptr_t image_mem_size(Image *image)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMB_moviecacheIter_step(iter);
|
||||
}
|
||||
IMB_moviecacheIter_free(iter);
|
||||
}
|
||||
|
@ -3487,7 +3472,6 @@ static void image_tag_frame_recalc(Image *ima, ID *iuser_id, ImageUser *iuser, v
|
|||
|
||||
if (ima == changed_image && BKE_image_is_animated(ima)) {
|
||||
iuser->flag |= IMA_NEED_FRAME_RECALC;
|
||||
iuser->ok = 1;
|
||||
|
||||
if (iuser_id) {
|
||||
/* Must copy image user changes to CoW datablock. */
|
||||
|
@ -3501,7 +3485,6 @@ static void image_tag_reload(Image *ima, ID *iuser_id, ImageUser *iuser, void *c
|
|||
Image *changed_image = customdata;
|
||||
|
||||
if (ima == changed_image) {
|
||||
iuser->ok = 1;
|
||||
if (iuser->scene) {
|
||||
image_update_views_format(ima, iuser);
|
||||
}
|
||||
|
@ -3515,7 +3498,6 @@ static void image_tag_reload(Image *ima, ID *iuser_id, ImageUser *iuser, void *c
|
|||
void BKE_imageuser_default(ImageUser *iuser)
|
||||
{
|
||||
memset(iuser, 0, sizeof(ImageUser));
|
||||
iuser->ok = 1;
|
||||
iuser->frames = 100;
|
||||
iuser->sfra = 1;
|
||||
}
|
||||
|
@ -3575,7 +3557,6 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
BKE_image_free_buffers(ima);
|
||||
|
||||
if (iuser) {
|
||||
iuser->ok = 1;
|
||||
if (iuser->scene) {
|
||||
image_update_views_format(ima, iuser);
|
||||
}
|
||||
|
@ -3590,7 +3571,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
|
||||
if (ima->source == IMA_SRC_GENERATED) {
|
||||
if (ima->gen_x == 0 || ima->gen_y == 0) {
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0, NULL);
|
||||
if (ibuf) {
|
||||
ima->gen_x = ibuf->x;
|
||||
ima->gen_y = ibuf->y;
|
||||
|
@ -3630,10 +3611,6 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
*/
|
||||
BKE_image_free_buffers(ima);
|
||||
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
tile->ok = 1;
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
image_tag_frame_recalc(ima, NULL, iuser, ima);
|
||||
}
|
||||
|
@ -3681,7 +3658,6 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
break;
|
||||
case IMA_SIGNAL_USER_NEW_IMAGE:
|
||||
if (iuser) {
|
||||
iuser->ok = 1;
|
||||
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
|
||||
if (ima->type == IMA_TYPE_MULTILAYER) {
|
||||
BKE_image_init_imageuser(ima, iuser);
|
||||
|
@ -3691,15 +3667,6 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
|||
break;
|
||||
case IMA_SIGNAL_COLORMANAGE:
|
||||
BKE_image_free_buffers(ima);
|
||||
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
tile->ok = 1;
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
iuser->ok = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3799,7 +3766,6 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la
|
|||
}
|
||||
|
||||
ImageTile *tile = MEM_callocN(sizeof(ImageTile), "image new tile");
|
||||
tile->ok = IMA_OK;
|
||||
tile->tile_number = tile_number;
|
||||
|
||||
if (next_tile) {
|
||||
|
@ -3864,14 +3830,14 @@ void BKE_image_reassign_tile(struct Image *ima, ImageTile *tile, int new_tile_nu
|
|||
if (BKE_image_is_multiview(ima)) {
|
||||
const int totviews = BLI_listbase_count(&ima->views);
|
||||
for (int i = 0; i < totviews; i++) {
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, i, old_tile_number);
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, i, old_tile_number, NULL);
|
||||
image_remove_ibuf(ima, i, old_tile_number);
|
||||
image_assign_ibuf(ima, ibuf, i, new_tile_number);
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, 0, old_tile_number);
|
||||
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, 0, old_tile_number, NULL);
|
||||
image_remove_ibuf(ima, 0, old_tile_number);
|
||||
image_assign_ibuf(ima, ibuf, 0, new_tile_number);
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
@ -3930,7 +3896,6 @@ bool BKE_image_fill_tile(struct Image *ima,
|
|||
if (tile_ibuf != NULL) {
|
||||
image_assign_ibuf(ima, tile_ibuf, 0, tile->tile_number);
|
||||
BKE_image_release_ibuf(ima, tile_ibuf, NULL);
|
||||
tile->ok = IMA_OK;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -4208,9 +4173,7 @@ static void image_init_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ib
|
|||
/* Images should never get loaded if the corresponding tile does not exist,
|
||||
* but we should at least not crash if it happens due to a bug elsewhere. */
|
||||
BLI_assert(tile != NULL);
|
||||
if (tile != NULL) {
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
}
|
||||
UNUSED_VARS_NDEBUG(tile);
|
||||
}
|
||||
|
||||
static int imbuf_alpha_flags_for_image(Image *ima)
|
||||
|
@ -4245,8 +4208,7 @@ static int image_num_files(Image *ima)
|
|||
return BLI_listbase_count(&ima->views);
|
||||
}
|
||||
|
||||
static ImBuf *load_sequence_single(
|
||||
Image *ima, ImageUser *iuser, int frame, const int view_id, bool *r_assign)
|
||||
static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, const int view_id)
|
||||
{
|
||||
struct ImBuf *ibuf;
|
||||
char name[FILE_MAX];
|
||||
|
@ -4296,19 +4258,11 @@ static ImBuf *load_sequence_single(
|
|||
}
|
||||
else {
|
||||
image_init_after_load(ima, iuser, ibuf);
|
||||
*r_assign = true;
|
||||
}
|
||||
#else
|
||||
image_init_after_load(ima, iuser, ibuf);
|
||||
*r_assign = true;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
||||
if (tile != NULL) {
|
||||
tile->ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
@ -4318,13 +4272,10 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int entry,
|
|||
struct ImBuf *ibuf = NULL;
|
||||
const bool is_multiview = BKE_image_is_multiview(ima);
|
||||
const int totfiles = image_num_files(ima);
|
||||
bool assign = false;
|
||||
|
||||
if (!is_multiview) {
|
||||
ibuf = load_sequence_single(ima, iuser, frame, 0, &assign);
|
||||
if (assign) {
|
||||
image_assign_ibuf(ima, ibuf, 0, entry);
|
||||
}
|
||||
ibuf = load_sequence_single(ima, iuser, frame, 0);
|
||||
image_assign_ibuf(ima, ibuf, 0, entry);
|
||||
}
|
||||
else {
|
||||
const int totviews = BLI_listbase_count(&ima->views);
|
||||
|
@ -4333,7 +4284,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int entry,
|
|||
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
||||
|
||||
for (int i = 0; i < totfiles; i++) {
|
||||
ibuf_arr[i] = load_sequence_single(ima, iuser, frame, i, &assign);
|
||||
ibuf_arr[i] = load_sequence_single(ima, iuser, frame, i);
|
||||
}
|
||||
|
||||
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
||||
|
@ -4343,10 +4294,8 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int entry,
|
|||
/* return the original requested ImBuf */
|
||||
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
|
||||
|
||||
if (assign) {
|
||||
for (int i = 0; i < totviews; i++) {
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, entry);
|
||||
}
|
||||
for (int i = 0; i < totviews; i++) {
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, entry);
|
||||
}
|
||||
|
||||
/* "remove" the others (decrease their refcount) */
|
||||
|
@ -4366,7 +4315,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int entry,
|
|||
static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int entry, int frame)
|
||||
{
|
||||
struct ImBuf *ibuf = NULL;
|
||||
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
||||
|
||||
/* either we load from RenderResult, or we have to load a new one */
|
||||
|
||||
|
@ -4408,13 +4356,6 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int e
|
|||
}
|
||||
// else printf("pass not found\n");
|
||||
}
|
||||
else {
|
||||
tile->ok = 0;
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
iuser->ok = tile->ok;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
@ -4426,8 +4367,6 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
|
|||
|
||||
ia = BLI_findlink(&ima->anims, view_id);
|
||||
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
|
||||
if (ia->anim == NULL) {
|
||||
char str[FILE_MAX];
|
||||
int flags = IB_rect;
|
||||
|
@ -4469,12 +4408,6 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
|
|||
if (ibuf) {
|
||||
image_init_after_load(ima, iuser, ibuf);
|
||||
}
|
||||
else {
|
||||
tile->ok = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tile->ok = 0;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
|
@ -4485,7 +4418,6 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
|||
struct ImBuf *ibuf = NULL;
|
||||
const bool is_multiview = BKE_image_is_multiview(ima);
|
||||
const int totfiles = image_num_files(ima);
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
|
||||
if (totfiles != BLI_listbase_count_at_most(&ima->anims, totfiles + 1)) {
|
||||
image_free_anims(ima);
|
||||
|
@ -4516,12 +4448,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
|||
}
|
||||
|
||||
for (int i = 0; i < totviews; i++) {
|
||||
if (ibuf_arr[i]) {
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, frame);
|
||||
}
|
||||
else {
|
||||
tile->ok = 0;
|
||||
}
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, frame);
|
||||
}
|
||||
|
||||
/* return the original requested ImBuf */
|
||||
|
@ -4538,19 +4465,11 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
|||
MEM_freeN(ibuf_arr);
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
iuser->ok = tile->ok;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
static ImBuf *load_image_single(Image *ima,
|
||||
ImageUser *iuser,
|
||||
int cfra,
|
||||
const int view_id,
|
||||
const bool has_packed,
|
||||
bool *r_assign)
|
||||
static ImBuf *load_image_single(
|
||||
Image *ima, ImageUser *iuser, int cfra, const int view_id, const bool has_packed)
|
||||
{
|
||||
char filepath[FILE_MAX];
|
||||
struct ImBuf *ibuf = NULL;
|
||||
|
@ -4612,7 +4531,6 @@ static ImBuf *load_image_single(Image *ima,
|
|||
#endif
|
||||
{
|
||||
image_init_after_load(ima, iuser, ibuf);
|
||||
*r_assign = true;
|
||||
|
||||
/* Make packed file for auto-pack. */
|
||||
if ((has_packed == false) && (G.fileflags & G_FILE_AUTOPACK)) {
|
||||
|
@ -4625,10 +4543,6 @@ static ImBuf *load_image_single(Image *ima,
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
||||
tile->ok = 0;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
@ -4639,7 +4553,6 @@ static ImBuf *load_image_single(Image *ima,
|
|||
static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
||||
{
|
||||
struct ImBuf *ibuf = NULL;
|
||||
bool assign = false;
|
||||
const bool is_multiview = BKE_image_is_multiview(ima);
|
||||
const int totfiles = image_num_files(ima);
|
||||
bool has_packed = BKE_image_has_packedfile(ima);
|
||||
|
@ -4656,10 +4569,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|||
}
|
||||
|
||||
if (!is_multiview) {
|
||||
ibuf = load_image_single(ima, iuser, cfra, 0, has_packed, &assign);
|
||||
if (assign) {
|
||||
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
||||
}
|
||||
ibuf = load_image_single(ima, iuser, cfra, 0, has_packed);
|
||||
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
||||
}
|
||||
else {
|
||||
struct ImBuf **ibuf_arr;
|
||||
|
@ -4669,7 +4580,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|||
ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
||||
|
||||
for (int i = 0; i < totfiles; i++) {
|
||||
ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, has_packed, &assign);
|
||||
ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, has_packed);
|
||||
}
|
||||
|
||||
/* multi-views/multi-layers OpenEXR files directly populate ima, and return NULL ibuf... */
|
||||
|
@ -4682,10 +4593,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|||
int i = (iuser && iuser->multi_index < totviews) ? iuser->multi_index : 0;
|
||||
ibuf = ibuf_arr[i];
|
||||
|
||||
if (assign) {
|
||||
for (i = 0; i < totviews; i++) {
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, 0);
|
||||
}
|
||||
for (i = 0; i < totviews; i++) {
|
||||
image_assign_ibuf(ima, ibuf_arr[i], i, 0);
|
||||
}
|
||||
|
||||
/* "remove" the others (decrease their refcount) */
|
||||
|
@ -4699,11 +4608,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|||
MEM_freeN(ibuf_arr);
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
iuser->ok = tile->ok;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
|
@ -4736,14 +4640,6 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
|
|||
}
|
||||
}
|
||||
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
if (ibuf == NULL) {
|
||||
tile->ok = 0;
|
||||
}
|
||||
if (iuser) {
|
||||
iuser->ok = tile->ok;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
|
@ -4861,7 +4757,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
|||
}
|
||||
}
|
||||
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0, NULL);
|
||||
|
||||
/* make ibuf if needed, and initialize it */
|
||||
if (ibuf == NULL) {
|
||||
|
@ -4938,9 +4834,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
|||
|
||||
ibuf->dither = dither;
|
||||
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
|
@ -4997,7 +4890,8 @@ static void image_get_entry_and_index(Image *ima, ImageUser *iuser, int *r_entry
|
|||
* call IMB_freeImBuf to de-reference the image buffer after
|
||||
* it's done handling it.
|
||||
*/
|
||||
static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_entry, int *r_index)
|
||||
static ImBuf *image_get_cached_ibuf(
|
||||
Image *ima, ImageUser *iuser, int *r_entry, int *r_index, bool *r_is_cached_empty)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
int entry = 0, index = image_get_multiview_index(ima, iuser);
|
||||
|
@ -5005,42 +4899,30 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_entry,
|
|||
/* see if we already have an appropriate ibuf, with image source and type */
|
||||
if (ima->source == IMA_SRC_MOVIE) {
|
||||
entry = iuser ? iuser->framenr : ima->lastframe;
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry, r_is_cached_empty);
|
||||
ima->lastframe = entry;
|
||||
}
|
||||
else if (ima->source == IMA_SRC_SEQUENCE) {
|
||||
if (ima->type == IMA_TYPE_IMAGE) {
|
||||
entry = iuser ? iuser->framenr : ima->lastframe;
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry, r_is_cached_empty);
|
||||
ima->lastframe = entry;
|
||||
|
||||
/* counter the fact that image is set as invalid when loading a frame
|
||||
* that is not in the cache (through image_acquire_ibuf for instance),
|
||||
* yet we have valid frames in the cache loaded */
|
||||
if (ibuf) {
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
|
||||
if (iuser) {
|
||||
iuser->ok = tile->ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
||||
entry = iuser ? iuser->framenr : ima->lastframe;
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry, r_is_cached_empty);
|
||||
}
|
||||
}
|
||||
else if (ima->source == IMA_SRC_FILE) {
|
||||
if (ima->type == IMA_TYPE_IMAGE) {
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0, r_is_cached_empty);
|
||||
}
|
||||
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0, r_is_cached_empty);
|
||||
}
|
||||
}
|
||||
else if (ima->source == IMA_SRC_GENERATED) {
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0, r_is_cached_empty);
|
||||
}
|
||||
else if (ima->source == IMA_SRC_VIEWER) {
|
||||
/* always verify entirely, not that this shouldn't happen
|
||||
|
@ -5050,17 +4932,7 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_entry,
|
|||
else if (ima->source == IMA_SRC_TILED) {
|
||||
if (ELEM(ima->type, IMA_TYPE_IMAGE, IMA_TYPE_MULTILAYER)) {
|
||||
entry = image_get_tile_number_from_iuser(ima, iuser);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
||||
|
||||
if ((ima->type == IMA_TYPE_IMAGE) && ibuf != NULL) {
|
||||
ImageTile *tile = BKE_image_get_tile(ima, entry);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
|
||||
/* iuser->ok is useless for tiled images because iuser->tile changes all the time. */
|
||||
if (iuser != NULL) {
|
||||
iuser->ok = 1;
|
||||
}
|
||||
}
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry, r_is_cached_empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5081,19 +4953,10 @@ BLI_INLINE bool image_quick_test(Image *ima, const ImageUser *iuser)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (iuser) {
|
||||
if (iuser->ok == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
||||
if (tile == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (tile->ok == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5116,7 +4979,11 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ibuf = image_get_cached_ibuf(ima, iuser, &entry, &index);
|
||||
bool is_cached_empty = false;
|
||||
ibuf = image_get_cached_ibuf(ima, iuser, &entry, &index, &is_cached_empty);
|
||||
if (is_cached_empty) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ibuf == NULL) {
|
||||
/* we are sure we have to load the ibuf, using source and type */
|
||||
|
@ -5178,8 +5045,6 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
|||
ima->gen_color,
|
||||
&ima->colorspace_settings);
|
||||
image_assign_ibuf(ima, ibuf, index, 0);
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
}
|
||||
else if (ima->source == IMA_SRC_VIEWER) {
|
||||
if (ima->type == IMA_TYPE_R_RESULT) {
|
||||
|
@ -5196,7 +5061,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
|||
|
||||
/* XXX anim play for viewer nodes not yet supported */
|
||||
entry = 0; // XXX iuser ? iuser->framenr : 0;
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
||||
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry, NULL);
|
||||
|
||||
if (!ibuf) {
|
||||
/* Composite Viewer, all handled in compositor */
|
||||
|
@ -5271,7 +5136,7 @@ bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
|
|||
|
||||
BLI_mutex_lock(image_mutex);
|
||||
|
||||
ibuf = image_get_cached_ibuf(ima, iuser, NULL, NULL);
|
||||
ibuf = image_get_cached_ibuf(ima, iuser, NULL, NULL, NULL);
|
||||
|
||||
if (!ibuf) {
|
||||
ibuf = image_acquire_ibuf(ima, iuser, NULL);
|
||||
|
@ -5492,18 +5357,6 @@ void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
|
|||
ima->gpuframenr = iuser->framenr;
|
||||
}
|
||||
|
||||
if (iuser->ok == 0) {
|
||||
iuser->ok = 1;
|
||||
}
|
||||
|
||||
if (ima) {
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
||||
if (tile->ok == 0) {
|
||||
tile->ok = IMA_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iuser->flag &= ~IMA_NEED_FRAME_RECALC;
|
||||
}
|
||||
}
|
||||
|
@ -5789,7 +5642,7 @@ bool BKE_image_is_dirty_writable(Image *image, bool *r_is_writable)
|
|||
|
||||
while (!IMB_moviecacheIter_done(iter)) {
|
||||
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||
if (ibuf->userflags & IB_BITMAPDIRTY) {
|
||||
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
|
||||
is_writable = BKE_image_buffer_format_writable(ibuf);
|
||||
is_dirty = true;
|
||||
break;
|
||||
|
@ -5833,8 +5686,10 @@ void BKE_image_file_format_set(Image *image, int ftype, const ImbFormatOptions *
|
|||
|
||||
while (!IMB_moviecacheIter_done(iter)) {
|
||||
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||
ibuf->ftype = ftype;
|
||||
ibuf->foptions = *options;
|
||||
if (ibuf != NULL) {
|
||||
ibuf->ftype = ftype;
|
||||
ibuf->foptions = *options;
|
||||
}
|
||||
IMB_moviecacheIter_step(iter);
|
||||
}
|
||||
IMB_moviecacheIter_free(iter);
|
||||
|
@ -5875,7 +5730,7 @@ ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
|
|||
|
||||
while (!IMB_moviecacheIter_done(iter)) {
|
||||
ImBuf *current_ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||
if (STREQ(current_ibuf->name, name)) {
|
||||
if (current_ibuf != NULL && STREQ(current_ibuf->name, name)) {
|
||||
ibuf = current_ibuf;
|
||||
IMB_refImBuf(ibuf);
|
||||
break;
|
||||
|
@ -5908,7 +5763,9 @@ ImBuf *BKE_image_get_first_ibuf(Image *image)
|
|||
|
||||
while (!IMB_moviecacheIter_done(iter)) {
|
||||
ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||
IMB_refImBuf(ibuf);
|
||||
if (ibuf != NULL) {
|
||||
IMB_refImBuf(ibuf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
IMB_moviecacheIter_free(iter);
|
||||
|
|
|
@ -373,15 +373,14 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
/* Check if image has been updated and tagged to be updated (full or partial). */
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
if (((ima->gpuflag & IMA_GPU_REFRESH) != 0) ||
|
||||
((ibuf == NULL || tile == NULL || !tile->ok) &&
|
||||
((ima->gpuflag & IMA_GPU_PARTIAL_REFRESH) != 0))) {
|
||||
((ibuf == NULL || tile == NULL) && ((ima->gpuflag & IMA_GPU_PARTIAL_REFRESH) != 0))) {
|
||||
image_free_gpu(ima, true);
|
||||
BLI_freelistN(&ima->gpu_refresh_areas);
|
||||
ima->gpuflag &= ~(IMA_GPU_REFRESH | IMA_GPU_PARTIAL_REFRESH);
|
||||
}
|
||||
else if (ima->gpuflag & IMA_GPU_PARTIAL_REFRESH) {
|
||||
BLI_assert(ibuf);
|
||||
BLI_assert(tile && tile->ok);
|
||||
BLI_assert(tile);
|
||||
ImagePartialRefresh *refresh_area;
|
||||
while ((refresh_area = BLI_pophead(&ima->gpu_refresh_areas))) {
|
||||
const int tile_offset_x = refresh_area->tile_x * IMA_PARTIAL_REFRESH_TILE_SIZE;
|
||||
|
@ -417,7 +416,7 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
|
||||
/* Check if we have a valid image. If not, we return a dummy
|
||||
* texture with zero bind-code so we don't keep trying. */
|
||||
if (tile == NULL || tile->ok == 0) {
|
||||
if (tile == NULL) {
|
||||
*tex = image_gpu_texture_error_create(textarget);
|
||||
return *tex;
|
||||
}
|
||||
|
|
|
@ -842,7 +842,7 @@ static ImBuf *get_imbuf_cache(MovieClip *clip, const MovieClipUser *user, int fl
|
|||
key.render_flag = 0;
|
||||
}
|
||||
|
||||
return IMB_moviecache_get(clip->cache->moviecache, &key);
|
||||
return IMB_moviecache_get(clip->cache->moviecache, &key, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -748,13 +748,11 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
|
|||
}
|
||||
case SH_NODE_TEX_IMAGE: {
|
||||
NodeTexImage *tex = (NodeTexImage *)node->storage;
|
||||
tex->iuser.ok = 1;
|
||||
tex->iuser.scene = nullptr;
|
||||
break;
|
||||
}
|
||||
case SH_NODE_TEX_ENVIRONMENT: {
|
||||
NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage;
|
||||
tex->iuser.ok = 1;
|
||||
tex->iuser.scene = nullptr;
|
||||
break;
|
||||
}
|
||||
|
@ -763,7 +761,6 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
|
|||
case CMP_NODE_VIEWER:
|
||||
case CMP_NODE_SPLITVIEWER: {
|
||||
ImageUser *iuser = (ImageUser *)node->storage;
|
||||
iuser->ok = 1;
|
||||
iuser->scene = nullptr;
|
||||
break;
|
||||
}
|
||||
|
@ -777,7 +774,6 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
|
|||
}
|
||||
case TEX_NODE_IMAGE: {
|
||||
ImageUser *iuser = (ImageUser *)node->storage;
|
||||
iuser->ok = 1;
|
||||
iuser->scene = nullptr;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4150,7 +4150,6 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value)
|
|||
if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
||||
if (!ob->iuser) {
|
||||
ob->iuser = MEM_callocN(sizeof(ImageUser), "image user");
|
||||
ob->iuser->ok = 1;
|
||||
ob->iuser->flag |= IMA_ANIM_ALWAYS;
|
||||
ob->iuser->frames = 100;
|
||||
ob->iuser->sfra = 1;
|
||||
|
|
|
@ -1624,7 +1624,6 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
|
|||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->iuser.scene = NULL;
|
||||
sima->iuser.ok = 1;
|
||||
sima->scopes.waveform_1 = NULL;
|
||||
sima->scopes.waveform_2 = NULL;
|
||||
sima->scopes.waveform_3 = NULL;
|
||||
|
|
|
@ -184,7 +184,6 @@ static void texture_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLO_read_data_address(reader, &tex->preview);
|
||||
BKE_previewimg_blend_read(reader, tex->preview);
|
||||
|
||||
tex->iuser.ok = 1;
|
||||
tex->iuser.scene = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1384,7 +1384,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
tex->iuser.frames = 1;
|
||||
tex->iuser.sfra = 1;
|
||||
tex->iuser.ok = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4517,7 +4517,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "tiles")) {
|
||||
for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
|
||||
ImageTile *tile = MEM_callocN(sizeof(ImageTile), "Image Tile");
|
||||
tile->ok = 1;
|
||||
tile->tile_number = 1001;
|
||||
BLI_addtail(&ima->tiles, tile);
|
||||
}
|
||||
|
|
|
@ -391,7 +391,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree)
|
|||
iuser->sfra = nia->sfra;
|
||||
iuser->offset = nia->nr - 1;
|
||||
iuser->cycl = nia->cyclic;
|
||||
iuser->ok = 1;
|
||||
|
||||
node->storage = iuser;
|
||||
MEM_freeN(nia);
|
||||
|
@ -399,7 +398,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree)
|
|||
else {
|
||||
ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user");
|
||||
iuser->sfra = 1;
|
||||
iuser->ok = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,8 +173,6 @@ void ViewerOperation::init_image()
|
|||
if (ibuf->x > 0 && ibuf->y > 0) {
|
||||
imb_addrectfloatImBuf(ibuf);
|
||||
}
|
||||
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
||||
tile->ok = IMA_OK_LOADED;
|
||||
|
||||
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_
|
|||
struct GPUTexture *gpu_tex = NULL;
|
||||
void *lock;
|
||||
|
||||
iuser.ok = true;
|
||||
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||
|
||||
if (ibuf != NULL && ibuf->rect != NULL) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void IMB_moviecache_set_priority_callback(struct MovieCache *cache,
|
|||
|
||||
void IMB_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
|
||||
bool IMB_moviecache_put_if_possible(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
|
||||
struct ImBuf *IMB_moviecache_get(struct MovieCache *cache, void *userkey);
|
||||
struct ImBuf *IMB_moviecache_get(struct MovieCache *cache, void *userkey, bool *r_is_cached_empty);
|
||||
void IMB_moviecache_remove(struct MovieCache *cache, void *userkey);
|
||||
bool IMB_moviecache_has_frame(struct MovieCache *cache, void *userkey);
|
||||
void IMB_moviecache_free(struct MovieCache *cache);
|
||||
|
|
|
@ -342,7 +342,7 @@ static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf,
|
|||
|
||||
*cache_handle = NULL;
|
||||
|
||||
cache_ibuf = IMB_moviecache_get(moviecache, key);
|
||||
cache_ibuf = IMB_moviecache_get(moviecache, key, NULL);
|
||||
|
||||
*cache_handle = cache_ibuf;
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ typedef struct MovieCacheItem {
|
|||
ImBuf *ibuf;
|
||||
MEM_CacheLimiterHandleC *c_handle;
|
||||
void *priority_data;
|
||||
/* Indicates that #ibuf is null, because there was an error during load. */
|
||||
bool added_empty;
|
||||
} MovieCacheItem;
|
||||
|
||||
static unsigned int moviecache_hashhash(const void *keyv)
|
||||
|
@ -141,11 +143,16 @@ static void check_unused_keys(MovieCache *cache)
|
|||
while (!BLI_ghashIterator_done(&gh_iter)) {
|
||||
const MovieCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
|
||||
const MovieCacheItem *item = BLI_ghashIterator_getValue(&gh_iter);
|
||||
bool remove;
|
||||
|
||||
BLI_ghashIterator_step(&gh_iter);
|
||||
|
||||
remove = !item->ibuf;
|
||||
if (item->added_empty) {
|
||||
/* Don't remove entries that have been added empty. Those indicate that the image couldn't be
|
||||
* loaded correctly. */
|
||||
continue;
|
||||
}
|
||||
|
||||
bool remove = !item->ibuf;
|
||||
|
||||
if (remove) {
|
||||
PRINT("%s: cache '%s' remove item %p without buffer\n", __func__, cache->name, item);
|
||||
|
@ -309,7 +316,9 @@ static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, boo
|
|||
IMB_moviecache_init();
|
||||
}
|
||||
|
||||
IMB_refImBuf(ibuf);
|
||||
if (ibuf != NULL) {
|
||||
IMB_refImBuf(ibuf);
|
||||
}
|
||||
|
||||
key = BLI_mempool_alloc(cache->keys_pool);
|
||||
key->cache_owner = cache;
|
||||
|
@ -324,6 +333,7 @@ static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, boo
|
|||
item->cache_owner = cache;
|
||||
item->c_handle = NULL;
|
||||
item->priority_data = NULL;
|
||||
item->added_empty = ibuf == NULL;
|
||||
|
||||
if (cache->getprioritydatafp) {
|
||||
item->priority_data = cache->getprioritydatafp(userkey);
|
||||
|
@ -365,7 +375,7 @@ bool IMB_moviecache_put_if_possible(MovieCache *cache, void *userkey, ImBuf *ibu
|
|||
size_t mem_in_use, mem_limit, elem_size;
|
||||
bool result = false;
|
||||
|
||||
elem_size = get_size_in_memory(ibuf);
|
||||
elem_size = (ibuf == NULL) ? 0 : get_size_in_memory(ibuf);
|
||||
mem_limit = MEM_CacheLimiter_get_maximum();
|
||||
|
||||
BLI_mutex_lock(&limitor_lock);
|
||||
|
@ -389,7 +399,7 @@ void IMB_moviecache_remove(MovieCache *cache, void *userkey)
|
|||
BLI_ghash_remove(cache->hash, &key, moviecache_keyfree, moviecache_valfree);
|
||||
}
|
||||
|
||||
ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey)
|
||||
ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey, bool *r_is_cached_empty)
|
||||
{
|
||||
MovieCacheKey key;
|
||||
MovieCacheItem *item;
|
||||
|
@ -398,6 +408,10 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey)
|
|||
key.userkey = userkey;
|
||||
item = (MovieCacheItem *)BLI_ghash_lookup(cache->hash, &key);
|
||||
|
||||
if (r_is_cached_empty) {
|
||||
*r_is_cached_empty = false;
|
||||
}
|
||||
|
||||
if (item) {
|
||||
if (item->ibuf) {
|
||||
BLI_mutex_lock(&limitor_lock);
|
||||
|
@ -408,6 +422,9 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey)
|
|||
|
||||
return item->ibuf;
|
||||
}
|
||||
if (r_is_cached_empty) {
|
||||
*r_is_cached_empty = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -51,16 +51,13 @@ typedef struct ImageUser {
|
|||
/** Offset within movie, start frame in global time. */
|
||||
int offset, sfra;
|
||||
/** Cyclic flag. */
|
||||
char _pad0, cycl;
|
||||
char ok;
|
||||
char cycl;
|
||||
|
||||
/** Multiview current eye - for internal use of drawing routines. */
|
||||
char multiview_eye;
|
||||
short pass;
|
||||
char _pad1[2];
|
||||
|
||||
int tile;
|
||||
int _pad2;
|
||||
|
||||
/** Listbase indices, for menu browsing or retrieve buffer. */
|
||||
short multi_index, view, layer;
|
||||
|
@ -112,9 +109,7 @@ typedef struct ImageTile {
|
|||
|
||||
struct ImageTile_Runtime runtime;
|
||||
|
||||
char ok;
|
||||
char _pad[3];
|
||||
|
||||
char _pad[4];
|
||||
int tile_number;
|
||||
char label[64];
|
||||
} ImageTile;
|
||||
|
|
|
@ -75,7 +75,6 @@ static void rna_Image_save_render(
|
|||
void *lock;
|
||||
|
||||
iuser.scene = scene;
|
||||
iuser.ok = 1;
|
||||
|
||||
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree,
|
|||
* So we manually construct image user to be sure first
|
||||
* image from sequence (that one which is set as filename
|
||||
* for image data-block) is used for sockets detection. */
|
||||
load_iuser.ok = 1;
|
||||
load_iuser.framenr = offset;
|
||||
|
||||
/* make sure ima->type is correct */
|
||||
|
@ -411,7 +410,6 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
|
|||
node->storage = iuser;
|
||||
iuser->frames = 1;
|
||||
iuser->sfra = 1;
|
||||
iuser->ok = 1;
|
||||
iuser->flag |= IMA_ANIM_ALWAYS;
|
||||
|
||||
/* setup initial outputs */
|
||||
|
|
|
@ -38,7 +38,6 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
|
|||
ImageUser *iuser = (ImageUser *)MEM_callocN(sizeof(ImageUser), "node image user");
|
||||
node->storage = iuser;
|
||||
iuser->sfra = 1;
|
||||
iuser->ok = 1;
|
||||
node->custom1 = 50; /* default 50% split */
|
||||
|
||||
node->id = (ID *)BKE_image_ensure_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
|
|
|
@ -44,7 +44,6 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
ImageUser *iuser = (ImageUser *)MEM_callocN(sizeof(ImageUser), "node image user");
|
||||
node->storage = iuser;
|
||||
iuser->sfra = 1;
|
||||
iuser->ok = 1;
|
||||
node->custom3 = 0.5f;
|
||||
node->custom4 = 0.5f;
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
|
||||
node->storage = iuser;
|
||||
iuser->sfra = 1;
|
||||
iuser->ok = 1;
|
||||
iuser->flag |= IMA_ANIM_ALWAYS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue