summaryrefslogtreecommitdiff
path: root/platform/windows/mupdfwinrt
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/mupdfwinrt')
-rw-r--r--platform/windows/mupdfwinrt/Cache.cpp14
-rw-r--r--platform/windows/mupdfwinrt/muctx.cpp23
-rw-r--r--platform/windows/mupdfwinrt/muctx.h1
-rw-r--r--platform/windows/mupdfwinrt/mudocument.cpp6
4 files changed, 32 insertions, 12 deletions
diff --git a/platform/windows/mupdfwinrt/Cache.cpp b/platform/windows/mupdfwinrt/Cache.cpp
index b129710f..d5108a7c 100644
--- a/platform/windows/mupdfwinrt/Cache.cpp
+++ b/platform/windows/mupdfwinrt/Cache.cpp
@@ -22,7 +22,6 @@ void Cache::Empty(fz_context *mu_ctx)
cache_entry_t *old_entry = curr_entry;
curr_entry = old_entry->next;
fz_drop_display_list(mu_ctx, old_entry->dlist);
-
delete old_entry;
}
this->size = 0;
@@ -49,7 +48,10 @@ void Cache::Add(int value, int width_in, int height_in, fz_display_list *dlist,
tail = prev_entry;
- /* Decrement the caches rc of this list */
+ /* Decrement the caches rc of this list. It is gone from cache but
+ may still be in use by other threads, when threads are done they
+ should decrement and it should be freed at that time. See
+ ReleaseDisplayLists in muctx class */
fz_drop_display_list(mu_ctx, curr_entry->dlist);
delete curr_entry;
size--;
@@ -76,8 +78,8 @@ void Cache::Add(int value, int width_in, int height_in, fz_display_list *dlist,
head = new_entry;
}
size++;
- /* We are going to use this item now */
- fz_keep_display_list(mu_ctx, new_entry->dlist);
+ /* Everytime we add an entry, we are also using it. Increment rc. See above */
+ fz_keep_display_list(mu_ctx, dlist);
}
fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_context *mu_ctx)
@@ -93,7 +95,6 @@ fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_conte
}
if (curr_entry != NULL)
{
- fz_keep_display_list(mu_ctx, curr_entry->dlist);
/* Move this to the front */
if (curr_entry != head)
{
@@ -113,6 +114,9 @@ fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_conte
}
*width_out = curr_entry->width;
*height_out = curr_entry->height;
+ /* We must increment our reference to this one to ensure it is not
+ freed when removed from the cache. See above comments */
+ fz_keep_display_list(mu_ctx, curr_entry->dlist);
return curr_entry->dlist;
}
else
diff --git a/platform/windows/mupdfwinrt/muctx.cpp b/platform/windows/mupdfwinrt/muctx.cpp
index d5c34c80..e51ea403 100644
--- a/platform/windows/mupdfwinrt/muctx.cpp
+++ b/platform/windows/mupdfwinrt/muctx.cpp
@@ -531,6 +531,21 @@ fz_display_list * muctx::CreateDisplayList(int page_num, int *width, int *height
return dlist;
}
+void muctx::ReleaseDisplayLists(void *opdlist, void *opannotlist)
+{
+ fz_display_list *dlist = (fz_display_list*) opdlist;
+ fz_display_list *annotlist = (fz_display_list*) opannotlist;
+
+ if (dlist != NULL)
+ {
+ fz_drop_display_list(mu_ctx, dlist);
+ }
+ if (annotlist != NULL)
+ {
+ fz_drop_display_list(mu_ctx, annotlist);
+ }
+}
+
/* A special version which will create the display list AND get the information
that we need for various text selection tasks */
fz_display_list * muctx::CreateDisplayListText(int page_num, int *width, int *height,
@@ -648,8 +663,6 @@ status_t muctx::RenderPageMT(void *dlist, void *a_dlist, int page_width, int pag
{
fz_free_device(dev);
fz_drop_pixmap(ctx_clone, pix);
- fz_drop_display_list(ctx_clone, display_list);
- fz_drop_display_list(ctx_clone, annot_displaylist);
}
fz_catch(ctx_clone)
{
@@ -689,11 +702,11 @@ status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width,
bmp_height, bmp_data);
fz_clear_pixmap_with_value(mu_ctx, pix, 255);
dev = fz_new_draw_device(mu_ctx, pix);
- fz_run_page(mu_doc, page, dev, pctm, NULL);
+ fz_run_page_contents(mu_doc, page, dev, pctm, NULL);
fz_annot *annot;
for (annot = fz_first_annot(mu_doc, page); annot; annot = fz_next_annot(mu_doc, annot))
- fz_run_annot(mu_doc, page, annot, dev, &fz_identity, NULL);
+ fz_run_annot(mu_doc, page, annot, dev, pctm, NULL);
}
fz_always(mu_ctx)
{
@@ -879,8 +892,6 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type,
fz_drop_pixmap(mu_ctx, pix);
fz_free_device(dev);
fz_free_page(mu_doc, page);
- if (dlist != NULL)
- fz_drop_display_list(mu_ctx, dlist);
if (out != NULL)
{
fz_close_output(out);
diff --git a/platform/windows/mupdfwinrt/muctx.h b/platform/windows/mupdfwinrt/muctx.h
index 16c44cd1..5b870543 100644
--- a/platform/windows/mupdfwinrt/muctx.h
+++ b/platform/windows/mupdfwinrt/muctx.h
@@ -101,6 +101,7 @@ public:
fz_display_list * CreateDisplayListText(int page_num, int *width,
int *height, fz_text_page **text, int *length);
fz_display_list * CreateAnnotationList(int page_num);
+ void ReleaseDisplayLists(void *dlist, void *annotlist);
int MeasurePage(int page_num, point_t *size);
point_t MeasurePage(fz_page *page);
unsigned int GetLinks(int page_num, sh_vector_link links_vec);
diff --git a/platform/windows/mupdfwinrt/mudocument.cpp b/platform/windows/mupdfwinrt/mudocument.cpp
index 060144b3..29df67c3 100644
--- a/platform/windows/mupdfwinrt/mudocument.cpp
+++ b/platform/windows/mupdfwinrt/mudocument.cpp
@@ -217,6 +217,8 @@ int mudocument::RenderPageBitmapSync(int page_num, int bmp_width, int bmp_height
&(bmp_data[0]), bmp_width, bmp_height,
scale, flipy, tile, { top_left.X, top_left.Y },
{ bottom_right.X, bottom_right.Y });
+ /* Done with lists */
+ mu_object.ReleaseDisplayLists(dlist, annotlist);
}
else
{
@@ -290,7 +292,9 @@ Windows::Foundation::IAsyncOperation<InMemoryRandomAccessStream^>^
&(bmp_data[0]), bmp_width, bmp_height,
scale, true, false, { 0.0, 0.0 },
{ (float) bmp_width, (float) bmp_height });
- }
+ /* Done with lists */
+ mu_object.ReleaseDisplayLists(dlist, annotlist);
+ }
else
{
/* Rendering in immediate mode. Keep lock in place */