Blender V4.3
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
18#include "COM_result.hh"
19
21
22class Context;
23
24/* ------------------------------------------------------------------------------------------------
25 * Cached Image Key.
26 */
28 public:
30 std::string pass_name;
31
33
34 uint64_t hash() const;
35};
36
37bool 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. */
45 public:
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
57};
58
59/* ------------------------------------------------------------------------------------------------
60 * Cached Image Container.
61 */
63 private:
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
Result * get(Context &context, Image *image, const ImageUser *image_user, const char *pass_name)
CachedImageKey(ImageUser image_user, std::string pass_name)
CachedImage(Context &context, Image *image, ImageUser *image_user, const char *pass_name)
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
unsigned __int64 uint64_t
Definition stdint.h:90