Blender V5.0
COM_realize_on_domain_operation.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 "COM_context.hh"
8#include "COM_domain.hh"
10#include "COM_result.hh"
12
13namespace blender::compositor {
14
15/* ------------------------------------------------------------------------------------------------
16 * Realize On Domain Operation
17 *
18 * A simple operation that projects the input on a certain target domain, copies the area of the
19 * input that intersects the target domain, and fill the rest with the extension options in the
20 * realization options of the input. See the discussion in COM_domain.hh for more information. */
22 private:
23 /* The target domain to realize the input on. */
24 Domain target_domain_;
25
26 public:
28
29 void execute() override;
30
31 /* Determine if a realize on domain operation is needed for the input with the given result and
32 * descriptor in an operation with the given operation domain. If it is not needed, return a null
33 * pointer. If it is needed, return an instance of the operation.
34 *
35 * Since operations might not be transform-invariant, the rotation and scale components of the
36 * operation domain are realized and the size of the domain is increased/reduced to adapt to the
37 * new transformation. For instance, if the transformation is a rotation, the domain will be
38 * rotated and expanded in size to account for the bounding box of the domain after rotation. */
40 const Result &input_result,
41 const InputDescriptor &input_descriptor,
42 const Domain &operation_domain);
43
44 /* Given a potentially transformed domain, compute a domain such that its rotation and scale
45 * become identity and the size of the domain is increased/reduced to adapt to the new
46 * transformation. For instance, if the domain is rotated, the returned domain will have zero
47 * rotation but expanded size to account for the bounding box of the domain after rotation.
48 * Similarly, if the realize_translation argument is true, translation will be set to zero,
49 * though this will not affect the size of the domain in any way. The size of the returned domain
50 * is bound and clipped by the maximum possible size to avoid allocations that surpass hardware
51 * limits. */
53 const Domain &domain,
54 const bool realize_translation = false);
55
56 protected:
57 /* The operation domain is just the target domain. */
58 Domain compute_domain() override;
59
60 private:
61 /* Get the name of the realization shader of the appropriate type. */
62 const char *get_realization_shader_name();
63
64 /* Computes the translation that the input should be translated by to fix the artifacts related
65 * to interpolation. See the implementation for more information. */
66 float2 compute_corrective_translation();
67
68 void realize_on_domain_gpu(const float3x3 &inverse_transformation);
69 void realize_on_domain_cpu(const float3x3 &inverse_transformation);
70};
71
72} // namespace blender::compositor
RealizeOnDomainOperation(Context &context, Domain target_domain, ResultType type)
static SimpleOperation * construct_if_needed(Context &context, const Result &input_result, const InputDescriptor &input_descriptor, const Domain &operation_domain)
static Domain compute_realized_transformation_domain(Context &context, const Domain &domain, const bool realize_translation=false)
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3