Merge to XFA: Separate agg-authored code from fx-authored code.
[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 {
16 public:
17     CAgg_PathData() {}
18     ~CAgg_PathData() {}
19     FX_NAMESPACE_DECLARE(agg, path_storage)     m_PathData;
20     void                        BuildPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device);
21 };
22 class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver
23 {
24 public:
25     CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout);
26     virtual ~CFX_AggDeviceDriver();
27     void                                InitPlatform();
28     void                                DestroyPlatform();
29
30
31     virtual int                 GetDeviceCaps(int caps_id);
32
33
34     virtual void                SaveState();
35     virtual void                RestoreState(FX_BOOL bKeepSaved);
36
37
38     virtual FX_BOOL             SetClip_PathFill(const CFX_PathData* pPathData,
39                                          const CFX_AffineMatrix* pObject2Device,
40                                          int fill_mode
41                                      );
42
43
44     virtual FX_BOOL             SetClip_PathStroke(const CFX_PathData* pPathData,
45                                            const CFX_AffineMatrix* pObject2Device,
46                                            const CFX_GraphStateData* pGraphState
47                                        );
48
49
50     virtual FX_BOOL             DrawPath(const CFX_PathData* pPathData,
51                                  const CFX_AffineMatrix* pObject2Device,
52                                  const CFX_GraphStateData* pGraphState,
53                                  FX_DWORD fill_color,
54                                  FX_DWORD stroke_color,
55                                  int fill_mode,
56                                  int alpha_flag,
57                                  void* pIccTransform,
58                                  int blend_type
59                              );
60
61     virtual FX_BOOL             SetPixel(int x, int y, FX_DWORD color,
62                                  int alpha_flag, void* pIccTransform);
63
64     virtual FX_BOOL             FillRect(const FX_RECT* pRect,
65                                  FX_DWORD fill_color, int alpha_flag, void* pIccTransform, int blend_type);
66
67
68     virtual FX_BOOL             DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,
69                                          int alpha_flag, void* pIccTransform, int blend_type)
70     {
71         return FALSE;
72     }
73
74     virtual FX_BOOL             GetClipBox(FX_RECT* pRect);
75
76
77     virtual FX_BOOL             GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE);
78     virtual CFX_DIBitmap*   GetBackDrop()
79     {
80         return m_pOriDevice;
81     }
82
83     virtual FX_BOOL             SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,
84                                   int alpha_flag, void* pIccTransform);
85     virtual FX_BOOL             StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
86                                       int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,
87                                       int alpha_flag, void* pIccTransform, int blend_type);
88
89     virtual FX_BOOL             StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
90                                     const CFX_AffineMatrix* pMatrix, FX_DWORD flags, void*& handle,
91                                     int alpha_flag, void* pIccTransform, int blend_type);
92     virtual FX_BOOL             ContinueDIBits(void* handle, IFX_Pause* pPause);
93     virtual void                CancelDIBits(void* handle);
94
95     virtual FX_BOOL     DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
96                                        CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,
97                                        int alpha_flag, void* pIccTransform);
98     virtual FX_BOOL             RenderRasterizer(FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa)& rasterizer, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout,
99                                          int alpha_flag, void* pIccTransform);
100
101     void                                SetClipMask(FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa)& rasterizer);
102
103     virtual     uint8_t*        GetBuffer() const
104     {
105         return m_pBitmap->GetBuffer();
106     }
107     virtual int                 GetDriverType()
108     {
109         return 1;
110     }
111
112     CFX_DIBitmap*               m_pBitmap;
113     CFX_ClipRgn*                m_pClipRgn;
114     CFX_PtrArray                m_StateStack;
115     void*                               m_pPlatformGraphics;
116     void*                               m_pPlatformBitmap;
117     void*                               m_pDwRenderTartget;
118     int                                 m_FillFlags;
119     int                                 m_DitherBits;
120     FX_BOOL                             m_bRgbByteOrder;
121     CFX_DIBitmap*       m_pOriDevice;
122     FX_BOOL             m_bGroupKnockout;
123 };
124
125 #endif  // FX_AGG_DRIVER_H_