2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2012 Blender Foundation. */
|
2012-06-04 15:49:58 +00:00
|
|
|
|
2018-08-08 11:49:51 +10:00
|
|
|
#pragma once
|
2012-06-04 15:49:58 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_listbase.h"
|
2021-08-10 15:24:17 +02:00
|
|
|
#include "COM_MultiThreadedOperation.h"
|
2012-06-04 15:49:58 +00:00
|
|
|
#include "DNA_mask_types.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
/* Forward declarations. */
|
|
|
|
|
struct MaskRasterHandle;
|
|
|
|
|
|
|
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2012-06-04 15:49:58 +00:00
|
|
|
/**
|
2012-06-13 23:31:47 +00:00
|
|
|
* Class with implementation of mask rasterization
|
|
|
|
|
*/
|
2021-08-10 15:24:17 +02:00
|
|
|
class MaskOperation : public MultiThreadedOperation {
|
2012-06-04 15:49:58 +00:00
|
|
|
protected:
|
2021-10-13 23:01:04 +02:00
|
|
|
Mask *mask_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: these are used more like aspect,
|
2012-07-26 13:29:38 +00:00
|
|
|
* but they _do_ impact on mask detail */
|
2021-10-13 23:01:15 +02:00
|
|
|
int mask_width_;
|
|
|
|
|
int mask_height_;
|
|
|
|
|
float mask_width_inv_; /* `1 / mask_width_` */
|
|
|
|
|
float mask_height_inv_; /* `1 / mask_height_` */
|
2021-10-13 23:01:04 +02:00
|
|
|
float mask_px_ofs_[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
float frame_shutter_;
|
|
|
|
|
int frame_number_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
bool do_feather_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
struct MaskRasterHandle *raster_mask_handles_[CMP_NODE_MASK_MBLUR_SAMPLES_MAX];
|
|
|
|
|
unsigned int raster_mask_handle_tot_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-04 15:49:58 +00:00
|
|
|
/**
|
2012-06-13 23:31:47 +00:00
|
|
|
* Determine the output resolution. The resolution is retrieved from the Renderer
|
|
|
|
|
*/
|
2021-09-28 19:32:49 +02:00
|
|
|
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-04 15:49:58 +00:00
|
|
|
public:
|
|
|
|
|
MaskOperation();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void init_execution() override;
|
|
|
|
|
void deinit_execution() override;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_mask(Mask *mask)
|
2012-06-26 01:22:05 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
mask_ = mask;
|
2012-06-26 01:22:05 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_mask_width(int width)
|
2012-07-26 13:29:38 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
mask_width_ = width;
|
|
|
|
|
mask_width_inv_ = 1.0f / (float)width;
|
|
|
|
|
mask_px_ofs_[0] = mask_width_inv_ * 0.5f;
|
2012-07-26 13:29:38 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_mask_height(int height)
|
2012-07-26 13:29:38 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
mask_height_ = height;
|
|
|
|
|
mask_height_inv_ = 1.0f / (float)height;
|
|
|
|
|
mask_px_ofs_[1] = mask_height_inv_ * 0.5f;
|
2012-07-26 13:29:38 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_framenumber(int frame_number)
|
2012-07-27 10:20:36 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
frame_number_ = frame_number;
|
2012-07-27 10:20:36 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_feather(bool feather)
|
2012-06-26 01:22:05 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
do_feather_ = feather;
|
2012-06-26 01:22:05 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_motion_blur_samples(int samples)
|
2012-08-01 12:59:38 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
raster_mask_handle_tot_ = MIN2(MAX2(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
|
2012-08-01 12:59:38 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_motion_blur_shutter(float shutter)
|
2012-07-27 10:20:36 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
frame_shutter_ = shutter;
|
2012-07-27 10:20:36 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override;
|
2021-08-10 15:24:17 +02:00
|
|
|
|
|
|
|
|
void update_memory_buffer_partial(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Vector<MaskRasterHandle *> get_non_null_handles() const;
|
2012-06-04 15:49:58 +00:00
|
|
|
};
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|