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 #ifndef CORE_SRC_FXGE_WIN32_WIN32_INT_H_ 7 #define CORE_SRC_FXGE_WIN32_WIN32_INT_H_ 8 9 struct WINDIB_Open_Args_; 10 class CGdiplusExt 11 { 12 public: 13 CGdiplusExt(); 14 ~CGdiplusExt(); 15 void Load(); IsAvailable()16 FX_BOOL IsAvailable() 17 { 18 return m_hModule != NULL; 19 } 20 FX_BOOL StretchBitMask(HDC hDC, BOOL bMonoDevice, const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, 21 int dest_width, int dest_height, FX_DWORD argb, const FX_RECT* pClipRect, int flags); 22 FX_BOOL StretchDIBits(HDC hDC, const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, 23 int dest_width, int dest_height, const FX_RECT* pClipRect, int flags); 24 FX_BOOL DrawPath(HDC hDC, const CFX_PathData* pPathData, 25 const CFX_AffineMatrix* pObject2Device, 26 const CFX_GraphStateData* pGraphState, 27 FX_DWORD fill_argb, 28 FX_DWORD stroke_argb, 29 int fill_mode 30 ); 31 32 void* LoadMemFont(FX_BYTE* pData, FX_DWORD size); 33 void DeleteMemFont(void* pFontCollection); 34 FX_BOOL GdipCreateFromImage(void* bitmap, void** graphics); 35 void GdipDeleteGraphics(void* graphics); 36 void GdipSetTextRenderingHint(void* graphics, int mode); 37 void GdipSetPageUnit(void* graphics, FX_DWORD unit); 38 void GdipSetWorldTransform(void* graphics, void* pMatrix); 39 FX_BOOL GdipDrawDriverString(void *graphics, unsigned short *text, int length, void *font, void* brush, void *positions, int flags, const void *matrix); 40 void GdipCreateBrush(FX_DWORD fill_argb, void** pBrush); 41 void GdipDeleteBrush(void* pBrush); 42 void GdipCreateMatrix(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, void** matrix); 43 void GdipDeleteMatrix(void* matrix); 44 FX_BOOL GdipCreateFontFamilyFromName(FX_LPCWSTR name, void* pFontCollection, void**pFamily); 45 void GdipDeleteFontFamily(void* pFamily); 46 FX_BOOL GdipCreateFontFromFamily(void* pFamily, FX_FLOAT font_size, int fontstyle, int flag, void** pFont); 47 void* GdipCreateFontFromCollection(void* pFontCollection, FX_FLOAT font_size, int fontstyle); 48 void GdipDeleteFont(void* pFont); 49 FX_BOOL GdipCreateBitmap(CFX_DIBitmap* pBitmap, void**bitmap); 50 void GdipDisposeImage(void* bitmap); 51 void GdipGetFontSize(void *pFont, FX_FLOAT *size); 52 void* GdiAddFontMemResourceEx(void *pFontdata, FX_DWORD size, void* pdv, FX_DWORD* num_face); 53 FX_BOOL GdiRemoveFontMemResourceEx(void* handle); 54 void* m_Functions[100]; 55 void* m_pGdiAddFontMemResourceEx; 56 void* m_pGdiRemoveFontMemResourseEx; 57 CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); 58 protected: 59 HMODULE m_hModule; 60 HMODULE m_GdiModule; 61 }; 62 #include "dwrite_int.h" 63 class CWin32Platform 64 { 65 public: 66 FX_BOOL m_bHalfTone; 67 CGdiplusExt m_GdiplusExt; 68 CDWriteExt m_DWriteExt; 69 }; 70 class CGdiDeviceDriver : public IFX_RenderDeviceDriver 71 { 72 protected: 73 virtual int GetDeviceCaps(int caps_id); SaveState()74 virtual void SaveState() 75 { 76 SaveDC(m_hDC); 77 } 78 virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) 79 { 80 RestoreDC(m_hDC, -1); 81 if (bKeepSaved) { 82 SaveDC(m_hDC); 83 } 84 } 85 virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, 86 const CFX_AffineMatrix* pObject2Device, 87 int fill_mode 88 ); 89 virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, 90 const CFX_AffineMatrix* pObject2Device, 91 const CFX_GraphStateData* pGraphState 92 ); 93 virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, 94 const CFX_AffineMatrix* pObject2Device, 95 const CFX_GraphStateData* pGraphState, 96 FX_DWORD fill_color, 97 FX_DWORD stroke_color, 98 int fill_mode, 99 int alpha_flag, 100 void* pIccTransform, 101 int blend_type 102 ); 103 virtual FX_BOOL FillRect(const FX_RECT* pRect, 104 FX_DWORD fill_color, 105 int alpha_flag, void* pIccTransform, int blend_type); 106 virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color, 107 int alpha_flag, void* pIccTransform, int blend_type); 108 virtual FX_LPVOID GetClipRgn() ; 109 virtual FX_BOOL SetClipRgn(FX_LPVOID pRgn) ; 110 virtual FX_BOOL GetClipBox(FX_RECT* pRect); 111 virtual FX_BOOL DeleteDeviceRgn(FX_LPVOID pRgn); 112 virtual void DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); GetPlatformSurface()113 virtual void* GetPlatformSurface() 114 { 115 return (void*)m_hDC; 116 } 117 FX_BOOL GDI_SetDIBits(const CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, int left, int top, 118 void* pIccTransform); 119 FX_BOOL GDI_StretchDIBits(const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, 120 int dest_width, int dest_height, FX_DWORD flags, 121 void* pIccTransform); 122 FX_BOOL GDI_StretchBitMask(const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, 123 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, 124 int alpha_flag, void* pIccTransform); 125 HDC m_hDC; 126 int m_Width, m_Height, m_nBitsPerPixel; 127 int m_DeviceClass, m_RenderCaps; 128 CGdiDeviceDriver(HDC hDC, int device_class); ~CGdiDeviceDriver()129 ~CGdiDeviceDriver() {} 130 }; 131 class CGdiDisplayDriver : public CGdiDeviceDriver 132 { 133 public: 134 CGdiDisplayDriver(HDC hDC); 135 protected: 136 virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE); 137 virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type, 138 int alpha_flag, void* pIccTransform); 139 virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top, 140 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags, 141 int alpha_flag, void* pIccTransform, int blend_type); StartDIBits(const CFX_DIBSource * pBitmap,int bitmap_alpha,FX_DWORD color,const CFX_AffineMatrix * pMatrix,FX_DWORD render_flags,FX_LPVOID & handle,int alpha_flag,void * pIccTransform,int blend_type)142 virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color, 143 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle, 144 int alpha_flag, void* pIccTransform, int blend_type) 145 { 146 return FALSE; 147 } 148 FX_BOOL UseFoxitStretchEngine(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top, 149 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_flags, 150 int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL); 151 }; 152 class CGdiPrinterDriver : public CGdiDeviceDriver 153 { 154 public: 155 CGdiPrinterDriver(HDC hDC); 156 protected: 157 virtual int GetDeviceCaps(int caps_id); 158 virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type, 159 int alpha_flag, void* pIccTransform); 160 virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top, 161 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags, 162 int alpha_flag, void* pIccTransform, int blend_type); 163 virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color, 164 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle, 165 int alpha_flag, void* pIccTransform, int blend_type); 166 int m_HorzSize, m_VertSize; 167 FX_BOOL m_bSupportROP; 168 }; 169 class CPSOutput : public IFX_PSOutput 170 { 171 public: 172 CPSOutput(HDC hDC); 173 virtual ~CPSOutput(); Release()174 virtual void Release() 175 { 176 delete this; 177 } 178 void Init(); 179 virtual void OutputPS(FX_LPCSTR string, int len); 180 HDC m_hDC; 181 FX_LPSTR m_pBuf; 182 }; 183 class CPSPrinterDriver : public IFX_RenderDeviceDriver 184 { 185 public: 186 CPSPrinterDriver(); 187 FX_BOOL Init(HDC hDC, int ps_level, FX_BOOL bCmykOutput); 188 ~CPSPrinterDriver(); 189 protected: IsPSPrintDriver()190 virtual FX_BOOL IsPSPrintDriver() 191 { 192 return TRUE; 193 } 194 virtual int GetDeviceCaps(int caps_id); 195 virtual FX_BOOL StartRendering(); 196 virtual void EndRendering(); 197 virtual void SaveState(); 198 virtual void RestoreState(FX_BOOL bKeepSaved = FALSE); 199 virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, 200 const CFX_AffineMatrix* pObject2Device, 201 int fill_mode 202 ); 203 virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, 204 const CFX_AffineMatrix* pObject2Device, 205 const CFX_GraphStateData* pGraphState 206 ); 207 virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, 208 const CFX_AffineMatrix* pObject2Device, 209 const CFX_GraphStateData* pGraphState, 210 FX_DWORD fill_color, 211 FX_DWORD stroke_color, 212 int fill_mode, 213 int alpha_flag, 214 void* pIccTransform, 215 int blend_type 216 ); 217 virtual FX_BOOL GetClipBox(FX_RECT* pRect); 218 virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type, 219 int alpha_flag, void* pIccTransform); 220 virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top, 221 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags, 222 int alpha_flag, void* pIccTransform, int blend_type); 223 virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color, 224 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle, 225 int alpha_flag, void* pIccTransform, int blend_type); 226 virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, 227 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color, 228 int alpha_flag, void* pIccTransform); GetPlatformSurface()229 virtual void* GetPlatformSurface() 230 { 231 return (void*)m_hDC; 232 } 233 HDC m_hDC; 234 FX_BOOL m_bCmykOutput; 235 int m_Width, m_Height, m_nBitsPerPixel; 236 int m_HorzSize, m_VertSize; 237 CPSOutput* m_pPSOutput; 238 CFX_PSRenderer m_PSRenderer; 239 }; 240 void _Color2Argb(FX_ARGB& argb, FX_DWORD color, int alpha_flag, void* pIccTransform); 241 242 #endif // CORE_SRC_FXGE_WIN32_WIN32_INT_H_ 243