xref: /aosp_15_r20/external/pdfium/public/fpdf_progressive.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef PUBLIC_FPDF_PROGRESSIVE_H_
8 #define PUBLIC_FPDF_PROGRESSIVE_H_
9 
10 // clang-format off
11 // NOLINTNEXTLINE(build/include)
12 #include "fpdfview.h"
13 
14 // Flags for progressive process status.
15 #define FPDF_RENDER_READY 0
16 #define FPDF_RENDER_TOBECONTINUED 1
17 #define FPDF_RENDER_DONE 2
18 #define FPDF_RENDER_FAILED 3
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 // IFPDF_RENDERINFO interface.
25 typedef struct _IFSDK_PAUSE {
26   /*
27    * Version number of the interface. Currently must be 1.
28    */
29   int version;
30 
31   /*
32    * Method: NeedToPauseNow
33    *           Check if we need to pause a progressive process now.
34    * Interface Version:
35    *           1
36    * Implementation Required:
37    *           yes
38    * Parameters:
39    *           pThis       -   Pointer to the interface structure itself
40    * Return Value:
41    *           Non-zero for pause now, 0 for continue.
42    */
43   FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis);
44 
45   // A user defined data pointer, used by user's application. Can be NULL.
46   void* user;
47 } IFSDK_PAUSE;
48 
49 // Experimental API.
50 // Function: FPDF_RenderPageBitmapWithColorScheme_Start
51 //          Start to render page contents to a device independent bitmap
52 //          progressively with a specified color scheme for the content.
53 // Parameters:
54 //          bitmap       -   Handle to the device independent bitmap (as the
55 //                           output buffer). Bitmap handle can be created by
56 //                           FPDFBitmap_Create function.
57 //          page         -   Handle to the page as returned by FPDF_LoadPage
58 //                           function.
59 //          start_x      -   Left pixel position of the display area in the
60 //                           bitmap coordinate.
61 //          start_y      -   Top pixel position of the display area in the
62 //                           bitmap coordinate.
63 //          size_x       -   Horizontal size (in pixels) for displaying the
64 //                           page.
65 //          size_y       -   Vertical size (in pixels) for displaying the page.
66 //          rotate       -   Page orientation: 0 (normal), 1 (rotated 90
67 //                           degrees clockwise), 2 (rotated 180 degrees),
68 //                           3 (rotated 90 degrees counter-clockwise).
69 //          flags        -   0 for normal display, or combination of flags
70 //                           defined in fpdfview.h. With FPDF_ANNOT flag, it
71 //                           renders all annotations that does not require
72 //                           user-interaction, which are all annotations except
73 //                           widget and popup annotations.
74 //          color_scheme -   Color scheme to be used in rendering the |page|.
75 //                           If null, this function will work similar to
76 //                           FPDF_RenderPageBitmap_Start().
77 //          pause        -   The IFSDK_PAUSE interface. A callback mechanism
78 //                           allowing the page rendering process.
79 // Return value:
80 //          Rendering Status. See flags for progressive process status for the
81 //          details.
82 FPDF_EXPORT int FPDF_CALLCONV
83 FPDF_RenderPageBitmapWithColorScheme_Start(FPDF_BITMAP bitmap,
84                                            FPDF_PAGE page,
85                                            int start_x,
86                                            int start_y,
87                                            int size_x,
88                                            int size_y,
89                                            int rotate,
90                                            int flags,
91                                            const FPDF_COLORSCHEME* color_scheme,
92                                            IFSDK_PAUSE* pause);
93 
94 // Function: FPDF_RenderPageBitmap_Start
95 //          Start to render page contents to a device independent bitmap
96 //          progressively.
97 // Parameters:
98 //          bitmap      -   Handle to the device independent bitmap (as the
99 //                          output buffer). Bitmap handle can be created by
100 //                          FPDFBitmap_Create().
101 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
102 //          start_x     -   Left pixel position of the display area in the
103 //                          bitmap coordinates.
104 //          start_y     -   Top pixel position of the display area in the bitmap
105 //                          coordinates.
106 //          size_x      -   Horizontal size (in pixels) for displaying the page.
107 //          size_y      -   Vertical size (in pixels) for displaying the page.
108 //          rotate      -   Page orientation: 0 (normal), 1 (rotated 90 degrees
109 //                          clockwise), 2 (rotated 180 degrees), 3 (rotated 90
110 //                          degrees counter-clockwise).
111 //          flags       -   0 for normal display, or combination of flags
112 //                          defined in fpdfview.h. With FPDF_ANNOT flag, it
113 //                          renders all annotations that does not require
114 //                          user-interaction, which are all annotations except
115 //                          widget and popup annotations.
116 //          pause       -   The IFSDK_PAUSE interface.A callback mechanism
117 //                          allowing the page rendering process
118 // Return value:
119 //          Rendering Status. See flags for progressive process status for the
120 //          details.
121 FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
122                                                           FPDF_PAGE page,
123                                                           int start_x,
124                                                           int start_y,
125                                                           int size_x,
126                                                           int size_y,
127                                                           int rotate,
128                                                           int flags,
129                                                           IFSDK_PAUSE* pause);
130 
131 // Function: FPDF_RenderPage_Continue
132 //          Continue rendering a PDF page.
133 // Parameters:
134 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
135 //          pause       -   The IFSDK_PAUSE interface (a callback mechanism
136 //                          allowing the page rendering process to be paused
137 //                          before it's finished). This can be NULL if you
138 //                          don't want to pause.
139 // Return value:
140 //          The rendering status. See flags for progressive process status for
141 //          the details.
142 FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page,
143                                                        IFSDK_PAUSE* pause);
144 
145 // Function: FPDF_RenderPage_Close
146 //          Release the resource allocate during page rendering. Need to be
147 //          called after finishing rendering or
148 //          cancel the rendering.
149 // Parameters:
150 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
151 // Return value:
152 //          None.
153 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif  // PUBLIC_FPDF_PROGRESSIVE_H_
160