[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.2-20090328-194-g3191d47)
The branch, master has been updated
via 3191d47aa5f71847c876a35371a89cb38825e66b (commit)
from a85d470427b905a5079ed1515034410fc3875ceb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
gschem/src/o_grips.c | 2 +-
gschem/src/o_picture.c | 88 +++++++++++++++++--------------------
libgeda/include/libgeda/struct.h | 3 +-
libgeda/src/o_picture.c | 23 ++++------
libgeda/src/s_basic.c | 6 +--
5 files changed, 53 insertions(+), 69 deletions(-)
=================
Commit Messages
=================
commit 3191d47aa5f71847c876a35371a89cb38825e66b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Render images using cairo, not GDK
:100644 100644 d6db1bb... 1889c0f... M gschem/src/o_grips.c
:100644 100644 f4e0140... 5302ded... M gschem/src/o_picture.c
:100644 100644 2606798... 7a19f39... M libgeda/include/libgeda/struct.h
:100644 100644 c3853b9... a90f3ff... M libgeda/src/o_picture.c
:100644 100644 0512945... 40eba1f... M libgeda/src/s_basic.c
=========
Changes
=========
commit 3191d47aa5f71847c876a35371a89cb38825e66b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
gschem: Render images using cairo, not GDK
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index d6db1bb..1889c0f 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -823,7 +823,7 @@ void o_grips_start_picture(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
/* erase the picture before */
o_invalidate (w_current, o_current);
- w_current->current_pixbuf = o_current->picture->original_picture;
+ w_current->current_pixbuf = o_current->picture->pixbuf;
w_current->pixbuf_filename = o_current->picture->filename;
w_current->pixbuf_wh_ratio = o_current->picture->ratio;
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index f4e0140..5302ded 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -303,9 +303,9 @@ void o_picture_draw (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
int s_upper_x, s_upper_y, s_lower_x, s_lower_y;
- GdkPixbuf *temp_pixbuf1, *temp_pixbuf2;
- if (o_current->picture == NULL) {
+ if (o_current->picture == NULL ||
+ toplevel->DONT_REDRAW) {
return;
}
@@ -314,53 +314,45 @@ void o_picture_draw (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
WORLDtoSCREEN (w_current, o_current->picture->lower_x,
o_current->picture->lower_y, &s_lower_x, &s_lower_y);
- if (o_current->picture->displayed_picture != NULL) {
- g_object_unref (o_current->picture->displayed_picture);
- o_current->picture->displayed_picture = NULL;
- }
-
- /* Create a copy of the pixbuf rotated */
- temp_pixbuf1 = gdk_pixbuf_rotate (o_current->picture->original_picture,
- o_current->picture->angle);
-
- if (temp_pixbuf1 == NULL) {
- fprintf (stderr, "Couldn't get enough memory for rotating the picture\n");
- return;
- }
-
- temp_pixbuf2 = gdk_pixbuf_mirror_flip (temp_pixbuf1,
- o_current->picture->mirrored, FALSE);
- g_object_unref (temp_pixbuf1);
-
- if (temp_pixbuf2 == NULL) {
- fprintf (stderr, "Couldn't get enough memory for mirroring the picture\n");
- return;
+ cairo_save (w_current->cr);
+
+ int swap_wh = (o_current->picture->angle == 90 || o_current->picture->angle == 270);
+ float orig_width = swap_wh ? gdk_pixbuf_get_height (o_current->picture->pixbuf) :
+ gdk_pixbuf_get_width (o_current->picture->pixbuf);
+ float orig_height = swap_wh ? gdk_pixbuf_get_width (o_current->picture->pixbuf) :
+ gdk_pixbuf_get_height (o_current->picture->pixbuf);
+
+ cairo_translate (w_current->cr, s_upper_x, s_upper_y);
+ cairo_scale (w_current->cr,
+ (float)SCREENabs (w_current, abs (o_current->picture->upper_x -
+ o_current->picture->lower_x)) / orig_width,
+ (float)SCREENabs (w_current, abs (o_current->picture->upper_y -
+ o_current->picture->lower_y)) / orig_height);
+
+ /* Evil magic translates picture origin to the right position for a given rotation */
+ switch (o_current->picture->angle) {
+ case 0: break;
+ case 90: cairo_translate (w_current->cr, 0, orig_height); break;
+ case 180: cairo_translate (w_current->cr, orig_width, orig_height); break;
+ case 270: cairo_translate (w_current->cr, orig_width, 0 ); break;
}
+ cairo_rotate (w_current->cr, -o_current->picture->angle * M_PI / 180.);
+ if (o_current->picture->mirrored)
+ cairo_scale (w_current->cr, -1, 1);
- o_current->picture->displayed_picture =
- gdk_pixbuf_scale_simple (temp_pixbuf2,
- abs (s_lower_x - s_upper_x),
- abs (s_lower_y - s_upper_y),
- GDK_INTERP_BILINEAR);
- g_object_unref (temp_pixbuf2);
+ gdk_cairo_set_source_pixbuf (w_current->cr,
+ o_current->picture->pixbuf, 0,0);
+ cairo_rectangle (w_current->cr, 0, 0,
+ gdk_pixbuf_get_width (o_current->picture->pixbuf),
+ gdk_pixbuf_get_height (o_current->picture->pixbuf));
- if (o_current->picture->displayed_picture == NULL) {
- fprintf (stderr, "Couldn't get enough memory for scaling the picture\n");
- return;
- }
-
- if (toplevel->DONT_REDRAW == 0) {
- gdk_draw_pixbuf (w_current->drawable, w_current->gc,
- o_current->picture->displayed_picture,
- 0, 0, s_upper_x, s_upper_y,
- -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
- }
+ cairo_clip (w_current->cr);
+ cairo_paint (w_current->cr);
+ cairo_restore (w_current->cr);
/* Grip specific stuff */
if (o_current->selected && w_current->draw_grips) {
- if (toplevel->DONT_REDRAW == 0) {
- o_picture_draw_grips (w_current, o_current);
- }
+ o_picture_draw_grips (w_current, o_current);
}
}
@@ -470,9 +462,9 @@ void o_picture_exchange (GSCHEM_TOPLEVEL *w_current, GdkPixbuf *pixbuf,
object->picture->filename = (char *) g_strdup(filename);
/* Unref the old pixmap */
- if (object->picture->original_picture != NULL) {
- g_object_unref(object->picture->original_picture);
- object->picture->original_picture=NULL;
+ if (object->picture->pixbuf != NULL) {
+ g_object_unref (object->picture->pixbuf);
+ object->picture->pixbuf = NULL;
}
if (object->picture->embedded) {
@@ -482,8 +474,8 @@ void o_picture_exchange (GSCHEM_TOPLEVEL *w_current, GdkPixbuf *pixbuf,
} else {
/* For non-embedded pictures, create a copy of the passed pixbuf
* and insert it manually */
- object->picture->original_picture = gdk_pixbuf_copy(pixbuf);
- if (object->picture->original_picture == NULL) {
+ object->picture->pixbuf = gdk_pixbuf_copy (pixbuf);
+ if (object->picture->pixbuf == NULL) {
fprintf(stderr, "change picture: Couldn't get enough memory for the new picture\n");
return;
}
diff --git a/libgeda/include/libgeda/struct.h b/libgeda/include/libgeda/struct.h
index 2606798..7a19f39 100644
--- a/libgeda/include/libgeda/struct.h
+++ b/libgeda/include/libgeda/struct.h
@@ -159,8 +159,7 @@ struct st_box {
#define BOX_LOWER_LEFT 3
struct st_picture {
- GdkPixbuf *original_picture;
- GdkPixbuf *displayed_picture;
+ GdkPixbuf *pixbuf;
gchar *file_content;
gsize file_length;
diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c
index c3853b9..a90f3ff 100644
--- a/libgeda/src/o_picture.c
+++ b/libgeda/src/o_picture.c
@@ -340,8 +340,7 @@ OBJECT *o_picture_new(TOPLEVEL *toplevel, GdkPixbuf *pixbuf,
picture->file_length = file_length;
picture->filename = g_strdup (filename);
picture->ratio = ratio;
- picture->original_picture = gdk_pixbuf_copy(pixbuf);
- picture->displayed_picture = NULL;
+ picture->pixbuf = gdk_pixbuf_copy (pixbuf);
picture->angle = angle;
picture->mirrored = mirrored;
picture->embedded = embedded;
@@ -701,11 +700,7 @@ OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *object)
picture->embedded = object->picture->embedded;
/* Copy the picture data */
- picture->original_picture =
- gdk_pixbuf_copy(object->picture->original_picture);
-
- picture->displayed_picture =
- gdk_pixbuf_copy(object->picture->displayed_picture);
+ picture->pixbuf = gdk_pixbuf_copy (object->picture->pixbuf);
new_node->draw_func = object->draw_func;
new_node->sel_func = object->sel_func;
@@ -814,7 +809,7 @@ void o_picture_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
{
int x1, y1, x, y;
int height, width;
- GdkPixbuf* image = o_current->picture->original_picture;
+ GdkPixbuf* image = o_current->picture->pixbuf;
int img_width, img_height, img_rowstride;
guint8 *rgb_data;
guint8 *mask_data;
@@ -921,10 +916,10 @@ void o_picture_embed (TOPLEVEL *toplevel, OBJECT *object)
}
/* Change to the new pixbuf loaded before we embedded. */
- if (object->picture->original_picture != NULL)
- g_object_unref(object->picture->original_picture);
+ if (object->picture->pixbuf != NULL)
+ g_object_unref (object->picture->pixbuf);
- object->picture->original_picture = pixbuf;
+ object->picture->pixbuf = pixbuf;
filename = g_path_get_basename(object->picture->filename);
s_log_message (_("Picture [%s] has been embedded\n"), filename);
@@ -956,10 +951,10 @@ void o_picture_unembed (TOPLEVEL *toplevel, OBJECT *object)
}
/* Change to the new pixbuf loaded from the file. */
- if (object->picture->original_picture != NULL)
- g_object_unref(object->picture->original_picture);
+ if (object->picture->pixbuf != NULL)
+ g_object_unref(object->picture->pixbuf);
- object->picture->original_picture = pixbuf;
+ object->picture->pixbuf = pixbuf;
g_free (object->picture->file_content);
object->picture->file_content = NULL;
diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
index 0512945..40eba1f 100644
--- a/libgeda/src/s_basic.c
+++ b/libgeda/src/s_basic.c
@@ -263,10 +263,8 @@ s_delete_object(TOPLEVEL *toplevel, OBJECT *o_current)
/* printf("sdeleting picture\n");*/
g_free(o_current->picture->file_content);
- if (o_current->picture->original_picture)
- g_object_unref(o_current->picture->original_picture);
- if (o_current->picture->displayed_picture)
- g_object_unref(o_current->picture->displayed_picture);
+ if (o_current->picture->pixbuf)
+ g_object_unref (o_current->picture->pixbuf);
g_free(o_current->picture->filename);
g_free(o_current->picture);
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs