[vte/wip/paint-simplification: 2/2] draw: Clip lines
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/paint-simplification: 2/2] draw: Clip lines
- Date: Wed, 8 May 2019 20:35:49 +0000 (UTC)
commit f259c8816442654be147d9e7c4de51d01337341b
Author: Christian Persch <chpe src gnome org>
Date: Wed May 8 22:35:13 2019 +0200
draw: Clip lines
Draw each line clipped to its rectangle, so there will be no overdrawing
of adjacent lines.
Instead of first iterating over all lines to draw the background, the again
iterating over all lines to draw the text, iterate only once over the lines,
first drawing all the backgrounds and then all the text of that line.
src/vte.cc | 20 ++++----------------
src/vtedraw.cc | 16 ++++++++++++++++
src/vtedraw.hh | 22 ++++++++++++++++++++++
3 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 4221d279..1c5731b8 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8830,6 +8830,9 @@ Terminal::draw_rows(VteScreen *screen_,
if (row_data == nullptr)
continue; /* Skip row. */
+ /* Clip to the line, so no drawing over adjacent lines happens */
+ _vte_draw_autoclip_t clipper{m_draw, &rect};
+
i = j = 0;
/* Walk the line.
* Locate runs of identical bg colors within a row, and paint each run as a single
rectangle. */
@@ -8866,23 +8869,8 @@ Terminal::draw_rows(VteScreen *screen_,
* match the first one in this set. */
i = j;
} while (i < column_count);
- }
-
-
- /* Render the text. */
- rect = cairo_rectangle_int_t{-m_padding.left, start_y, rect_width, row_height}; /* reset rect */
- for (row = start_row, y = start_y; row < end_row; row++, y += row_height, rect.y = y) {
- /* Check whether we need to draw this row at all */
- if (cairo_region_contains_rectangle(region, &rect) == CAIRO_REGION_OVERLAP_OUT)
- continue;
-
- row_data = find_row_data(row);
- if (row_data == NULL) {
- /* Skip row. */
- continue;
- }
- /* Walk the line.
+ /* Walk the line again to draw the text.
* Locate runs of identical attributes within a row, and draw each run using a single
draw_cells() call. */
item_count = 0;
for (col = 0; col < column_count; ) {
diff --git a/src/vtedraw.cc b/src/vtedraw.cc
index 4f56f611..215e27ee 100644
--- a/src/vtedraw.cc
+++ b/src/vtedraw.cc
@@ -812,6 +812,22 @@ _vte_draw_set_cairo (struct _vte_draw *draw,
}
}
+void
+_vte_draw_clip(struct _vte_draw *draw,
+ cairo_rectangle_int_t const* rect)
+{
+ cairo_save(draw->cr);
+ cairo_rectangle(draw->cr,
+ rect->x, rect->y, rect->width, rect->height);
+ cairo_clip(draw->cr);
+}
+
+void
+_vte_draw_unclip(struct _vte_draw *draw)
+{
+ cairo_restore(draw->cr);
+}
+
static void
_vte_draw_set_source_color_alpha (struct _vte_draw *draw,
vte::color::rgb const* color,
diff --git a/src/vtedraw.hh b/src/vtedraw.hh
index f10af608..7352d376 100644
--- a/src/vtedraw.hh
+++ b/src/vtedraw.hh
@@ -55,6 +55,11 @@ void _vte_draw_free(struct _vte_draw *draw);
void _vte_draw_set_cairo(struct _vte_draw *draw,
cairo_t *cr);
+void _vte_draw_clip(struct _vte_draw *draw,
+ cairo_rectangle_int_t const* rect);
+
+void _vte_draw_unclip(struct _vte_draw *draw);
+
void _vte_draw_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height,
vte::color::rgb const* color, double alpha);
@@ -102,4 +107,21 @@ _vte_draw_draw_undercurl(struct _vte_draw *draw,
G_END_DECLS
+class _vte_draw_autoclip_t {
+private:
+ struct _vte_draw* m_draw;
+public:
+ _vte_draw_autoclip_t(struct _vte_draw* draw,
+ cairo_rectangle_int_t const* rect)
+ : m_draw{draw}
+ {
+ _vte_draw_clip(m_draw, rect);
+ }
+
+ ~_vte_draw_autoclip_t()
+ {
+ _vte_draw_unclip(m_draw);
+ }
+};
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]