Commit 149b7fec authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

glib: Remove deprecated GDK API

It removes the GDK dependency so that poppler-glib now only depends on
glib and cairo.
parent a5482d64
......@@ -97,15 +97,7 @@ if(CAIRO_FOUND)
set(GLIB_REQ "glib-2.0 >= ${GLIB_REQUIRED} gobject-2.0 >= ${GLIB_REQUIRED} cairo >= ${CAIRO_VERSION}")
set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED")
set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DG_DISABLE_SINGLE_INCLUDES")
macro_optional_find_package(GDK)
macro_optional_find_package(GTK)
if(GDK_FOUND)
set(GDK_REQ "gdk-2.0 gdk-pixbuf-2.0")
set(POPPLER_WITH_GDK ${GDK_FOUND})
set(GDK_FEATURE "#define POPPLER_WITH_GDK 1")
set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED")
set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DGTK_DISABLE_SINGLE_INCLUDES")
endif(GDK_FOUND)
endif(GLIB_FOUND)
else(CAIRO_FOUND)
set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO")
......@@ -585,7 +577,6 @@ show_end_message_yesno("cairo output" CAIRO_FOUND)
show_end_message_yesno("abiword output" ENABLE_ABIWORD)
show_end_message_yesno("qt4 wrapper" QT4_FOUND)
show_end_message_yesno("glib wrapper" ENABLE_GLIB)
show_end_message_yesno(" use GDK" POPPLER_WITH_GDK)
show_end_message_yesno(" introspection" INTROSPECTION_FOUND)
show_end_message_yesno("cpp wrapper" ENABLE_CPP)
show_end_message("use gtk-doc" "not supported with this CMake build system")
......
......@@ -439,50 +439,11 @@ fi
AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes)
AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
AC_SUBST(GLIB_REQ)
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
dnl
dnl GDK
dnl
AC_ARG_ENABLE(gdk,
AC_HELP_STRING([--disable-gdk],
[Compile without gdk.]),
enable_gdk=$enableval,
enable_gdk="try")
if test x$enable_poppler_glib = xyes; then
if test x$enable_gdk = xyes; then
PKG_CHECK_MODULES(GDK, gdk-2.0)
elif test x$enable_gdk = xtry; then
PKG_CHECK_MODULES(GDK, gdk-2.0,
[enable_gdk="yes"],
[enable_gdk="no"])
fi
if test x$enable_gdk = xyes; then
GDK_REQ="gdk-2.0 gdk-pixbuf-2.0"
AC_DEFINE(POPPLER_WITH_GDK,[1], [Have GDK])
GDK_FEATURE="#define POPPLER_WITH_GDK 1"
POPPLER_GLIB_DISABLE_DEPRECATED="$POPPLER_GLIB_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED"
POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="$POPPLER_GLIB_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES"
else
enable_gdk="no"
GDK_FEATURE=""
GDK_REQ=""
fi
else
enable_gdk="no"
GDK_REQ=""
fi
AM_CONDITIONAL(BUILD_WITH_GDK, test x$enable_gdk = xyes)
AC_SUBST(GDK_CFLAGS)
AC_SUBST(GDK_LIBS)
AC_SUBST(GDK_FEATURE)
AC_SUBST(GDK_REQ)
AC_SUBST(POPPLER_GLIB_DISABLE_DEPRECATED)
AC_SUBST(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES)
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
dnl
dnl Try Qt4
dnl
......@@ -689,7 +650,6 @@ echo " cairo output: $enable_cairo_output"
echo " abiword output: $enable_abiword_output"
echo " qt4 wrapper: $enable_poppler_qt4"
echo " glib wrapper: $enable_poppler_glib"
echo " use GDK: $enable_gdk"
echo " introspection: $found_introspection"
echo " cpp wrapper: $enable_poppler_cpp"
echo " use gtk-doc: $enable_gtk_doc"
......
......@@ -12,11 +12,6 @@ add_definitions(
${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES}
)
if (GDK_FOUND)
include_directories(${GDK2_INCLUDE_DIRS})
add_definitions(${GDK2_CFLAGS_OTHER})
endif (GDK_FOUND)
configure_file(poppler-features.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h @ONLY)
if (GTK_FOUND AND BUILD_GTK_TESTS)
......@@ -82,11 +77,8 @@ set(poppler_glib_generated_SRCS
${CMAKE_SOURCE_DIR}/poppler/CairoRescaleBox.cc
)
add_library(poppler-glib SHARED ${poppler_glib_SRCS} ${poppler_glib_generated_SRCS})
set_target_properties(poppler-glib PROPERTIES VERSION 6.0.0 SOVERSION 6)
set_target_properties(poppler-glib PROPERTIES VERSION 7.0.0 SOVERSION 7)
target_link_libraries(poppler-glib poppler ${GLIB2_LIBRARIES} ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES})
if (GDK_FOUND)
target_link_libraries(poppler-glib ${GDK2_LIBRARIES})
endif (GDK_FOUND)
install(TARGETS poppler-glib RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX})
install(FILES
......@@ -128,10 +120,6 @@ if (HAVE_INTROSPECTION)
)
set(Poppler_0_16_gir_FILES ${_abs_introspection_files})
if (GDK_FOUND)
list(APPEND Poppler_0_16_gir_INCLUDES Gdk-2.0)
endif ()
list(APPEND INTROSPECTION_GIRS Poppler-0.16.gir)
gir_add_introspections(INTROSPECTION_GIRS)
......
......@@ -6,7 +6,6 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/poppler \
$(POPPLER_GLIB_CFLAGS) \
$(GDK_CFLAGS) \
$(FREETYPE_CFLAGS) \
$(FONTCONFIG_CFLAGS) \
$(POPPLER_GLIB_DISABLE_DEPRECATED) \
......@@ -72,11 +71,10 @@ libpoppler_glib_la_LIBADD = \
$(top_builddir)/poppler/libpoppler.la \
$(top_builddir)/poppler/libpoppler-cairo.la \
$(POPPLER_GLIB_LIBS) \
$(GDK_LIBS) \
$(FREETYPE_LIBS) \
$(FONTCONFIG_LIBS)
libpoppler_glib_la_LDFLAGS = -version-info 6:0:0 @create_shared_lib@ @auto_import_flags@
libpoppler_glib_la_LDFLAGS = -version-info 7:0:0 @create_shared_lib@ @auto_import_flags@
BUILT_SOURCES = \
poppler-enums.c \
......@@ -100,10 +98,6 @@ Poppler_0_16_gir_CFLAGS = $(INCLUDES) -I$(top_builddir)
Poppler_0_16_gir_LIBS = libpoppler-glib.la
Poppler_0_16_gir_FILES = $(addprefix $(srcdir)/, $(introspection_files))
if BUILD_WITH_GDK
Poppler_0_16_gir_INCLUDES += Gdk-2.0
endif
INTROSPECTION_GIRS += Poppler-0.16.gir
girdir = $(datadir)/gir-1.0
......
......@@ -36,12 +36,6 @@
* Defined if poppler was compiled with cairo support.
*/
@CAIRO_FEATURE@
/**
* POPPLER_WITH_GDK:
*
* Defined if poppler was compiled with GDK support.
*/
@GDK_FEATURE@
/**
* POPPLER_MAJOR_VERSION:
......
......@@ -285,48 +285,6 @@ poppler_page_get_text_page (PopplerPage *page)
return page->text;
}
#ifdef POPPLER_WITH_GDK
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++;
}
}
}
#endif /* POPPLER_WITH_GDK */
static gboolean
annot_is_markup (Annot *annot)
{
......@@ -614,260 +572,6 @@ poppler_page_render_selection (PopplerPage *page,
output_dev->setCairo (NULL);
}
#ifdef POPPLER_WITH_GDK
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);
}
/**
* poppler_page_render_to_pixbuf_for_printing:
* @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 printed.
*
* Deprecated: 0.16
**/
void
poppler_page_render_to_pixbuf_for_printing (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,
gTrue,
pixbuf);
}
/**
* poppler_page_get_thumbnail_pixbuf:
* @page: the #PopperPage to get the thumbnail for
*
* Get the embedded thumbnail for the specified page. If the document
* doesn't have an embedded thumbnail for the page, this function
* returns %NULL.
*
* Return value: the tumbnail as a #GdkPixbuf or %NULL if the document
* doesn't have a thumbnail for this page.
*
* Deprecated: 0.16
**/
GdkPixbuf *
poppler_page_get_thumbnail_pixbuf (PopplerPage *page)
{
unsigned char *data;
int width, height, rowstride;
g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL);
if (!page->page->loadThumb (&data, &width, &height, &rowstride))
return NULL;
return gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB,
FALSE, 8, width, height, rowstride,
(GdkPixbufDestroyNotify)gfree, NULL);
}
/**
* poppler_page_render_selection_to_pixbuf:
* @page: the #PopplerPage for which to render selection
* @scale: scale specified as pixels per point
* @rotation: rotate the document by the specified degree
* @pixbuf: pixbuf to render to
* @selection: start and end point of selection as a rectangle
* @old_selection: previous selection
* @style: a #PopplerSelectionStyle
* @glyph_color: color to use for drawing glyphs
* @background_color: color to use for the selection background
*
* Render the selection specified by @selection for @page into
* @pixbuf. The selection will be rendered at @scale, using
* @glyph_color for the glyphs and @background_color for the selection
* background.
*
* If non-NULL, @old_selection specifies the selection that is already
* rendered in @pixbuf, in which case this function will (some day)
* only render the changed part of the selection.
*
* Deprecated: 0.16
**/
void
poppler_page_render_selection_to_pixbuf (PopplerPage *page,
gdouble scale,
int rotation,
GdkPixbuf *pixbuf,
PopplerRectangle *selection,
PopplerRectangle *old_selection,
PopplerSelectionStyle style,
GdkColor *glyph_color,
GdkColor *background_color)
{
cairo_t *cr;
cairo_surface_t *surface;
double width, height;
int cairo_width, cairo_height, rotate;
PopplerColor poppler_background_color;
PopplerColor poppler_glyph_color;
poppler_background_color.red = background_color->red;
poppler_background_color.green = background_color->green;
poppler_background_color.blue = background_color->blue;
poppler_glyph_color.red = glyph_color->red;
poppler_glyph_color.green = glyph_color->green;
poppler_glyph_color.blue = glyph_color->blue;
rotate = rotation + page->page->getRotate ();
if (rotate == 90 || rotate == 270) {
height = page->page->getCropWidth ();
width = page->page->getCropHeight ();
} else {
width = page->page->getCropWidth ();
height = page->page->getCropHeight ();
}
cairo_width = (int) ceil(width * scale);
cairo_height = (int) ceil(height * scale);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
cairo_width, cairo_height);
cr = cairo_create (surface);
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_paint (cr);
switch (rotate) {
case 90:
cairo_translate (cr, cairo_width, 0);
break;
case 180:
cairo_translate (cr, cairo_width, cairo_height);
break;
case 270:
cairo_translate (cr, 0, cairo_height);
break;
default:
cairo_translate (cr, 0, 0);
}
if (scale != 1.0)
cairo_scale (cr, scale, scale);
if (rotate != 0)
cairo_rotate (cr, rotation * G_PI / 180.0);
poppler_page_render_selection (page, cr, selection, old_selection, style,
&poppler_glyph_color, &poppler_background_color);
cairo_destroy (cr);
copy_cairo_surface_to_pixbuf (surface, pixbuf);
cairo_surface_destroy (surface);
}
#endif /* POPPLER_WITH_GDK */
/**
* poppler_page_get_thumbnail_size:
* @page: A #PopplerPage
......
......@@ -23,10 +23,6 @@
#include "poppler.h"
#ifdef POPPLER_WITH_GDK
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif
#include <cairo.h>
G_BEGIN_DECLS
......@@ -38,36 +34,6 @@ G_BEGIN_DECLS
GType poppler_page_get_type (void) G_GNUC_CONST;
#ifdef POPPLER_WITH_GDK
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);
void poppler_page_render_to_pixbuf_for_printing (PopplerPage *page,
int src_x,
int src_y,
int src_width,
int src_height,
double scale,
int rotation,
GdkPixbuf *pixbuf);
GdkPixbuf *poppler_page_get_thumbnail_pixbuf (PopplerPage *page);
void poppler_page_render_selection_to_pixbuf (
PopplerPage *page,
gdouble scale,
int rotation,
GdkPixbuf *pixbuf,
PopplerRectangle *selection,
PopplerRectangle *old_selection,
PopplerSelectionStyle style,
GdkColor *glyph_color,
GdkColor *background_color);
#endif /* POPPLER_WITH_GDK */
void poppler_page_render (PopplerPage *page,
cairo_t *cairo);
void poppler_page_render_for_printing (PopplerPage *page,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment