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