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