Discussion:
[PATCH 2/5] Prepare to deduplicate pdf_page_render_cairo
Alexander Monakov
2013-10-30 21:15:59 UTC
Permalink
---
pdf.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/pdf.c b/pdf.c
index 68fc713..1e3c0a6 100644
--- a/pdf.c
+++ b/pdf.c
@@ -550,14 +550,18 @@ pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* c
return ZATHURA_ERROR_UNKNOWN;
}

- mupdf_document_t* mupdf_document = zathura_document_get_data(document);
-
unsigned int page_width = cairo_image_surface_get_width(surface);
unsigned int page_height = cairo_image_surface_get_height(surface);

double scalex = ((double) page_width) / zathura_page_get_width(page);
double scaley = ((double) page_height) /zathura_page_get_height(page);

+ int rowstride = cairo_image_surface_get_stride(surface);
+ unsigned char* image = cairo_image_surface_get_data(surface);
+ int components = 4;
+
+ mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+
/* render */
fz_display_list* display_list = fz_new_display_list(mupdf_page->ctx);
fz_device* device = fz_new_list_device(mupdf_page->ctx, display_list);
@@ -583,14 +587,11 @@ pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* c
fz_run_display_list(display_list, device, &fz_identity, &rect, NULL);
fz_free_device(device);

- int rowstride = cairo_image_surface_get_stride(surface);
- unsigned char* image = cairo_image_surface_get_data(surface);
-
unsigned char* s = fz_pixmap_samples(mupdf_page->ctx, pixmap);
unsigned int n = fz_pixmap_components(mupdf_page->ctx, pixmap);
for (unsigned int y = 0; y < fz_pixmap_height(mupdf_page->ctx, pixmap); y++) {
for (unsigned int x = 0; x < fz_pixmap_width(mupdf_page->ctx, pixmap); x++) {
- guchar* p = image + y * rowstride + x * 4;
+ guchar* p = image + y * rowstride + x * components;
p[0] = s[2];
p[1] = s[1];
p[2] = s[0];
--
1.8.3.2

-------------- next part --------------
Loading...