44 const short imaprepeat,
45 const short imapextend);
72 col[0] =
float(rect[0]) * (1.0f / 255.0f);
73 col[1] =
float(rect[1]) * (1.0f / 255.0f);
74 col[2] =
float(rect[2]) * (1.0f / 255.0f);
75 col[3] =
float(rect[3]) * (1.0f / 255.0f);
86 const float texvec[3],
89 const bool skip_load_image)
100 if (ima ==
nullptr) {
113 local_iuser = tex->
iuser;
114 iuser = &local_iuser;
170 fx = (fx - 0.5f) / (1.0f - tex->
checkerdist) + 0.5f;
171 fy = (fy - 0.5f) / (1.0f - tex->
checkerdist) + 0.5f;
179 if (
x < 0 ||
y < 0 || x >= ibuf->
x ||
y >= ibuf->
y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
236 float filterx, filtery;
266 texres->
trgba[3] = texres->
tin = 1.0;
276 fx = 1.0f / texres->
trgba[3];
277 texres->
trgba[0] *= fx;
278 texres->
trgba[1] *= fx;
279 texres->
trgba[2] *= fx;
301 rf->
xmin += (x2 - x1);
302 rf->
xmax += (x2 - x1);
306 newrct = stack + *
count;
310 newrct->
xmin = rf->
xmin + (x2 - x1);
321 else if (rf->
xmax > x2) {
323 rf->
xmin -= (x2 - x1);
324 rf->
xmax -= (x2 - x1);
328 newrct = stack + *
count;
332 newrct->
xmax = rf->
xmax - (x2 - x1);
357 rf->
ymin += (y2 - y1);
358 rf->
ymax += (y2 - y1);
362 newrct = stack + *
count;
366 newrct->
ymin = rf->
ymin + (y2 - y1);
377 else if (rf->
ymax > y2) {
379 rf->
ymin -= (y2 - y1);
380 rf->
ymax -= (y2 - y1);
384 newrct = stack + *
count;
388 newrct->
ymax = rf->
ymax - (y2 - y1);
454 float muly, mulx, div,
col[4];
455 int x,
y, startx, endx, starty, endy;
462 startx = std::max(startx, 0);
463 starty = std::max(starty, 0);
464 if (endx >= ibuf->
x) {
467 if (endy >= ibuf->
y) {
471 if (starty == endy && startx == endx) {
476 for (
y = starty;
y <= endy;
y++) {
480 if (starty == endy) {
485 muly = 1.0f - (rf->
ymin -
y);
488 muly = (rf->
ymax -
y);
492 if (startx == endx) {
500 for (
x = startx;
x <= endx;
x++) {
503 mulx *= 1.0f - (rf->
xmin -
x);
506 mulx *= (rf->
xmax -
x);
540 const short imaprepeat,
541 const short imapextend)
555 float opp, tot, alphaclip = 1.0;
559 rf->
xmin = minx * (ibuf->
x);
560 rf->
xmax = maxx * (ibuf->
x);
561 rf->
ymin = miny * (ibuf->
y);
562 rf->
ymax = maxy * (ibuf->
y);
570 else if (imaprepeat) {
576 if (alphaclip <= 0.0f) {
586 else if (imaprepeat) {
592 if (alphaclip <= 0.0f) {
615 texres->
trgba[0] /= tot;
616 texres->
trgba[1] /= tot;
617 texres->
trgba[2] /= tot;
619 texres->
trgba[3] /= tot;
627 if (texres->
talpha == 0) {
628 texres->
trgba[3] = 1.0;
631 if (alphaclip != 1.0f) {
633 texres->
trgba[0] *= alphaclip;
634 texres->
trgba[1] *= alphaclip;
635 texres->
trgba[2] *= alphaclip;
636 texres->
trgba[3] *= alphaclip;
662 x +=
x < 0 ? 2 * ibuf->
x : 0;
663 x =
x >= ibuf->
x ? 2 * ibuf->
x -
x - 1 :
x;
665 y +=
y < 0 ? ibuf->
y : 0;
669 x +=
x < 0 ? ibuf->
x : 0;
671 y +=
y < 0 ? 2 * ibuf->
y : 0;
672 y =
y >= ibuf->
y ? 2 * ibuf->
y -
y - 1 :
y;
675 x = (
x < 0) ? 0 : ((
x >= ibuf->
x) ? (ibuf->
x - 1) :
x);
676 y = (
y < 0) ? 0 : ((
y >= ibuf->
y) ? (ibuf->
y - 1) :
y);
680 x += (
x < 0) ? ibuf->
x : 0;
682 y += (
y < 0) ? ibuf->
y : 0;
705 col[3] = clip ? 0.0f : (ibuf->
channels == 4 ? fp[3] : 1.0f);
710 float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
711 col[0] = rect[0] * inv_alpha_fac;
712 col[1] = rect[1] * inv_alpha_fac;
713 col[2] = rect[2] * inv_alpha_fac;
714 col[3] = clip ? 0.0f : rect[3] * (1.0f / 255.0f);
733 const float uv[2] = {fx, fy};
762 boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
785 ewa_eval(&texres, ibuf, fx, fy, &AFD);
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
bool BKE_image_has_loaded_ibuf(Image *image)
MINLINE float max_fff(float a, float b, float c)
void BLI_ewa_filter(int width, int height, bool intpol, bool use_alpha, const float uv[2], const float du[2], const float dv[2], ewa_filter_read_pixel_cb read_pixel_cb, void *userdata, float result[4])
MINLINE void mul_v4_fl(float r[4], float f)
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_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
void image_sample(Image *ima, float fx, float fy, float dx, float dy, float result[4], ImagePool *pool)
void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4])
static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, const AFData *AFD)
static float clipy_rctf(rctf *rf, float y1, float y2)
static float square_rctf(const rctf *rf)
int imagewrap(Tex *tex, Image *ima, const float texvec[3], TexResult *texres, ImagePool *pool, const bool skip_load_image)
static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres, const short imaprepeat, const short imapextend)
static float clipx_rctf(rctf *rf, float x1, float x2)
static void boxsampleclip(ImBuf *ibuf, const rctf *rf, TexResult *texres)
static void ibuf_get_color(float col[4], ImBuf *ibuf, int x, int y)
static void ewa_read_pixel_cb(void *userdata, int x, int y, float result[4])
static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)