aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-10-23 16:18:24 +0100
committerThomas White <taw@bitwiz.org.uk>2015-10-23 16:18:24 +0100
commit5694221626157e5200f02b564c9c6c2b4f0d746c (patch)
treee61e4ea0aee52029f631568b90d4d7ee3e953994
parent548a3256d607ca564b25a98e7f4d8286fb07e6dd (diff)
Cull like crazy when rendering lines
-rw-r--r--src/render.c30
-rw-r--r--src/render.h3
-rw-r--r--src/sc_editor.c3
3 files changed, 25 insertions, 11 deletions
diff --git a/src/render.c b/src/render.c
index 9cef68f..1139ff6 100644
--- a/src/render.c
+++ b/src/render.c
@@ -258,7 +258,7 @@ static void draw_underfull_marker(cairo_t *cr, struct frame *fr, int i)
static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
- enum is_size isz)
+ enum is_size isz, double min_y, double max_y)
{
int i;
double y_pos = 0.0;
@@ -266,6 +266,16 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
for ( i=0; i<fr->n_lines; i++ ) {
+ /* FIXME: Line spacing */
+ double lh = pango_units_to_double(fr->lines[i].height);
+
+ if ( y_pos+lh < min_y ) {
+ y_pos += lh;
+ continue;
+ }
+
+ if ( y_pos > max_y ) break;
+
cairo_save(cr);
/* Move to beginning of the line */
@@ -304,8 +314,7 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
draw_underfull_marker(cr, fr, i);
}
- /* FIXME: line spacing */
- y_pos += pango_units_to_double(fr->lines[i].height);
+ y_pos += lh;
cairo_restore(cr);
@@ -361,7 +370,7 @@ static void do_background(cairo_t *cr, struct frame *fr)
static int draw_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
- enum is_size isz)
+ enum is_size isz, double min_y, double max_y)
{
cairo_save(cr);
do_background(cr, fr);
@@ -376,7 +385,7 @@ static int draw_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
/* Actually render the lines */
cairo_translate(cr, fr->pad_l, fr->pad_t);
- render_lines(fr, cr, is, isz);
+ render_lines(fr, cr, is, isz, min_y, max_y);
cairo_restore(cr);
return 0;
@@ -384,16 +393,19 @@ static int draw_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
int recursive_draw(struct frame *fr, cairo_t *cr,
- ImageStore *is, enum is_size isz)
+ ImageStore *is, enum is_size isz,
+ double min_y, double max_y)
{
int i;
- draw_frame(cr, fr, is, isz);
+ draw_frame(cr, fr, is, isz, min_y, max_y);
for ( i=0; i<fr->num_children; i++ ) {
cairo_save(cr);
cairo_translate(cr, fr->children[i]->x, fr->children[i]->y);
- recursive_draw(fr->children[i], cr, is, isz);
+ recursive_draw(fr->children[i], cr, is, isz,
+ min_y - fr->children[i]->y,
+ max_y - fr->children[i]->y);
cairo_restore(cr);
}
@@ -492,7 +504,7 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su
recursive_wrap(top, is, isz);
- recursive_draw(top, cr, is, isz);
+ recursive_draw(top, cr, is, isz, 0.0, log_h);
return top;
}
diff --git a/src/render.h b/src/render.h
index 88e333d..10da19f 100644
--- a/src/render.h
+++ b/src/render.h
@@ -54,6 +54,7 @@ extern int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz);
extern int export_pdf(struct presentation *p, const char *filename);
extern int recursive_draw(struct frame *fr, cairo_t *cr,
- ImageStore *is, enum is_size isz);
+ ImageStore *is, enum is_size isz,
+ double min_y, double max_y);
#endif /* RENDER_H */
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 2e1d17b..05f74f8 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -642,7 +642,8 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, SCEditor *e)
/* Contents */
cairo_translate(cr, 0.0, -e->scroll_pos);
cairo_translate(cr, e->border_offs_x, e->border_offs_y);
- recursive_draw(e->top, cr, e->is, ISZ_EDITOR);
+ recursive_draw(e->top, cr, e->is, ISZ_EDITOR,
+ e->scroll_pos, e->scroll_pos + e->visible_height);
/* Editing overlay */
draw_overlay(cr, e);