Blender
V4.3
source
blender
compositor
realtime_compositor
cached_resources
COM_cached_image.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include <cstdint>
8
#include <memory>
9
#include <string>
10
11
#include "
BLI_map.hh
"
12
13
#include "
GPU_texture.hh
"
14
15
#include "
DNA_image_types.h
"
16
17
#include "
COM_cached_resource.hh
"
18
#include "
COM_result.hh
"
19
20
namespace
blender::realtime_compositor
{
21
22
class
Context
;
23
24
/* ------------------------------------------------------------------------------------------------
25
* Cached Image Key.
26
*/
27
class
CachedImageKey
{
28
public
:
29
ImageUser
image_user
;
30
std::string
pass_name
;
31
32
CachedImageKey
(
ImageUser
image_user
, std::string
pass_name
);
33
34
uint64_t
hash
()
const
;
35
};
36
37
bool
operator==
(
const
CachedImageKey
&a,
const
CachedImageKey
&
b
);
38
39
/* -------------------------------------------------------------------------------------------------
40
* Cached Image.
41
*
42
* A cached resource that computes and caches a result containing the contents of the image with
43
* the given image user. */
44
class
CachedImage
:
public
CachedResource
{
45
public
:
46
Result
result
;
47
48
private
:
49
/* For GPU, the result wraps an external GPU texture that is generated by the IMB module and
50
* stored in this member to be freed when the cached resource is deleted. */
51
GPUTexture *texture_ =
nullptr
;
52
53
public
:
54
CachedImage
(
Context
&context,
Image
*
image
,
ImageUser
*image_user,
const
char
*pass_name);
55
56
~CachedImage
();
57
};
58
59
/* ------------------------------------------------------------------------------------------------
60
* Cached Image Container.
61
*/
62
class
CachedImageContainer
:
CachedResourceContainer
{
63
private
:
64
Map<std::string, Map<CachedImageKey, std::unique_ptr<CachedImage>
>> map_;
65
66
public
:
67
void
reset
()
override
;
68
69
/* Check if the given image ID has changed since the last time it was retrieved through its
70
* recalculate flag, and if so, invalidate its corresponding cached image and reset the
71
* recalculate flag to ready it to track the next change. Then, check if there is an available
72
* CachedImage cached resource with the given image user and pass_name in the container, if one
73
* exists, return it, otherwise, return a newly created one and add it to the container. In both
74
* cases, tag the cached resource as needed to keep it cached for the next evaluation. */
75
Result
*
get
(
Context
&context,
Image
*
image
,
const
ImageUser
*image_user,
const
char
*pass_name);
76
};
77
78
}
// namespace blender::realtime_compositor
BLI_map.hh
COM_cached_resource.hh
COM_result.hh
DNA_image_types.h
GPU_texture.hh
blender::Map
Definition
BLI_map.hh:129
blender::realtime_compositor::CachedImageContainer
Definition
COM_cached_image.hh:62
blender::realtime_compositor::CachedImageContainer::get
Result * get(Context &context, Image *image, const ImageUser *image_user, const char *pass_name)
Definition
cached_image.cc:274
blender::realtime_compositor::CachedImageContainer::reset
void reset() override
Definition
cached_image.cc:257
blender::realtime_compositor::CachedImageKey
Definition
COM_cached_image.hh:27
blender::realtime_compositor::CachedImageKey::hash
uint64_t hash() const
Definition
cached_image.cc:44
blender::realtime_compositor::CachedImageKey::pass_name
std::string pass_name
Definition
COM_cached_image.hh:30
blender::realtime_compositor::CachedImageKey::CachedImageKey
CachedImageKey(ImageUser image_user, std::string pass_name)
Definition
cached_image.cc:39
blender::realtime_compositor::CachedImageKey::image_user
ImageUser image_user
Definition
COM_cached_image.hh:29
blender::realtime_compositor::CachedImage::CachedImage
CachedImage(Context &context, Image *image, ImageUser *image_user, const char *pass_name)
Definition
cached_image.cc:191
blender::realtime_compositor::CachedImage::result
Result result
Definition
COM_cached_image.hh:46
blender::realtime_compositor::CachedImage::~CachedImage
~CachedImage()
Definition
cached_image.cc:247
blender::realtime_compositor::CachedResourceContainer
Definition
COM_cached_resource.hh:43
blender::realtime_compositor::CachedResource
Definition
COM_cached_resource.hh:26
blender::realtime_compositor::Context
Definition
COM_context.hh:37
blender::realtime_compositor::Result
Definition
COM_result.hh:92
image
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
b
local_group_size(16, 16) .push_constant(Type b
Definition
compositor_morphological_distance_info.hh:16
blender::realtime_compositor
Definition
BKE_node.hh:80
blender::realtime_compositor::operator==
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
Definition
bokeh_kernel.cc:42
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:90
ImageUser
Definition
DNA_image_types.h:26
Image
Definition
DNA_image_types.h:142
Generated on Sat Oct 4 2025 05:32:23 for Blender by
doxygen
1.14.0