• 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_FXGE_AGG_FX_AGG_DRIVER_H_
8 #define CORE_FXGE_AGG_FX_AGG_DRIVER_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "core/fxge/ifx_renderdevicedriver.h"
14 #include "third_party/agg23/agg_clip_liang_barsky.h"
15 #include "third_party/agg23/agg_path_storage.h"
16 #include "third_party/agg23/agg_rasterizer_scanline_aa.h"
17 
18 class CFX_ClipRgn;
19 class CFX_GraphStateData;
20 class CFX_Matrix;
21 class CFX_PathData;
22 
23 class CAgg_PathData {
24  public:
CAgg_PathData()25   CAgg_PathData() {}
~CAgg_PathData()26   ~CAgg_PathData() {}
27   void BuildPath(const CFX_PathData* pPathData,
28                  const CFX_Matrix* pObject2Device);
29 
30   agg::path_storage m_PathData;
31 };
32 
33 class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
34  public:
35   CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap,
36                       bool bRgbByteOrder,
37                       CFX_DIBitmap* pOriDevice,
38                       bool bGroupKnockout);
39   ~CFX_AggDeviceDriver() override;
40 
41   void InitPlatform();
42   void DestroyPlatform();
43 
44   // IFX_RenderDeviceDriver
45   int GetDeviceCaps(int caps_id) const override;
46   void SaveState() override;
47   void RestoreState(bool bKeepSaved) override;
48   bool SetClip_PathFill(const CFX_PathData* pPathData,
49                         const CFX_Matrix* pObject2Device,
50                         int fill_mode) override;
51   bool SetClip_PathStroke(const CFX_PathData* pPathData,
52                           const CFX_Matrix* pObject2Device,
53                           const CFX_GraphStateData* pGraphState) override;
54   bool DrawPath(const CFX_PathData* pPathData,
55                 const CFX_Matrix* pObject2Device,
56                 const CFX_GraphStateData* pGraphState,
57                 uint32_t fill_color,
58                 uint32_t stroke_color,
59                 int fill_mode,
60                 int blend_type) override;
61   bool SetPixel(int x, int y, uint32_t color) override;
62   bool FillRectWithBlend(const FX_RECT* pRect,
63                          uint32_t fill_color,
64                          int blend_type) override;
65   bool GetClipBox(FX_RECT* pRect) override;
66   bool GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override;
67   CFX_DIBitmap* GetBackDrop() override;
68   bool SetDIBits(const CFX_DIBSource* pBitmap,
69                  uint32_t color,
70                  const FX_RECT* pSrcRect,
71                  int left,
72                  int top,
73                  int blend_type) override;
74   bool StretchDIBits(const CFX_DIBSource* pBitmap,
75                      uint32_t color,
76                      int dest_left,
77                      int dest_top,
78                      int dest_width,
79                      int dest_height,
80                      const FX_RECT* pClipRect,
81                      uint32_t flags,
82                      int blend_type) override;
83   bool StartDIBits(const CFX_DIBSource* pBitmap,
84                    int bitmap_alpha,
85                    uint32_t color,
86                    const CFX_Matrix* pMatrix,
87                    uint32_t flags,
88                    void*& handle,
89                    int blend_type) override;
90   bool ContinueDIBits(void* handle, IFX_Pause* pPause) override;
91   void CancelDIBits(void* handle) override;
92   bool DrawDeviceText(int nChars,
93                       const FXTEXT_CHARPOS* pCharPos,
94                       CFX_Font* pFont,
95                       const CFX_Matrix* pObject2Device,
96                       FX_FLOAT font_size,
97                       uint32_t color) override;
98   int GetDriverType() const override;
99 
100   bool RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer,
101                         uint32_t color,
102                         bool bFullCover,
103                         bool bGroupKnockout,
104                         int alpha_flag,
105                         void* pIccTransform);
106 
107   void SetClipMask(agg::rasterizer_scanline_aa& rasterizer);
108 
109   virtual uint8_t* GetBuffer() const;
110 
111  private:
112   CFX_DIBitmap* m_pBitmap;
113   std::unique_ptr<CFX_ClipRgn> m_pClipRgn;
114   std::vector<std::unique_ptr<CFX_ClipRgn>> m_StateStack;
115 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
116   void* m_pPlatformGraphics;
117 #endif
118   int m_FillFlags;
119   bool m_bRgbByteOrder;
120   CFX_DIBitmap* m_pOriDevice;
121   bool m_bGroupKnockout;
122 };
123 
124 #endif  // CORE_FXGE_AGG_FX_AGG_DRIVER_H_
125