Refactor: Return cached image by value
Return cached image by value for consistency with other cached resources.
This commit is contained in:
@@ -72,7 +72,7 @@ class CachedImageContainer : CachedResourceContainer {
|
||||
* CachedImage cached resource with the given image user and pass_name in the container, if one
|
||||
* exists, return it, otherwise, return a newly created one and add it to the container. In both
|
||||
* cases, tag the cached resource as needed to keep it cached for the next evaluation. */
|
||||
Result *get(Context &context, Image *image, const ImageUser *image_user, const char *pass_name);
|
||||
Result get(Context &context, Image *image, const ImageUser *image_user, const char *pass_name);
|
||||
};
|
||||
|
||||
} // namespace blender::realtime_compositor
|
||||
|
||||
@@ -271,13 +271,13 @@ void CachedImageContainer::reset()
|
||||
}
|
||||
}
|
||||
|
||||
Result *CachedImageContainer::get(Context &context,
|
||||
Image *image,
|
||||
const ImageUser *image_user,
|
||||
const char *pass_name)
|
||||
Result CachedImageContainer::get(Context &context,
|
||||
Image *image,
|
||||
const ImageUser *image_user,
|
||||
const char *pass_name)
|
||||
{
|
||||
if (!image || !image_user) {
|
||||
return nullptr;
|
||||
return Result(context);
|
||||
}
|
||||
|
||||
/* Compute the effective frame number of the image if it was animated. */
|
||||
@@ -300,7 +300,7 @@ Result *CachedImageContainer::get(Context &context,
|
||||
});
|
||||
|
||||
cached_image.needed = true;
|
||||
return &cached_image.result;
|
||||
return cached_image.result;
|
||||
}
|
||||
|
||||
} // namespace blender::realtime_compositor
|
||||
|
||||
@@ -631,9 +631,9 @@ class CryptoMatteOperation : public BaseCryptoMatteOperation {
|
||||
continue;
|
||||
}
|
||||
|
||||
Result *pass_result = context().cache_manager().cached_images.get(
|
||||
Result pass_result = context().cache_manager().cached_images.get(
|
||||
context(), image, &image_user_for_layer, render_pass->name);
|
||||
layers.append(*pass_result);
|
||||
layers.append(pass_result);
|
||||
}
|
||||
|
||||
/* If we already found Cryptomatte layers, no need to check other render layers. */
|
||||
|
||||
@@ -459,22 +459,22 @@ class ImageOperation : public NodeOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
Result *cached_image = context().cache_manager().cached_images.get(
|
||||
Result cached_image = context().cache_manager().cached_images.get(
|
||||
context(), get_image(), get_image_user(), get_pass_name(identifier));
|
||||
|
||||
Result &result = get_result(identifier);
|
||||
if (!cached_image || !cached_image->is_allocated()) {
|
||||
if (!cached_image.is_allocated()) {
|
||||
result.allocate_invalid();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Alpha is not an actual pass, but one that is extracted from the combined pass. */
|
||||
if (identifier == "Alpha") {
|
||||
extract_alpha(context(), *cached_image, result);
|
||||
extract_alpha(context(), cached_image, result);
|
||||
}
|
||||
else {
|
||||
result.set_precision(cached_image->precision());
|
||||
result.wrap_external(*cached_image);
|
||||
result.set_precision(cached_image.precision());
|
||||
result.wrap_external(cached_image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user