• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   // Version number of the interface. Currently must be 1.
27   int version;
28 
29   // Method: NeedToPauseNow
30   //           Check if we need to pause a progressive process now.
31   // Interface Version:
32   //           1
33   // Implementation Required:
34   //           yes
35   // Parameters:
36   //           pThis       -   Pointer to the interface structure itself
37   // Return Value:
38   //           Non-zero for pause now, 0 for continue.
39   FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis);
40 
41   // A user defined data pointer, used by user's application. Can be NULL.
42   void* user;
43 } IFSDK_PAUSE;
44 
45 // Experimental API.
46 // Function: FPDF_RenderPageBitmapWithColorScheme_Start
47 //          Start to render page contents to a device independent bitmap
48 //          progressively with a specified color scheme for the content.
49 // Parameters:
50 //          bitmap       -   Handle to the device independent bitmap (as the
51 //                           output buffer). Bitmap handle can be created by
52 //                           FPDFBitmap_Create function.
53 //          page         -   Handle to the page as returned by FPDF_LoadPage
54 //                           function.
55 //          start_x      -   Left pixel position of the display area in the
56 //                           bitmap coordinate.
57 //          start_y      -   Top pixel position of the display area in the
58 //                           bitmap coordinate.
59 //          size_x       -   Horizontal size (in pixels) for displaying the
60 //                           page.
61 //          size_y       -   Vertical size (in pixels) for displaying the page.
62 //          rotate       -   Page orientation: 0 (normal), 1 (rotated 90
63 //                           degrees clockwise), 2 (rotated 180 degrees),
64 //                           3 (rotated 90 degrees counter-clockwise).
65 //          flags        -   0 for normal display, or combination of flags
66 //                           defined in fpdfview.h. With FPDF_ANNOT flag, it
67 //                           renders all annotations that does not require
68 //                           user-interaction, which are all annotations except
69 //                           widget and popup annotations.
70 //          color_scheme -   Color scheme to be used in rendering the |page|.
71 //                           If null, this function will work similar to
72 //                           FPDF_RenderPageBitmap_Start().
73 //          pause        -   The IFSDK_PAUSE interface. A callback mechanism
74 //                           allowing the page rendering process.
75 // Return value:
76 //          Rendering Status. See flags for progressive process status for the
77 //          details.
78 FPDF_EXPORT int FPDF_CALLCONV
79 FPDF_RenderPageBitmapWithColorScheme_Start(FPDF_BITMAP bitmap,
80                                            FPDF_PAGE page,
81                                            int start_x,
82                                            int start_y,
83                                            int size_x,
84                                            int size_y,
85                                            int rotate,
86                                            int flags,
87                                            const FPDF_COLORSCHEME* color_scheme,
88                                            IFSDK_PAUSE* pause);
89 
90 // Function: FPDF_RenderPageBitmap_Start
91 //          Start to render page contents to a device independent bitmap
92 //          progressively.
93 // Parameters:
94 //          bitmap      -   Handle to the device independent bitmap (as the
95 //                          output buffer). Bitmap handle can be created by
96 //                          FPDFBitmap_Create().
97 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
98 //          start_x     -   Left pixel position of the display area in the
99 //                          bitmap coordinates.
100 //          start_y     -   Top pixel position of the display area in the bitmap
101 //                          coordinates.
102 //          size_x      -   Horizontal size (in pixels) for displaying the page.
103 //          size_y      -   Vertical size (in pixels) for displaying the page.
104 //          rotate      -   Page orientation: 0 (normal), 1 (rotated 90 degrees
105 //                          clockwise), 2 (rotated 180 degrees), 3 (rotated 90
106 //                          degrees counter-clockwise).
107 //          flags       -   0 for normal display, or combination of flags
108 //                          defined in fpdfview.h. With FPDF_ANNOT flag, it
109 //                          renders all annotations that does not require
110 //                          user-interaction, which are all annotations except
111 //                          widget and popup annotations.
112 //          pause       -   The IFSDK_PAUSE interface.A callback mechanism
113 //                          allowing the page rendering process
114 // Return value:
115 //          Rendering Status. See flags for progressive process status for the
116 //          details.
117 FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
118                                                           FPDF_PAGE page,
119                                                           int start_x,
120                                                           int start_y,
121                                                           int size_x,
122                                                           int size_y,
123                                                           int rotate,
124                                                           int flags,
125                                                           IFSDK_PAUSE* pause);
126 
127 // Function: FPDF_RenderPage_Continue
128 //          Continue rendering a PDF page.
129 // Parameters:
130 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
131 //          pause       -   The IFSDK_PAUSE interface (a callback mechanism
132 //                          allowing the page rendering process to be paused
133 //                          before it's finished). This can be NULL if you
134 //                          don't want to pause.
135 // Return value:
136 //          The rendering status. See flags for progressive process status for
137 //          the details.
138 FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page,
139                                                        IFSDK_PAUSE* pause);
140 
141 // Function: FPDF_RenderPage_Close
142 //          Release the resource allocate during page rendering. Need to be
143 //          called after finishing rendering or
144 //          cancel the rendering.
145 // Parameters:
146 //          page        -   Handle to the page, as returned by FPDF_LoadPage().
147 // Return value:
148 //          None.
149 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif  // PUBLIC_FPDF_PROGRESSIVE_H_
156