comparison mupdf-source/include/mupdf/fitz/display-list.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2021 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifndef MUPDF_FITZ_DISPLAY_LIST_H
24 #define MUPDF_FITZ_DISPLAY_LIST_H
25
26 #include "mupdf/fitz/system.h"
27 #include "mupdf/fitz/context.h"
28 #include "mupdf/fitz/geometry.h"
29 #include "mupdf/fitz/device.h"
30
31 /**
32 Display list device -- record and play back device commands.
33 */
34
35 /**
36 fz_display_list is a list containing drawing commands (text,
37 images, etc.). The intent is two-fold: as a caching-mechanism
38 to reduce parsing of a page, and to be used as a data
39 structure in multi-threading where one thread parses the page
40 and another renders pages.
41
42 Create a display list with fz_new_display_list, hand it over to
43 fz_new_list_device to have it populated, and later replay the
44 list (once or many times) by calling fz_run_display_list. When
45 the list is no longer needed drop it with fz_drop_display_list.
46 */
47 typedef struct fz_display_list fz_display_list;
48
49 /**
50 Create an empty display list.
51
52 A display list contains drawing commands (text, images, etc.).
53 Use fz_new_list_device for populating the list.
54
55 mediabox: Bounds of the page (in points) represented by the
56 display list.
57 */
58 fz_display_list *fz_new_display_list(fz_context *ctx, fz_rect mediabox);
59
60 /**
61 Create a rendering device for a display list.
62
63 When the device is rendering a page it will populate the
64 display list with drawing commands (text, images, etc.). The
65 display list can later be reused to render a page many times
66 without having to re-interpret the page from the document file
67 for each rendering. Once the device is no longer needed, free
68 it with fz_drop_device.
69
70 list: A display list that the list device takes a reference to.
71 */
72 fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);
73
74 /**
75 (Re)-run a display list through a device.
76
77 list: A display list, created by fz_new_display_list and
78 populated with objects from a page by running fz_run_page on a
79 device obtained from fz_new_list_device.
80
81 ctm: Transform to apply to display list contents. May include
82 for example scaling and rotation, see fz_scale, fz_rotate and
83 fz_concat. Set to fz_identity if no transformation is desired.
84
85 scissor: Only the part of the contents of the display list
86 visible within this area will be considered when the list is
87 run through the device. This does not imply for tile objects
88 contained in the display list.
89
90 cookie: Communication mechanism between caller and library
91 running the page. Intended for multi-threaded applications,
92 while single-threaded applications set cookie to NULL. The
93 caller may abort an ongoing page run. Cookie also communicates
94 progress information back to the caller. The fields inside
95 cookie are continually updated while the page is being run.
96 */
97 void fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, fz_matrix ctm, fz_rect scissor, fz_cookie *cookie);
98
99 /**
100 Increment the reference count for a display list. Returns the
101 same pointer.
102
103 Never throws exceptions.
104 */
105 fz_display_list *fz_keep_display_list(fz_context *ctx, fz_display_list *list);
106
107 /**
108 Decrement the reference count for a display list. When the
109 reference count reaches zero, all the references in the display
110 list itself are dropped, and the display list is freed.
111
112 Never throws exceptions.
113 */
114 void fz_drop_display_list(fz_context *ctx, fz_display_list *list);
115
116 /**
117 Return the bounding box of the page recorded in a display list.
118 */
119 fz_rect fz_bound_display_list(fz_context *ctx, fz_display_list *list);
120
121 /**
122 Create a new image from a display list.
123
124 w, h: The conceptual width/height of the image.
125
126 transform: The matrix that needs to be applied to the given
127 list to make it render to the unit square.
128
129 list: The display list.
130 */
131 fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_display_list *list);
132
133 /**
134 Check for a display list being empty
135
136 list: The list to check.
137
138 Returns true if empty, false otherwise.
139 */
140 int fz_display_list_is_empty(fz_context *ctx, const fz_display_list *list);
141
142 #endif