diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-01-09 13:27:17 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-01-09 17:46:26 +0100 |
commit | 9d96d035d3b7af53256ee64b5ddb0ad8bcf8df38 (patch) | |
tree | 408cbbb72315089db1b8efe58bce322f8734bb1b /platform/ios/common.m | |
parent | 50b39c939345c36eb5e95c8a71ccdb8cd24c9aad (diff) | |
download | mupdf-9d96d035d3b7af53256ee64b5ddb0ad8bcf8df38.tar.xz |
Remove platform/ios directory.
The iOS viewer has been moved to its own git repository.
Diffstat (limited to 'platform/ios/common.m')
-rw-r--r-- | platform/ios/common.m | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/platform/ios/common.m b/platform/ios/common.m deleted file mode 100644 index 232f3b29..00000000 --- a/platform/ios/common.m +++ /dev/null @@ -1,73 +0,0 @@ -#include "common.h" - -fz_context *ctx; -dispatch_queue_t queue; -float screenScale = 1; - -CGSize fitPageToScreen(CGSize page, CGSize screen) -{ - float hscale = screen.width / page.width; - float vscale = screen.height / page.height; - float scale = fz_min(hscale, vscale); - hscale = floorf(page.width * scale) / page.width; - vscale = floorf(page.height * scale) / page.height; - return CGSizeMake(hscale, vscale); -} - -static int hit_count = 0; -static fz_rect hit_bbox[500]; - -int search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie) -{ - fz_page *page = fz_load_page(ctx, doc, number); - fz_rect mediabox; - fz_stext_sheet *sheet = fz_new_stext_sheet(ctx); - fz_stext_page *text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); - fz_device *dev = fz_new_stext_device(ctx, sheet, text, NULL); - fz_run_page(ctx, page, dev, &fz_identity, cookie); - fz_close_device(ctx, dev); - fz_drop_device(ctx, dev); - - hit_count = fz_search_stext_page(ctx, text, needle, hit_bbox, nelem(hit_bbox)); - - fz_drop_stext_page(ctx, text); - fz_drop_stext_sheet(ctx, sheet); - fz_drop_page(ctx, page); - - return hit_count; -} - -fz_rect search_result_bbox(fz_document *doc, int i) -{ - return hit_bbox[i]; -} - -static void releasePixmap(void *info, const void *data, size_t size) -{ - if (queue) - dispatch_async(queue, ^{ - fz_drop_pixmap(ctx, info); - }); - else - { - fz_drop_pixmap(ctx, info); - } -} - -CGDataProviderRef CreateWrappedPixmap(fz_pixmap *pix) -{ - unsigned char *samples = fz_pixmap_samples(ctx, pix); - int w = fz_pixmap_width(ctx, pix); - int h = fz_pixmap_height(ctx, pix); - return CGDataProviderCreateWithData(pix, samples, w * 4 * h, releasePixmap); -} - -CGImageRef CreateCGImageWithPixmap(fz_pixmap *pix, CGDataProviderRef cgdata) -{ - int w = fz_pixmap_width(ctx, pix); - int h = fz_pixmap_height(ctx, pix); - CGColorSpaceRef cgcolor = CGColorSpaceCreateDeviceRGB(); - CGImageRef cgimage = CGImageCreate(w, h, 8, 32, 4 * w, cgcolor, kCGBitmapByteOrderDefault, cgdata, NULL, NO, kCGRenderingIntentDefault); - CGColorSpaceRelease(cgcolor); - return cgimage; -} |