Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MuPDF 1.12 #577

Merged
merged 29 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e6f1aa1
Updated to MuPDF 1.12
TnS-hun Dec 1, 2017
826859b
mupdf_new_pixmap_with_data missed parameters
TnS-hun Dec 3, 2017
962d94d
Make all parameters of fz_get_pixmap_from_image available, remove the…
TnS-hun Dec 3, 2017
5dfbad5
Drop buffer and image as soon as possible as per poire-z's recommenda…
TnS-hun Dec 3, 2017
3ba30a5
encrypted zip patch for MuPDF 1.12
TnS-hun Dec 4, 2017
44d9736
external fonts patch for MuPDF 1.12
TnS-hun Dec 4, 2017
7136f55
Use libjpeg as a shared library
TnS-hun Dec 4, 2017
9144221
Wrong patch number
TnS-hun Dec 7, 2017
968fb9e
git.ghostscript.com is slow, so we use the official mirror on GitHub
TnS-hun Dec 8, 2017
c5455e4
html-font patch, just enough to test html & epub rendering
poire-z Dec 8, 2017
fb7670f
TOC segmentation fault fix
poire-z Dec 8, 2017
84bb6dc
Regenerated mupdf_h.lua with ffi-cdecl
TnS-hun Dec 8, 2017
c1eee61
fz_scale_pixmap was missing
TnS-hun Dec 8, 2017
7ea4d64
fz_new_text_page has been renamed to fz_new_stext_page
TnS-hun Dec 8, 2017
f24310e
Fixed most of the warnings caused by the patches and wrap-mupdf.c
TnS-hun Dec 8, 2017
a9fc268
Wrong mupdf_new_text_page parameters, mupdf_new_text_sheet is no long…
TnS-hun Dec 9, 2017
3677ae9
getPageText works again
TnS-hun Dec 9, 2017
bfa8d9c
Adding higlights almost works (width is 50% off), PDF saving works
TnS-hun Dec 9, 2017
b0c4bd9
Fixed wrong number of arguments for mupdf_new_pixmap_with_bbox
TnS-hun Dec 9, 2017
347ad39
Do not select bullet points
TnS-hun Dec 12, 2017
17ab6da
The incompatible bb error messages show the blitbuffer types
TnS-hun Dec 12, 2017
5b68329
Support blitting from RGB24 to RGB32 in BB_alpha_blit_from
TnS-hun Dec 12, 2017
185cb81
getPageText returned everything twice
TnS-hun Dec 13, 2017
2b9058a
Unit test update
TnS-hun Dec 15, 2017
5008599
vec_dot fix
TnS-hun Dec 15, 2017
99396fb
MuPDF v1.12.0 has been tagged, use that
TnS-hun Dec 16, 2017
a529c65
Removed unused variable
TnS-hun Dec 16, 2017
5c4e351
'SIZE_MAX' was undeclared on Android
TnS-hun Dec 16, 2017
d269c44
Forgot to remove the comment about the v1.12.0 tag
TnS-hun Dec 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ MUPDF_BUILD_DIR=$(CURDIR)/$(THIRDPARTY_DIR)/mupdf/build/$(MACHINE)
MUPDF_DIR=$(MUPDF_BUILD_DIR)/mupdf-prefix/src/mupdf
MUPDF_LIB_DIR=$(MUPDF_DIR)/build/release
MUPDF_LIB_STATIC=$(MUPDF_LIB_DIR)/libmupdf.a
MUPDF_JS_LIB_STATIC=$(MUPDF_LIB_DIR)/libmujs.a
MUPDF_THIRDPARTY_LIBS=$(MUPDF_LIB_DIR)/libopenjpeg.a \
$(MUPDF_LIB_DIR)/libjbig2dec.a \
MUPDF_THIRDPARTY_LIBS=$(MUPDF_LIB_DIR)/libmupdfthird.a \
$(AES_LIB)
MUPDF_LIB=$(OUTPUT_DIR)/libs/libmupdf$(LIB_EXT)

Expand Down
1 change: 0 additions & 1 deletion Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ $(MUPDF_LIB) $(MUPDF_DIR)/include: $(JPEG_LIB) \
-DAR="$(AR)" -DLDFLAGS="$(LDFLAGS) -L$(CURDIR)/$(OUTPUT_DIR)" \
-DXCFLAGS="$(CFLAGS) -DNOBUILTINFONT -I$(JPEG_DIR)/include -I$(FREETYPE_DIR)/include/freetype2 -I$(ZLIB_DIR) -I$(MINIZIP_DIR)" \
-DMUPDF_LIB_STATIC=$(MUPDF_LIB_STATIC) \
-DMUPDF_JS_LIB_STATIC=$(MUPDF_JS_LIB_STATIC) \
-DMUPDF_THIRDPARTY_LIBS=$(MUPDF_THIRDPARTY_LIBS) \
-DMUPDF_LIB=$(CURDIR)/$(MUPDF_LIB) \
-DMUPDF_SONAME=$(notdir $(MUPDF_LIB)) \
Expand Down
41 changes: 28 additions & 13 deletions blitbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ void BB_add_blit_from(BlitBuffer *dst, BlitBuffer *src,
int sbb_rotation = GET_BB_ROTATION(src);
int dbb_rotation = GET_BB_ROTATION(dst);
if (dbb_type != sbb_type) {
fprintf(stderr, "incompatible bb in file %s, line %d!\r\n",
__FILE__, __LINE__); exit(1);
fprintf(stderr, "incompatible bb (dst: %d, src: %d) in file %s, line %d!\r\n",
dbb_type, sbb_type, __FILE__, __LINE__); exit(1);
}
uint8_t r, g, b;
uint8_t ainv = 0xFF - alpha;
Expand Down Expand Up @@ -686,13 +686,9 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
int sbb_type = GET_BB_TYPE(src);
int sbb_rotation = GET_BB_ROTATION(src);
int dbb_rotation = GET_BB_ROTATION(dst);
if (dbb_type != sbb_type) {
fprintf(stderr, "incompatible bb in file %s, line %d!\r\n",
__FILE__, __LINE__); exit(1);
}
uint8_t r, g, b, ainv, alpha;
int d_x, d_y, o_x, o_y;
if (dbb_type == TYPE_BB8) {
if (dbb_type == TYPE_BB8 && sbb_type == TYPE_BB8) {
o_x = offs_x;
Color8 *dstptr, *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
Expand All @@ -705,7 +701,7 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
}
o_x += 1;
}
} else if (dbb_type == TYPE_BB8A) {
} else if (dbb_type == TYPE_BB8A && sbb_type == TYPE_BB8A) {
o_x = offs_x;
Color8A *dstptr, *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
Expand All @@ -720,7 +716,7 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
}
o_x += 1;
}
} else if (dbb_type == TYPE_BBRGB16) {
} else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BBRGB16) {
o_x = offs_x;
ColorRGB16 *dstptr, *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
Expand All @@ -733,7 +729,7 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
}
o_x += 1;
}
} else if (dbb_type == TYPE_BBRGB24) {
} else if (dbb_type == TYPE_BBRGB24 && sbb_type == TYPE_BBRGB24) {
o_x = offs_x;
ColorRGB24 *dstptr, *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
Expand All @@ -746,7 +742,7 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
}
o_x += 1;
}
} else if (dbb_type == TYPE_BBRGB32) {
} else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB32) {
o_x = offs_x;
ColorRGB32 *dstptr, *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
Expand All @@ -763,6 +759,25 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
}
o_x += 1;
}
} else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB24) {
o_x = offs_x;
ColorRGB32 *dstptr;
ColorRGB24 *srcptr;
for (d_x = dest_x; d_x < dest_x + w; d_x++) {
o_y = offs_y;
for (d_y = dest_y; d_y < dest_y + h; d_y++) {
BB_GET_PIXEL(dst, dbb_rotation, ColorRGB32, d_x, d_y, &dstptr);
BB_GET_PIXEL(src, sbb_rotation, ColorRGB24, o_x, o_y, &srcptr);
dstptr->r = srcptr->r;
dstptr->g = srcptr->g;
dstptr->b = srcptr->b;
o_y += 1;
}
o_x += 1;
}
} else {
fprintf(stderr, "incompatible bb (dst: %d, src: %d) in file %s, line %d!\r\n",
dbb_type, sbb_type, __FILE__, __LINE__); exit(1);
}
}

Expand All @@ -773,8 +788,8 @@ void BB_invert_blit_from(BlitBuffer *dst, BlitBuffer *src,
int sbb_rotation = GET_BB_ROTATION(src);
int dbb_rotation = GET_BB_ROTATION(dst);
if (dbb_type != sbb_type) {
fprintf(stderr, "incompatible bb in file %s, line %d!\r\n",
__FILE__, __LINE__); exit(1);
fprintf(stderr, "incompatible bb (dst: %d, src: %d) in file %s, line %d!\r\n",
dbb_type, sbb_type, __FILE__, __LINE__); exit(1);
}
int d_x, d_y, o_x, o_y;
if (dbb_type == TYPE_BB8) {
Expand Down
77 changes: 39 additions & 38 deletions ffi-cdecl/mupdf_decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "ffi-cdecl.h"

cdecl_const(FZ_PAGE_BLOCK_TEXT)
cdecl_const(FZ_STEXT_BLOCK_TEXT)

/* math */
cdecl_type(fz_point)
Expand Down Expand Up @@ -41,9 +41,17 @@ cdecl_func(fz_transform_rect)

/* misc/assorted */
cdecl_type(fz_context)
cdecl_type(fz_font)
cdecl_type(fz_hash_table)
cdecl_type(fz_storable)
cdecl_type(fz_key_storable)
cdecl_type(fz_store_drop_fn)
cdecl_struct(fz_storable_s)
cdecl_struct(fz_key_storable_s)

/* buffer */
cdecl_func(mupdf_new_buffer_from_shared_data)
cdecl_func(mupdf_drop_buffer)

/* context */
cdecl_type(fz_alloc_context)
Expand All @@ -57,27 +65,24 @@ cdecl_type(fz_image)
cdecl_type(fz_pixmap)
cdecl_struct(fz_image_s)
cdecl_struct(fz_pixmap_s)
cdecl_func(fz_new_image_from_data) // compat, use wrapper instead:
cdecl_func(mupdf_new_image_from_data)
cdecl_func(fz_new_pixmap_from_image) // compat, use wrapper instead:
cdecl_func(mupdf_new_pixmap_from_image)
cdecl_func(mupdf_new_image_from_buffer)
cdecl_func(mupdf_get_pixmap_from_image)
cdecl_func(mupdf_save_pixmap_as_png)
cdecl_func(fz_keep_image)
cdecl_func(fz_drop_image)

cdecl_func(fz_load_png)
cdecl_func(fz_runetochar)

/* document */
cdecl_enum(fz_link_kind_e)
cdecl_type(fz_link_dest)
cdecl_struct(fz_link_dest_s)
cdecl_type(fz_annot)
cdecl_struct(fz_annot_s)
cdecl_type(fz_outline)
cdecl_struct(fz_outline_s)
cdecl_type(fz_document)
cdecl_type(fz_page)
cdecl_type(fz_write_options)
cdecl_struct(fz_document_s)
cdecl_type(fz_link)
cdecl_struct(fz_document_s)
cdecl_struct(fz_page_s)

cdecl_func(mupdf_open_document)
Expand All @@ -86,6 +91,7 @@ cdecl_func(fz_authenticate_password)
cdecl_func(fz_drop_document) // NOTE: libk2pdfopt uses old fz_free_document symbol
cdecl_func(mupdf_count_pages)
cdecl_func(fz_lookup_metadata)
cdecl_func(fz_resolve_link)

/* page */
cdecl_func(mupdf_load_page)
Expand All @@ -102,33 +108,20 @@ cdecl_func(mupdf_load_outline)
cdecl_func(fz_drop_outline) // NOTE: libk2pdfopt uses old fz_free_outline symbol

/* structured text */
cdecl_type(fz_text_style)
cdecl_struct(fz_text_style_s)

cdecl_type(fz_text_char)
cdecl_struct(fz_text_char_s)

cdecl_type(fz_text_span)
cdecl_struct(fz_text_span_s)

cdecl_type(fz_text_line)
cdecl_struct(fz_text_line_s)

cdecl_type(fz_text_sheet)
cdecl_struct(fz_text_sheet_s)
cdecl_func(mupdf_new_text_sheet)
cdecl_func(fz_drop_text_sheet) // NOTE: libk2pdfopt uses old fz_free_text_sheet symbol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these comments? Do they no longer apply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fz_drop_text_sheet function no longer exists.

I don't think those comments are relevant anymore because libk2pdfopt is built without using MuPDF (HAVE_MUPDF_LIB).

cdecl_type(fz_stext_char)
cdecl_struct(fz_stext_char_s)

cdecl_type(fz_text_page)
cdecl_type(fz_page_block)
cdecl_struct(fz_text_page_s)
cdecl_func(mupdf_new_text_page)
cdecl_func(fz_drop_text_page) // NOTE: libk2pdfopt uses old fz_free_text_page symbol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That cdecl and the comment are still there but fz_drop_text_page has been renamed to fz_drop_stext_page.

cdecl_type(fz_text_block)
cdecl_struct(fz_page_block_s)
cdecl_struct(fz_text_block_s)
cdecl_type(fz_stext_line)
cdecl_struct(fz_stext_line_s)

cdecl_func(fz_text_char_bbox)
cdecl_type(fz_stext_block)
cdecl_struct(fz_stext_block_s)
cdecl_type(fz_stext_options)
cdecl_struct(fz_stext_options_s)
cdecl_type(fz_stext_page)
cdecl_struct(fz_stext_page_s)
cdecl_func(mupdf_new_stext_page_from_page)
cdecl_func(fz_drop_stext_page) // NOTE: libk2pdfopt uses old fz_free_text_page symbol

/* pixmaps */
cdecl_func(mupdf_new_pixmap)
Expand All @@ -141,6 +134,7 @@ cdecl_func(fz_keep_pixmap)
cdecl_func(fz_drop_pixmap)
cdecl_func(fz_clear_pixmap_with_value)
cdecl_func(fz_gamma_pixmap)
cdecl_func(fz_scale_pixmap)
cdecl_func(fz_pixmap_width)
cdecl_func(fz_pixmap_height)
cdecl_func(fz_pixmap_components)
Expand All @@ -154,28 +148,35 @@ cdecl_func(mupdf_new_draw_device)
cdecl_func(mupdf_new_text_device)
cdecl_func(mupdf_new_bbox_device)
cdecl_func(mupdf_run_page)
cdecl_func(fz_close_device)
cdecl_func(fz_drop_device) // NOTE: libk2pdfopt uses old fz_free_device symbol

/* pdf specifics */
cdecl_enum(fz_annot_type)
cdecl_type(pdf_hotspot)
cdecl_struct(pdf_hotspot_s)
cdecl_type(pdf_lexbuf)
cdecl_struct(pdf_lexbuf_s)
cdecl_type(pdf_lexbuf_large)
cdecl_struct(pdf_lexbuf_large_s)
cdecl_type(pdf_obj)
cdecl_type(pdf_xobject)
cdecl_type(pdf_annot)
cdecl_type(pdf_page)
cdecl_struct(pdf_xobject_s)
cdecl_struct(pdf_annot_s)
cdecl_type(pdf_document)
cdecl_struct(pdf_document_s)
cdecl_func(pdf_specifics)
cdecl_func(mupdf_pdf_create_annot)
cdecl_func(mupdf_pdf_set_markup_annot_quadpoints)
cdecl_func(mupdf_pdf_set_annot_quad_points)
cdecl_func(mupdf_pdf_set_text_annot_position)
cdecl_func(mupdf_pdf_set_markup_appearance)

/* saving documents */
cdecl_struct(fz_write_options_s)
cdecl_func(mupdf_write_document)
cdecl_type(pdf_write_options)
cdecl_struct(pdf_write_options_s)
cdecl_func(mupdf_pdf_save_document)

/* the following is for our own wrapper lib: */
cdecl_func(mupdf_get_my_alloc_context)
Expand Down
Loading