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
diff --git a/BUILD.gn b/BUILD.gn
index 57f9823..872baf7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -684,6 +684,7 @@
     "core/fxge/android/fx_android_font.h",
     "core/fxge/android/fx_android_imp.cpp",
     "core/fxge/apple/apple_int.h",
+    "core/fxge/apple/cfx_quartzdevice.h",
     "core/fxge/apple/fx_mac_imp.cpp",
     "core/fxge/apple/fx_quartz_device.cpp",
     "core/fxge/dib/dib_int.h",
@@ -726,13 +727,13 @@
     "core/fxge/ge/include/cfx_fontmgr.h",
     "core/fxge/ge/include/ifx_systemfontinfo.h",
     "core/fxge/ifx_renderdevicedriver.cpp",
+    "core/fxge/include/cfx_windowsdevice.h",
     "core/fxge/include/fx_dib.h",
     "core/fxge/include/fx_font.h",
     "core/fxge/include/fx_freetype.h",
     "core/fxge/include/fx_ge.h",
-    "core/fxge/include/fx_ge_apple.h",
-    "core/fxge/include/fx_ge_win32.h",
     "core/fxge/include/ifx_renderdevicedriver.h",
+    "core/fxge/win32/cfx_windowsdib.h",
   ]
 
   configs += [
diff --git a/core/fxge/include/fx_ge_apple.h b/core/fxge/apple/cfx_quartzdevice.h
similarity index 83%
rename from core/fxge/include/fx_ge_apple.h
rename to core/fxge/apple/cfx_quartzdevice.h
index 6dce866..e9261d6 100644
--- a/core/fxge/include/fx_ge_apple.h
+++ b/core/fxge/apple/cfx_quartzdevice.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
-#define CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
+#ifndef CORE_FXGE_APPLE_CFX_QUARTZDEVICE_H_
+#define CORE_FXGE_APPLE_CFX_QUARTZDEVICE_H_
 
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
 
@@ -28,4 +28,4 @@
 };
 #endif
 
-#endif  // CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
+#endif  // CORE_FXGE_APPLE_CFX_QUARTZDEVICE_H_
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index c7e81d5..a3665ef 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -14,10 +14,10 @@
 #endif
 
 #include "core/fxge/apple/apple_int.h"
+#include "core/fxge/apple/cfx_quartzdevice.h"
 #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_apple.h"
 
 #ifndef _SKIA_SUPPORT_
 
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index a9b9268..966f0bd 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -18,7 +18,7 @@
 
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
 #include "core/fxge/apple/apple_int.h"
-#include "core/fxge/include/fx_ge_apple.h"
+#include "core/fxge/apple/cfx_quartzdevice.h"
 #ifndef CGFLOAT_IS_DOUBLE
 #error Expected CGFLOAT_IS_DOUBLE to be defined by CoreGraphics headers
 #endif
diff --git a/core/fxge/include/cfx_windowsdevice.h b/core/fxge/include/cfx_windowsdevice.h
new file mode 100644
index 0000000..906442d
--- /dev/null
+++ b/core/fxge/include/cfx_windowsdevice.h
@@ -0,0 +1,39 @@
+// Copyright 2016 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_INCLUDE_CFX_WINDOWSDEVICE_H_
+#define CORE_FXGE_INCLUDE_CFX_WINDOWSDEVICE_H_
+
+#ifdef _WIN32
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+class IFX_RenderDeviceDriver;
+
+#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
+typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
+                                                         const wchar_t* text,
+                                                         size_t text_length);
+
+extern bool g_pdfium_print_text_with_gdi;
+extern PDFiumEnsureTypefaceCharactersAccessible
+    g_pdfium_typeface_accessible_func;
+#endif
+
+class CFX_WindowsDevice : public CFX_RenderDevice {
+ public:
+  static IFX_RenderDeviceDriver* CreateDriver(HDC hDC);
+
+  explicit CFX_WindowsDevice(HDC hDC);
+  ~CFX_WindowsDevice() override;
+
+  HDC GetDC() const;
+};
+
+#endif  // _WIN32
+
+#endif  // CORE_FXGE_INCLUDE_CFX_WINDOWSDEVICE_H_
diff --git a/core/fxge/include/fx_ge_win32.h b/core/fxge/include/fx_ge_win32.h
deleted file mode 100644
index e53ee2e..0000000
--- a/core/fxge/include/fx_ge_win32.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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_INCLUDE_FX_GE_WIN32_H_
-#define CORE_FXGE_INCLUDE_FX_GE_WIN32_H_
-
-#ifdef _WIN32
-#ifndef _WINDOWS_
-#include <windows.h>
-#endif
-#define WINDIB_OPEN_MEMORY 0x1
-#define WINDIB_OPEN_PATHNAME 0x2
-
-class IFX_RenderDeviceDriver;
-
-#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
-typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
-                                                         const wchar_t* text,
-                                                         size_t text_length);
-
-extern bool g_pdfium_print_text_with_gdi;
-extern PDFiumEnsureTypefaceCharactersAccessible
-    g_pdfium_typeface_accessible_func;
-#endif
-
-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;
-};
-
-class CFX_WindowsDevice : public CFX_RenderDevice {
- public:
-  static IFX_RenderDeviceDriver* CreateDriver(HDC hDC);
-
-  explicit CFX_WindowsDevice(HDC hDC);
-  ~CFX_WindowsDevice() override;
-
-  HDC GetDC() const;
-};
-
-class CFX_WinBitmapDevice : public CFX_RenderDevice {
- public:
-  CFX_WinBitmapDevice(int width, int height, FXDIB_Format format);
-  ~CFX_WinBitmapDevice() override;
-
-  HDC GetDC() { return m_hDC; }
-
- protected:
-  HBITMAP m_hBitmap;
-
-  HBITMAP m_hOldBitmap;
-
-  HDC m_hDC;
-};
-#endif
-
-#endif  // CORE_FXGE_INCLUDE_FX_GE_WIN32_H_
diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h
new file mode 100644
index 0000000..2564b7f
--- /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 8a8be62..20b277e 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 @@
   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 ae28a34..8f223a3 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 b3ba28c..305a8a8 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 8acf23b..6a70425 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -17,7 +17,7 @@
 
 #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 9e19873..c78546a 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)
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index b82714c..1d2f6de 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -40,7 +40,7 @@
 #endif  // PDF_ENABLE_XFA
 
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#include "core/fxge/include/fx_ge_win32.h"
+#include "core/fxge/include/cfx_windowsdevice.h"
 #endif
 
 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) {
diff --git a/pdfium.gyp b/pdfium.gyp
index a994691..3a3c71e 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -668,6 +668,7 @@
         'core/fxge/android/fx_android_font.h',
         'core/fxge/android/fx_android_imp.cpp',
         'core/fxge/apple/apple_int.h',
+        'core/fxge/apple/cfx_quartzdevice.h',
         'core/fxge/apple/fx_apple_platform.cpp',
         'core/fxge/apple/fx_mac_imp.cpp',
         'core/fxge/apple/fx_quartz_device.cpp',
@@ -711,13 +712,13 @@
         'core/fxge/ge/fx_ge_text.cpp',
         'core/fxge/ge/fx_text_int.h',
         'core/fxge/ifx_renderdevicedriver.cpp',
+        "core/fxge/include/cfx_windowsdevice.h",
         'core/fxge/include/fx_dib.h',
         'core/fxge/include/fx_font.h',
         'core/fxge/include/fx_freetype.h',
         'core/fxge/include/fx_ge.h',
-        'core/fxge/include/fx_ge_apple.h',
-        'core/fxge/include/fx_ge_win32.h',
         'core/fxge/include/ifx_renderdevicedriver.h',
+        'core/fxge/win32/cfx_windowsdib.h',
       ],
       'variables': {
         'clang_warning_flags': [