Blender V5.0
COM_bokeh_kernel.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
10#include "BLI_map.hh"
12
14#include "COM_result.hh"
15
16namespace blender::compositor {
17
18class Context;
19
20/* ------------------------------------------------------------------------------------------------
21 * Bokeh Kernel Key.
22 */
24 public:
26 int sides;
27 float rotation;
28 float roundness;
31
33 int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift);
34
35 uint64_t hash() const;
36};
37
38bool operator==(const BokehKernelKey &a, const BokehKernelKey &b);
39
40/* -------------------------------------------------------------------------------------------------
41 * Bokeh Kernel.
42 *
43 * A cached resource that computes and caches a result containing the unnormalized convolution
44 * kernel, which when convolved with an image emulates a bokeh lens with the given parameters. */
46 public:
48
49 BokehKernel(Context &context,
50 int2 size,
51 int sides,
52 float rotation,
53 float roundness,
54 float catadioptric,
55 float lens_shift);
56
58
59 private:
60 void compute_gpu(Context &context,
61 const int sides,
62 const float rotation,
63 const float roundness,
64 const float catadioptric,
65 const float lens_shift);
66
67 void compute_cpu(const int sides,
68 const float rotation,
69 const float roundness,
70 const float catadioptric,
71 const float lens_shift);
72};
73
74/* ------------------------------------------------------------------------------------------------
75 * Bokeh Kernel Container.
76 */
78 private:
80
81 public:
82 void reset() override;
83
84 /* Check if there is an available BokehKernel cached resource with the given parameters in the
85 * container, if one exists, return it, otherwise, return a newly created one and add it to the
86 * container. In both cases, tag the cached resource as needed to keep it cached for the next
87 * evaluation. */
88 Result &get(Context &context,
89 int2 size,
90 int sides,
91 float rotation,
92 float roundness,
93 float catadioptric,
94 float lens_shift);
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, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
BokehKernelKey(int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
BokehKernel(Context &context, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
VecBase< int32_t, 2 > int2