Blender V4.5
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 "DNA_mask_types.h"
15
17#include "COM_result.hh"
18
19namespace blender::compositor {
20
21class Context;
22
23/* ------------------------------------------------------------------------------------------------
24 * Cached Mask Key.
25 */
42
43bool operator==(const CachedMaskKey &a, const CachedMaskKey &b);
44
45/* -------------------------------------------------------------------------------------------------
46 * Cached Mask.
47 *
48 * A cached resource that computes and caches a result containing the result of evaluating the
49 * given mask ID on a space that spans the given size, parameterized by the given parameters. */
50class CachedMask : public CachedResource {
51 private:
52 Array<float> evaluated_mask_;
53
54 public:
56
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
69/* ------------------------------------------------------------------------------------------------
70 * Cached Mask Container.
71 */
73 private:
75
76 /* A map that stores the update counts of the masks at the moment they were cached. */
77 Map<std::string, uint64_t> update_counts_;
78
79 public:
80 void reset() override;
81
82 /* Check if the given mask ID has changed since the last time it was retrieved through its
83 * recalculate flag, and if so, invalidate its corresponding cached mask and reset the
84 * recalculate flag to ready it to track the next change. Then, check if there is an available
85 * CachedMask cached resource with the given parameters in the container, if one exists, return
86 * it, otherwise, return a newly created one and add it to the container. In both cases, tag the
87 * cached resource as needed to keep it cached for the next evaluation. */
88 Result &get(Context &context,
89 Mask *mask,
90 int2 size,
91 float aspect_ratio,
92 bool use_feather,
93 int motion_blur_samples,
94 float motion_blur_shutter);
95};
96
97} // namespace blender::compositor
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
Result & 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)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
VecBase< int32_t, 2 > int2