diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2010-04-08 13:22:32 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2010-04-08 13:22:32 +0000 |
commit | 19a38aa18e359136742182c437e23fc002bfde94 (patch) | |
tree | 8164e62020557209f8f47279254b9c76a2f8948f /gtk/gtk_plotters.c | |
parent | 42622329563e1814c292be589586b3de709dcee0 (diff) | |
download | netsurf-19a38aa18e359136742182c437e23fc002bfde94.tar.gz netsurf-19a38aa18e359136742182c437e23fc002bfde94.tar.bz2 |
Manually clip for scaled plots too. Doesn't make much difference to performance because the creation of scaled bitmaps is so slow.
svn path=/trunk/netsurf/; revision=10305
Diffstat (limited to 'gtk/gtk_plotters.c')
-rw-r--r-- | gtk/gtk_plotters.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c index d8753ad05..433390365 100644 --- a/gtk/gtk_plotters.c +++ b/gtk/gtk_plotters.c @@ -320,8 +320,7 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height, */ int x0, y0, x1, y1; - int src_x = 0; - int src_y = 0; + int dx, dy, dwidth, dheight; /* Bail early if we can */ if (width == 0 || height == 0) @@ -341,41 +340,48 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height, x1 = (x + width) - (cliprect.x + cliprect.width); y1 = (y + height) - (cliprect.y + cliprect.height); + /* Set initial draw geometry */ + dx = dy = 0; + dwidth = width; + dheight = height; + + /* Manually clip draw coordinates to area of image to be rendered */ + if (x0 > 0) { + /* Clip left */ + dx = x0; + x += x0; + dwidth -= x0; + } + if (y0 > 0) { + /* Clip top */ + dy = y0; + y += y0; + dheight -= y0; + } + if (x1 > 0) { + /* Clip right */ + dwidth -= x1; + } + if (y1 > 0) { + /* Clip bottom */ + dheight -= y1; + } + /* Render the bitmap */ if (gdk_pixbuf_get_width(pixbuf) == width && gdk_pixbuf_get_height(pixbuf) == height) { /* Bitmap is not scaled */ - - /* Manually clip to area of image to be rendered */ - if (x0 > 0) { - /* Clip left */ - src_x = x0; - x += x0; - width -= x0; - } - if (y0 > 0) { - /* Clip top */ - src_y = y0; - y += y0; - height -= y0; - } - if (x1 > 0) { - /* Clip right */ - width -= x1; - } - if (y1 > 0) { - /* Clip bottom */ - height -= y1; - } - /* Plot the bitmap */ gdk_draw_pixbuf(current_drawable, current_gc, pixbuf, - src_x, src_y, x, y, width, height, + dx, dy, x, y, dwidth, dheight, GDK_RGB_DITHER_MAX, 0, 0); } else { /* Bitmap is scaled */ GdkPixbuf *scaled; + + /* Create scaled bitmap + * VERY SLOW */ scaled = gdk_pixbuf_scale_simple(pixbuf, width, height, option_render_resample ? @@ -384,11 +390,9 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height, if (!scaled) return false; - gdk_draw_pixbuf(current_drawable, current_gc, - scaled, - 0, 0, - x, y, - width, height, + /* Plot the scaled bitmap */ + gdk_draw_pixbuf(current_drawable, current_gc, scaled, + dx, dy, x, y, dwidth, dheight, GDK_RGB_DITHER_MAX, 0, 0); g_object_unref(scaled); |