5#include "testing/testing.h"
44 for (
int y = 0;
y < img->
y;
y++) {
45 for (
int x = 0;
x < img->
x;
x++) {
46 for (
int ch = 0; ch < channels; ch++) {
47 *
col =
x * 1.25f +
y * 0.5f + ch * 0.125f;
106TEST(imbuf_scaling, nearest_2x_smaller)
116TEST(imbuf_scaling, threaded_2x_smaller)
126TEST(imbuf_scaling, bilinear_2x_smaller)
138TEST(imbuf_scaling, nearest_to_1x1)
146TEST(imbuf_scaling, threaded_to_1x1)
154TEST(imbuf_scaling, bilinear_to_1x1)
162TEST(imbuf_scaling, nearest_fractional_larger)
175TEST(imbuf_scaling, bilinear_fractional_larger)
191static constexpr float EPS = 0.0001f;
193TEST(imbuf_scaling, nearest_2x_smaller_fl1)
197 EXPECT_NEAR(got[0], 0.0f,
EPS);
198 EXPECT_NEAR(got[1], 2.5f,
EPS);
199 EXPECT_NEAR(got[2], 5.0f,
EPS);
203TEST(imbuf_scaling, nearest_2x_smaller_fl2)
207 EXPECT_V2_NEAR(got[0],
float2(0.0f, 0.125f),
EPS);
208 EXPECT_V2_NEAR(got[1],
float2(2.5f, 2.625f),
EPS);
209 EXPECT_V2_NEAR(got[2],
float2(5.0f, 5.125f),
EPS);
213TEST(imbuf_scaling, nearest_2x_smaller_fl3)
217 EXPECT_V3_NEAR(got[0],
float3(0.0f, 0.125f, 0.25f),
EPS);
218 EXPECT_V3_NEAR(got[1],
float3(2.5f, 2.625f, 2.75f),
EPS);
219 EXPECT_V3_NEAR(got[2],
float3(5.0f, 5.125f, 5.25f),
EPS);
223TEST(imbuf_scaling, nearest_2x_smaller_fl4)
227 EXPECT_V4_NEAR(got[0],
float4(0.0f, 0.125f, 0.25f, 0.375f),
EPS);
228 EXPECT_V4_NEAR(got[1],
float4(2.5f, 2.625f, 2.75f, 2.875f),
EPS);
229 EXPECT_V4_NEAR(got[2],
float4(5.0f, 5.125f, 5.25f, 5.375f),
EPS);
233TEST(imbuf_scaling, nearest_to_1x1_fl3)
237 EXPECT_V3_NEAR(got[0],
float3(0, 0.125f, 0.25f),
EPS);
241TEST(imbuf_scaling, threaded_to_1x1_fl3)
245 EXPECT_V3_NEAR(got[0],
float3(3.375f, 3.5f, 3.625f),
EPS);
249TEST(imbuf_scaling, bilinear_to_1x1_fl3)
253 EXPECT_V3_NEAR(got[0],
float3(3.36853f, 3.49353f, 3.61853f),
EPS);
257TEST(imbuf_scaling, bilinear_2x_smaller_fl3)
261 EXPECT_V3_NEAR(got[0],
float3(0.87270f, 0.99770f, 1.12270f),
EPS);
262 EXPECT_V3_NEAR(got[1],
float3(3.36853f, 3.49353f, 3.61853f),
EPS);
263 EXPECT_V3_NEAR(got[2],
float3(5.86435f, 5.98935f, 6.11435f),
EPS);
267TEST(imbuf_scaling, bilinear_2x_smaller_fl4)
271 EXPECT_V4_NEAR(got[0],
float4(0.87270f, 0.99770f, 1.12270f, 1.24770f),
EPS);
272 EXPECT_V4_NEAR(got[1],
float4(3.36853f, 3.49353f, 3.61853f, 3.74353f),
EPS);
273 EXPECT_V4_NEAR(got[2],
float4(5.86435f, 5.98935f, 6.11435f, 6.23935f),
EPS);
277TEST(imbuf_scaling, threaded_2x_smaller_fl3)
281 EXPECT_V3_NEAR(got[0],
float3(0.875f, 1.0f, 1.125f),
EPS);
282 EXPECT_V3_NEAR(got[1],
float3(3.375f, 3.5f, 3.625f),
EPS);
283 EXPECT_V3_NEAR(got[2],
float3(5.875f, 6.0f, 6.125f),
EPS);
287TEST(imbuf_scaling, threaded_2x_smaller_fl4)
291 EXPECT_V4_NEAR(got[0],
float4(0.875f, 1.0f, 1.125f, 1.25f),
EPS);
292 EXPECT_V4_NEAR(got[1],
float4(3.375f, 3.5f, 3.625f, 3.75f),
EPS);
293 EXPECT_V4_NEAR(got[2],
float4(5.875f, 6.0f, 6.125f, 6.25f),
EPS);
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void IMB_freeImBuf(ImBuf *ibuf)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
bool IMB_scale(ImBuf *ibuf, unsigned int newx, unsigned int newy, IMBScaleFilter filter, bool threaded=true)
TEST(imbuf_scaling, nearest_2x_smaller)
static constexpr float EPS
static ImBuf * create_6x2_test_image_fl(int channels)
static ImBuf * create_6x2_test_image()
static ImBuf * scale_fractional_larger(bool nearest, bool threaded, int float_channels=0)
static ImBuf * scale_2x_smaller(bool nearest, bool threaded, int float_channels=0)
static ImBuf * scale_to_1x1(bool nearest, bool threaded, int float_channels=0)
VecBase< uint32_t, 4 > uint4
blender::VecBase< uint8_t, 4 > uchar4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer