Blender V4.3
COM_cached_mask.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"
13
14#include "GPU_texture.hh"
15
16#include "DNA_mask_types.h"
17#include "DNA_scene_types.h"
18
20
22
23class Context;
24
25/* ------------------------------------------------------------------------------------------------
26 * Cached Mask Key.
27 */
29 public:
35
37 float aspect_ratio,
38 bool use_feather,
41
42 uint64_t hash() const;
43};
44
45bool operator==(const CachedMaskKey &a, const CachedMaskKey &b);
46
47/* -------------------------------------------------------------------------------------------------
48 * Cached Mask.
49 *
50 * A cached resource that computes and caches a GPU texture containing the result of evaluating the
51 * given mask ID on a space that spans the given size, parameterized by the given parameters. */
52class CachedMask : public CachedResource {
53 private:
54 GPUTexture *texture_ = nullptr;
55
56 public:
57 CachedMask(Context &context,
58 Mask *mask,
59 int2 size,
60 int frame,
61 float aspect_ratio,
62 bool use_feather,
63 int motion_blur_samples,
64 float motion_blur_shutter);
65
67
68 GPUTexture *texture();
69};
70
71/* ------------------------------------------------------------------------------------------------
72 * Cached Mask Container.
73 */
75 private:
77
78 public:
79 void reset() override;
80
81 /* Check if the given mask ID has changed since the last time it was retrieved through its
82 * recalculate flag, and if so, invalidate its corresponding cached mask and reset the
83 * recalculate flag to ready it to track the next change. Then, check if there is an available
84 * CachedMask cached resource with the given parameters in the container, if one exists, return
85 * it, otherwise, return a newly created one and add it to the container. In both cases, tag the
86 * cached resource as needed to keep it cached for the next evaluation. */
87 CachedMask &get(Context &context,
88 Mask *mask,
89 int2 size,
90 float aspect_ratio,
91 bool use_feather,
92 int motion_blur_samples,
93 float motion_blur_shutter);
94};
95
96} // namespace blender::realtime_compositor
CachedMask & get(Context &context, Mask *mask, int2 size, float aspect_ratio, bool use_feather, int motion_blur_samples, float motion_blur_shutter)
CachedMaskKey(int2 size, float aspect_ratio, bool use_feather, int motion_blur_samples, float motion_blur_shutter)
CachedMask(Context &context, Mask *mask, int2 size, int frame, float aspect_ratio, bool use_feather, int motion_blur_samples, float motion_blur_shutter)
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