Skip to content
Permalink
Browse files

render: fix off-by-one error in rectangle clipping

Test: gpu/clipping
Thanks @BodbDearg for the fix
  • Loading branch information
JaCzekanski committed Feb 5, 2020
1 parent c9b7b8b commit a72bdaebbc54a3ccfc6774596c0d30c83c4f1dcb
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/device/gpu/render/render_rectangle.cpp
@@ -45,9 +45,9 @@ INLINE void rectangle(GPU* gpu, const primitive::Rect& rect) {
gpu->minDrawingX(pos.x), //
gpu->minDrawingY(pos.y) //
);
const ivec2 max( //
gpu->maxDrawingX(pos.x + rect.size.x), //
gpu->maxDrawingY(pos.y + rect.size.y) //
const ivec2 max( //
gpu->maxDrawingX(pos.x + rect.size.x - 1), //
gpu->maxDrawingY(pos.y + rect.size.y - 1) //
);

const ivec2 uv( //
@@ -66,8 +66,8 @@ INLINE void rectangle(GPU* gpu, const primitive::Rect& rect) {
}

int x, y, u, v;
for (y = min.y, v = uv.y; y < max.y; y++, v += vStep) {
for (x = min.x, u = uv.x; x < max.x; x++, u += uStep) {
for (y = min.y, v = uv.y; y <= max.y; y++, v += vStep) {
for (x = min.x, u = uv.x; x <= max.x; x++, u += uStep) {
PSXColor bg = VRAM[y][x];
if (unlikely(checkMaskBeforeDraw)) {
if (bg.k) continue;

0 comments on commit a72bdae

Please sign in to comment.
You can’t perform that action at this time.