diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-03-21 17:57:33 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-03-21 17:57:33 +0100 |
commit | 3960e9a02f4064422645b1e65230fe39708dd48f (patch) | |
tree | 18860fd8be44ef7bdcab056162d94f74aeff9a9f | |
parent | 9a278ec1303231d24b0ba1abb8a934409f2cd73a (diff) | |
download | mupdf-3960e9a02f4064422645b1e65230fe39708dd48f.tar.xz |
Update iOS app.
-rw-r--r-- | Makerules | 2 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 16 | ||||
-rw-r--r-- | fitz/fitz.h | 16 | ||||
-rw-r--r-- | ios/Info.plist | 8 | ||||
-rw-r--r-- | ios/MuPDF.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | ios/document.c | 99 | ||||
-rw-r--r-- | ios/document.h | 20 | ||||
-rw-r--r-- | ios/main.m | 7 |
8 files changed, 89 insertions, 87 deletions
@@ -92,7 +92,7 @@ endif # The following section works for both device and simulator builds. ifeq "$(OS)" "ios" -CC = $(PLATFORM_DEVELOPER_BIN_DIR)/clang +CC = $(PLATFORM_DEVELOPER_BIN_DIR)/gcc AR = $(PLATFORM_DEVELOPER_BIN_DIR)/ar RANLIB_CMD = $(PLATFORM_DEVELOPER_BIN_DIR)/ranlib $@ CROSSCOMPILE=yes diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index ae64b89d..b47d984a 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -61,22 +61,6 @@ fz_unlock(fz_context *ctx, int lock) * Basic runtime and utility functions */ -/* - fz_malloc_struct: Allocate storage for a structure (with scavenging), - clear it, and (in Memento builds) tag the pointer as belonging to a - struct of this type. - - CTX: The context. - - STRUCT: The structure type. - - Returns a pointer to allocated (and cleared) structure. Throws - exception on failure to allocate. -*/ -/* alloc and zero a struct, and tag it for memento */ -#define fz_malloc_struct(CTX, STRUCT) \ - Memento_label(fz_calloc(CTX,1,sizeof(STRUCT)), #STRUCT) - /* Range checking atof */ float fz_atof(const char *s); diff --git a/fitz/fitz.h b/fitz/fitz.h index 55af47a0..1197a048 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -365,6 +365,22 @@ void *fz_malloc(fz_context *ctx, unsigned int size); void *fz_calloc(fz_context *ctx, unsigned int count, unsigned int size); /* + fz_malloc_struct: Allocate storage for a structure (with scavenging), + clear it, and (in Memento builds) tag the pointer as belonging to a + struct of this type. + + CTX: The context. + + STRUCT: The structure type. + + Returns a pointer to allocated (and cleared) structure. Throws + exception on failure to allocate. +*/ +/* alloc and zero a struct, and tag it for memento */ +#define fz_malloc_struct(CTX, STRUCT) \ + Memento_label(fz_calloc(CTX,1,sizeof(STRUCT)), #STRUCT) + +/* fz_malloc_array: Allocate a block of (non zeroed) memory (with scavenging). Equivalent to fz_calloc without the memory clearing. diff --git a/ios/Info.plist b/ios/Info.plist index 85213b7c..6afbcf12 100644 --- a/ios/Info.plist +++ b/ios/Info.plist @@ -19,15 +19,17 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>0.9.1</string> + <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>0.9</string> + <string>1.0</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UIFileSharingEnabled</key> <true/> + <key>UIPrerenderedIcon</key> + <true/> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> @@ -46,7 +48,5 @@ <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> - <key>UIPrerenderedIcon</key> - <true/> </dict> </plist> diff --git a/ios/MuPDF.xcodeproj/project.pbxproj b/ios/MuPDF.xcodeproj/project.pbxproj index 73fe67c6..1c047a36 100644 --- a/ios/MuPDF.xcodeproj/project.pbxproj +++ b/ios/MuPDF.xcodeproj/project.pbxproj @@ -245,7 +245,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -262,7 +262,7 @@ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ..; + HEADER_SEARCH_PATHS = "../**"; INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -279,7 +279,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -289,7 +289,7 @@ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ..; + HEADER_SEARCH_PATHS = "../**"; INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; diff --git a/ios/document.c b/ios/document.c index 7004d702..0fb077ad 100644 --- a/ios/document.c +++ b/ios/document.c @@ -164,71 +164,84 @@ draw_page(struct document *doc, int number, fz_device *dev, fz_matrix ctm, fz_co fz_flush_warnings(doc->ctx); } -static int -charat(fz_text_span *span, int idx) +static fz_text_char +textcharat(fz_text_page *page, int idx) { + static fz_text_char emptychar = { {0,0,0,0}, ' ' }; + fz_text_block *block; + fz_text_line *line; + fz_text_span *span; int ofs = 0; - while (span) { - if (idx < ofs + span->len) - return span->text[idx - ofs].c; - if (span->eol) { - if (idx == ofs + span->len) - return ' '; - ofs ++; + for (block = page->blocks; block < page->blocks + page->len; block++) + { + for (line = block->lines; line < block->lines + block->len; line++) + { + for (span = line->spans; span < line->spans + line->len; span++) + { + if (idx < ofs + span->len) + return span->text[idx - ofs]; + /* pseudo-newline */ + if (span + 1 == line->spans + line->len) + { + if (idx == ofs + span->len) + return emptychar; + ofs++; + } + ofs += span->len; + } } - ofs += span->len; - span = span->next; } - return 0; + return emptychar; +} + +static int +charat(fz_text_page *page, int idx) +{ + return textcharat(page, idx).c; } static fz_bbox -bboxat(fz_text_span *span, int idx) +bboxat(fz_text_page *page, int idx) { - int ofs = 0; - while (span) { - if (idx < ofs + span->len) - return span->text[idx - ofs].bbox; - if (span->eol) { - if (idx == ofs + span->len) - return fz_empty_bbox; - ofs ++; - } - ofs += span->len; - span = span->next; - } - return fz_empty_bbox; + return fz_round_rect(textcharat(page, idx).bbox); } static int -textlen(fz_text_span *span) +textlen(fz_text_page *page) { + fz_text_block *block; + fz_text_line *line; + fz_text_span *span; int len = 0; - while (span) { - len += span->len; - if (span->eol) - len ++; - span = span->next; + for (block = page->blocks; block < page->blocks + page->len; block++) + { + for (line = block->lines; line < block->lines + block->len; line++) + { + for (span = line->spans; span < line->spans + line->len; span++) + len += span->len; + len++; /* pseudo-newline */ + } } return len; } static int -match(fz_text_span *span, char *s, int n) +match(fz_text_page *page, const char *s, int n) { - int start = n, c; + int orig = n; + int c; while (*s) { - s += chartorune(&c, s); - if (c == ' ' && charat(span, n) == ' ') { - while (charat(span, n) == ' ') + s += fz_chartorune(&c, (char *)s); + if (c == ' ' && charat(page, n) == ' ') { + while (charat(page, n) == ' ') n++; } else { - if (tolower(c) != tolower(charat(span, n))) + if (tolower(c) != tolower(charat(page, n))) return 0; n++; } } - return n - start; + return n - orig; } int @@ -239,8 +252,9 @@ search_page(struct document *doc, int number, char *needle, fz_cookie *cookie) if (strlen(needle) == 0) return 0; - fz_text_span *text = fz_new_text_span(doc->ctx); - fz_device *dev = fz_new_text_device(doc->ctx, text); + fz_text_sheet *sheet = fz_new_text_sheet(doc->ctx); + fz_text_page *text = fz_new_text_page(doc->ctx, fz_empty_rect); + fz_device *dev = fz_new_text_device(doc->ctx, sheet, text); draw_page(doc, number, dev, fz_identity, cookie); fz_free_device(dev); @@ -258,7 +272,8 @@ search_page(struct document *doc, int number, char *needle, fz_cookie *cookie) } } - fz_free_text_span(doc->ctx, text); + fz_free_text_page(doc->ctx, text); + fz_free_text_sheet(doc->ctx, sheet); return doc->hit_count; } diff --git a/ios/document.h b/ios/document.h index 0003070e..b4555578 100644 --- a/ios/document.h +++ b/ios/document.h @@ -1,21 +1,5 @@ -#ifndef _DOCUMENT_H_ -#define _DOCUMENT_H_ - -#ifndef _FITZ_H_ -#error "fitz.h must be included before document.h" -#endif - -#ifndef _MUPDF_H_ -#error "mupdf.h must be included before document.h" -#endif - -#ifndef _MUXPS_H_ -#error "muxps.h must be included before document.h" -#endif - -#ifndef _MUCBZ_H_ -#error "mucbz.h must be included before document.h" -#endif +#ifndef DOCUMENT_H +#define DOCUMENT_H struct document { @@ -167,9 +167,12 @@ static void releasePixmap(void *info, const void *data, size_t size) static UIImage *newImageWithPixmap(fz_pixmap *pix) { - CGDataProviderRef cgdata = CGDataProviderCreateWithData(pix, pix->samples, pix->w * 4 * pix->h, releasePixmap); + unsigned char *samples = fz_pixmap_samples(ctx, pix); + int w = fz_pixmap_width(ctx, pix); + int h = fz_pixmap_height(ctx, pix); + CGDataProviderRef cgdata = CGDataProviderCreateWithData(pix, samples, w * 4 * h, releasePixmap); CGColorSpaceRef cgcolor = CGColorSpaceCreateDeviceRGB(); - CGImageRef cgimage = CGImageCreate(pix->w, pix->h, 8, 32, 4 * pix->w, + CGImageRef cgimage = CGImageCreate(w, h, 8, 32, 4 * w, cgcolor, kCGBitmapByteOrderDefault, cgdata, NULL, NO, kCGRenderingIntentDefault); UIImage *image = [[UIImage alloc] |