This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/compositor/operations/COM_SMAAOperation.h
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

159 lines
4.8 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2017 Blender Foundation. */
#pragma once
#include "COM_MultiThreadedOperation.h"
namespace blender::compositor {
/*-----------------------------------------------------------------------------*/
/* Edge Detection (First Pass) */
class SMAAEdgeDetectionOperation : public MultiThreadedOperation {
protected:
SocketReader *image_reader_;
SocketReader *value_reader_;
float threshold_;
float contrast_limit_;
public:
SMAAEdgeDetectionOperation();
/**
* the inner loop of this program
*/
virtual void execute_pixel(float output[4], int x, int y, void *data) override;
/**
* Initialize the execution
*/
void init_execution() override;
/**
* Deinitialize the execution
*/
void deinit_execution() override;
void set_threshold(float threshold);
void set_local_contrast_adaptation_factor(float factor);
bool determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *read_operation,
rcti *output) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
};
/*-----------------------------------------------------------------------------*/
/* Blending Weight Calculation (Second Pass) */
class SMAABlendingWeightCalculationOperation : public MultiThreadedOperation {
private:
SocketReader *image_reader_;
std::function<void(int x, int y, float *out)> sample_image_fn_;
int corner_rounding_;
public:
SMAABlendingWeightCalculationOperation();
/**
* the inner loop of this program
*/
void execute_pixel(float output[4], int x, int y, void *data) override;
/**
* Initialize the execution
*/
void init_execution() override;
void *initialize_tile_data(rcti *rect) override;
/**
* Deinitialize the execution
*/
void deinit_execution() override;
void set_corner_rounding(float rounding);
bool determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *read_operation,
rcti *output) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
void update_memory_buffer_started(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
private:
/* Diagonal Search Functions */
/**
* These functions allows to perform diagonal pattern searches.
*/
int search_diag1(int x, int y, int dir, bool *found);
int search_diag2(int x, int y, int dir, bool *found);
/**
* This searches for diagonal patterns and returns the corresponding weights.
*/
void calculate_diag_weights(int x, int y, const float edges[2], float weights[2]);
bool is_vertical_search_unneeded(int x, int y);
/* Horizontal/Vertical Search Functions */
int search_xleft(int x, int y);
int search_xright(int x, int y);
int search_yup(int x, int y);
int search_ydown(int x, int y);
/* Corner Detection Functions */
void detect_horizontal_corner_pattern(
float weights[2], int left, int right, int y, int d1, int d2);
void detect_vertical_corner_pattern(
float weights[2], int x, int top, int bottom, int d1, int d2);
};
/*-----------------------------------------------------------------------------*/
/* Neighborhood Blending (Third Pass) */
class SMAANeighborhoodBlendingOperation : public MultiThreadedOperation {
private:
SocketReader *image1Reader_;
SocketReader *image2Reader_;
public:
SMAANeighborhoodBlendingOperation();
/**
* the inner loop of this program
*/
void execute_pixel(float output[4], int x, int y, void *data) override;
/**
* Initialize the execution
*/
void init_execution() override;
void *initialize_tile_data(rcti *rect) override;
/**
* Deinitialize the execution
*/
void deinit_execution() override;
bool determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *read_operation,
rcti *output) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor