2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2021 Blender Foundation. */
|
2021-07-06 16:16:08 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "COM_NodeOperation.h"
|
|
|
|
|
|
|
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
/* TODO(manzanilla): After removing tiled implementation, implement a default #determine_resolution
|
2021-08-10 15:24:28 +02:00
|
|
|
* for all constant operations and make all initialization and deinitilization methods final. */
|
2021-07-06 16:16:08 +02:00
|
|
|
/**
|
2021-08-10 15:24:28 +02:00
|
|
|
* Base class for operations that are always constant. Operations that can be constant only when
|
|
|
|
|
* all their inputs are so, are evaluated into primitive constants (Color/Vector/Value) during
|
|
|
|
|
* constant folding.
|
2021-07-06 16:16:08 +02:00
|
|
|
*/
|
|
|
|
|
class ConstantOperation : public NodeOperation {
|
2021-08-10 15:24:28 +02:00
|
|
|
protected:
|
2021-09-28 19:32:49 +02:00
|
|
|
bool needs_canvas_to_get_constant_;
|
2021-08-10 15:24:28 +02:00
|
|
|
|
2021-07-06 16:16:08 +02:00
|
|
|
public:
|
|
|
|
|
ConstantOperation();
|
|
|
|
|
|
2021-08-10 15:24:28 +02:00
|
|
|
/** May require resolution to be already determined. */
|
2021-07-06 16:16:08 +02:00
|
|
|
virtual const float *get_constant_elem() = 0;
|
2021-08-10 15:24:28 +02:00
|
|
|
bool can_get_constant_elem() const;
|
|
|
|
|
|
|
|
|
|
void update_memory_buffer(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs) final;
|
2021-07-06 16:16:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|