[dia/cairo-port: 42/53] Port Gdk exporter to use DiaCairo
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/cairo-port: 42/53] Port Gdk exporter to use DiaCairo
- Date: Sat, 11 May 2019 15:35:48 +0000 (UTC)
commit 659179878502e515b6748c3e76dd3d51422a1925
Author: Zander Brown <zbrown gnome org>
Date: Fri Dec 7 04:44:15 2018 +0000
Port Gdk exporter to use DiaCairo
Tad meta but gets the job done
plug-ins/pixbuf/pixbuf.c | 51 +++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/plug-ins/pixbuf/pixbuf.c b/plug-ins/pixbuf/pixbuf.c
index 5c0b3f32..571d6eaa 100644
--- a/plug-ins/pixbuf/pixbuf.c
+++ b/plug-ins/pixbuf/pixbuf.c
@@ -26,7 +26,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "geometry.h"
-#include "diagdkrenderer.h"
+#include "renderer/diacairo.h"
#include "filter.h"
#include "plug-ins.h"
#include "properties.h"
@@ -38,13 +38,14 @@ export_data(DiagramData *data, DiaContext *ctx,
const gchar *filename, const gchar *diafilename,
void* user_data)
{
- DiaGdkRenderer *renderer;
+ DiaCairoRenderer *renderer;
GdkColor color;
int width, height;
GdkPixbuf* pixbuf = NULL;
GError* error = NULL;
Rectangle rect;
real zoom = 1.0;
+ cairo_t *cctx;
const char* format = (const char*)user_data;
rect.left = data->extents.left;
@@ -59,23 +60,41 @@ export_data(DiagramData *data, DiaContext *ctx,
width = ceil((rect.right - rect.left) * zoom) + 1;
height = ceil((rect.bottom - rect.top) * zoom) + 1;
- renderer = g_object_new (DIA_TYPE_GDK_RENDERER, NULL);
- renderer->transform = dia_transform_new (&rect, &zoom);
- renderer->pixmap = gdk_pixmap_new(NULL, width, height, gdk_visual_get_system()->depth);
- renderer->gc = gdk_gc_new(renderer->pixmap);
+ renderer = g_object_new (dia_cairo_renderer_get_type(), NULL);
+ renderer->scale = zoom;
+ renderer->surface = cairo_surface_reference (cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height));
+
+ cctx = cairo_create (renderer->surface);
/* draw background */
color_convert (&data->bg_color, &color);
- gdk_gc_set_foreground(renderer->gc, &color);
- gdk_draw_rectangle(renderer->pixmap, renderer->gc, 1,
- 0, 0, width, height);
-
- data_render(data, DIA_RENDERER (renderer), NULL, NULL, NULL);
-
- pixbuf = gdk_pixbuf_get_from_drawable (NULL, renderer->pixmap,
- gdk_colormap_get_system (),
- 0, 0, 0, 0,
- width, height);
+ gdk_cairo_set_source_color (cctx, &color);
+ cairo_rectangle (cctx, 0, 0, width, height);
+ cairo_fill (cctx);
+
+ data_render (data, DIA_RENDERER (renderer), NULL, NULL, NULL);
+
+ #if GTK_CHECK_VERSION(3,0,0)
+ pixbuf = gdk_pixbuf_get_from_surface (renderer->surface, 0, 0,
+ width, height);
+ #else
+ {
+ GdkPixmap *pixmap;
+ cairo_t *cr;
+
+ pixmap = gdk_pixmap_new (NULL, width, height, 24);
+ cr = gdk_cairo_create (pixmap);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface (cr, renderer->surface, 0, 0);
+ cairo_paint (cr);
+ pixbuf = gdk_pixbuf_get_from_drawable (NULL,
+ pixmap,
+ gdk_colormap_get_system (),
+ 0, 0, 0, 0, width, height);
+ }
+ #endif
if (pixbuf)
{
gdk_pixbuf_save (pixbuf, filename, format, &error, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]