Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: core/include/fpdfapi/fpdf_render.h

Issue 1805603002: core/include/fdpfapi cleanup Part I. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/include/fpdfapi/fpdf_parser_decode.h ('k') | core/include/fpdfapi/fpdf_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 CORE_INCLUDE_FPDFAPI_FPDF_RENDER_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_RENDER_H_
9
10 #include <map>
11 #include <memory>
12
13 #include "core/include/fpdfapi/fpdf_page.h"
14 #include "core/include/fxge/fx_ge.h"
15
16 class CFX_GraphStateData;
17 class CFX_PathData;
18 class CFX_RenderDevice;
19 class CPDF_ImageCacheEntry;
20 class CPDF_RenderStatus;
21 class IFX_Pause;
22
23 class IPDF_OCContext {
24 public:
25 virtual ~IPDF_OCContext() {}
26
27 virtual FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCG) = 0;
28
29 FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj);
30 };
31 #define RENDER_COLOR_NORMAL 0
32 #define RENDER_COLOR_GRAY 1
33 #define RENDER_COLOR_TWOCOLOR 2
34 #define RENDER_COLOR_ALPHA 3
35 #define RENDER_CLEARTYPE 0x00000001
36 #define RENDER_PRINTGRAPHICTEXT 0x00000002
37 #define RENDER_FORCE_DOWNSAMPLE 0x00000004
38 #define RENDER_PRINTPREVIEW 0x00000008
39 #define RENDER_BGR_STRIPE 0x00000010
40 #define RENDER_NO_NATIVETEXT 0x00000020
41 #define RENDER_FORCE_HALFTONE 0x00000040
42 #define RENDER_RECT_AA 0x00000080
43 #define RENDER_FILL_FULLCOVER 0x00000100
44 #define RENDER_PRINTIMAGETEXT 0x00000200
45 #define RENDER_OVERPRINT 0x00000400
46 #define RENDER_THINLINE 0x00000800
47 #define RENDER_NOTEXTSMOOTH 0x10000000
48 #define RENDER_NOPATHSMOOTH 0x20000000
49 #define RENDER_NOIMAGESMOOTH 0x40000000
50 #define RENDER_LIMITEDIMAGECACHE 0x80000000
51
52 class CPDF_RenderOptions {
53 public:
54 CPDF_RenderOptions();
55 FX_ARGB TranslateColor(FX_ARGB argb) const;
56
57 int m_ColorMode;
58 FX_COLORREF m_BackColor;
59 FX_COLORREF m_ForeColor;
60 FX_DWORD m_Flags;
61 int m_Interpolation;
62 FX_DWORD m_AddFlags;
63 IPDF_OCContext* m_pOCContext;
64 FX_DWORD m_dwLimitCacheSize;
65 int m_HalftoneLimit;
66 };
67
68 class CPDF_RenderContext {
69 public:
70 class Layer {
71 public:
72 CPDF_PageObjectHolder* m_pObjectHolder;
73 CFX_Matrix m_Matrix;
74 };
75
76 explicit CPDF_RenderContext(CPDF_Page* pPage);
77 CPDF_RenderContext(CPDF_Document* pDoc, CPDF_PageRenderCache* pPageCache);
78 ~CPDF_RenderContext();
79
80 void AppendLayer(CPDF_PageObjectHolder* pObjectHolder,
81 const CFX_Matrix* pObject2Device);
82
83 void Render(CFX_RenderDevice* pDevice,
84 const CPDF_RenderOptions* pOptions,
85 const CFX_Matrix* pFinalMatrix);
86
87 void Render(CFX_RenderDevice* pDevice,
88 const CPDF_PageObject* pStopObj,
89 const CPDF_RenderOptions* pOptions,
90 const CFX_Matrix* pFinalMatrix);
91
92 void GetBackground(CFX_DIBitmap* pBuffer,
93 const CPDF_PageObject* pObj,
94 const CPDF_RenderOptions* pOptions,
95 CFX_Matrix* pFinalMatrix);
96
97 FX_DWORD CountLayers() const { return m_Layers.GetSize(); }
98 Layer* GetLayer(FX_DWORD index) { return m_Layers.GetDataPtr(index); }
99
100 CPDF_Document* GetDocument() const { return m_pDocument; }
101 CPDF_Dictionary* GetPageResources() const { return m_pPageResources; }
102 CPDF_PageRenderCache* GetPageCache() const { return m_pPageCache; }
103
104 protected:
105 CPDF_Document* const m_pDocument;
106 CPDF_Dictionary* m_pPageResources;
107 CPDF_PageRenderCache* m_pPageCache;
108 FX_BOOL m_bFirstLayer;
109 CFX_ArrayTemplate<Layer> m_Layers;
110 };
111
112 class CPDF_ProgressiveRenderer {
113 public:
114 // Must match FDF_RENDER_* definitions in public/fpdf_progressive.h, but
115 // cannot #include that header. fpdfsdk/fpdf_progressive.cpp has
116 // static_asserts to make sure the two sets of values match.
117 enum Status {
118 Ready, // FPDF_RENDER_READER
119 ToBeContinued, // FPDF_RENDER_TOBECOUNTINUED
120 Done, // FPDF_RENDER_DONE
121 Failed // FPDF_RENDER_FAILED
122 };
123
124 static int ToFPDFStatus(Status status) { return static_cast<int>(status); }
125
126 CPDF_ProgressiveRenderer(CPDF_RenderContext* pContext,
127 CFX_RenderDevice* pDevice,
128 const CPDF_RenderOptions* pOptions);
129 ~CPDF_ProgressiveRenderer();
130
131 Status GetStatus() const { return m_Status; }
132 void Start(IFX_Pause* pPause);
133 void Continue(IFX_Pause* pPause);
134
135 private:
136 void RenderStep();
137
138 // Maximum page objects to render before checking for pause.
139 static const int kStepLimit = 100;
140
141 Status m_Status;
142 CPDF_RenderContext* const m_pContext;
143 CFX_RenderDevice* const m_pDevice;
144 const CPDF_RenderOptions* const m_pOptions;
145 std::unique_ptr<CPDF_RenderStatus> m_pRenderStatus;
146 CFX_FloatRect m_ClipRect;
147 FX_DWORD m_LayerIndex;
148 CPDF_RenderContext::Layer* m_pCurrentLayer;
149 CPDF_PageObjectList::iterator m_LastObjectRendered;
150 };
151
152 class CPDF_TextRenderer {
153 public:
154 static void DrawTextString(CFX_RenderDevice* pDevice,
155 int left,
156 int top,
157 CPDF_Font* pFont,
158 int height,
159 const CFX_ByteString& str,
160 FX_ARGB argb);
161
162 static void DrawTextString(CFX_RenderDevice* pDevice,
163 FX_FLOAT origin_x,
164 FX_FLOAT origin_y,
165 CPDF_Font* pFont,
166 FX_FLOAT font_size,
167 const CFX_Matrix* matrix,
168 const CFX_ByteString& str,
169 FX_ARGB fill_argb,
170 FX_ARGB stroke_argb = 0,
171 const CFX_GraphStateData* pGraphState = NULL,
172 const CPDF_RenderOptions* pOptions = NULL);
173
174 static FX_BOOL DrawTextPath(CFX_RenderDevice* pDevice,
175 int nChars,
176 FX_DWORD* pCharCodes,
177 FX_FLOAT* pCharPos,
178 CPDF_Font* pFont,
179 FX_FLOAT font_size,
180 const CFX_Matrix* pText2User,
181 const CFX_Matrix* pUser2Device,
182 const CFX_GraphStateData* pGraphState,
183 FX_ARGB fill_argb,
184 FX_ARGB stroke_argb,
185 CFX_PathData* pClippingPath,
186 int nFlag = 0);
187
188 static FX_BOOL DrawNormalText(CFX_RenderDevice* pDevice,
189 int nChars,
190 FX_DWORD* pCharCodes,
191 FX_FLOAT* pCharPos,
192 CPDF_Font* pFont,
193 FX_FLOAT font_size,
194 const CFX_Matrix* pText2Device,
195 FX_ARGB fill_argb,
196 const CPDF_RenderOptions* pOptions);
197
198 static FX_BOOL DrawType3Text(CFX_RenderDevice* pDevice,
199 int nChars,
200 FX_DWORD* pCharCodes,
201 FX_FLOAT* pCharPos,
202 CPDF_Font* pFont,
203 FX_FLOAT font_size,
204 const CFX_Matrix* pText2Device,
205 FX_ARGB fill_argb);
206 };
207 class CPDF_PageRenderCache {
208 public:
209 explicit CPDF_PageRenderCache(CPDF_Page* pPage)
210 : m_pPage(pPage),
211 m_pCurImageCacheEntry(nullptr),
212 m_nTimeCount(0),
213 m_nCacheSize(0),
214 m_bCurFindCache(FALSE) {}
215 ~CPDF_PageRenderCache();
216 void ClearImageData();
217
218 FX_DWORD EstimateSize();
219 void CacheOptimization(int32_t dwLimitCacheSize);
220 FX_DWORD GetTimeCount() const { return m_nTimeCount; }
221 void SetTimeCount(FX_DWORD dwTimeCount) { m_nTimeCount = dwTimeCount; }
222
223 void GetCachedBitmap(CPDF_Stream* pStream,
224 CFX_DIBSource*& pBitmap,
225 CFX_DIBSource*& pMask,
226 FX_DWORD& MatteColor,
227 FX_BOOL bStdCS = FALSE,
228 FX_DWORD GroupFamily = 0,
229 FX_BOOL bLoadMask = FALSE,
230 CPDF_RenderStatus* pRenderStatus = NULL,
231 int32_t downsampleWidth = 0,
232 int32_t downsampleHeight = 0);
233
234 void ResetBitmap(CPDF_Stream* pStream, const CFX_DIBitmap* pBitmap);
235 void ClearImageCacheEntry(CPDF_Stream* pStream);
236 CPDF_Page* GetPage() const { return m_pPage; }
237 CPDF_ImageCacheEntry* GetCurImageCacheEntry() const {
238 return m_pCurImageCacheEntry;
239 }
240
241 FX_BOOL StartGetCachedBitmap(CPDF_Stream* pStream,
242 FX_BOOL bStdCS = FALSE,
243 FX_DWORD GroupFamily = 0,
244 FX_BOOL bLoadMask = FALSE,
245 CPDF_RenderStatus* pRenderStatus = NULL,
246 int32_t downsampleWidth = 0,
247 int32_t downsampleHeight = 0);
248
249 FX_BOOL Continue(IFX_Pause* pPause);
250
251 protected:
252 friend class CPDF_Page;
253 CPDF_Page* const m_pPage;
254 CPDF_ImageCacheEntry* m_pCurImageCacheEntry;
255 std::map<CPDF_Stream*, CPDF_ImageCacheEntry*> m_ImageCache;
256 FX_DWORD m_nTimeCount;
257 FX_DWORD m_nCacheSize;
258 FX_BOOL m_bCurFindCache;
259 };
260
261 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix);
262
263 #endif // CORE_INCLUDE_FPDFAPI_FPDF_RENDER_H_
OLDNEW
« no previous file with comments | « core/include/fpdfapi/fpdf_parser_decode.h ('k') | core/include/fpdfapi/fpdf_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698