Compositor: Fix pixels being wrapped outside buffer area
Not causing issues in current master because all buffer areas are at (0, 0) position and `Extend` is not used. But areas may be at any position in future developments and it will crash. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D11784
This commit is contained in:
parent
209aff0a35
commit
2ea47057d3
|
@ -264,11 +264,14 @@ class MemoryBuffer {
|
|||
x = 0;
|
||||
}
|
||||
if (x >= w) {
|
||||
x = w;
|
||||
x = w - 1;
|
||||
}
|
||||
break;
|
||||
case MemoryBufferExtend::Repeat:
|
||||
x = (x >= 0.0f ? (x % w) : (x % w) + w);
|
||||
x %= w;
|
||||
if (x < 0) {
|
||||
x += w;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -280,13 +283,19 @@ class MemoryBuffer {
|
|||
y = 0;
|
||||
}
|
||||
if (y >= h) {
|
||||
y = h;
|
||||
y = h - 1;
|
||||
}
|
||||
break;
|
||||
case MemoryBufferExtend::Repeat:
|
||||
y = (y >= 0.0f ? (y % h) : (y % h) + h);
|
||||
y %= h;
|
||||
if (y < 0) {
|
||||
y += h;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
}
|
||||
|
||||
inline void wrap_pixel(float &x,
|
||||
|
@ -307,11 +316,14 @@ class MemoryBuffer {
|
|||
x = 0.0f;
|
||||
}
|
||||
if (x >= w) {
|
||||
x = w;
|
||||
x = w - 1;
|
||||
}
|
||||
break;
|
||||
case MemoryBufferExtend::Repeat:
|
||||
x = fmodf(x, w);
|
||||
if (x < 0.0f) {
|
||||
x += w;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -323,13 +335,19 @@ class MemoryBuffer {
|
|||
y = 0.0f;
|
||||
}
|
||||
if (y >= h) {
|
||||
y = h;
|
||||
y = h - 1;
|
||||
}
|
||||
break;
|
||||
case MemoryBufferExtend::Repeat:
|
||||
y = fmodf(y, h);
|
||||
if (y < 0.0f) {
|
||||
y += h;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
}
|
||||
|
||||
inline void read(float *result,
|
||||
|
|
Loading…
Reference in New Issue