#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <algorithm>
#include "base/check_op.h"
#include "base/notreached.h"
#include "skia/ext/convolver.h"
#include "skia/ext/convolver_SSE2.h"
#include "skia/ext/convolver_mips_dspr2.h"
#include "skia/ext/convolver_neon.h"
#include "skia/ext/convolver_LSX.h"
#include "third_party/skia/include/core/SkSize.h"
#include "third_party/skia/include/core/SkTypes.h"
namespace skia {
namespace {
inline unsigned char ClampTo8(int a) { … }
inline unsigned char BringBackTo8(int a, bool take_absolute) { … }
class CircularRowBuffer { … };
template<bool has_alpha>
void ConvolveHorizontally(const unsigned char* src_data,
const ConvolutionFilter1D& filter,
unsigned char* out_row) { … }
template<bool has_alpha>
void ConvolveVertically(const ConvolutionFilter1D::Fixed* filter_values,
int filter_length,
unsigned char* const* source_data_rows,
int pixel_width,
unsigned char* out_row) { … }
void ConvolveVertically(const ConvolutionFilter1D::Fixed* filter_values,
int filter_length,
unsigned char* const* source_data_rows,
int pixel_width,
unsigned char* out_row,
bool source_has_alpha) { … }
}
ConvolutionFilter1D::ConvolutionFilter1D()
: … { … }
ConvolutionFilter1D::~ConvolutionFilter1D() = default;
void ConvolutionFilter1D::AddFilter(int filter_offset,
const float* filter_values,
int filter_length) { … }
void ConvolutionFilter1D::AddFilter(int filter_offset,
const Fixed* filter_values,
int filter_length) { … }
const ConvolutionFilter1D::Fixed* ConvolutionFilter1D::GetSingleFilter(
int* specified_filter_length,
int* filter_offset,
int* filter_length) const { … }
ConvolveVertically_pointer;
Convolve4RowsHorizontally_pointer;
ConvolveHorizontally_pointer;
struct ConvolveProcs { … };
void SetupSIMD(ConvolveProcs *procs) { … }
void BGRAConvolve2D(const unsigned char* source_data,
int source_byte_row_stride,
bool source_has_alpha,
const ConvolutionFilter1D& filter_x,
const ConvolutionFilter1D& filter_y,
int output_byte_row_stride,
unsigned char* output,
bool use_simd_if_possible) { … }
void SingleChannelConvolveX1D(const unsigned char* source_data,
int source_byte_row_stride,
int input_channel_index,
int input_channel_count,
const ConvolutionFilter1D& filter,
const SkISize& image_size,
unsigned char* output,
int output_byte_row_stride,
int output_channel_index,
int output_channel_count,
bool absolute_values) { … }
void SingleChannelConvolveY1D(const unsigned char* source_data,
int source_byte_row_stride,
int input_channel_index,
int input_channel_count,
const ConvolutionFilter1D& filter,
const SkISize& image_size,
unsigned char* output,
int output_byte_row_stride,
int output_channel_index,
int output_channel_count,
bool absolute_values) { … }
void SetUpGaussianConvolutionKernel(ConvolutionFilter1D* filter,
float kernel_sigma,
bool derivative) { … }
}