Blender V5.3
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 <optional>
8
10
11#include "COM_context.hh"
12#include "COM_domain.hh"
14#include "COM_result.hh"
16
17namespace blender::compositor {
18
19/* ------------------------------------------------------------------------------------------------
20 * Realize On Domain Operation
21 *
22 * A simple operation that projects the input on a certain target domain, copies the area of the
23 * input that intersects the target domain, and fill the rest with the extension options in the
24 * realization options of the input. See the discussion in COM_domain.hh for more information. */
26 private:
27 /* The target domain to realize the input on. */
28 Domain target_domain_;
29
30 public:
32
33 void execute() override;
34
35 /* Determine if a realize on domain operation is needed for the input with the given result and
36 * descriptor in an operation with the given operation domain. If it is not needed, return a null
37 * pointer. If it is needed, return an instance of the operation.
38 *
39 * Since operations might not be transform-invariant, the rotation and scale components of the
40 * operation domain are realized and the size of the domain is increased/reduced to adapt to the
41 * new transformation. For instance, if the transformation is a rotation, the domain will be
42 * rotated and expanded in size to account for the bounding box of the domain after rotation. */
44 const Result &input_result,
45 const InputDescriptor &input_descriptor,
46 const Domain &operation_domain);
47
48 protected:
49 /* The operation domain is just the target domain. */
50 Domain compute_domain() override;
51
52 private:
53 /* Get the name of the realization shader of the appropriate type. */
54 const char *get_realization_shader_name(const float3x3 &transformation);
55
56 /* Computes the translation that the input should be translated by to fix the artifacts related
57 * to interpolation. See the implementation for more information. */
58 float2 compute_corrective_translation();
59
60 /* Computes the Jacobian of the given output texel to input sampler transformation. If no area
61 * sampling is needed, possibly because it is just a rotation/translation, nullopt is returned to
62 * indicate simple point sampling should be used. */
63 std::optional<float2x2> compute_jacobian(const float3x3 &transformation);
64
65 void realize_on_domain_gpu(const float3x3 &transformation);
66 void realize_on_domain_cpu(const float3x3 &transformation);
67};
68
69} // namespace blender::compositor
Context & context() const
Definition operation.cc:57
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)