[poppler] 3 commits - configure.ac glib/demo glib/poppler-page.cc glib/poppler-page.h glib/reference poppler/CairoOutputDev.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Sun Oct 17 04:49:07 PDT 2010
configure.ac | 2
glib/demo/selections.c | 73 +++++++++-----------------------
glib/poppler-page.cc | 81 ++++++++++++++++++++++++++++++++++++
glib/poppler-page.h | 4 +
glib/reference/poppler-sections.txt | 1
poppler/CairoOutputDev.cc | 4 -
6 files changed, 109 insertions(+), 56 deletions(-)
New commits:
commit e2fad550c3cbf86541730582151e1bb6470ed9c1
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Oct 17 13:47:33 2010 +0200
[glib-demo] Use poppler_page_get_selected_region() in selections demo
diff --git a/glib/demo/selections.c b/glib/demo/selections.c
index 4dc9fb6..27c053b 100644
--- a/glib/demo/selections.c
+++ b/glib/demo/selections.c
@@ -46,8 +46,8 @@ typedef struct {
PopplerColor glyph_color;
PopplerColor background_color;
guint selections_idle;
- GdkRegion *selection_region;
- GdkRegion *selected_region;
+ cairo_region_t *selection_region;
+ cairo_region_t *selected_region;
GdkCursorType cursor;
gchar *selected_text;
} PgdSelectionsDemo;
@@ -63,7 +63,7 @@ pgd_selections_clear_selections (PgdSelectionsDemo *demo)
}
if (demo->selection_region) {
- gdk_region_destroy (demo->selection_region);
+ cairo_region_destroy (demo->selection_region);
demo->selection_region = NULL;
}
@@ -73,7 +73,7 @@ pgd_selections_clear_selections (PgdSelectionsDemo *demo)
}
if (demo->selected_region) {
- gdk_region_destroy (demo->selected_region);
+ cairo_region_destroy (demo->selected_region);
demo->selected_region = NULL;
}
}
@@ -109,46 +109,19 @@ pgd_selections_free (PgdSelectionsDemo *demo)
g_free (demo);
}
-static GdkRegion *
-pgd_selections_create_region (GList *region)
-{
- GdkRegion *retval = gdk_region_new ();
- GList *l;
-
- for (l = region; l; l = g_list_next (l)) {
- PopplerRectangle *rectangle;
- GdkRectangle r;
-
- rectangle = (PopplerRectangle *)l->data;
-
- r.x = (gint) rectangle->x1;
- r.y = (gint) rectangle->y1;
- r.width = (gint) (rectangle->x2 - rectangle->x1);
- r.height = (gint) (rectangle->y2 - rectangle->y1);
- gdk_region_union_with_rect (retval, &r);
-
- poppler_rectangle_free (rectangle);
- }
-
- return retval;
-}
-
static void
pgd_selections_update_selection_region (PgdSelectionsDemo *demo)
{
- GList *region;
PopplerRectangle area = { 0, 0, 0, 0 };
if (demo->selection_region)
- gdk_region_destroy (demo->selection_region);
+ cairo_region_destroy (demo->selection_region);
poppler_page_get_size (demo->page, &area.x2, &area.y2);
- region = poppler_page_get_selection_region (demo->page,
- 1.0,
- POPPLER_SELECTION_GLYPH,
- &area);
- demo->selection_region = pgd_selections_create_region (region);
- g_list_free (region);
+ demo->selection_region = poppler_page_get_selected_region (demo->page,
+ 1.0,
+ POPPLER_SELECTION_GLYPH,
+ &area);
}
static void
@@ -158,14 +131,11 @@ pgd_selections_update_seleted_text (PgdSelectionsDemo *demo)
gchar *text;
if (demo->selected_region)
- gdk_region_destroy (demo->selected_region);
- region = poppler_page_get_selection_region (demo->page,
- 1.0,
- demo->style,
- &demo->doc_area);
- demo->selected_region = pgd_selections_create_region (region);
- g_list_free (region);
-
+ cairo_region_destroy (demo->selected_region);
+ demo->selected_region = poppler_page_get_selected_region (demo->page,
+ 1.0,
+ demo->style,
+ &demo->doc_area);
if (demo->selected_text)
g_free (demo->selected_text);
demo->selected_text = NULL;
@@ -325,9 +295,9 @@ pgd_selections_drawing_area_motion_notify (GtkWidget *area,
} else {
gboolean over_text;
- over_text = gdk_region_point_in (demo->selection_region,
- event->x / demo->scale,
- event->y / demo->scale);
+ over_text = cairo_region_contains_point (demo->selection_region,
+ event->x / demo->scale,
+ event->y / demo->scale);
pgd_selections_update_cursor (demo, over_text ? GDK_XTERM : GDK_LAST_CURSOR);
}
@@ -390,14 +360,15 @@ pgd_selections_drawing_area_query_tooltip (GtkWidget *area,
if (!demo->selected_text)
return FALSE;
- over_selection = gdk_region_point_in (demo->selected_region,
- x / demo->scale,
- y / demo->scale);
+ over_selection = cairo_region_contains_point (demo->selected_region,
+ x / demo->scale,
+ y / demo->scale);
if (over_selection) {
GdkRectangle selection_area;
- gdk_region_get_clipbox (demo->selected_region, &selection_area);
+ cairo_region_get_extents (demo->selected_region,
+ (cairo_rectangle_int_t *)&selection_area);
selection_area.x *= demo->scale;
selection_area.y *= demo->scale;
selection_area.width *= demo->scale;
commit 88013458e141de58ed801480707ae0dfe92b9aa2
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Oct 17 13:46:26 2010 +0200
[glib] Add poppler_page_get_selected_region()
that returns a cairo_region_t, and deprecate
poppler_page_get_selection_region().
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index 4e2bef5..f215959 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -928,6 +928,8 @@ poppler_page_get_thumbnail_size (PopplerPage *page,
* poppler_page_selection_region_free().
*
* Return value: (element-type PopplerRectangle) (transfer full): a #GList of #PopplerRectangle
+ *
+ * Deprecated: 0.16: Use poppler_page_get_selected_region() instead.
**/
GList *
poppler_page_get_selection_region (PopplerPage *page,
@@ -985,6 +987,14 @@ poppler_page_get_selection_region (PopplerPage *page,
return g_list_reverse (region);
}
+/**
+ * poppler_page_selection_region_free:
+ * @region: a #GList of #PopplerRectangle
+ *
+ * Frees @region
+ *
+ * Deprecated: 0.16
+ */
void
poppler_page_selection_region_free (GList *region)
{
@@ -996,6 +1006,77 @@ poppler_page_selection_region_free (GList *region)
}
/**
+ * poppler_page_get_selected_region:
+ * @page: a #PopplerPage
+ * @scale: scale specified as pixels per point
+ * @style: a #PopplerSelectionStyle
+ * @selection: start and end point of selection as a rectangle
+ *
+ * Returns a region containing the area that would be rendered by
+ * poppler_page_render_selection() or
+ * poppler_page_render_selection_to_pixbuf().
+ * The returned region must be freed with cairo_region_destroy()
+ *
+ * Return value: (transfer full): a cairo_region_t
+ *
+ * Since: 0.16
+ **/
+cairo_region_t *
+poppler_page_get_selected_region (PopplerPage *page,
+ gdouble scale,
+ PopplerSelectionStyle style,
+ PopplerRectangle *selection)
+{
+ PDFRectangle poppler_selection;
+ TextPage *text;
+ SelectionStyle selection_style = selectionStyleGlyph;
+ GooList *list;
+ cairo_region_t *region;
+ int i;
+
+ poppler_selection.x1 = selection->x1;
+ poppler_selection.y1 = selection->y1;
+ poppler_selection.x2 = selection->x2;
+ poppler_selection.y2 = selection->y2;
+
+ switch (style)
+ {
+ case POPPLER_SELECTION_GLYPH:
+ selection_style = selectionStyleGlyph;
+ break;
+ case POPPLER_SELECTION_WORD:
+ selection_style = selectionStyleWord;
+ break;
+ case POPPLER_SELECTION_LINE:
+ selection_style = selectionStyleLine;
+ break;
+ }
+
+ text = poppler_page_get_text_page (page);
+ list = text->getSelectionRegion(&poppler_selection,
+ selection_style, 1.0);
+
+ region = cairo_region_create ();
+
+ for (i = 0; i < list->getLength(); i++) {
+ PDFRectangle *selection_rect = (PDFRectangle *) list->get(i);
+ cairo_rectangle_int_t rect;
+
+ rect.x = (gint) ((selection_rect->x1 * scale) + 0.5);
+ rect.y = (gint) ((selection_rect->y1 * scale) + 0.5);
+ rect.width = (gint) (((selection_rect->x2 - selection_rect->x1) * scale) + 0.5);
+ rect.height = (gint) (((selection_rect->y2 - selection_rect->y1) * scale) + 0.5);
+ cairo_region_union_rectangle (region, &rect);
+
+ delete selection_rect;
+ }
+
+ delete list;
+
+ return region;
+}
+
+/**
* poppler_page_get_selected_text:
* @page: a #PopplerPage
* @style: a #PopplerSelectionStyle
diff --git a/glib/poppler-page.h b/glib/poppler-page.h
index ceb77af..d40c0ee 100644
--- a/glib/poppler-page.h
+++ b/glib/poppler-page.h
@@ -102,6 +102,10 @@ char *poppler_page_get_text (PopplerPage *pa
char *poppler_page_get_selected_text (PopplerPage *page,
PopplerSelectionStyle style,
PopplerRectangle *selection);
+cairo_region_t *poppler_page_get_selected_region (PopplerPage *page,
+ gdouble scale,
+ PopplerSelectionStyle style,
+ PopplerRectangle *selection);
GList *poppler_page_get_selection_region (PopplerPage *page,
gdouble scale,
PopplerSelectionStyle style,
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index f06b6eb..6ad9ee2 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -31,6 +31,7 @@ poppler_page_render_to_pixbuf_for_printing
poppler_page_render_to_ps
poppler_page_render_selection
poppler_page_render_selection_to_pixbuf
+poppler_page_get_selected_region
poppler_page_get_selection_region
poppler_page_selection_region_free
poppler_page_get_selected_text
commit fc9b85894754d175af916eaf6cb127efd601df7e
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Oct 17 12:54:18 2010 +0200
[configure] Bump cairo dependency to 1.10
diff --git a/configure.ac b/configure.ac
index 71b1537..29cca1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -332,7 +332,7 @@ if test x$enable_splash_output = xyes; then
AC_DEFINE(HAVE_SPLASH)
fi
-CAIRO_VERSION="1.8.4"
+CAIRO_VERSION="1.10.0"
AC_SUBST(CAIRO_VERSION)
AC_ARG_ENABLE(cairo-output,
AC_HELP_STRING([--disable-cairo-output],
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f832074..e7c9dc5 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -500,7 +500,6 @@ void CairoOutputDev::updateFillColorStop(GfxState *state, double offset) {
}
void CairoOutputDev::updateBlendMode(GfxState *state) {
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 9, 4)
switch (state->getBlendMode()) {
default:
case gfxBlendNormal:
@@ -553,7 +552,6 @@ void CairoOutputDev::updateBlendMode(GfxState *state) {
break;
}
LOG(printf ("blend mode: %d\n", (int)state->getBlendMode()));
-#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 9, 4) */
}
void CairoOutputDev::updateFont(GfxState *state) {
@@ -2387,7 +2385,6 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
cairo_surface_mark_dirty (image);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 9, 6)
if (printing && (str->getKind() == strDCT || str->getKind() == strJPX)) {
char *strBuffer;
int len;
@@ -2403,7 +2400,6 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
gfree (strBuffer);
}
}
-#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 9, 6) */
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
More information about the poppler
mailing list