| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ | 7 #ifndef CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ |
| 8 #define CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ | 8 #define CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ |
| 9 | 9 |
| 10 #ifdef _WIN32 | 10 #ifdef _WIN32 |
| 11 #ifndef _WINDOWS_ | 11 #ifndef _WINDOWS_ |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 #endif | 13 #endif |
| 14 #define WINDIB_OPEN_MEMORY 0x1 | 14 #define WINDIB_OPEN_MEMORY 0x1 |
| 15 #define WINDIB_OPEN_PATHNAME 0x2 | 15 #define WINDIB_OPEN_PATHNAME 0x2 |
| 16 typedef struct WINDIB_Open_Args_ { | 16 typedef struct WINDIB_Open_Args_ { |
| 17 int flags; | 17 int flags; |
| 18 | 18 |
| 19 const uint8_t* memory_base; | 19 const uint8_t* memory_base; |
| 20 | 20 |
| 21 size_t memory_size; | 21 size_t memory_size; |
| 22 | 22 |
| 23 const FX_WCHAR* path_name; | 23 const FX_WCHAR* path_name; |
| 24 } WINDIB_Open_Args_; | 24 } WINDIB_Open_Args_; |
| 25 | 25 |
| 26 class CFX_WindowsDIB : public CFX_DIBitmap { | 26 class CFX_WindowsDIB : public CFX_DIBitmap { |
| 27 public: | 27 public: |
| 28 CFX_WindowsDIB(HDC hDC, int width, int height); |
| 29 ~CFX_WindowsDIB() override; |
| 30 |
| 28 static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); | 31 static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); |
| 29 | |
| 30 static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); | 32 static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); |
| 31 | |
| 32 static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); | 33 static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); |
| 33 | |
| 34 static CFX_DIBitmap* LoadFromDDB(HDC hDC, | 34 static CFX_DIBitmap* LoadFromDDB(HDC hDC, |
| 35 HBITMAP hBitmap, | 35 HBITMAP hBitmap, |
| 36 uint32_t* pPalette = nullptr, | 36 uint32_t* pPalette = nullptr, |
| 37 uint32_t size = 256); | 37 uint32_t size = 256); |
| 38 | |
| 39 static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); | 38 static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); |
| 40 | 39 static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename); |
| 41 static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename) { | |
| 42 return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); | |
| 43 } | |
| 44 | |
| 45 static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); | 40 static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); |
| 46 | 41 |
| 47 CFX_WindowsDIB(HDC hDC, int width, int height); | |
| 48 | |
| 49 ~CFX_WindowsDIB(); | |
| 50 | |
| 51 HDC GetDC() const { return m_hMemDC; } | 42 HDC GetDC() const { return m_hMemDC; } |
| 52 | |
| 53 HBITMAP GetWindowsBitmap() const { return m_hBitmap; } | 43 HBITMAP GetWindowsBitmap() const { return m_hBitmap; } |
| 54 | 44 |
| 55 void LoadFromDevice(HDC hDC, int left, int top); | 45 void LoadFromDevice(HDC hDC, int left, int top); |
| 56 | |
| 57 void SetToDevice(HDC hDC, int left, int top); | 46 void SetToDevice(HDC hDC, int left, int top); |
| 58 | 47 |
| 59 protected: | 48 protected: |
| 60 HDC m_hMemDC; | 49 HDC m_hMemDC; |
| 61 | |
| 62 HBITMAP m_hBitmap; | 50 HBITMAP m_hBitmap; |
| 63 | |
| 64 HBITMAP m_hOldBitmap; | 51 HBITMAP m_hOldBitmap; |
| 65 }; | 52 }; |
| 66 | 53 |
| 67 class CFX_WindowsDevice : public CFX_RenderDevice { | 54 class CFX_WindowsDevice : public CFX_RenderDevice { |
| 68 public: | 55 public: |
| 69 static IFX_RenderDeviceDriver* CreateDriver(HDC hDC); | 56 static IFX_RenderDeviceDriver* CreateDriver(HDC hDC); |
| 70 | 57 |
| 71 explicit CFX_WindowsDevice(HDC hDC); | 58 explicit CFX_WindowsDevice(HDC hDC); |
| 72 ~CFX_WindowsDevice(); | 59 ~CFX_WindowsDevice() override; |
| 73 | 60 |
| 74 HDC GetDC() const; | 61 HDC GetDC() const; |
| 75 }; | 62 }; |
| 76 | 63 |
| 77 class CFX_WinBitmapDevice : public CFX_RenderDevice { | 64 class CFX_WinBitmapDevice : public CFX_RenderDevice { |
| 78 public: | 65 public: |
| 79 CFX_WinBitmapDevice(int width, int height, FXDIB_Format format); | 66 CFX_WinBitmapDevice(int width, int height, FXDIB_Format format); |
| 80 ~CFX_WinBitmapDevice(); | 67 ~CFX_WinBitmapDevice() override; |
| 81 | 68 |
| 82 HDC GetDC() { return m_hDC; } | 69 HDC GetDC() { return m_hDC; } |
| 83 | 70 |
| 84 protected: | 71 protected: |
| 85 HBITMAP m_hBitmap; | 72 HBITMAP m_hBitmap; |
| 86 | 73 |
| 87 HBITMAP m_hOldBitmap; | 74 HBITMAP m_hOldBitmap; |
| 88 | 75 |
| 89 HDC m_hDC; | 76 HDC m_hDC; |
| 90 }; | 77 }; |
| 91 #endif | 78 #endif |
| 92 | 79 |
| 93 #endif // CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ | 80 #endif // CORE_FXGE_INCLUDE_FX_GE_WIN32_H_ |
| OLD | NEW |