51 void init(
const float3x3 &transform_matrix,
const bool has_source_crop)
56 init_destination_region(transform_matrix, has_source_crop);
60 void init_destination_region(
const float3x3 &transform_matrix,
const bool has_source_crop)
62 if (!has_source_crop) {
77 for (
int i = 0;
i < 4;
i++) {
78 int2 src_co = src_coords[
i];
125template<eIMBInterpolationFilterMode Filter,
typename T,
int NumChannels,
bool WrapUV>
128 if constexpr (WrapUV) {
139 if constexpr (Filter ==
IMB_FILTER_BILINEAR && std::is_same_v<T, float> && NumChannels == 4) {
142 else if constexpr (Filter ==
IMB_FILTER_NEAREST && std::is_same_v<T, uchar> && NumChannels == 4)
146 else if constexpr (Filter ==
IMB_FILTER_BILINEAR && std::is_same_v<T, uchar> && NumChannels == 4)
151 if constexpr (WrapUV) {
225 if constexpr (SrcChannels == 4) {
228 else if constexpr (SrcChannels == 3) {
231 else if constexpr (SrcChannels == 2) {
234 else if constexpr (SrcChannels == 1) {
267 const float inv_count = 1.0f / (sub_count_x * sub_count_y);
271 for (
int yi : y_range) {
278 for (
int sub_y = 0; sub_y < sub_count_y; sub_y++) {
279 for (
int sub_x = 0; sub_x < sub_count_x; sub_x++) {
280 float2 delta = (sub_x + 0.5f) * sub_step_x + (sub_y + 0.5f) * sub_step_y;
281 float2 sub_uv = uv + delta;
287 WrapUV>(ctx.
src, sub_uv.x, sub_uv.y, sub_sample);
304 for (
int yi : y_range) {
320template<eIMBInterpolationFilterMode Filter,
typename T,
int SrcChannels>
339template<eIMBInterpolationFilterMode Filter>
349 else if (channels == 3) {
352 else if (channels == 2) {
355 else if (channels == 1) {
401 for (
int line_idx = 0; line_idx < 4; line_idx++) {
410 bool is_steep =
length == abs_delta.y;
415 constexpr float NO_ROTATION = 1.0e-6f;
416 constexpr float NO_AA_CONTRIB = 1.0e-2f;
418 if ((abs_delta.x < NO_ROTATION) && (
fabsf(ptA.x -
roundf(ptA.x)) < NO_AA_CONTRIB)) {
423 if ((abs_delta.y < NO_ROTATION) && (
fabsf(ptA.y -
roundf(ptA.y)) < NO_AA_CONTRIB)) {
436 if (ipos.x >= 0 && ipos.x < ctx.
dst->
x && ipos.y >= 0 && ipos.y < ctx.
dst->
y) {
438 size_t idx = (size_t(ipos.y) * ctx.
dst->
x + ipos.x) * 4;
452 if (ipos.x >= 0 && ipos.x < ctx.
dst->
x && ipos.y >= 0 && ipos.y < ctx.
dst->
y) {
454 size_t idx = (size_t(ipos.y) * ctx.
dst->
x + ipos.x) * 4;
472 const rctf *src_crop)
475 "No source crop rect given, but crop source is requested. Or source crop rect "
476 "was given, but crop source was not requested.");
487 ctx.
init(transform_matrix, crop);
490 if (filter == IMB_FILTER_NEAREST) {
491 transform_scanlines_filter<IMB_FILTER_NEAREST>(ctx, y_range);
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
#define BLI_assert_msg(a, msg)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init_minmax(struct rcti *rect)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
eIMBTransformMode
Transform modes to use for IMB_transform function.
@ IMB_TRANSFORM_MODE_WRAP_REPEAT
Wrap repeat the source buffer. Only supported in with nearest filtering.
@ IMB_TRANSFORM_MODE_REGULAR
Do not crop or repeat.
@ IMB_TRANSFORM_MODE_CROP_SRC
Crop the source buffer.
eIMBInterpolationFilterMode
@ IMB_FILTER_CUBIC_BSPLINE
@ IMB_FILTER_CUBIC_MITCHELL
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr int64_t first() const
MatBase< C, R > inverse(MatBase< C, R >) RET
float length(VecOp< float, D >) RET
float4 interpolate_bilinear_fl(const ImBuf *in, float u, float v)
uchar4 interpolate_nearest_border_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_bilinear_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_mitchell_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_bspline_byte(const ImBuf *in, float u, float v)
T clamp(const T &a, const T &min, const T &max)
void interpolate_nearest_border_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
T length(const VecBase< T, Size > &a)
float4 interpolate_cubic_bspline_fl(const float *buffer, int width, int height, float u, float v)
CartesianBasis invert(const CartesianBasis &basis)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_mitchell_fl(const float *buffer, int width, int height, float u, float v)
T max(const T &a, const T &b)
void interpolate_bilinear_wrapmode_fl(const float *buffer, float *output, int width, int height, int components, float u, float v, InterpWrapMode wrap_u, InterpWrapMode wrap_v)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
blender::VecBase< uint8_t, 4 > uchar4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
VecBase< T, 2 > xy() const
IndexRange dst_region_y_range
void init(const float3x3 &transform_matrix, const bool has_source_crop)
IndexRange dst_region_x_range