[evince] djvu: Make empty pages white.



commit f644cad4d7819e9b97cbc93a32c7ab9d60f4196c
Author: Josà Aliste <jaliste src gnome org>
Date:   Wed Jan 9 23:52:54 2013 +0100

    djvu: Make empty pages white.
    
    The djvulibre render method does nothing on empty page.
    Thus, we need to paint the surface white by ourselves
    to solve the "empty pages are shown black" bug.
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=669017

 backend/djvu/djvu-document.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index a61d609..5a3561c 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -319,6 +319,7 @@ djvu_document_render (EvDocument      *document,
 	ddjvu_rect_t prect;
 	ddjvu_page_t *d_page;
 	ddjvu_page_rotation_t rotation;
+	gint buffer_modified;
 	double page_width, page_height, tmp;
 
 	d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
@@ -354,6 +355,7 @@ djvu_document_render (EvDocument      *document,
 
 	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);
 
@@ -365,14 +367,22 @@ djvu_document_render (EvDocument      *document,
 
 	ddjvu_page_set_rotation (d_page, rotation);
 	
-	ddjvu_page_render (d_page, DDJVU_RENDER_COLOR,
-			   &prect,
-			   &rrect,
-			   djvu_document->d_format,
-			   rowstride,
-			   pixels);
-
-	cairo_surface_mark_dirty (surface);
+	buffer_modified = ddjvu_page_render (d_page, DDJVU_RENDER_COLOR,
+					     &prect,
+					     &rrect,
+					     djvu_document->d_format,
+					     rowstride,
+					     pixels);
+
+	if (!buffer_modified) {
+		cairo_t *cr = cairo_create (surface);
+
+		cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+		cairo_paint (cr);
+		cairo_destroy (cr);
+	} else {
+		cairo_surface_mark_dirty (surface);
+	}
 
 	return surface;
 }



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