[poppler] poppler/glib: Makefile.am, 1.14, 1.15 poppler-features.h.in, NONE, 1.1 poppler-page.cc, 1.45, 1.46 poppler-page.h, 1.20, 1.21 poppler.h, 1.10, 1.11

Kristian Høgsberg krh at kemper.freedesktop.org
Tue Apr 11 19:07:09 PDT 2006


Update of /cvs/poppler/poppler/glib
In directory kemper:/tmp/cvs-serv7212/glib

Modified Files:
	Makefile.am poppler-page.cc poppler-page.h poppler.h 
Added Files:
	poppler-features.h.in 
Log Message:
2006-04-11  Kristian Høgsberg  <krh at redhat.com>

	* configure.ac:
	* poppler-glib.pc.in:
	* glib/Makefile.am:
	* glib/poppler-page.cc:
	* glib/poppler-page.h:
	* glib/poppler.h:
	* poppler/CairoOutputDev.cc:
	* poppler/CairoOutputDev.h:
	* glib/poppler-features.h.in:
	Make the CairoOutputDev render to a cairo_t instead of a
	cairo_surface_t and expose that functionality in the glib wrapper
	(poppler_page_render).

	* test/Makefile.am:
	* test/gtk-cairo-test.cc:
	Update gtk-cairo-test to use this new interface and add a spin
	button for changing page (#5951).

	* utils/Makefile.am (EXTRA_DIST): Fix warning where this was
	assigned twice.
	


Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/glib/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.am	9 Mar 2006 21:56:08 -0000	1.14
+++ Makefile.am	12 Apr 2006 02:07:07 -0000	1.15
@@ -66,7 +66,8 @@
 
 poppler_glib_include_HEADERS =			\
 	$(poppler_glib_public_headers)		\
-	poppler-enums.h
+	poppler-enums.h				\
+	poppler-features.h
 
 lib_LTLIBRARIES = libpoppler-glib.la
 libpoppler_glib_la_SOURCES =			\
@@ -98,9 +99,10 @@
 	$(FREETYPE_LIBS)			\
 	$(cairo_libs)
 
-BUILT_SOURCES = \
-	poppler-enums.c	\
-	poppler-enums.h
+BUILT_SOURCES =					\
+	poppler-enums.c				\
+	poppler-enums.h				\
+	poppler-features.h
 
 CLEANFILES = $(BUILT_SOURCES) $(stamp_files)
 DISTCLEANFILES = $(BUILT_SOURCES) $(stamp_files)

--- NEW FILE: poppler-features.h.in ---
/* poppler-features.h: glib interface to poppler
 * Copyright (C) 2006, Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __POPPLER_FEATURES_H__
#define __POPPLER_FEATURES_H__

@CAIRO_FEATURE@

#endif /* __POPPLER_FEATURES_H__ */

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- poppler-page.cc	21 Mar 2006 04:25:53 -0000	1.45
+++ poppler-page.cc	12 Apr 2006 02:07:07 -0000	1.46
@@ -127,6 +127,7 @@
 typedef struct {
   unsigned char *cairo_data;
   cairo_surface_t *surface;
+  cairo_t *cairo;
 } OutputDevData;
 
 static void
@@ -138,19 +139,13 @@
 {
   CairoOutputDev *output_dev;
   cairo_surface_t *surface;
+  double width, height;
   int cairo_width, cairo_height, cairo_rowstride;
-  int rotate;
   unsigned char *cairo_data;
 
-  rotate = (rotation + page->page->getRotate()) % 360;
-
-  if (rotate == 90 || rotate == 270) {
-    cairo_width = MAX ((int)(page->page->getCropHeight() * scale + 0.5), 1);
-    cairo_height = MAX ((int)(page->page->getCropWidth() * scale + 0.5), 1);
-  } else {
-    cairo_width = MAX ((int)(page->page->getCropWidth() * scale + 0.5), 1);
-    cairo_height = MAX ((int)(page->page->getCropHeight() * scale + 0.5), 1);
-  }
+  poppler_page_get_size (page, &width, &height);
+  cairo_width = (int) ceil(width * scale);
+  cairo_height = (int) ceil(height * scale);
 
   output_dev = page->document->output_dev;
   cairo_rowstride = cairo_width * 4;
@@ -167,7 +162,8 @@
 
   output_dev_data->cairo_data = cairo_data;
   output_dev_data->surface = surface;
-  output_dev->setSurface (surface);
+  output_dev_data->cairo = cairo_create (surface);
+  output_dev->setCairo (output_dev_data->cairo);
 }
 
 static void
@@ -194,7 +190,6 @@
     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);
@@ -211,8 +206,9 @@
 	}
     }
 
-  page->document->output_dev->setSurface (NULL);
+  page->document->output_dev->setCairo (NULL);
   cairo_surface_destroy (output_dev_data->surface);
+  cairo_destroy (output_dev_data->cairo);
   gfree (output_dev_data->cairo_data);
 }
 
@@ -282,13 +278,44 @@
 
 #endif
 
+#if defined (HAVE_CAIRO)
+
 /**
- * poppler_page_render_to_pixbuf:
+ * poppler_page_render:
+ * @page: the page to render from
+ * @cairo: cairo context to render to
+ *
+ * Render the page to the given cairo context.
+ **/
+void
+poppler_page_render (PopplerPage *page,
+		     cairo_t *cairo)
+{
+  CairoOutputDev *output_dev;
+
+  g_return_if_fail (POPPLER_IS_PAGE (page));
+
+  output_dev = page->document->output_dev;
+  output_dev->setCairo (cairo);
+
+  page->page->displaySlice(output_dev,
+			   72.0, 72.0, 0,
+			   gFalse, /* useMediaBox */
+			   gTrue, /* Crop */
+			   0, 0,
+			   (int) ceil (page->page->getCropWidth ()),
+			   (int) ceil (page->page->getCropHeight ()),
+			   NULL, /* links */
+			   page->document->doc->getCatalog ());
+
+  output_dev->setCairo (NULL);
+}
+
+#endif
+
+/**
+ * poppler_page_render:
  * @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

Index: poppler-page.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- poppler-page.h	24 Aug 2005 18:57:46 -0000	1.20
+++ poppler-page.h	12 Apr 2006 02:07:07 -0000	1.21
@@ -24,6 +24,10 @@
 #include <gdk/gdkcolor.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
+#ifdef POPPLER_HAS_CAIRO
+#include <cairo.h>
+#endif
+
 #include "poppler.h"
 
 G_BEGIN_DECLS
@@ -43,6 +47,12 @@
 						       double              scale,
 						       int                 rotation,
 						       GdkPixbuf          *pixbuf);
+
+#ifdef POPPLER_HAS_CAIRO
+void                poppler_page_render               (PopplerPage        *page,
+						       cairo_t            *cairo);
+#endif
+
 void                poppler_page_get_size             (PopplerPage        *page,
 						       double             *width,
 						       double             *height);

Index: poppler.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- poppler.h	24 Jan 2006 06:21:39 -0000	1.10
+++ poppler.h	12 Apr 2006 02:07:07 -0000	1.11
@@ -65,6 +65,7 @@
 
 G_END_DECLS
 
+#include "poppler-features.h"
 #include "poppler-document.h"
 #include "poppler-page.h"
 #include "poppler-action.h"



More information about the poppler mailing list