Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a01039

Browse files
committed
Fix Agg extent calculations for empty draws
1 parent b99e636 commit 2a01039

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/_backend_agg.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,15 @@ agg::rect_i RendererAgg::get_content_extents()
201201
}
202202
}
203203

204-
r.x1 = std::max(0, r.x1);
205-
r.y1 = std::max(0, r.y1);
206-
r.x2 = std::min(r.x2 + 1, (int)width);
207-
r.y2 = std::min(r.y2 + 1, (int)height);
204+
if (r.x1 == width && r.x2 == 0) {
205+
// The buffer is completely empty.
206+
r.x1 = r.y1 = r.x2 = r.y2 = 0;
207+
} else {
208+
r.x1 = std::max(0, r.x1);
209+
r.y1 = std::max(0, r.y1);
210+
r.x2 = std::min(r.x2 + 1, (int)width);
211+
r.y2 = std::min(r.y2 + 1, (int)height);
212+
}
208213

209214
return r;
210215
}

0 commit comments

Comments
 (0)