Create the temporary buffer to the size of the interesction of the

1999-11-22  Federico Mena Quintero  <federico@redhat.com>

	* src/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_draw): Create the
	temporary buffer to the size of the interesction of the bounding
	box and the expose area, not the whole expose area.  This speeds
	up things a lot.

	* src/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Do
	not paint black on the mask, since we already cleared it in a
	single gdk_draw_rectangle() operation.
This commit is contained in:
Federico Mena Quintero 1999-11-24 08:19:58 +00:00 committed by Arturo Espinosa
parent 0b793d2cc8
commit b990b30723
3 changed files with 58 additions and 21 deletions

View File

@ -3,6 +3,17 @@
* Removed #PRAGMA } from headers. Also, make compile if you don't
have it installed, already.
1999-11-22 Federico Mena Quintero <federico@redhat.com>
* src/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_draw): Create the
temporary buffer to the size of the interesction of the bounding
box and the expose area, not the whole expose area. This speeds
up things a lot.
* src/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Do
not paint black on the mask, since we already cleared it in a
single gdk_draw_rectangle() operation.
1999-11-22 Raja R Harinath <harinath@cs.umn.edu>
* configure.in (GDK_PIXBUF_DIR): Fix for srcdir != builddir.

View File

@ -552,14 +552,14 @@ compute_viewport_affine (GnomeCanvasPixbuf *gcp, double *viewport_affine, double
/* Computes the affine transformation with which the pixbuf needs to be
* transformed to render it on the canvas. This is not the same as the
* item_to_canvas transformation because we may need to scale the pixbuf
* item_to_canvas transformation because we may need to scale the pixbuf
* by some other amount.
*/
static void
compute_render_affine (GnomeCanvasPixbuf *gcp, double *render_affine, double *i2c)
{
double viewport_affine[6];
compute_viewport_affine (gcp, viewport_affine, i2c);
art_affine_multiply (render_affine, viewport_affine, i2c);
}
@ -703,6 +703,8 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
double i2c[6], render_affine[6];
guchar *buf;
GdkPixbuf *pixbuf;
ArtIRect p_rect, a_rect, d_rect;
int w, h;
gcp = GNOME_CANVAS_PIXBUF (item);
priv = gcp->priv;
@ -713,21 +715,44 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gnome_canvas_item_i2c_affine (item, i2c);
compute_render_affine (gcp, render_affine, i2c);
buf = g_new0 (guchar, width * height * 4);
transform_pixbuf (buf, x, y, width, height, width * 4, priv->pixbuf, render_affine);
/* Compute the area we need to repaint */
pixbuf = gdk_pixbuf_new_from_data (buf, ART_PIX_RGB, TRUE,
width, height, width * 4,
NULL, NULL);
p_rect.x0 = item->x1;
p_rect.y0 = item->y1;
p_rect.x1 = item->x2;
p_rect.y1 = item->y2;
a_rect.x0 = x;
a_rect.y0 = y;
a_rect.x1 = x + width;
a_rect.y1 = y + height;
art_irect_intersect (&d_rect, &p_rect, &a_rect);
if (art_irect_empty (&d_rect))
return;
/* Create a temporary buffer and transform the pixbuf there */
w = d_rect.x1 - d_rect.x0;
h = d_rect.y1 - d_rect.y0;
buf = g_new0 (guchar, w * h * 4);
transform_pixbuf (buf,
d_rect.x0, d_rect.y0,
w, h,
w * 4,
priv->pixbuf, render_affine);
pixbuf = gdk_pixbuf_new_from_data (buf, ART_PIX_RGB, TRUE, w, h, w * 4, NULL, NULL);
gdk_pixbuf_render_to_drawable_alpha (pixbuf, drawable,
0, 0,
0, 0,
width, height,
d_rect.x0 - x, d_rect.y0 - y,
w, h,
GDK_PIXBUF_ALPHA_BILEVEL,
128,
GDK_RGB_DITHER_MAX,
x, y);
d_rect.x0, d_rect.y0);
gdk_pixbuf_unref (pixbuf);
g_free (buf);
@ -837,7 +862,7 @@ gnome_canvas_pixbuf_bounds (GnomeCanvasItem *item, double *x1, double *y1, doubl
rect.y0 = 0.0;
rect.y1 = priv->pixbuf->art_pixbuf->height;
gnome_canvas_item_i2c_affine (item, i2c);
compute_viewport_affine (gcp, viewport_affine, i2c);
art_drect_affine_transform (&rect, &rect, viewport_affine);

View File

@ -87,6 +87,9 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
gdk_gc_set_foreground (gc, &color);
gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
color.pixel = 1;
gdk_gc_set_foreground (gc, &color);
for (y = 0; y < height; y++) {
p = (apb->pixels + (y + src_y) * apb->rowstride + src_x * apb->n_channels
+ apb->n_channels - 1);
@ -98,11 +101,10 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
status = *p < alpha_threshold;
if (status != start_status) {
color.pixel = start_status ? 0 : 1;
gdk_gc_set_foreground (gc, &color);
gdk_draw_line (bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
if (!start_status)
gdk_draw_line (bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
start = x;
start_status = status;
@ -111,11 +113,10 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
p += apb->n_channels;
}
color.pixel = start_status ? 0 : 1;
gdk_gc_set_foreground (gc, &color);
gdk_draw_line (bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
if (!start_status)
gdk_draw_line (bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
}
gdk_gc_unref (gc);