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
This commit is contained in:
Michael Drake 2010-04-08 13:22:32 +00:00
parent 4262232956
commit 19a38aa18e

View File

@ -320,8 +320,7 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height,
*/ */
int x0, y0, x1, y1; int x0, y0, x1, y1;
int src_x = 0; int dx, dy, dwidth, dheight;
int src_y = 0;
/* Bail early if we can */ /* Bail early if we can */
if (width == 0 || height == 0) 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); x1 = (x + width) - (cliprect.x + cliprect.width);
y1 = (y + height) - (cliprect.y + cliprect.height); 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 */ /* Render the bitmap */
if (gdk_pixbuf_get_width(pixbuf) == width && if (gdk_pixbuf_get_width(pixbuf) == width &&
gdk_pixbuf_get_height(pixbuf) == height) { gdk_pixbuf_get_height(pixbuf) == height) {
/* Bitmap is not scaled */ /* 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 */ /* Plot the bitmap */
gdk_draw_pixbuf(current_drawable, current_gc, pixbuf, 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); GDK_RGB_DITHER_MAX, 0, 0);
} else { } else {
/* Bitmap is scaled */ /* Bitmap is scaled */
GdkPixbuf *scaled; GdkPixbuf *scaled;
/* Create scaled bitmap
* VERY SLOW */
scaled = gdk_pixbuf_scale_simple(pixbuf, scaled = gdk_pixbuf_scale_simple(pixbuf,
width, height, width, height,
option_render_resample ? option_render_resample ?
@ -384,11 +390,9 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height,
if (!scaled) if (!scaled)
return false; return false;
gdk_draw_pixbuf(current_drawable, current_gc, /* Plot the scaled bitmap */
scaled, gdk_draw_pixbuf(current_drawable, current_gc, scaled,
0, 0, dx, dy, x, y, dwidth, dheight,
x, y,
width, height,
GDK_RGB_DITHER_MAX, 0, 0); GDK_RGB_DITHER_MAX, 0, 0);
g_object_unref(scaled); g_object_unref(scaled);