Blender V5.0
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 public:
53
54 CachedMask(Context &context,
55 Mask *mask,
56 int2 size,
57 int frame,
58 float aspect_ratio,
59 bool use_feather,
60 int motion_blur_samples,
61 float motion_blur_shutter);
62
64};
65
66/* ------------------------------------------------------------------------------------------------
67 * Cached Mask Container.
68 */
70 private:
72
73 /* A map that stores the update counts of the masks at the moment they were cached. */
74 Map<std::string, uint64_t> update_counts_;
75
76 public:
77 void reset() override;
78
79 /* Check if the given mask ID has changed since the last time it was retrieved through its
80 * recalculate flag, and if so, invalidate its corresponding cached mask and reset the
81 * recalculate flag to ready it to track the next change. Then, check if there is an available
82 * CachedMask cached resource with the given parameters in the container, if one exists, return
83 * it, otherwise, return a newly created one and add it to the container. In both cases, tag the
84 * cached resource as needed to keep it cached for the next evaluation. */
85 Result &get(Context &context,
86 Mask *mask,
87 int2 size,
88 float aspect_ratio,
89 bool use_feather,
90 int motion_blur_samples,
91 float motion_blur_shutter);
92};
93
94} // 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