Skip to content

Commit 5b13328

Browse files
qarkaicaclark
authored andcommitted
Simplify rt_redraw() parameters
1 parent b1d7fdd commit 5b13328

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/renderer-tiles.cc

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void rt_overlay_draw(RendererTiles *rt, GdkRectangle request_rect, ImageTile *it
173173
gboolean rt_tile_is_visible(RendererTiles *rt, ImageTile *it);
174174
void rt_queue_merge(QueueData *parent, QueueData *qd);
175175
void rt_queue(RendererTiles *rt, gint x, gint y, gint w, gint h,
176-
gint clamp, TileRender render, gboolean new_data, gboolean only_existing);
176+
bool clamp, TileRender render, gboolean new_data, bool only_existing);
177177

178178
gint rt_queue_draw_idle_cb(gpointer data);
179179

@@ -602,7 +602,7 @@ void rt_overlay_queue_draw(RendererTiles *rt, OverlayData *od, gint x1, gint y1,
602602
rt->x_scroll - pr->x_offset + od_rect.x,
603603
rt->y_scroll - pr->y_offset + od_rect.y,
604604
od_rect.width, od_rect.height,
605-
FALSE, TileRender::ALL, FALSE, FALSE);
605+
false, TileRender::ALL, FALSE, false);
606606

607607
rt_border_draw(rt, od_rect);
608608
}
@@ -1704,9 +1704,9 @@ gboolean rt_clamp_to_visible(RendererTiles *rt, gint *x, gint *y, gint *w, gint
17041704
return TRUE;
17051705
}
17061706

1707-
gboolean rt_queue_to_tiles(RendererTiles *rt, gint x, gint y, gint w, gint h,
1708-
gboolean clamp, TileRender render,
1709-
gboolean new_data, gboolean only_existing)
1707+
bool rt_queue_to_tiles(RendererTiles *rt, gint x, gint y, gint w, gint h,
1708+
bool clamp, TileRender render,
1709+
gboolean new_data, bool only_existing)
17101710
{
17111711
PixbufRenderer *pr = rt->pr;
17121712
gint i;
@@ -1716,7 +1716,7 @@ gboolean rt_queue_to_tiles(RendererTiles *rt, gint x, gint y, gint w, gint h,
17161716
gint y1;
17171717
gint y2;
17181718

1719-
if (clamp && !rt_clamp_to_visible(rt, &x, &y, &w, &h)) return FALSE;
1719+
if (clamp && !rt_clamp_to_visible(rt, &x, &y, &w, &h)) return false;
17201720

17211721
x1 = ROUND_DOWN(x, rt->tile_width);
17221722
x2 = ROUND_UP(x + w, rt->tile_width);
@@ -1788,12 +1788,12 @@ gboolean rt_queue_to_tiles(RendererTiles *rt, gint x, gint y, gint w, gint h,
17881788
}
17891789
}
17901790

1791-
return TRUE;
1791+
return true;
17921792
}
17931793

17941794
void rt_queue(RendererTiles *rt, gint x, gint y, gint w, gint h,
1795-
gboolean clamp, TileRender render,
1796-
gboolean new_data, gboolean only_existing)
1795+
bool clamp, TileRender render,
1796+
gboolean new_data, bool only_existing)
17971797
{
17981798
PixbufRenderer *pr = rt->pr;
17991799

@@ -1831,7 +1831,7 @@ void renderer_scroll(void *renderer, gint x_off, gint y_off)
18311831
if (w < 1 || h < 1)
18321832
{
18331833
/* scrolled completely to new material */
1834-
rt_queue(rt, 0, 0, pr->width, pr->height, TRUE, TileRender::ALL, FALSE, FALSE);
1834+
rt_queue(rt, 0, 0, pr->width, pr->height, true, TileRender::ALL, FALSE, false);
18351835
return;
18361836
}
18371837

@@ -1889,14 +1889,14 @@ void renderer_scroll(void *renderer, gint x_off, gint y_off)
18891889
{
18901890
rt_queue(rt,
18911891
x_off > 0 ? rt->x_scroll + (pr->vis_width - w) : rt->x_scroll, rt->y_scroll,
1892-
w, pr->vis_height, TRUE, TileRender::ALL, FALSE, FALSE);
1892+
w, pr->vis_height, true, TileRender::ALL, FALSE, false);
18931893
}
18941894
if (h > 0)
18951895
{
18961896
/** @FIXME to optimize this, remove overlap */
18971897
rt_queue(rt,
18981898
rt->x_scroll, y_off > 0 ? rt->y_scroll + (pr->vis_height - h) : rt->y_scroll,
1899-
pr->vis_width, h, TRUE, TileRender::ALL, FALSE, FALSE);
1899+
pr->vis_width, h, true, TileRender::ALL, FALSE, false);
19001900
}
19011901
}
19021902

@@ -1926,27 +1926,26 @@ void renderer_area_changed(void *renderer, GdkRectangle src)
19261926
x2 = static_cast<gint>(ceil(static_cast<gdouble>(rect.x + rect.width) * pr->scale));
19271927
y2 = static_cast<gint>(ceil(static_cast<gdouble>(rect.y + rect.height) * pr->scale * pr->aspect_ratio));
19281928

1929-
rt_queue(rt, x1, y1, x2 - x1, y2 - y1, FALSE, TileRender::AREA, TRUE, TRUE);
1929+
rt_queue(rt, x1, y1, x2 - x1, y2 - y1, false, TileRender::AREA, TRUE, true);
19301930
}
19311931

1932-
void rt_redraw(RendererTiles *rt, gint x, gint y, gint w, gint h,
1933-
gint clamp, TileRender render, gboolean new_data, gboolean only_existing)
1932+
void rt_redraw(RendererTiles *rt, GdkRectangle rect,
1933+
bool clamp, gboolean new_data)
19341934
{
19351935
PixbufRenderer *pr = rt->pr;
19361936

1937-
x -= rt->stereo_off_x;
1938-
y -= rt->stereo_off_y;
1937+
rect.x -= rt->stereo_off_x;
1938+
rect.y -= rt->stereo_off_y;
19391939

1940-
rt_border_draw(rt, {x, y, w, h});
1940+
rt_border_draw(rt, rect);
19411941

1942-
x = std::max(0, x - pr->x_offset + pr->x_scroll);
1943-
y = std::max(0, y - pr->y_offset + pr->y_scroll);
1942+
rect.x = std::max(0, rect.x - pr->x_offset + pr->x_scroll);
1943+
rect.y = std::max(0, rect.y - pr->y_offset + pr->y_scroll);
1944+
rect.width = std::min(rect.width, pr->width - rect.x);
1945+
rect.height = std::min(rect.height, pr->height - rect.y);
19441946

1945-
rt_queue(rt,
1946-
x, y,
1947-
std::min(w, pr->width - x),
1948-
std::min(h, pr->height - y),
1949-
clamp, render, new_data, only_existing);
1947+
rt_queue(rt, rect.x, rect.y, rect.width, rect.height,
1948+
clamp, TileRender::ALL, new_data, false);
19501949
}
19511950

19521951
void renderer_update_pixbuf(void *renderer, gboolean)
@@ -1962,7 +1961,7 @@ void renderer_update_zoom(void *renderer, gboolean lazy)
19621961
rt_tile_invalidate_all(rt);
19631962
if (!lazy)
19641963
{
1965-
rt_redraw(rt, 0, 0, pr->width, pr->height, TRUE, TileRender::ALL, TRUE, FALSE);
1964+
rt_redraw(rt, {0, 0, pr->width, pr->height}, true, TRUE);
19661965
}
19671966
rt_border_clear(rt);
19681967
}
@@ -2066,7 +2065,7 @@ gboolean rt_realize_cb(GtkWidget *widget, gpointer data)
20662065
return FALSE;
20672066
}
20682067

2069-
gboolean rt_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, gpointer data)
2068+
gboolean rt_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, gpointer data)
20702069
{
20712070
auto rt = static_cast<RendererTiles *>(data);
20722071
cairo_t *cr;
@@ -2086,7 +2085,7 @@ gboolean rt_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, gpoin
20862085
cairo_destroy(cr);
20872086
cairo_surface_destroy(old_surface);
20882087

2089-
rt_redraw(rt, allocation->x, allocation->y, allocation->width, allocation->height, FALSE, TileRender::ALL, FALSE, FALSE);
2088+
rt_redraw(rt, *allocation, false, FALSE);
20902089
}
20912090

20922091
return FALSE;

0 commit comments

Comments
 (0)