1 // Copyright 2014 PDFium Authors. All rights reserved.
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 // NOLINTNEXTLINE(build/include)
11 #include "fpdfview.h"
12 
13 // Flags for progressive process status.
14 #define FPDF_RENDER_READER 0
15 #define FPDF_RENDER_TOBECOUNTINUED 1
16 #define FPDF_RENDER_DONE 2
17 #define FPDF_RENDER_FAILED 3
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 // IFPDF_RENDERINFO interface.
24 typedef struct _IFSDK_PAUSE {
25   /**
26   * Version number of the interface. Currently must be 1.
27   **/
28   int version;
29 
30   /*
31   * Method: NeedToPauseNow
32   *           Check if we need to pause a progressive process now.
33   * Interface Version:
34   *           1
35   * Implementation Required:
36   *           yes
37   * Parameters:
38   *           pThis       -   Pointer to the interface structure itself
39   * Return Value:
40   *            Non-zero for pause now, 0 for continue.
41   *
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 // Function: FPDF_RenderPageBitmap_Start
50 //          Start to render page contents to a device independent bitmap
51 //          progressively.
52 // Parameters:
53 //          bitmap      -   Handle to the device independent bitmap (as the
54 //          output buffer).
55 //                          Bitmap handle can be created by FPDFBitmap_Create
56 //                          function.
57 //          page        -   Handle to the page. 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 bitmap
62 //          coordinate.
63 //          size_x      -   Horizontal size (in pixels) for displaying the page.
64 //          size_y      -   Vertical size (in pixels) for displaying the page.
65 //          rotate      -   Page orientation: 0 (normal), 1 (rotated 90 degrees
66 //          clockwise),
67 //                              2 (rotated 180 degrees), 3 (rotated 90 degrees
68 //                              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 //          pause       -   The IFSDK_PAUSE interface.A callback mechanism
75 //          allowing the page rendering process
76 // Return value:
77 //          Rendering Status. See flags for progressive process status for the
78 //          details.
79 //
80 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
81                                                   FPDF_PAGE page,
82                                                   int start_x,
83                                                   int start_y,
84                                                   int size_x,
85                                                   int size_y,
86                                                   int rotate,
87                                                   int flags,
88                                                   IFSDK_PAUSE* pause);
89 
90 // Function: FPDF_RenderPage_Continue
91 //          Continue rendering a PDF page.
92 // Parameters:
93 //          page        -   Handle to the page. Returned by FPDF_LoadPage
94 //          function.
95 //          pause       -   The IFSDK_PAUSE interface.A callback mechanism
96 //          allowing the page rendering process
97 //                          to be paused before it's finished. This can be NULL
98 //                          if you don't want to pause.
99 // Return value:
100 //          The rendering status. See flags for progressive process status for
101 //          the details.
102 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,
103                                                IFSDK_PAUSE* pause);
104 
105 // Function: FPDF_RenderPage_Close
106 //          Release the resource allocate during page rendering. Need to be
107 //          called after finishing rendering or
108 //          cancel the rendering.
109 // Parameters:
110 //          page        -   Handle to the page. Returned by FPDF_LoadPage
111 //          function.
112 // Return value:
113 //          NULL
114 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif  // PUBLIC_FPDF_PROGRESSIVE_H_
121