Skip to content

Commit

Permalink
render: fix off-by-one error in rectangle clipping
Browse files Browse the repository at this point in the history
Test: gpu/clipping
Thanks @BodbDearg for the fix
  • Loading branch information
JaCzekanski committed Feb 5, 2020
1 parent c9b7b8b commit a72bdae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/device/gpu/render/render_rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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( //
Expand All @@ -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;
Expand Down

0 comments on commit a72bdae

Please sign in to comment.