diff options
author | npm <npm@chromium.org> | 2016-07-29 15:20:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-29 15:20:25 -0700 |
commit | 7484762421e85aa5d610f47aa547470786eecab8 (patch) | |
tree | 321455e17ca3796a17f3edc9b33e11435bc9d7fb /core/fxge/win32 | |
parent | 246221724a106c11481eedbf1f94475afba23569 (diff) | |
download | pdfium-7484762421e85aa5d610f47aa547470786eecab8.tar.xz |
Refactor fxge/fx_apple and fx_win header files
- Renamed header for CFX_QuartzDevice class
- Removed unused class CFX_WinBitmapDevice
- Split remaining fx_ge_win32 header
Review-Url: https://codereview.chromium.org/2197513004
Diffstat (limited to 'core/fxge/win32')
-rw-r--r-- | core/fxge/win32/cfx_windowsdib.h | 52 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 38 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dib.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dwrite.cpp | 1 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 2 |
6 files changed, 57 insertions, 40 deletions
diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h new file mode 100644 index 0000000000..2564b7fa36 --- /dev/null +++ b/core/fxge/win32/cfx_windowsdib.h @@ -0,0 +1,52 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ +#define CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ +#ifdef _WIN32 +#ifndef _WINDOWS_ +#include <windows.h> +#endif +#define WINDIB_OPEN_MEMORY 0x1 +#define WINDIB_OPEN_PATHNAME 0x2 + +typedef struct WINDIB_Open_Args_ { + int flags; + + const uint8_t* memory_base; + + size_t memory_size; + + const FX_WCHAR* path_name; +} WINDIB_Open_Args_; + +class CFX_WindowsDIB : public CFX_DIBitmap { + public: + CFX_WindowsDIB(HDC hDC, int width, int height); + ~CFX_WindowsDIB() override; + + static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); + static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); + static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); + static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); + static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename); + static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); + + HDC GetDC() const { return m_hMemDC; } + HBITMAP GetWindowsBitmap() const { return m_hBitmap; } + + void LoadFromDevice(HDC hDC, int left, int top); + void SetToDevice(HDC hDC, int left, int top); + + protected: + HDC m_hMemDC; + HBITMAP m_hBitmap; + HBITMAP m_hOldBitmap; +}; + +#endif // _WIN32 + +#endif // CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 8a8be62f7b..20b277e3f7 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -24,10 +24,11 @@ #include "core/fxge/ge/cfx_folderfontinfo.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/cfx_fontmapper.h" +#include "core/fxge/include/cfx_windowsdevice.h" #include "core/fxge/include/ifx_systemfontinfo.h" #include "core/fxge/include/fx_font.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge_win32.h" +#include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/dwrite_int.h" #include "core/fxge/win32/win32_int.h" #include "third_party/base/stl_util.h" @@ -1389,39 +1390,4 @@ IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { return new CGdiDisplayDriver(hDC); } -CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width, - int height, - FXDIB_Format format) { - BITMAPINFOHEADER bmih; - FXSYS_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); - bmih.biSize = sizeof(BITMAPINFOHEADER); - bmih.biBitCount = format & 0xff; - bmih.biHeight = -height; - bmih.biPlanes = 1; - bmih.biWidth = width; - void* pBufferPtr; - m_hBitmap = CreateDIBSection(nullptr, reinterpret_cast<BITMAPINFO*>(&bmih), - DIB_RGB_COLORS, &pBufferPtr, nullptr, 0); - if (!m_hBitmap) - return; - - uint8_t* pBuffer = static_cast<uint8_t*>(pBufferPtr); - CFX_DIBitmap* pBitmap = new CFX_DIBitmap; - pBitmap->Create(width, height, format, pBuffer); - SetBitmap(pBitmap); - m_hDC = ::CreateCompatibleDC(nullptr); - m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); - SetDeviceDriver(WrapUnique(new CGdiDisplayDriver(m_hDC))); -} - -CFX_WinBitmapDevice::~CFX_WinBitmapDevice() { - if (m_hDC) { - SelectObject(m_hDC, m_hOldBitmap); - DeleteDC(m_hDC); - } - if (m_hBitmap) - DeleteObject(m_hBitmap); - delete GetBitmap(); -} - #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index ae28a3498f..8f223a3f06 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -9,7 +9,7 @@ #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include <windows.h> -#include "core/fxge/include/fx_ge_win32.h" +#include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/win32_int.h" CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) { diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index b3ba28cfc7..305a8a8dda 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -9,7 +9,6 @@ #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include <dwrite.h> -#include "core/fxge/include/fx_ge_win32.h" #include "core/fxge/win32/dwrite_int.h" typedef HRESULT(__stdcall* FuncType_DWriteCreateFactory)( diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 8acf23b22a..6a70425df7 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -17,7 +17,7 @@ using std::max; #include <gdiplus.h> -#include "core/fxge/include/fx_ge_win32.h" +#include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/win32_int.h" using namespace Gdiplus; // NOLINT diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 9e19873577..c78546a513 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -15,7 +15,7 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge_win32.h" +#include "core/fxge/include/cfx_windowsdevice.h" #include "core/fxge/win32/win32_int.h" #if defined(PDFIUM_PRINT_TEXT_WITH_GDI) |