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

Side by Side Diff: core/fxge/include/fx_ge.h

Issue 2223213002: Refactor fx_ge part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase Created 4 years, 4 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/fxge/include/cfx_renderdevice.h ('k') | core/fxge/skia/fx_skia_device.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_FXGE_INCLUDE_FX_GE_H_
8 #define CORE_FXGE_INCLUDE_FX_GE_H_
9
10 #include <memory>
11
12 #include "core/fxge/include/cfx_fontmgr.h"
13 #include "core/fxge/include/fx_dib.h"
14 #include "core/fxge/include/fx_font.h"
15
16 class CCodec_ModuleMgr;
17 class CFX_FaceCache;
18 class CFX_Font;
19 class CFX_FontCache;
20 class CFX_FontMgr;
21 class CPDF_ShadingPattern;
22 class IFX_RenderDeviceDriver;
23 class SkPictureRecorder;
24
25 class CFX_GraphStateData {
26 public:
27 enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 };
28
29 CFX_GraphStateData();
30 CFX_GraphStateData(const CFX_GraphStateData& src);
31 ~CFX_GraphStateData();
32
33 void Copy(const CFX_GraphStateData& src);
34 void SetDashCount(int count);
35
36 LineCap m_LineCap;
37 int m_DashCount;
38 FX_FLOAT* m_DashArray;
39 FX_FLOAT m_DashPhase;
40
41 enum LineJoin {
42 LineJoinMiter = 0,
43 LineJoinRound = 1,
44 LineJoinBevel = 2,
45 };
46 LineJoin m_LineJoin;
47 FX_FLOAT m_MiterLimit;
48 FX_FLOAT m_LineWidth;
49 };
50
51 #define FXDC_DEVICE_CLASS 1
52 #define FXDC_PIXEL_WIDTH 2
53 #define FXDC_PIXEL_HEIGHT 3
54 #define FXDC_BITS_PIXEL 4
55 #define FXDC_HORZ_SIZE 5
56 #define FXDC_VERT_SIZE 6
57 #define FXDC_RENDER_CAPS 7
58 #define FXDC_DISPLAY 1
59 #define FXDC_PRINTER 2
60
61 #define FXPT_CLOSEFIGURE 0x01
62 #define FXPT_LINETO 0x02
63 #define FXPT_BEZIERTO 0x04
64 #define FXPT_MOVETO 0x06
65 #define FXPT_TYPE 0x06
66
67 #define FXRC_GET_BITS 0x01
68 #define FXRC_BIT_MASK 0x02
69 #define FXRC_ALPHA_MASK 0x04
70 #define FXRC_ALPHA_PATH 0x10
71 #define FXRC_ALPHA_IMAGE 0x20
72 #define FXRC_ALPHA_OUTPUT 0x40
73 #define FXRC_BLEND_MODE 0x80
74 #define FXRC_SOFT_CLIP 0x100
75 #define FXRC_CMYK_OUTPUT 0x200
76 #define FXRC_BITMASK_OUTPUT 0x400
77 #define FXRC_BYTEMASK_OUTPUT 0x800
78 #define FXRENDER_IMAGE_LOSSY 0x1000
79 #define FXRC_FILLSTROKE_PATH 0x2000
80 #define FXRC_SHADING 0x4000
81
82 #define FXFILL_ALTERNATE 1
83 #define FXFILL_WINDING 2
84 #define FXFILL_FULLCOVER 4
85 #define FXFILL_RECT_AA 8
86 #define FX_FILL_STROKE 16
87 #define FX_STROKE_ADJUST 32
88 #define FX_STROKE_TEXT_MODE 64
89 #define FX_FILL_TEXT_MODE 128
90 #define FX_ZEROAREA_FILL 256
91 #define FXFILL_NOPATHSMOOTH 512
92
93 #define FXTEXT_CLEARTYPE 0x01
94 #define FXTEXT_BGR_STRIPE 0x02
95 #define FXTEXT_PRINTGRAPHICTEXT 0x04
96 #define FXTEXT_NO_NATIVETEXT 0x08
97 #define FXTEXT_PRINTIMAGETEXT 0x10
98 #define FXTEXT_NOSMOOTH 0x20
99
100 struct FXTEXT_CHARPOS {
101 uint32_t m_GlyphIndex;
102 FX_FLOAT m_OriginX;
103 FX_FLOAT m_OriginY;
104 int m_FontCharWidth;
105 FX_BOOL m_bGlyphAdjust;
106 FX_FLOAT m_AdjustMatrix[4];
107 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
108 uint32_t m_ExtGID;
109 #endif
110 bool m_bFontStyle;
111 };
112
113 class CFX_RenderDevice {
114 public:
115 CFX_RenderDevice();
116 virtual ~CFX_RenderDevice();
117
118 // Take ownership of |pDriver|.
119 void SetDeviceDriver(std::unique_ptr<IFX_RenderDeviceDriver> pDriver);
120 IFX_RenderDeviceDriver* GetDeviceDriver() const {
121 return m_pDeviceDriver.get();
122 }
123
124 FX_BOOL StartRendering();
125 void EndRendering();
126 void SaveState();
127 void RestoreState(bool bKeepSaved);
128
129 int GetWidth() const { return m_Width; }
130 int GetHeight() const { return m_Height; }
131 int GetDeviceClass() const { return m_DeviceClass; }
132 int GetBPP() const { return m_bpp; }
133 int GetRenderCaps() const { return m_RenderCaps; }
134 int GetDeviceCaps(int id) const;
135 CFX_Matrix GetCTM() const;
136 CFX_DIBitmap* GetBitmap() const { return m_pBitmap; }
137 void SetBitmap(CFX_DIBitmap* pBitmap) { m_pBitmap = pBitmap; }
138 FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
139 int width,
140 int height) const;
141 const FX_RECT& GetClipBox() const { return m_ClipBox; }
142 FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
143 const CFX_Matrix* pObject2Device,
144 int fill_mode);
145 FX_BOOL SetClip_Rect(const FX_RECT& pRect);
146 FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
147 const CFX_Matrix* pObject2Device,
148 const CFX_GraphStateData* pGraphState);
149 FX_BOOL DrawPath(const CFX_PathData* pPathData,
150 const CFX_Matrix* pObject2Device,
151 const CFX_GraphStateData* pGraphState,
152 uint32_t fill_color,
153 uint32_t stroke_color,
154 int fill_mode) {
155 return DrawPathWithBlend(pPathData, pObject2Device, pGraphState, fill_color,
156 stroke_color, fill_mode, FXDIB_BLEND_NORMAL);
157 }
158 FX_BOOL DrawPathWithBlend(const CFX_PathData* pPathData,
159 const CFX_Matrix* pObject2Device,
160 const CFX_GraphStateData* pGraphState,
161 uint32_t fill_color,
162 uint32_t stroke_color,
163 int fill_mode,
164 int blend_type);
165 FX_BOOL SetPixel(int x, int y, uint32_t color);
166 FX_BOOL FillRect(const FX_RECT* pRect, uint32_t color) {
167 return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL);
168 }
169 FX_BOOL FillRectWithBlend(const FX_RECT* pRect,
170 uint32_t color,
171 int blend_type);
172 FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
173 FX_FLOAT y1,
174 FX_FLOAT x2,
175 FX_FLOAT y2,
176 uint32_t color) {
177 return DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, color, 0,
178 FXDIB_BLEND_NORMAL);
179 }
180 FX_BOOL DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1,
181 FX_FLOAT y1,
182 FX_FLOAT x2,
183 FX_FLOAT y2,
184 uint32_t color,
185 int fill_mode,
186 int blend_type);
187
188 FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top);
189 CFX_DIBitmap* GetBackDrop();
190 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top) {
191 return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL);
192 }
193 FX_BOOL SetDIBitsWithBlend(const CFX_DIBSource* pBitmap,
194 int left,
195 int top,
196 int blend_type);
197 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
198 int left,
199 int top,
200 int dest_width,
201 int dest_height) {
202 return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width,
203 dest_height, 0, FXDIB_BLEND_NORMAL);
204 }
205 FX_BOOL StretchDIBitsWithFlagsAndBlend(const CFX_DIBSource* pBitmap,
206 int left,
207 int top,
208 int dest_width,
209 int dest_height,
210 uint32_t flags,
211 int blend_type);
212 FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap,
213 int left,
214 int top,
215 uint32_t color);
216 FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap,
217 int left,
218 int top,
219 int dest_width,
220 int dest_height,
221 uint32_t color);
222 FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
223 int left,
224 int top,
225 int dest_width,
226 int dest_height,
227 uint32_t color,
228 uint32_t flags);
229 FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
230 int bitmap_alpha,
231 uint32_t color,
232 const CFX_Matrix* pMatrix,
233 uint32_t flags,
234 void*& handle) {
235 return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags,
236 handle, FXDIB_BLEND_NORMAL);
237 }
238 FX_BOOL StartDIBitsWithBlend(const CFX_DIBSource* pBitmap,
239 int bitmap_alpha,
240 uint32_t color,
241 const CFX_Matrix* pMatrix,
242 uint32_t flags,
243 void*& handle,
244 int blend_type);
245 FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause);
246 void CancelDIBits(void* handle);
247
248 FX_BOOL DrawNormalText(int nChars,
249 const FXTEXT_CHARPOS* pCharPos,
250 CFX_Font* pFont,
251 CFX_FontCache* pCache,
252 FX_FLOAT font_size,
253 const CFX_Matrix* pText2Device,
254 uint32_t fill_color,
255 uint32_t text_flags);
256 FX_BOOL DrawTextPath(int nChars,
257 const FXTEXT_CHARPOS* pCharPos,
258 CFX_Font* pFont,
259 CFX_FontCache* pCache,
260 FX_FLOAT font_size,
261 const CFX_Matrix* pText2User,
262 const CFX_Matrix* pUser2Device,
263 const CFX_GraphStateData* pGraphState,
264 uint32_t fill_color,
265 uint32_t stroke_color,
266 CFX_PathData* pClippingPath) {
267 return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size,
268 pText2User, pUser2Device, pGraphState,
269 fill_color, stroke_color, pClippingPath, 0);
270 }
271 FX_BOOL DrawTextPathWithFlags(int nChars,
272 const FXTEXT_CHARPOS* pCharPos,
273 CFX_Font* pFont,
274 CFX_FontCache* pCache,
275 FX_FLOAT font_size,
276 const CFX_Matrix* pText2User,
277 const CFX_Matrix* pUser2Device,
278 const CFX_GraphStateData* pGraphState,
279 uint32_t fill_color,
280 uint32_t stroke_color,
281 CFX_PathData* pClippingPath,
282 int nFlag);
283
284 #ifdef _SKIA_SUPPORT_
285 virtual void DebugVerifyBitmapIsPreMultiplied() const;
286 void Flush();
287 #endif
288
289 private:
290 void InitDeviceInfo();
291 void UpdateClipBox();
292 FX_BOOL DrawFillStrokePath(const CFX_PathData* pPathData,
293 const CFX_Matrix* pObject2Device,
294 const CFX_GraphStateData* pGraphState,
295 uint32_t fill_color,
296 uint32_t stroke_color,
297 int fill_mode,
298 int blend_type);
299
300 CFX_DIBitmap* m_pBitmap;
301 int m_Width;
302 int m_Height;
303 int m_bpp;
304 int m_RenderCaps;
305 int m_DeviceClass;
306 FX_RECT m_ClipBox;
307 std::unique_ptr<IFX_RenderDeviceDriver> m_pDeviceDriver;
308 };
309
310 class CFX_FxgeDevice : public CFX_RenderDevice {
311 public:
312 CFX_FxgeDevice();
313 ~CFX_FxgeDevice() override;
314
315 bool Attach(CFX_DIBitmap* pBitmap,
316 bool bRgbByteOrder,
317 CFX_DIBitmap* pOriDevice,
318 bool bGroupKnockout);
319 bool Create(int width,
320 int height,
321 FXDIB_Format format,
322 CFX_DIBitmap* pOriDevice);
323
324 #ifdef _SKIA_SUPPORT_
325 bool AttachRecorder(SkPictureRecorder* recorder);
326 SkPictureRecorder* CreateRecorder(int size_x, int size_y);
327 void DebugVerifyBitmapIsPreMultiplied() const override;
328 #endif
329
330 protected:
331 bool m_bOwnedBitmap;
332 };
333
334 #endif // CORE_FXGE_INCLUDE_FX_GE_H_
OLDNEW
« no previous file with comments | « core/fxge/include/cfx_renderdevice.h ('k') | core/fxge/skia/fx_skia_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698