Commit a3110818 authored by Zander's avatar Zander 💥

Merge branch 'cairo-port' into 'master'

Cairo port

See merge request !31
parents 24c91435 07971282
......@@ -328,13 +328,9 @@ do_convert(const char *infname,
* are quite some filter selecting their output format by it. --hb
*/
if (size) {
if (ef == filter_export_get_by_name ("png-libart")) /* the warning we get is appropriate, don't cast */
ef->export_func(diagdata, ctx, outfname, infname, (gpointer) size);
else {
g_warning ("--size parameter unsupported for %s filter",
ef->unique_name ? ef->unique_name : "selected");
ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
}
g_warning ("--size parameter unsupported for %s filter",
ef->unique_name ? ef->unique_name : "selected");
ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
}
else
ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
......@@ -370,15 +366,8 @@ dump_dependencies(void)
#ifdef G_THREADS_ENABLED
"threads "
#endif
#ifdef HAVE_CAIRO
"cairo "
#endif
#ifdef HAVE_LIBART
"libart "
#endif
#ifdef HAVE_PANGOCAIRO
"pangocairo "
#endif
"\n");
/* print out all those dependies, both compile and runtime if possible
......@@ -438,13 +427,7 @@ dump_dependencies(void)
#else
g_print ("pango : version not available (>= 1.14.x)\n"); /* Pango did not provide such */
#endif
#if HAVE_CAIRO
# ifdef CAIRO_VERSION_STRING
g_print ("cairo : %s (%s)\n", cairo_version_string(), CAIRO_VERSION_STRING);
# else
g_print ("cairo : %s (%d.%d.%d)\n", cairo_version_string(), CAIRO_VERSION_MAJOR, CAIRO_VERSION_MINOR, CAIRO_VERSION_MICRO);
# endif
#endif
#if 0
{
gchar linkedname[1024];
......@@ -492,11 +475,7 @@ handle_initial_diagram(const char *in_file_name,
/* First try guessing based on extension */
export_file_name = build_output_file_name(in_file_name, export_file_format, outdir);
/* to make the --size hack even uglier but work again for the only filter supporting it */
if ( size && strcmp(export_file_format, "png") == 0)
ef = filter_export_get_by_name ("png-libart");
if (!ef)
ef = filter_guess_export_filter(export_file_name);
ef = filter_guess_export_filter(export_file_name);
if (ef == NULL) {
ef = filter_export_get_by_name(export_file_format);
if (ef == NULL) {
......@@ -512,11 +491,6 @@ handle_initial_diagram(const char *in_file_name,
g_free(export_file_name);
} else if (out_file_name) {
DiaExportFilter *ef = NULL;
/* if this looks like an ugly hack to you, agreed ;) */
if (size && strstr(out_file_name, ".png"))
ef = filter_export_get_by_name ("png-libart");
made_conversions |= do_convert(in_file_name, out_file_name, ef,
size, show_layers);
} else {
......
......@@ -42,14 +42,9 @@ int active_color = 0;
/* Static variables */
GtkWidget *color_area;
static GdkGC *color_area_gc = NULL;
static GdkGC *mask_gc = NULL;
static GdkPixmap *color_area_pixmap = NULL;
static GdkBitmap *color_area_mask = NULL;
static GdkPixmap *default_pixmap = NULL;
static GdkBitmap *default_mask = NULL;
static GdkPixmap *swap_pixmap = NULL;
static GdkBitmap *swap_mask = NULL;
static GdkPixbuf *default_pixmap = NULL;
static GdkPixbuf *swap_pixmap = NULL;
static GtkWidget *color_select = NULL;
static int color_select_active = 0;
......@@ -109,22 +104,20 @@ color_area_target (int x,
}
static void
color_area_draw ()
color_area_draw (cairo_t *color_area_ctx)
{
Color col;
GdkColor *win_bg;
GdkColor fg, bg;
gint rect_w, rect_h;
gint width, height;
gint def_width, def_height;
gint swap_width, swap_height;
GdkColor mask_pattern;
gint img_width, img_height;
GtkStyle *style;
/* Check we haven't gotten initial expose yet,
* no point in drawing anything
*/
if (!color_area_pixmap || !color_area_gc)
if (!color_area_pixmap || !color_area_ctx)
return;
gdk_drawable_get_size (color_area_pixmap, &width, &height);
......@@ -139,24 +132,15 @@ color_area_draw ()
rect_w = width * 0.65;
rect_h = height * 0.65;
/* initialize the mask to transparent */
mask_pattern.pixel = 0;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);
gdk_cairo_set_source_color (color_area_ctx, win_bg);
cairo_rectangle (color_area_ctx, 0, 0, width, height);
cairo_fill (color_area_ctx);
/* set the mask's gc to opaque */
mask_pattern.pixel = 1;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_cairo_set_source_color (color_area_ctx, &bg);
gdk_gc_set_foreground (color_area_gc, win_bg);
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
0, 0, width, height);
gdk_gc_set_foreground (color_area_gc, &bg);
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
(width - rect_w), (height - rect_h), rect_w, rect_h);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
(width - rect_w), (height - rect_h), rect_w, rect_h);
cairo_rectangle (color_area_ctx,
(width - rect_w), (height - rect_h), rect_w, rect_h);
cairo_fill (color_area_ctx);
if (active_color == FOREGROUND)
gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
......@@ -171,11 +155,9 @@ color_area_draw ()
(width - rect_w), (height - rect_h),
rect_w, rect_h);
gdk_gc_set_foreground (color_area_gc, &fg);
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
0, 0, rect_w, rect_h);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
0, 0, rect_w, rect_h);
gdk_cairo_set_source_color (color_area_ctx, &fg);
cairo_rectangle (color_area_ctx, 0, 0, rect_w, rect_h);
cairo_fill (color_area_ctx);
if (active_color == FOREGROUND)
gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
......@@ -190,28 +172,19 @@ color_area_draw ()
0, 0,
rect_w, rect_h);
/* draw the default pixmap */
gdk_drawable_get_size (default_pixmap, &def_width, &def_height);
gdk_draw_drawable (color_area_pixmap, color_area_gc, default_pixmap,
0, 0, 0, height - def_height, def_width, def_height);
gdk_draw_drawable (color_area_mask, mask_gc, default_mask,
0, 0, 0, height - def_height, def_width, def_height);
/* draw the default colours pixmap */
img_width = gdk_pixbuf_get_width (default_pixmap);
img_height = gdk_pixbuf_get_height (default_pixmap);
gdk_cairo_set_source_pixbuf (color_area_ctx, default_pixmap, 0, height - img_height);
cairo_rectangle (color_area_ctx, 0, height - img_height, img_width, img_height);
cairo_fill (color_area_ctx);
/* draw the swap pixmap */
gdk_drawable_get_size (swap_pixmap, &swap_width, &swap_height);
gdk_draw_drawable (color_area_pixmap, color_area_gc, swap_pixmap,
0, 0, width - swap_width, 0, swap_width, swap_height);
gdk_draw_drawable (color_area_mask, mask_gc, swap_mask,
0, 0, width - swap_width, 0, swap_width, swap_height);
/* draw the widget */
gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
gdk_gc_set_clip_origin (color_area_gc, 0, 0);
gdk_draw_drawable (gtk_widget_get_window(color_area), color_area_gc, color_area_pixmap,
0, 0, 0, 0, width, height);
/* reset the clip mask */
gdk_gc_set_clip_mask (color_area_gc, NULL);
img_width = gdk_pixbuf_get_width (swap_pixmap);
img_height = gdk_pixbuf_get_height (swap_pixmap);
gdk_cairo_set_source_pixbuf (color_area_ctx, swap_pixmap, width - img_width, 0);
cairo_rectangle (color_area_ctx, width - img_width, 0, img_width, img_height);
cairo_fill (color_area_ctx);
}
static void
......@@ -236,7 +209,8 @@ color_selection_ok (GtkWidget *w,
} else {
attributes_set_background(&col);
}
color_area_draw ();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
/* gtk_color_selection_set_currentcolor(colorsel,&color);*/
......@@ -254,7 +228,8 @@ color_selection_cancel (GtkWidget *w,
attributes_set_foreground(&stored_foreground);
attributes_set_background(&stored_background);
color_area_draw ();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
}
static gint
......@@ -297,7 +272,8 @@ color_selection_changed (GtkWidget *w,
} else {
attributes_set_background(&col);
}
color_area_draw ();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
}
static void
......@@ -392,37 +368,19 @@ color_area_events (GtkWidget *widget,
GdkEventButton *bevent;
int target;
switch (event->type)
{
switch (event->type) {
case GDK_CONFIGURE:
if (color_area_pixmap)
{
g_object_unref (color_area_pixmap);
g_object_unref (color_area_mask);
}
color_area_pixmap = gdk_pixmap_new (gtk_widget_get_window(color_area),
color_area->allocation.width,
color_area->allocation.height, -1);
color_area_mask = gdk_pixmap_new (gtk_widget_get_window(color_area),
color_area->allocation.width,
color_area->allocation.height, 1);
if (color_area_pixmap) {
g_object_unref (color_area_pixmap);
}
color_area_pixmap = gdk_pixmap_new (gtk_widget_get_window (color_area),
color_area->allocation.width,
color_area->allocation.height, -1);
break;
case GDK_EXPOSE:
#if GTK_CHECK_VERSION(2,18,0)
if (gtk_widget_is_drawable(color_area))
#else
if (GTK_WIDGET_DRAWABLE (color_area))
#endif
{
if (!color_area_gc)
{
color_area_gc = gdk_gc_new (gtk_widget_get_window(color_area));
mask_gc = gdk_gc_new (color_area_mask);
}
color_area_draw ();
}
if (gtk_widget_is_drawable (color_area)) {
color_area_draw (gdk_cairo_create (gtk_widget_get_window (color_area)));
}
break;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
......@@ -435,16 +393,19 @@ color_area_events (GtkWidget *widget,
color_area_edit ();
} else {
active_color = target;
color_area_draw();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
}
break;
case SWAP_AREA:
attributes_swap_fgbg();
color_area_draw();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
break;
case DEF_AREA:
attributes_default_fgbg();
color_area_draw();
/* Trigger redraw */
gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
break;
}
}
......@@ -461,21 +422,15 @@ color_area_events (GtkWidget *widget,
#include "pixmaps/default.xpm"
GtkWidget *
color_area_create (int width,
int height,
GtkWidget *parent,
GtkStyle *style)
color_area_create (int width,
int height)
{
GtkWidget *event_box;
default_pixmap =
gdk_pixmap_colormap_create_from_xpm_d(NULL,
gtk_widget_get_colormap(parent), &default_mask,
&style->bg[GTK_STATE_NORMAL], default_xpm);
gdk_pixbuf_new_from_xpm_data (default_xpm);
swap_pixmap =
gdk_pixmap_colormap_create_from_xpm_d(NULL,
gtk_widget_get_colormap(parent), &swap_mask,
&style->bg[GTK_STATE_NORMAL], swap_xpm);
gdk_pixbuf_new_from_xpm_data (swap_xpm);
attributes_set_foreground(persistence_register_color("fg_color", &color_black));
attributes_set_background(persistence_register_color("bg_color", &color_white));
......
......@@ -20,6 +20,6 @@
#include <gtk/gtk.h>
GtkWidget *color_area_create (int width, int height, GtkWidget *parent, GtkStyle *style);
GtkWidget *color_area_create (int width, int height);
#endif /* COLOR_AREA_H */
......@@ -58,7 +58,6 @@ struct _DiaPageLayout {
GtkWidget *darea;
GdkGC *gc;
GdkColor white, black, blue;
gint papernum; /* index into page_metrics array */
......@@ -366,7 +365,6 @@ dia_page_layout_init(DiaPageLayout *self)
self->blue.blue = 0x7fff;
gdk_color_alloc(gtk_widget_get_colormap(GTK_WIDGET(self)), &self->blue);
self->gc = NULL;
self->block_changed = FALSE;
}
......@@ -610,68 +608,96 @@ darea_expose_event(DiaPageLayout *self, GdkEventExpose *event)
GdkWindow *window = gtk_widget_get_window(self->darea);
gfloat val;
gint num;
cairo_t *ctx;
if (!window)
return FALSE;
if (!self->gc)
self->gc = gdk_gc_new(window);
ctx = gdk_cairo_create (window);
cairo_set_line_cap (ctx, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_width (ctx, 1);
cairo_set_antialias (ctx, CAIRO_ANTIALIAS_NONE);
gdk_window_clear_area (window,
0, 0,
self->darea->allocation.width,
self->darea->allocation.height);
cairo_set_source_rgba (ctx, 0, 0, 0, 0);
cairo_rectangle (ctx, 0, 0,
self->darea->allocation.width,
self->darea->allocation.height);
cairo_fill (ctx);
/* draw the page image */
gdk_gc_set_foreground(self->gc, &self->black);
gdk_draw_rectangle(window, self->gc, TRUE, self->x+3, self->y+3,
self->width, self->height);
gdk_gc_set_foreground(self->gc, &self->white);
gdk_draw_rectangle(window, self->gc, TRUE, self->x, self->y,
self->width, self->height);
gdk_gc_set_foreground(self->gc, &self->black);
gdk_draw_rectangle(window, self->gc, FALSE, self->x, self->y,
self->width-1, self->height-1);
gdk_gc_set_foreground(self->gc, &self->blue);
gdk_cairo_set_source_color (ctx, &self->black);
cairo_rectangle(ctx, self->x+3, self->y+3, self->width, self->height);
cairo_fill (ctx);
gdk_cairo_set_source_color (ctx, &self->white);
cairo_rectangle (ctx, self->x, self->y, self->width, self->height);
cairo_fill (ctx);
gdk_cairo_set_source_color (ctx, &self->black);
cairo_rectangle (ctx, self->x + 1, self->y, self->width, self->height);
cairo_stroke (ctx);
gdk_cairo_set_source_color (ctx, &self->blue);
/* draw margins */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(self->orient_portrait))) {
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->tmargin));
num = self->y + val * self->height /get_paper_psheight(self->papernum);
gdk_draw_line(window, self->gc, self->x+1, num, self->x+self->width-2,num);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->bmargin));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->orient_portrait))) {
/* Top */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->tmargin));
num = self->y + val * self->height / get_paper_psheight (self->papernum);
cairo_move_to (ctx, self->x + 2, num);
cairo_line_to (ctx, self->x + self->width, num);
cairo_stroke (ctx);
/* Bottom */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->bmargin));
num = self->y + self->height -
val * self->height / get_paper_psheight(self->papernum);
gdk_draw_line(window, self->gc, self->x+1, num, self->x+self->width-2,num);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->lmargin));
num = self->x + val * self->width / get_paper_pswidth(self->papernum);
gdk_draw_line(window, self->gc, num, self->y+1,num,self->y+self->height-2);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->rmargin));
val * self->height / get_paper_psheight (self->papernum);
cairo_move_to (ctx, self->x + 2, num);
cairo_line_to (ctx, self->x + self->width, num);
cairo_stroke (ctx);
/* Left */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->lmargin));
num = self->x + val * self->width / get_paper_pswidth (self->papernum);
cairo_move_to (ctx, num + 1, self->y + 1);
cairo_line_to (ctx, num + 1, self->y + self->height - 1);
cairo_stroke (ctx);
/* Right */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->rmargin));
num = self->x + self->width -
val * self->width / get_paper_pswidth(self->papernum);
gdk_draw_line(window, self->gc, num, self->y+1,num,self->y+self->height-2);
val * self->width / get_paper_pswidth (self->papernum);
cairo_move_to (ctx, num + 1, self->y + 1);
cairo_line_to (ctx, num + 1, self->y + self->height - 1);
cairo_stroke (ctx);
} else {
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->tmargin));
num = self->y + val * self->height /get_paper_pswidth(self->papernum);
gdk_draw_line(window, self->gc, self->x+1, num, self->x+self->width-2,num);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->bmargin));
/* Top */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->tmargin));
num = self->y + val * self->height / get_paper_pswidth (self->papernum);
cairo_move_to (ctx, self->x + 2, num);
cairo_line_to (ctx, self->x + self->width, num);
cairo_stroke (ctx);
/* Bottom */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->bmargin));
num = self->y + self->height -
val * self->height / get_paper_pswidth(self->papernum);
gdk_draw_line(window, self->gc, self->x+1, num, self->x+self->width-2,num);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->lmargin));
num = self->x + val * self->width / get_paper_psheight(self->papernum);
gdk_draw_line(window, self->gc, num, self->y+1,num,self->y+self->height-2);
val = dia_unit_spinner_get_value(DIA_UNIT_SPINNER(self->rmargin));
val * self->height / get_paper_pswidth (self->papernum);
cairo_move_to (ctx, self->x + 2, num);
cairo_line_to (ctx, self->x + self->width, num);
cairo_stroke (ctx);
/* Left */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->lmargin));
num = self->x + val * self->width / get_paper_psheight (self->papernum);
cairo_move_to (ctx, num + 1, self->y + 1);
cairo_line_to (ctx, num + 1, self->y + self->height - 1);
cairo_stroke (ctx);
/* Right */
val = dia_unit_spinner_get_value (DIA_UNIT_SPINNER (self->rmargin));
num = self->x + self->width -
val * self->width / get_paper_psheight(self->papernum);
gdk_draw_line(window, self->gc, num, self->y+1,num,self->y+self->height-2);
val * self->width / get_paper_psheight (self->papernum);
cairo_move_to (ctx, num + 1, self->y + 1);
cairo_line_to (ctx, num + 1, self->y + self->height - 1);
cairo_stroke (ctx);
}
return FALSE;
......@@ -801,13 +827,6 @@ scale_changed(DiaPageLayout *self)
static void
dia_page_layout_destroy(GtkObject *object)
{
DiaPageLayout *self = DIA_PAGE_LAYOUT(object);
if (self->gc) {
g_object_unref(self->gc);
self->gc = NULL;
}
if (parent_class->destroy)
(* parent_class->destroy)(object);
}
......
......@@ -44,7 +44,7 @@
#include "layer_dialog.h"
#include "load_save.h"
#include "dia-props.h"
#include "render_gdk.h"
#include "renderer/diacairo.h"
#include "diatransform.h"
#include "recent_files.h"
#include "filedlg.h"
......@@ -199,8 +199,6 @@ copy_display(DDisplay *orig_ddisp)
ddisp->aa_renderer = orig_ddisp->aa_renderer;
ddisp->update_areas = orig_ddisp->update_areas;
ddisp->display_areas = orig_ddisp->display_areas;
ddisp->update_id = 0;
ddisp->clicked_position.x = ddisp->clicked_position.y = 0.0;
......@@ -258,8 +256,6 @@ new_display(Diagram *dia)
ddisp->aa_renderer = (preset > 0 ? TRUE : FALSE);
ddisp->update_areas = NULL;
ddisp->display_areas = NULL;
ddisp->update_id = 0;
ddisp->clicked_position.x = ddisp->clicked_position.y = 0.0;
......@@ -362,20 +358,6 @@ ddisplay_add_update_pixels(DDisplay *ddisp, Point *point,
ddisplay_add_update(ddisp, &rect);
}
/** Free display_areas list */
static void
ddisplay_free_display_areas(DDisplay *ddisp)
{
GSList *l;
l = ddisp->display_areas;
while(l!=NULL) {
g_free(l->data);
l = g_slist_next(l);
}
g_slist_free(ddisp->display_areas);
ddisp->display_areas = NULL;
}
/** Free update_areas list */
static void
ddisplay_free_update_areas(DDisplay *ddisp)
......@@ -399,9 +381,6 @@ ddisplay_add_update_all(DDisplay *ddisp)
if (ddisp->update_areas != NULL) {
ddisplay_free_update_areas(ddisp);
}
if (ddisp->display_areas != NULL) {
ddisplay_free_display_areas(ddisp);
}
ddisplay_add_update(ddisp, &ddisp->visible);
}
......@@ -426,14 +405,12 @@ void
ddisplay_add_update(DDisplay *ddisp, const Rectangle *rect)
{
Rectangle *r;
int top,bottom,left,right;
Rectangle *visible;
int width, height;
// int width, height;
if (!ddisp->renderer)
return; /* can happen at creation time of the diagram */
width = dia_renderer_get_width_pixels (ddisp->renderer);
height = dia_renderer_get_height_pixels (ddisp->renderer);
// width = dia_renderer_get_width_pixels (ddisp->renderer);
// height = dia_renderer_get_height_pixels (ddisp->renderer);
if (!rectangle_intersects(rect, &ddisp->visible))
return;
......@@ -450,122 +427,7 @@ ddisplay_add_update(DDisplay *ddisp, const Rectangle *rect)
rectangle_intersection(r, &ddisp->visible);
}
visible = &ddisp->visible;
left = floor( (r->left - visible->left) * (real)width /
(visible->right - visible->left) ) - 1;
top = floor( (r->top - visible->top) * (real)height /
(visible->bottom - visible->top) ) - 1;
right = ceil( (r->right - visible->left) * (real)width /
(visible->right - visible->left) ) + 1;
bottom = ceil( (r->bottom - visible->top) * (real)height /
(visible->bottom - visible->top) ) + 1;
ddisplay_add_display_area(ddisp,
left, top,
right, bottom);
}
void
ddisplay_add_display_area(DDisplay *ddisp,
int left, int top,
int right, int bottom)
{
IRectangle *r;
if (!ddisp->renderer)
return; /* if we don't have a renderer yet prefer ignoring over crashing */
if (left < 0)
left = 0;
if (top < 0)
top = 0;
if (right > dia_renderer_get_width_pixels (ddisp->renderer))
right = dia_renderer_get_width_pixels (ddisp->renderer);
if (bottom > dia_renderer_get_height_pixels (ddisp->renderer))
bottom = dia_renderer_get_height_pixels (ddisp->renderer);
/* draw some rectangles to show where updates are...*/
/*
gdk_draw_rectangle(gtk_widget_get_window(ddisp->canvas),
gtk_widget_get_style(ddisp->canvas)->black_gc, TRUE,
left, top, right-left,bottom-top);
*/
/* Temporarily just do a union of all Irectangles: */
if (ddisp->display_areas==NULL) {
r = g_new(IRectangle,1);
r->top = top; r->bottom = bottom;
r->left = left; r->right = right;
ddisp->display_areas = g_slist_prepend(ddisp->display_areas, r);
} else {
r = (IRectangle *) ddisp->display_areas->data;
r->top = MIN( r->top, top );
r->bottom = MAX( r->bottom, bottom );
r->left = MIN( r->left, left );
r->right = MAX( r->right, right );
}
}
static gboolean
ddisplay_update_handler(DDisplay *ddisp)
{
GSList *l;
IRectangle *ir;
Rectangle *r, totrect;
DiaInteractiveRendererInterface *renderer;
g_return_val_if_fail (ddisp->renderer != NULL, FALSE);
/* Renders updates to pixmap + copies display_areas to canvas(screen) */
renderer = DIA_GET_INTERACTIVE_RENDERER_INTERFACE (ddisp->renderer);
/* Only update if update_areas exist */
l = ddisp->update_areas;
if (l != NULL)
{
totrect = *(Rectangle *) l->data;
g_return_val_if_fail ( renderer->clip_region_clear != NULL
&& renderer->clip_region_add_rect != NULL, FALSE);
renderer->clip_region_clear (ddisp->renderer);
while(l!=NULL) {
r = (Rectangle *) l->data;
rectangle_union(&totrect, r);
renderer->clip_region_add_rect (ddisp->renderer, r);
l = g_slist_next(l);
}
/* Free update_areas list: */
ddisplay_free_update_areas(ddisp);
totrect.left -= 0.1;
totrect.right += 0.1;
totrect.top -= 0.1;
totrect.bottom += 0.1;
ddisplay_render_pixmap(ddisp, &totrect);
}
l = ddisp->display_areas;
while(l!=NULL) {
ir = (IRectangle *) l->data;
g_return_val_if_fail (renderer->copy_to_window, FALSE);
renderer->copy_to_window(ddisp->renderer,
gtk_widget_get_window(ddisp->canvas),
ir->left, ir->top,
ir->right - ir->left, ir->bottom - ir->top);
l = g_slist_next(l);
}
ddisplay_free_display_areas(ddisp);
ddisp->update_id = 0;
return FALSE;
gtk_widget_queue_draw (ddisp->canvas);
}