View | Details | Raw Unified | Return to bug 200154 | Differences between
and this patch

Collapse All | Expand All

(-)graphics/zathura-pdf-mupdf/Makefile (-2 / +2 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	zathura-pdf-mupdf
4
PORTNAME=	zathura-pdf-mupdf
5
PORTVERSION=	0.2.7
5
PORTVERSION=	0.2.7
6
PORTREVISION=	2
6
PORTREVISION=	3
7
CATEGORIES=	graphics
7
CATEGORIES=	graphics
8
MASTER_SITES=	http://pwmt.org/projects/zathura-pdf-mupdf/download/
8
MASTER_SITES=	http://pwmt.org/projects/zathura-pdf-mupdf/download/
9
9
Lines 16-22 Link Here
16
LICENSE_PERMS=	dist-mirror pkg-mirror auto-accept
16
LICENSE_PERMS=	dist-mirror pkg-mirror auto-accept
17
17
18
BUILD_DEPENDS=	zathura:${PORTSDIR}/graphics/zathura \
18
BUILD_DEPENDS=	zathura:${PORTSDIR}/graphics/zathura \
19
		mupdf>=1.5_1,1:${PORTSDIR}/graphics/mupdf
19
		mupdf>=1.7,1:${PORTSDIR}/graphics/mupdf
20
RUN_DEPENDS=	zathura:${PORTSDIR}/graphics/zathura
20
RUN_DEPENDS=	zathura:${PORTSDIR}/graphics/zathura
21
21
22
PLIST_FILES=	lib/zathura/pdf.so share/applications/zathura-pdf-mupdf.desktop
22
PLIST_FILES=	lib/zathura/pdf.so share/applications/zathura-pdf-mupdf.desktop
(-)graphics/zathura-pdf-mupdf/files/patch-document.c (+53 lines)
Line 0 Link Here
1
--- document.c.orig	2015-05-12 16:37:29 UTC
2
+++ document.c
3
@@ -51,14 +51,14 @@ pdf_document_open(zathura_document_t* do
4
   }
5
 
6
   /* authenticate if password is required and given */
7
-  if (fz_needs_password(mupdf_document->document) != 0) {
8
-    if (password == NULL || fz_authenticate_password(mupdf_document->document, (char*) password) == 0) {
9
+  if (fz_needs_password(mupdf_document->ctx, mupdf_document->document) != 0) {
10
+    if (password == NULL || fz_authenticate_password(mupdf_document->ctx, mupdf_document->document, (char*) password) == 0) {
11
       error = ZATHURA_ERROR_INVALID_PASSWORD;
12
       goto error_free;
13
     }
14
   }
15
 
16
-  zathura_document_set_number_of_pages(document, fz_count_pages(mupdf_document->document));
17
+  zathura_document_set_number_of_pages(document, fz_count_pages(mupdf_document->ctx, mupdf_document->document));
18
   zathura_document_set_data(document, mupdf_document);
19
 
20
   return error;
21
@@ -67,10 +67,10 @@ error_free:
22
 
23
   if (mupdf_document != NULL) {
24
     if (mupdf_document->document != NULL) {
25
-      fz_close_document(mupdf_document->document);
26
+      fz_drop_document(mupdf_document->ctx, mupdf_document->document);
27
     }
28
     if (mupdf_document->ctx != NULL) {
29
-      fz_free_context(mupdf_document->ctx);
30
+      fz_drop_context(mupdf_document->ctx);
31
     }
32
 
33
     free(mupdf_document);
34
@@ -90,8 +90,8 @@ pdf_document_free(zathura_document_t* do
35
     return ZATHURA_ERROR_INVALID_ARGUMENTS;
36
   }
37
 
38
-  fz_close_document(mupdf_document->document);
39
-  fz_free_context(mupdf_document->ctx);
40
+  fz_drop_document(mupdf_document->ctx, mupdf_document->document);
41
+  fz_drop_context(mupdf_document->ctx);
42
   free(mupdf_document);
43
   zathura_document_set_data(document, NULL);
44
 
45
@@ -112,7 +112,7 @@ pdf_document_save_as(zathura_document_t*
46
      * options. */
47
 
48
     fz_write_options opts = { 0 }; /* just use the default options */
49
-    fz_write_document(mupdf_document->document, (char*) path, &opts);
50
+    fz_write_document(mupdf_document->ctx, mupdf_document->document, (char*) path, &opts);
51
   } fz_catch (mupdf_document->ctx) {
52
     return ZATHURA_ERROR_UNKNOWN;
53
   }
(-)graphics/zathura-pdf-mupdf/files/patch-image.c (+143 lines)
Line 0 Link Here
1
--- image.c.orig	2015-05-12 16:41:50 UTC
2
+++ image.c
3
@@ -9,8 +9,8 @@
4
 #include "plugin.h"
5
 
6
 static void pdf_zathura_image_free(zathura_image_t* image);
7
-static void get_images(pdf_obj* dict, girara_list_t* list);
8
-static void get_resources(pdf_obj* resource, girara_list_t* list);
9
+static void get_images(zathura_page_t* page, pdf_obj* dict, girara_list_t* list);
10
+static void get_resources(zathura_page_t* page, pdf_obj* resource, girara_list_t* list);
11
 
12
 girara_list_t*
13
 pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
14
@@ -30,12 +30,12 @@ pdf_page_images_get(zathura_page_t* page
15
 
16
   mupdf_document_t* mupdf_document = zathura_document_get_data(document);
17
 
18
-  pdf_obj* page_object = pdf_load_object((pdf_document*) mupdf_document->document, zathura_page_get_index(page), 0);
19
+  pdf_obj* page_object = pdf_load_object(mupdf_document->ctx, (pdf_document*) mupdf_document->document, zathura_page_get_index(page), 0);
20
   if (page_object == NULL) {
21
     goto error_free;
22
   }
23
 
24
-  pdf_obj* resource = pdf_dict_gets(page_object, "Resources");
25
+  pdf_obj* resource = pdf_dict_gets(mupdf_document->ctx, page_object, "Resources");
26
   if (resource == NULL) {
27
     goto error_free;
28
   }
29
@@ -50,7 +50,7 @@ pdf_page_images_get(zathura_page_t* page
30
 
31
   girara_list_set_free_function(list, (girara_free_function_t) pdf_zathura_image_free);
32
 
33
-  get_resources(resource, list);
34
+  get_resources(page, resource, list);
35
 
36
   return list;
37
 
38
@@ -81,20 +81,32 @@ pdf_zathura_image_free(zathura_image_t* 
39
 }
40
 
41
 static void
42
-get_images(pdf_obj* dict, girara_list_t* list)
43
+get_images(zathura_page_t* page, pdf_obj* dict, girara_list_t* list)
44
 {
45
   if (dict == NULL || list == NULL) {
46
     return;
47
   }
48
 
49
-  for (int i = 0; i < pdf_dict_len(dict); i++) {
50
-    pdf_obj* image_dict = pdf_dict_get_val(dict, i);
51
-    if (pdf_is_dict(image_dict) == 0) {
52
+  if (page == NULL) {
53
+    return;
54
+  }
55
+
56
+  zathura_document_t* document = zathura_page_get_document(page);
57
+
58
+  if (document == NULL) {
59
+    return;
60
+  }
61
+
62
+  mupdf_document_t* mupdf_document = zathura_document_get_data(document);
63
+
64
+  for (int i = 0; i < pdf_dict_len(mupdf_document->ctx, dict); i++) {
65
+    pdf_obj* image_dict = pdf_dict_get_val(mupdf_document->ctx, dict, i);
66
+    if (pdf_is_dict(mupdf_document->ctx, image_dict) == 0) {
67
       continue;
68
     }
69
 
70
-    pdf_obj* type = pdf_dict_gets(image_dict, "Subtype");
71
-    if (strcmp(pdf_to_name(type), "Image") != 0) {
72
+    pdf_obj* type = pdf_dict_gets(mupdf_document->ctx, image_dict, "Subtype");
73
+    if (strcmp(pdf_to_name(mupdf_document->ctx, type), "Image") != 0) {
74
       continue;
75
     }
76
 
77
@@ -110,8 +122,8 @@ get_images(pdf_obj* dict, girara_list_t*
78
       continue;
79
     }
80
 
81
-    pdf_obj* width  = pdf_dict_gets(image_dict, "Width");
82
-    pdf_obj* height = pdf_dict_gets(image_dict, "Height");
83
+    pdf_obj* width  = pdf_dict_gets(mupdf_document->ctx, image_dict, "Width");
84
+    pdf_obj* height = pdf_dict_gets(mupdf_document->ctx, image_dict, "Height");
85
 
86
     zathura_image_t* zathura_image = g_malloc(sizeof(zathura_image_t));
87
 
88
@@ -120,33 +132,45 @@ get_images(pdf_obj* dict, girara_list_t*
89
     // FIXME: Get correct image coordinates
90
     zathura_image->data        = image_dict;
91
     zathura_image->position.x1 = 0;
92
-    zathura_image->position.x2 = pdf_to_int(width);
93
+    zathura_image->position.x2 = pdf_to_int(mupdf_document->ctx, width);
94
     zathura_image->position.y1 = 0;
95
-    zathura_image->position.y2 = pdf_to_int(height);
96
+    zathura_image->position.y2 = pdf_to_int(mupdf_document->ctx, height);
97
 
98
     girara_list_append(list, zathura_image);
99
   }
100
 }
101
 
102
 static void
103
-get_resources(pdf_obj* resource, girara_list_t* list)
104
+get_resources(zathura_page_t* page, pdf_obj* resource, girara_list_t* list)
105
 {
106
   if (resource == NULL || list == NULL) {
107
     return;
108
   }
109
 
110
-  pdf_obj* x_object = pdf_dict_gets(resource, "XObject");
111
+  if (page == NULL) {
112
+    return;
113
+  }
114
+
115
+  zathura_document_t* document = zathura_page_get_document(page);
116
+
117
+  if (document == NULL) {
118
+    return;
119
+  }
120
+
121
+  mupdf_document_t* mupdf_document = zathura_document_get_data(document);
122
+
123
+  pdf_obj* x_object = pdf_dict_gets(mupdf_document->ctx, resource, "XObject");
124
   if (x_object == NULL) {
125
     return;
126
   }
127
 
128
-  get_images(x_object, list);
129
+  get_images(page, x_object, list);
130
 
131
-  for (int i = 0; i < pdf_dict_len(x_object); i++) {
132
-    pdf_obj* obj = pdf_dict_get_val(x_object, i);
133
-    pdf_obj* subsrc = pdf_dict_gets(obj, "Resources");
134
-    if (subsrc != NULL && pdf_objcmp(resource, subsrc)) {
135
-      get_resources(subsrc, list);
136
+  for (int i = 0; i < pdf_dict_len(mupdf_document->ctx, x_object); i++) {
137
+    pdf_obj* obj = pdf_dict_get_val(mupdf_document->ctx, x_object, i);
138
+    pdf_obj* subsrc = pdf_dict_gets(mupdf_document->ctx, obj, "Resources");
139
+    if (subsrc != NULL && pdf_objcmp(mupdf_document->ctx, resource, subsrc)) {
140
+      get_resources(page, subsrc, list);
141
     }
142
   }
143
 }
(-)graphics/zathura-pdf-mupdf/files/patch-index.c (+20 lines)
Line 0 Link Here
1
--- index.c.orig	2015-05-12 16:53:43 UTC
2
+++ index.c
3
@@ -19,7 +19,7 @@ pdf_document_index_generate(zathura_docu
4
   }
5
 
6
   /* get outline */
7
-  fz_outline* outline = fz_load_outline(mupdf_document->document);
8
+  fz_outline* outline = fz_load_outline(mupdf_document->ctx, mupdf_document->document);
9
   if (outline == NULL) {
10
     if (error != NULL) {
11
       *error = ZATHURA_ERROR_UNKNOWN;
12
@@ -32,7 +32,7 @@ pdf_document_index_generate(zathura_docu
13
   build_index(outline, root);
14
 
15
   /* free outline */
16
-  fz_free_outline(mupdf_document->ctx, outline);
17
+  fz_drop_outline(mupdf_document->ctx, outline);
18
 
19
   return root;
20
 }
(-)graphics/zathura-pdf-mupdf/files/patch-links.c (+11 lines)
Line 0 Link Here
1
--- links.c.orig	2015-05-12 16:54:40 UTC
2
+++ links.c
3
@@ -31,7 +31,7 @@ pdf_page_links_get(zathura_page_t* page,
4
     goto error_free;
5
   }
6
 
7
-  fz_link* link = fz_load_links(mupdf_document->document, mupdf_page->page);
8
+  fz_link* link = fz_load_links(mupdf_document->ctx, mupdf_page->page);
9
   for (; link != NULL; link = link->next) {
10
     /* extract position */
11
     zathura_rectangle_t position;
(-)graphics/zathura-pdf-mupdf/files/patch-page.c (+36 lines)
Line 0 Link Here
1
--- page.c.orig	2015-05-12 16:55:28 UTC
2
+++ page.c
3
@@ -29,12 +29,12 @@ pdf_page_init(zathura_page_t* page)
4
 
5
   /* load page */
6
   fz_try (mupdf_page->ctx) {
7
-    mupdf_page->page = fz_load_page(mupdf_document->document, index);
8
+    mupdf_page->page = fz_load_page(mupdf_document->ctx, mupdf_document->document, index);
9
   } fz_catch (mupdf_page->ctx) {
10
     goto error_free;
11
   }
12
 
13
-  fz_bound_page(mupdf_document->document, (fz_page*) mupdf_page->page, &mupdf_page->bbox);
14
+  fz_bound_page(mupdf_document->ctx, (fz_page*) mupdf_page->page, &mupdf_page->bbox);
15
 
16
   /* get page dimensions */
17
   zathura_page_set_width(page,  mupdf_page->bbox.x1 - mupdf_page->bbox.x0);
18
@@ -74,15 +74,15 @@ pdf_page_clear(zathura_page_t* page, mup
19
 
20
   if (mupdf_page != NULL) {
21
     if (mupdf_page->text != NULL) {
22
-      fz_free_text_page(mupdf_page->ctx, mupdf_page->text);
23
+      fz_drop_text_page(mupdf_page->ctx, mupdf_page->text);
24
     }
25
 
26
     if (mupdf_page->sheet != NULL) {
27
-      fz_free_text_sheet(mupdf_page->ctx, mupdf_page->sheet);
28
+      fz_drop_text_sheet(mupdf_page->ctx, mupdf_page->sheet);
29
     }
30
 
31
     if (mupdf_page->page != NULL) {
32
-      fz_free_page(mupdf_document->document, mupdf_page->page);
33
+      fz_drop_page(mupdf_document->ctx, mupdf_page->page);
34
     }
35
 
36
     free(mupdf_page);
(-)graphics/zathura-pdf-mupdf/files/patch-render.c (+28 lines)
Line 0 Link Here
1
--- render.c.orig	2015-05-12 17:00:05 UTC
2
+++ render.c
3
@@ -26,12 +26,12 @@ pdf_page_render_to_buffer(mupdf_document
4
   fz_try (mupdf_document->ctx) {
5
     fz_matrix m;
6
     fz_scale(&m, scalex, scaley);
7
-    fz_run_page(mupdf_document->document, mupdf_page->page, device, &m, NULL);
8
+    fz_run_page(mupdf_document->ctx, mupdf_page->page, device, &m, NULL);
9
   } fz_catch (mupdf_document->ctx) {
10
     return ZATHURA_ERROR_UNKNOWN;
11
   }
12
 
13
-  fz_free_device(device);
14
+  fz_drop_device(mupdf_page->ctx, device);
15
 
16
   fz_irect irect = { .x1 = page_width, .y1 = page_height };
17
   fz_rect rect = { .x1 = page_width, .y1 = page_height };
18
@@ -41,8 +41,8 @@ pdf_page_render_to_buffer(mupdf_document
19
   fz_clear_pixmap_with_value(mupdf_page->ctx, pixmap, 0xFF);
20
 
21
   device = fz_new_draw_device(mupdf_page->ctx, pixmap);
22
-  fz_run_display_list(display_list, device, &fz_identity, &rect, NULL);
23
-  fz_free_device(device);
24
+  fz_run_display_list(mupdf_page->ctx, display_list, device, &fz_identity, &rect, NULL);
25
+  fz_drop_device(mupdf_page->ctx, device);
26
 
27
   unsigned char* s = fz_pixmap_samples(mupdf_page->ctx, pixmap);
28
   unsigned int n   = fz_pixmap_components(mupdf_page->ctx, pixmap);
(-)graphics/zathura-pdf-mupdf/files/patch-utils.c (+14 lines)
Line 0 Link Here
1
--- utils.c.orig	2015-05-12 17:02:07 UTC
2
+++ utils.c
3
@@ -17,9 +17,9 @@ mupdf_page_extract_text(mupdf_document_t
4
     text_device = fz_new_text_device(mupdf_page->ctx, mupdf_page->sheet, mupdf_page->text);
5
     fz_matrix ctm;
6
     fz_scale(&ctm, 1.0, 1.0);
7
-    fz_run_page(mupdf_document->document, mupdf_page->page, text_device, &ctm, NULL);
8
+    fz_run_page(mupdf_document->ctx, mupdf_page->page, text_device, &ctm, NULL);
9
   } fz_always (mupdf_document->ctx) {
10
-    fz_free_device(text_device);
11
+    fz_drop_device(mupdf_page->ctx, text_device);
12
   } fz_catch(mupdf_document->ctx) {
13
   }
14
 

Return to bug 200154