[evince] [djvu] Do not alloc image buffer, let cairo do that



commit 8521bad72ca742fe3fced95a66076ed93cd77253
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Feb 21 15:35:35 2010 +0100

    [djvu] Do not alloc image buffer, let cairo do that

 backend/djvu/djvu-document.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index e26db4a..7ab5c76 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -323,7 +323,6 @@ djvu_document_render (EvDocument      *document,
 	ddjvu_page_t *d_page;
 	ddjvu_page_rotation_t rotation;
 	double page_width, page_height, tmp;
-	static const cairo_user_data_key_t key;
 
 	d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
 	
@@ -355,19 +354,12 @@ djvu_document_render (EvDocument      *document,
 	        default:
 			rotation = DDJVU_ROTATE_0;
 	}
-#ifdef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH
-	rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, page_width);
-#else
-	rowstride = page_width * 4;
-#endif
-	pixels = (gchar *) g_malloc (page_height * rowstride);
-	surface = cairo_image_surface_create_for_data ((guchar *)pixels,
-						       CAIRO_FORMAT_RGB24,
-						       page_width,
-						       page_height,
-						       rowstride);
-	cairo_surface_set_user_data (surface, &key,
-				     pixels, (cairo_destroy_func_t)g_free);
+
+	surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+					      page_width, page_height);
+	rowstride = cairo_image_surface_get_stride (surface);
+	pixels = (gchar *)cairo_image_surface_get_data (surface);
+
 	prect.x = 0;
 	prect.y = 0;
 	prect.w = page_width;
@@ -383,6 +375,8 @@ djvu_document_render (EvDocument      *document,
 			   rowstride,
 			   pixels);
 
+	cairo_surface_mark_dirty (surface);
+
 	return surface;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]