2954526cd57645b7e531471edcd4848220277f84
[pdfium.git] / core / src / fxge / agg / include / fx_agg_driver.h
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 FX_AGG_DRIVER_H_
8 #define FX_AGG_DRIVER_H_
9
10 #include "../../../../../third_party/agg23/agg_clip_liang_barsky.h"
11 #include "../../../../../third_party/agg23/agg_path_storage.h"
12 #include "../../../../../third_party/agg23/agg_rasterizer_scanline_aa.h"
13
14 class CAgg_PathData {
15  public:
16   CAgg_PathData() {}
17   ~CAgg_PathData() {}
18   FX_NAMESPACE_DECLARE(agg, path_storage) m_PathData;
19   void BuildPath(const CFX_PathData* pPathData,
20                  const CFX_AffineMatrix* pObject2Device);
21 };
22 class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
23  public:
24   CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap,
25                       int dither_bits,
26                       FX_BOOL bRgbByteOrder,
27                       CFX_DIBitmap* pOriDevice,
28                       FX_BOOL bGroupKnockout);
29   virtual ~CFX_AggDeviceDriver();
30   void InitPlatform();
31   void DestroyPlatform();
32
33   virtual int GetDeviceCaps(int caps_id);
34
35   virtual void SaveState();
36   virtual void RestoreState(FX_BOOL bKeepSaved);
37
38   virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
39                                    const CFX_AffineMatrix* pObject2Device,
40                                    int fill_mode);
41
42   virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
43                                      const CFX_AffineMatrix* pObject2Device,
44                                      const CFX_GraphStateData* pGraphState);
45
46   virtual FX_BOOL DrawPath(const CFX_PathData* pPathData,
47                            const CFX_AffineMatrix* pObject2Device,
48                            const CFX_GraphStateData* pGraphState,
49                            FX_DWORD fill_color,
50                            FX_DWORD stroke_color,
51                            int fill_mode,
52                            int alpha_flag,
53                            void* pIccTransform,
54                            int blend_type);
55
56   virtual FX_BOOL SetPixel(int x,
57                            int y,
58                            FX_DWORD color,
59                            int alpha_flag,
60                            void* pIccTransform);
61
62   virtual FX_BOOL FillRect(const FX_RECT* pRect,
63                            FX_DWORD fill_color,
64                            int alpha_flag,
65                            void* pIccTransform,
66                            int blend_type);
67
68   virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
69                                    FX_FLOAT y1,
70                                    FX_FLOAT x2,
71                                    FX_FLOAT y2,
72                                    FX_DWORD color,
73                                    int alpha_flag,
74                                    void* pIccTransform,
75                                    int blend_type) {
76     return FALSE;
77   }
78
79   virtual FX_BOOL GetClipBox(FX_RECT* pRect);
80
81   virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap,
82                             int left,
83                             int top,
84                             void* pIccTransform = NULL,
85                             FX_BOOL bDEdge = FALSE);
86   virtual CFX_DIBitmap* GetBackDrop() { return m_pOriDevice; }
87
88   virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
89                             FX_DWORD color,
90                             const FX_RECT* pSrcRect,
91                             int left,
92                             int top,
93                             int blend_type,
94                             int alpha_flag,
95                             void* pIccTransform);
96   virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
97                                 FX_DWORD color,
98                                 int dest_left,
99                                 int dest_top,
100                                 int dest_width,
101                                 int dest_height,
102                                 const FX_RECT* pClipRect,
103                                 FX_DWORD flags,
104                                 int alpha_flag,
105                                 void* pIccTransform,
106                                 int blend_type);
107
108   virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
109                               int bitmap_alpha,
110                               FX_DWORD color,
111                               const CFX_AffineMatrix* pMatrix,
112                               FX_DWORD flags,
113                               void*& handle,
114                               int alpha_flag,
115                               void* pIccTransform,
116                               int blend_type);
117   virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause);
118   virtual void CancelDIBits(void* handle);
119
120   virtual FX_BOOL DrawDeviceText(int nChars,
121                                  const FXTEXT_CHARPOS* pCharPos,
122                                  CFX_Font* pFont,
123                                  CFX_FontCache* pCache,
124                                  const CFX_AffineMatrix* pObject2Device,
125                                  FX_FLOAT font_size,
126                                  FX_DWORD color,
127                                  int alpha_flag,
128                                  void* pIccTransform);
129   virtual FX_BOOL RenderRasterizer(
130       FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa) & rasterizer,
131       FX_DWORD color,
132       FX_BOOL bFullCover,
133       FX_BOOL bGroupKnockout,
134       int alpha_flag,
135       void* pIccTransform);
136
137   void SetClipMask(FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa) &
138                    rasterizer);
139
140   virtual uint8_t* GetBuffer() const { return m_pBitmap->GetBuffer(); }
141   virtual int GetDriverType() { return 1; }
142
143   CFX_DIBitmap* m_pBitmap;
144   CFX_ClipRgn* m_pClipRgn;
145   CFX_PtrArray m_StateStack;
146   void* m_pPlatformGraphics;
147   void* m_pPlatformBitmap;
148   void* m_pDwRenderTartget;
149   int m_FillFlags;
150   int m_DitherBits;
151   FX_BOOL m_bRgbByteOrder;
152   CFX_DIBitmap* m_pOriDevice;
153   FX_BOOL m_bGroupKnockout;
154 };
155
156 #endif  // FX_AGG_DRIVER_H_