summaryrefslogtreecommitdiff
path: root/fitz/dev_list.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-04 18:33:33 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-04 19:13:41 +0000
commit2ae2a7b68381f0fc5940e983ccdec5b4cc08d188 (patch)
treea0ff2e359868cf6d4bcc6de7fabc06d9ade9774a /fitz/dev_list.c
parent94439d77f23763d59457b9946ba35bd354ea4841 (diff)
downloadmupdf-2ae2a7b68381f0fc5940e983ccdec5b4cc08d188.tar.xz
Bug 692739: Add ability to abort time consuming actions
A new 'cookie' parameter is added to page rendering/interpretation functions. Supply this as NULL to get existing behaviour. If you supply a non-NULL cookie, then this is taken as a pointer to a struct that can be used for simple, non-thread locked communication between caller and library. The entire struct should be memset to zero before entry, except for specific flags (thus coping with future extensions to this struct). The abort flag should be zero on entry. It will be checked periodically by the library - if the caller sets it non-zero (via another thread) then the current operation will be aborted. No guarantees are given as to how often this will be checked, or how fast it will be responded to. The progress_max field will be set to an integer (-1 for unknown) representing the number of 'things' to do. The progress field will count up from 0 to this number as time goes by. No guarantees are made as to the accuracy of this information, but it should be useful for offering some sort of progress bar etc. Note that progress_max may increase during the job. In general, callers should be careful to accept out of range or invalid data in this structure as this is deliberately accessed 'unlocked'.
Diffstat (limited to 'fitz/dev_list.c')
-rw-r--r--fitz/dev_list.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index 376cdac8..c6a71ec9 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -591,7 +591,7 @@ fz_free_display_list(fz_context *ctx, fz_display_list *list)
}
void
-fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox scissor)
+fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox scissor, fz_cookie *cookie)
{
fz_display_node *node;
fz_matrix ctm;
@@ -600,6 +600,7 @@ fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm
int clipped = 0;
int tiled = 0;
int empty;
+ int progress = 0;
if (!fz_is_infinite_bbox(scissor))
{
@@ -609,8 +610,22 @@ fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm
scissor.x1 += 20; scissor.y1 += 20;
}
+ if (cookie)
+ {
+ cookie->progress_max = list->last - list->first;
+ cookie->progress = 0;
+ }
+
for (node = list->first; node; node = node->next)
{
+ /* Check the cookie for aborting */
+ if (cookie)
+ {
+ if (cookie->abort)
+ break;
+ cookie->progress = progress++;
+ }
+
/* cull objects to draw using a quick visibility test */
if (tiled || node->cmd == FZ_CMD_BEGIN_TILE || node->cmd == FZ_CMD_END_TILE)