Package: webkit2pdf
Version: 0.2-2
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch precise

Hello,

In http://bugs.debian.org/644447 there is some discussion about
updating poppler to 0.18 in Debian. This will cause some FTBFS. We are
doing the transition in Ubuntu now and want to forward patches so that
they are readily available in Debian once 0.18 lands there. But this
patch works with poppler 0.16 just as well, so it's fine to apply to
Debian now.

This was reported upstream at

  
https://sourceforge.net/tracker/?func=detail&aid=3306044&group_id=264450&atid=1127720

I sent the patch there as well.

Thanks for considering,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
diff -Nru webkit2pdf-0.2/debian/changelog webkit2pdf-0.2/debian/changelog
--- webkit2pdf-0.2/debian/changelog     2011-07-31 12:27:13.000000000 +0200
+++ webkit2pdf-0.2/debian/changelog     2011-12-12 17:38:11.000000000 +0100
@@ -1,3 +1,10 @@
+webkit2pdf (0.2-2ubuntu1) precise; urgency=low
+
+  * Add debian/patches/poppler-0.18.patch: If building with a poppler >= 0.17,
+    provide our own poppler_page_render_to_pixbuf() function.
+
+ -- Martin Pitt <[email protected]>  Mon, 12 Dec 2011 17:38:11 +0100
+
 webkit2pdf (0.2-2) unstable; urgency=low
 
   * debian/control
diff -Nru webkit2pdf-0.2/debian/control webkit2pdf-0.2/debian/control
diff -Nru webkit2pdf-0.2/debian/patches/poppler-0.18.patch 
webkit2pdf-0.2/debian/patches/poppler-0.18.patch
--- webkit2pdf-0.2/debian/patches/poppler-0.18.patch    1970-01-01 
01:00:00.000000000 +0100
+++ webkit2pdf-0.2/debian/patches/poppler-0.18.patch    2011-12-12 
17:34:36.000000000 +0100
@@ -0,0 +1,150 @@
+Description: If building with a poppler >= 0.17, provide our own 
poppler_page_render_to_pixbuf() function.
+Author: Martin Pitt <[email protected]>
+Bug: 
http://sourceforge.net/tracker/?func=detail&aid=3306044&group_id=264450&atid=1127720
+
+Index: webkit2pdf/src/main.c
+===================================================================
+--- webkit2pdf.orig/src/main.c 2011-12-12 16:42:39.662892000 +0100
++++ webkit2pdf/src/main.c      2011-12-12 17:29:41.403366937 +0100
+@@ -53,6 +53,141 @@
+ gboolean enable_scripts = TRUE;
+ gboolean print_backgrounds = FALSE;
+ 
++#ifndef POPPLER_WITH_GDK
++#include <goo/gtypes.h>
++
++static void
++copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
++                            GdkPixbuf       *pixbuf)
++{
++  int cairo_width, cairo_height, cairo_rowstride;
++  unsigned char *pixbuf_data, *dst, *cairo_data;
++  int pixbuf_rowstride, pixbuf_n_channels;
++  unsigned int *src;
++  int x, y;
++
++  cairo_width = cairo_image_surface_get_width (surface);
++  cairo_height = cairo_image_surface_get_height (surface);
++  cairo_rowstride = cairo_image_surface_get_stride (surface);
++  cairo_data = cairo_image_surface_get_data (surface);
++
++  pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
++  pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
++  pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
++
++  if (cairo_width > gdk_pixbuf_get_width (pixbuf))
++    cairo_width = gdk_pixbuf_get_width (pixbuf);
++  if (cairo_height > gdk_pixbuf_get_height (pixbuf))
++    cairo_height = gdk_pixbuf_get_height (pixbuf);
++  for (y = 0; y < cairo_height; y++)
++    {
++      src = (unsigned int *) (cairo_data + y * cairo_rowstride);
++      dst = pixbuf_data + y * pixbuf_rowstride;
++      for (x = 0; x < cairo_width; x++) 
++      {
++        dst[0] = (*src >> 16) & 0xff;
++        dst[1] = (*src >> 8) & 0xff; 
++        dst[2] = (*src >> 0) & 0xff;
++        if (pixbuf_n_channels == 4)
++            dst[3] = (*src >> 24) & 0xff;
++        dst += pixbuf_n_channels;
++        src++;
++      }
++    }
++}
++
++static void
++_poppler_page_render_to_pixbuf (PopplerPage *page,
++                              int src_x, int src_y,
++                              int src_width, int src_height,
++                              double scale,
++                              int rotation,
++                              GBool printing,
++                              GdkPixbuf *pixbuf)
++{
++  cairo_t *cr;
++  cairo_surface_t *surface;
++
++  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
++                                      src_width, src_height);
++  cr = cairo_create (surface);
++  cairo_save (cr);
++  switch (rotation) {
++  case 90:
++        cairo_translate (cr, src_x + src_width, -src_y);
++        break;
++  case 180:
++        cairo_translate (cr, src_x + src_width, src_y + src_height);
++        break;
++  case 270:
++        cairo_translate (cr, -src_x, src_y + src_height);
++        break;
++  default:
++        cairo_translate (cr, -src_x, -src_y);
++  }
++
++  if (scale != 1.0)
++        cairo_scale (cr, scale, scale);
++
++  if (rotation != 0)
++        cairo_rotate (cr, rotation * G_PI / 180.0);
++
++  if (printing)
++        poppler_page_render_for_printing (page, cr);
++  else
++        poppler_page_render (page, cr);
++  cairo_restore (cr);
++
++  cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
++  cairo_set_source_rgb (cr, 1., 1., 1.);
++  cairo_paint (cr);
++
++  cairo_destroy (cr);
++
++  copy_cairo_surface_to_pixbuf (surface, pixbuf);
++  cairo_surface_destroy (surface);
++}
++
++/**
++ * poppler_page_render_to_pixbuf:
++ * @page: the page to render from
++ * @src_x: x coordinate of upper left corner  
++ * @src_y: y coordinate of upper left corner  
++ * @src_width: width of rectangle to render  
++ * @src_height: height of rectangle to render
++ * @scale: scale specified as pixels per point
++ * @rotation: rotate the document by the specified degree
++ * @pixbuf: pixbuf to render into
++ *
++ * First scale the document to match the specified pixels per point,
++ * then render the rectangle given by the upper left corner at
++ * (src_x, src_y) and src_width and src_height.
++ * This function is for rendering a page that will be displayed.
++ * If you want to render a page that will be printed use
++ * poppler_page_render_to_pixbuf_for_printing() instead
++ *
++ * Deprecated: 0.16
++ **/
++void
++poppler_page_render_to_pixbuf (PopplerPage *page,
++                             int src_x, int src_y,
++                             int src_width, int src_height,
++                             double scale,
++                             int rotation,
++                             GdkPixbuf *pixbuf)
++{
++  g_return_if_fail (POPPLER_IS_PAGE (page));
++  g_return_if_fail (scale > 0.0);
++  g_return_if_fail (pixbuf != NULL);
++
++  _poppler_page_render_to_pixbuf (page, src_x, src_y,
++                                src_width, src_height,
++                                scale, rotation,
++                                gFalse,
++                                pixbuf);
++}
++#endif
++
+ static WebKitNavigationResponse navigation_requested(WebKitWebView *view, 
+               WebKitWebFrame *frame, 
+               WebKitNetworkRequest *netreq, 
diff -Nru webkit2pdf-0.2/debian/patches/series 
webkit2pdf-0.2/debian/patches/series
--- webkit2pdf-0.2/debian/patches/series        1970-01-01 01:00:00.000000000 
+0100
+++ webkit2pdf-0.2/debian/patches/series        2011-12-12 17:27:33.000000000 
+0100
@@ -0,0 +1 @@
+poppler-0.18.patch

Attachment: signature.asc
Description: Digital signature

Reply via email to