summaryrefslogtreecommitdiff
path: root/platform/winrt/mupdfwinrt
diff options
context:
space:
mode:
Diffstat (limited to 'platform/winrt/mupdfwinrt')
-rw-r--r--platform/winrt/mupdfwinrt/muctx.cpp34
-rw-r--r--platform/winrt/mupdfwinrt/muctx.h5
-rw-r--r--platform/winrt/mupdfwinrt/mudocument.cpp25
-rw-r--r--platform/winrt/mupdfwinrt/mudocument.h8
4 files changed, 44 insertions, 28 deletions
diff --git a/platform/winrt/mupdfwinrt/muctx.cpp b/platform/winrt/mupdfwinrt/muctx.cpp
index 2c40a85d..4e8a4ad2 100644
--- a/platform/winrt/mupdfwinrt/muctx.cpp
+++ b/platform/winrt/mupdfwinrt/muctx.cpp
@@ -127,6 +127,7 @@ status_t muctx::InitializeContext()
}
else
{
+ fz_register_document_handlers(this->mu_ctx);
return S_ISOK;
}
}
@@ -159,7 +160,7 @@ muctx::~muctx(void)
status_t muctx::InitializeStream(IRandomAccessStream^ readStream, char *ext)
{
win_stream.stream = readStream;
- fz_stream *mu_stream = fz_new_stream(mu_ctx, 0, win_read_file, win_close_file);
+ fz_stream *mu_stream = fz_new_stream(mu_ctx, 0, win_read_file, win_close_file, NULL);
mu_stream->seek = win_seek_file;
mu_stream->state = reinterpret_cast <void*> (&win_stream);
@@ -442,9 +443,10 @@ fz_display_list * muctx::CreateDisplayList(int page_num, int *width, int *height
}
/* Render display list bmp_data buffer. No lock needed for this operation */
-status_t muctx::RenderPageMT(void *dlist, int page_width, int page_height,
+status_t muctx::RenderPageMT(void *dlist, int page_width, int page_height,
unsigned char *bmp_data, int bmp_width, int bmp_height,
- bool flipy)
+ float scale, bool flipy, bool tile, Point top_left,
+ Point bottom_right)
{
fz_device *dev = NULL;
fz_pixmap *pix = NULL;
@@ -460,16 +462,22 @@ status_t muctx::RenderPageMT(void *dlist, int page_width, int page_height,
fz_try(ctx_clone)
{
- /* Figure out scale factors so that we get the desired size */
- pctm = fz_scale(pctm, (float) bmp_width / page_width, (float) bmp_height / page_height);
- /* Flip on Y */
+ pctm = fz_scale(pctm, scale, scale);
+ /* Flip on Y. */
if (flipy)
{
- ctm.f = bmp_height;
+ ctm.f = (float) page_height * ctm.d;
ctm.d = -ctm.d;
+ ctm.f += top_left.Y;
}
- pix = fz_new_pixmap_with_data(ctx_clone, fz_device_bgr(ctx_clone), bmp_width,
- bmp_height, bmp_data);
+ else
+ {
+ ctm.f -= top_left.Y;
+ }
+ ctm.e -= top_left.X;
+
+ pix = fz_new_pixmap_with_data(ctx_clone, fz_device_bgr(ctx_clone),
+ bmp_width, bmp_height, bmp_data);
fz_clear_pixmap_with_value(ctx_clone, pix, 255);
dev = fz_new_draw_device(ctx_clone, pix);
fz_run_display_list(display_list, dev, pctm, NULL, NULL);
@@ -485,14 +493,13 @@ status_t muctx::RenderPageMT(void *dlist, int page_width, int page_height,
fz_free_context(ctx_clone);
return E_FAILURE;
}
-
fz_free_context(ctx_clone);
return S_ISOK;
}
/* Render page_num to size width by height into bmp_data buffer. Lock needed. */
status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width,
- int bmp_height, bool flipy)
+ int bmp_height, float scale, bool flipy)
{
fz_device *dev = NULL;
fz_pixmap *pix = NULL;
@@ -508,10 +515,7 @@ status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width,
{
page = fz_load_page(mu_doc, page_num);
page_size = MeasurePage(page);
-
- /* Figure out scale factors so that we get the desired size */
- pctm = fz_scale(pctm, (float) bmp_width / page_size.X,
- (float) bmp_height / page_size.Y);
+ pctm = fz_scale(pctm, scale, scale);
/* Flip on Y */
if (flipy)
{
diff --git a/platform/winrt/mupdfwinrt/muctx.h b/platform/winrt/mupdfwinrt/muctx.h
index 5c452155..80d165ed 100644
--- a/platform/winrt/mupdfwinrt/muctx.h
+++ b/platform/winrt/mupdfwinrt/muctx.h
@@ -86,10 +86,11 @@ public:
int GetPageCount();
status_t InitializeContext();
status_t RenderPage(int page_num, unsigned char *bmp_data, int bmp_width,
- int bmp_height, bool flipy);
+ int bmp_height, float scale, bool flipy);
status_t RenderPageMT(void *dlist, int page_width, int page_height,
unsigned char *bmp_data, int bmp_width, int bmp_height,
- bool flipy);
+ float scale, bool flipy, bool tile, Point top_left,
+ Point bottom_right);
fz_display_list* CreateDisplayList(int page_num, int *width, int *height);
int MeasurePage(int page_num, Point *size);
Point MeasurePage(fz_page *page);
diff --git a/platform/winrt/mupdfwinrt/mudocument.cpp b/platform/winrt/mupdfwinrt/mudocument.cpp
index 48093780..b37b45aa 100644
--- a/platform/winrt/mupdfwinrt/mudocument.cpp
+++ b/platform/winrt/mupdfwinrt/mudocument.cpp
@@ -173,7 +173,9 @@ Windows::Foundation::IAsyncOperationWithProgress<int, double>^
thread to ensure that the thumbs are created in order and we don't create
thousands of threads */
int mudocument::RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height,
- bool use_dlist, bool flipy, Array<unsigned char>^* bit_map)
+ float scale, bool use_dlist, bool flipy, bool tile,
+ Point top_left, Point bottom_right,
+ Array<unsigned char>^* bit_map)
{
status_t code;
/* Allocate space for bmp */
@@ -206,14 +208,20 @@ int mudocument::RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height
}
code = mu_object.RenderPageMT(dlist, page_width, page_height,
&(bmp_data[0]), bmp_width, bmp_height,
- flipy);
+ scale, flipy, tile, top_left, bottom_right);
}
else
{
+ /* Not dealing with the case of tiling and no display list at this time. */
+ if (tile)
+ {
+ *bit_map = nullptr;
+ return E_FAILURE;
+ }
/* Rendering in immediate mode. Keep lock in place */
mutex_lock.lock();
code = mu_object.RenderPage(page_num, &(bmp_data[0]), bmp_width,
- bmp_height, flipy);
+ bmp_height, scale, flipy);
mutex_lock.unlock();
}
if (code != S_ISOK)
@@ -229,9 +237,9 @@ int mudocument::RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height
/* Pack the page into a bmp stream */
Windows::Foundation::IAsyncOperation<InMemoryRandomAccessStream^>^
mudocument::RenderPageAsync(int page_num, int bmp_width, int bmp_height,
- bool use_dlist)
+ bool use_dlist, float scale)
{
- return create_async([this, bmp_width, bmp_height, page_num, use_dlist]
+ return create_async([this, bmp_width, bmp_height, page_num, use_dlist, scale]
(cancellation_token ct) -> InMemoryRandomAccessStream^
{
/* Allocate space for bmp */
@@ -270,14 +278,15 @@ Windows::Foundation::IAsyncOperation<InMemoryRandomAccessStream^>^
/* Rendering of display list can occur with other threads so unlock */
code = mu_object.RenderPageMT(dlist, page_width, page_height,
&(bmp_data[0]), bmp_width, bmp_height,
- true);
+ scale, true, false, { 0.0, 0.0 },
+ { (float) bmp_width, (float) bmp_height });
}
else
- {
+ {
/* Rendering in immediate mode. Keep lock in place */
mutex_lock.lock();
code = mu_object.RenderPage(page_num, &(bmp_data[0]), bmp_width,
- bmp_height, true);
+ bmp_height, scale, true);
mutex_lock.unlock();
}
if (code != S_ISOK)
diff --git a/platform/winrt/mupdfwinrt/mudocument.h b/platform/winrt/mupdfwinrt/mudocument.h
index 3e0b9fcf..9ab37ed7 100644
--- a/platform/winrt/mupdfwinrt/mudocument.h
+++ b/platform/winrt/mupdfwinrt/mudocument.h
@@ -33,9 +33,11 @@ namespace mupdfwinrt
int GetNumPages(void);
Point GetPageSize(int page_num);
Windows::Foundation::IAsyncOperation<InMemoryRandomAccessStream^>^
- RenderPageAsync(int page_num, int width, int height, bool use_dlist);
- int RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height,
- bool use_dlist, bool flipy, Array<unsigned char>^* bit_map);
+ RenderPageAsync(int page_num, int width, int height,
+ bool use_dlist, float scale);
+ int RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height,
+ float scale, bool use_dlist, bool flipy, bool tiling, Point top_left,
+ Point bottom_right, Array<unsigned char>^* bit_map);
Windows::Foundation::IAsyncOperationWithProgress<int, double>^
SearchDocumentWithProgressAsync(String^ textToFind, int dir,
int start_page, int num_pages);