]> www.fi.muni.cz Git - evince.git/blobdiff - backend/pixbuf/pixbuf-document.c
Added. Returns whether the animation has everything necessary to run. Do
[evince.git] / backend / pixbuf / pixbuf-document.c
index c1cace00baeee607f0750b3d8f35513144533740..21c6bb936e9454bf1425eace7b24e73461a545df 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
+#include <glib/gi18n.h>
+
 #include "pixbuf-document.h"
 #include "ev-document-thumbnails.h"
+#include "ev-document-misc.h"
+#include "ev-file-helpers.h"
 
 struct _PixbufDocumentClass
 {
@@ -39,12 +44,11 @@ typedef struct _PixbufDocumentClass PixbufDocumentClass;
 static void pixbuf_document_document_iface_init (EvDocumentIface *iface);
 static void pixbuf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (PixbufDocument, pixbuf_document, G_TYPE_OBJECT,
-                         { G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,
-                                                 pixbuf_document_document_iface_init);
+EV_BACKEND_REGISTER_WITH_CODE (PixbufDocument, pixbuf_document,
+                   {
                         G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
                                                pixbuf_document_document_thumbnails_iface_init)                            
-                                  });
+                  });
 
 static gboolean
 pixbuf_document_load (EvDocument  *document,
@@ -101,22 +105,27 @@ pixbuf_document_get_page_size (EvDocument   *document,
        *height = gdk_pixbuf_get_height (pixbuf_document->pixbuf);
 }
 
-static GdkPixbuf*
-pixbuf_document_render_pixbuf (EvDocument      *document,
-                              EvRenderContext *rc)
+static cairo_surface_t *
+pixbuf_document_render (EvDocument      *document,
+                       EvRenderContext *rc)
 {
        PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
        GdkPixbuf *scaled_pixbuf, *rotated_pixbuf;
+       cairo_surface_t *surface;
 
-       scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf,
-                                                gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale,
-                                                gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale,
-                                                GDK_INTERP_BILINEAR);
-
+       scaled_pixbuf = gdk_pixbuf_scale_simple (
+               pixbuf_document->pixbuf,
+               (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale) + 0.5,
+               (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale) + 0.5,
+               GDK_INTERP_BILINEAR);
+       
         rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation);
         g_object_unref (scaled_pixbuf);
 
-       return rotated_pixbuf;
+       surface = ev_document_misc_surface_from_pixbuf (rotated_pixbuf);
+       g_object_unref (rotated_pixbuf);
+
+       return surface;
 }
 
 static void
@@ -138,12 +147,6 @@ pixbuf_document_class_init (PixbufDocumentClass *klass)
        gobject_class->finalize = pixbuf_document_finalize;
 }
 
-static gboolean
-pixbuf_document_can_get_text (EvDocument *document)
-{
-       return FALSE;
-}
-
 static EvDocumentInfo *
 pixbuf_document_get_info (EvDocument *document)
 {
@@ -160,10 +163,9 @@ pixbuf_document_document_iface_init (EvDocumentIface *iface)
 {
        iface->load = pixbuf_document_load;
        iface->save = pixbuf_document_save;
-       iface->can_get_text = pixbuf_document_can_get_text;
        iface->get_n_pages = pixbuf_document_get_n_pages;
        iface->get_page_size = pixbuf_document_get_page_size;
-       iface->render_pixbuf = pixbuf_document_render_pixbuf;
+       iface->render = pixbuf_document_render;
        iface->get_info = pixbuf_document_get_info;
 }