Made draw_text/draw_rect not push command if result is not on-screen
This commit is contained in:
parent
2b32edf7f0
commit
4c2c03ed4d
|
@ -119,6 +119,7 @@ void rencache_set_clip_rect(RenRect rect) {
|
||||||
|
|
||||||
|
|
||||||
void rencache_draw_rect(RenRect rect, RenColor color) {
|
void rencache_draw_rect(RenRect rect, RenColor color) {
|
||||||
|
if (!rects_overlap(screen_rect, rect)) { return; }
|
||||||
Command *cmd = push_command(DRAW_RECT, sizeof(Command));
|
Command *cmd = push_command(DRAW_RECT, sizeof(Command));
|
||||||
cmd->rect = rect;
|
cmd->rect = rect;
|
||||||
cmd->color = color;
|
cmd->color = color;
|
||||||
|
@ -126,16 +127,22 @@ void rencache_draw_rect(RenRect rect, RenColor color) {
|
||||||
|
|
||||||
|
|
||||||
int rencache_draw_text(RenFont *font, const char *text, int x, int y, RenColor color) {
|
int rencache_draw_text(RenFont *font, const char *text, int x, int y, RenColor color) {
|
||||||
int sz = strlen(text) + 1;
|
RenRect rect;
|
||||||
Command *cmd = push_command(DRAW_TEXT, sizeof(Command) + sz);
|
rect.x = x;
|
||||||
memcpy(cmd->text, text, sz);
|
rect.y = y;
|
||||||
cmd->color = color;
|
rect.width = ren_get_font_width(font, text);
|
||||||
cmd->font = font;
|
rect.height = ren_get_font_height(font);
|
||||||
cmd->rect.x = x;
|
|
||||||
cmd->rect.y = y;
|
if (rects_overlap(screen_rect, rect)) {
|
||||||
cmd->rect.width = ren_get_font_width(font, text);
|
int sz = strlen(text) + 1;
|
||||||
cmd->rect.height = ren_get_font_height(font);
|
Command *cmd = push_command(DRAW_TEXT, sizeof(Command) + sz);
|
||||||
return x + cmd->rect.width;
|
memcpy(cmd->text, text, sz);
|
||||||
|
cmd->color = color;
|
||||||
|
cmd->font = font;
|
||||||
|
cmd->rect = rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x + rect.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue