| 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 #include "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
| 9 #include "../../../include/fxge/fx_ge_win32.h" | 9 #include "../../../include/fxge/fx_ge_win32.h" |
| 10 #include <crtdbg.h> | 10 #include <crtdbg.h> |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 { | 386 { |
| 387 TEXTMETRIC tm; | 387 TEXTMETRIC tm; |
| 388 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); | 388 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); |
| 389 ::GetTextMetrics(m_hDC, &tm); | 389 ::GetTextMetrics(m_hDC, &tm); |
| 390 ::SelectObject(m_hDC, hOldFont); | 390 ::SelectObject(m_hDC, hOldFont); |
| 391 charset = tm.tmCharSet; | 391 charset = tm.tmCharSet; |
| 392 return TRUE; | 392 return TRUE; |
| 393 } | 393 } |
| 394 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() | 394 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() |
| 395 { | 395 { |
| 396 return FX_NEW CWin32FontInfo; | 396 return new CWin32FontInfo; |
| 397 } | 397 } |
| 398 void CFX_GEModule::InitPlatform() | 398 void CFX_GEModule::InitPlatform() |
| 399 { | 399 { |
| 400 CWin32Platform* pPlatformData = FX_NEW CWin32Platform; | 400 CWin32Platform* pPlatformData = new CWin32Platform; |
| 401 if (!pPlatformData) { | |
| 402 return; | |
| 403 } | |
| 404 OSVERSIONINFO ver; | 401 OSVERSIONINFO ver; |
| 405 ver.dwOSVersionInfoSize = sizeof(ver); | 402 ver.dwOSVersionInfoSize = sizeof(ver); |
| 406 GetVersionEx(&ver); | 403 GetVersionEx(&ver); |
| 407 pPlatformData->m_bHalfTone = ver.dwMajorVersion >= 5; | 404 pPlatformData->m_bHalfTone = ver.dwMajorVersion >= 5; |
| 408 pPlatformData->m_GdiplusExt.Load(); | 405 pPlatformData->m_GdiplusExt.Load(); |
| 409 m_pPlatformData = pPlatformData; | 406 m_pPlatformData = pPlatformData; |
| 410 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); | 407 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); |
| 411 } | 408 } |
| 412 void CFX_GEModule::DestroyPlatform() | 409 void CFX_GEModule::DestroyPlatform() |
| 413 { | 410 { |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 } | 1133 } |
| 1137 } | 1134 } |
| 1138 return 2; | 1135 return 2; |
| 1139 } | 1136 } |
| 1140 int CFX_WindowsDevice::m_psLevel = 2; | 1137 int CFX_WindowsDevice::m_psLevel = 2; |
| 1141 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput, FX_BOOL bForc
ePSOutput, int psLevel) | 1138 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput, FX_BOOL bForc
ePSOutput, int psLevel) |
| 1142 { | 1139 { |
| 1143 m_bForcePSOutput = bForcePSOutput; | 1140 m_bForcePSOutput = bForcePSOutput; |
| 1144 m_psLevel = psLevel; | 1141 m_psLevel = psLevel; |
| 1145 if (bForcePSOutput) { | 1142 if (bForcePSOutput) { |
| 1146 IFX_RenderDeviceDriver* pDriver = FX_NEW CPSPrinterDriver; | 1143 IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver; |
| 1147 if (!pDriver) { | |
| 1148 return; | |
| 1149 } | |
| 1150 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput); | 1144 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput); |
| 1151 SetDeviceDriver(pDriver); | 1145 SetDeviceDriver(pDriver); |
| 1152 return; | 1146 return; |
| 1153 } | 1147 } |
| 1154 SetDeviceDriver(CreateDriver(hDC, bCmykOutput)); | 1148 SetDeviceDriver(CreateDriver(hDC, bCmykOutput)); |
| 1155 } | 1149 } |
| 1156 HDC CFX_WindowsDevice::GetDC() const | 1150 HDC CFX_WindowsDevice::GetDC() const |
| 1157 { | 1151 { |
| 1158 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver(); | 1152 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver(); |
| 1159 if (!pRDD) { | 1153 if (!pRDD) { |
| 1160 return NULL; | 1154 return NULL; |
| 1161 } | 1155 } |
| 1162 return (HDC)pRDD->GetPlatformSurface(); | 1156 return (HDC)pRDD->GetPlatformSurface(); |
| 1163 } | 1157 } |
| 1164 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, FX_BOOL bCmykOu
tput) | 1158 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, FX_BOOL bCmykOu
tput) |
| 1165 { | 1159 { |
| 1166 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); | 1160 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); |
| 1167 int obj_type = ::GetObjectType(hDC); | 1161 int obj_type = ::GetObjectType(hDC); |
| 1168 int device_class; | 1162 int device_class; |
| 1169 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type ==
OBJ_ENHMETADC) { | 1163 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type ==
OBJ_ENHMETADC) { |
| 1170 device_class = FXDC_PRINTER; | 1164 device_class = FXDC_PRINTER; |
| 1171 } else { | 1165 } else { |
| 1172 device_class = FXDC_DISPLAY; | 1166 device_class = FXDC_DISPLAY; |
| 1173 } | 1167 } |
| 1174 if (device_class == FXDC_PRINTER) { | 1168 if (device_class == FXDC_PRINTER) { |
| 1175 return FX_NEW CGdiPrinterDriver(hDC); | 1169 return new CGdiPrinterDriver(hDC); |
| 1176 } | 1170 } |
| 1177 return FX_NEW CGdiDisplayDriver(hDC); | 1171 return new CGdiDisplayDriver(hDC); |
| 1178 } | 1172 } |
| 1179 CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width, int height, FXDIB_Format for
mat) | 1173 CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width, int height, FXDIB_Format for
mat) |
| 1180 { | 1174 { |
| 1181 BITMAPINFOHEADER bmih; | 1175 BITMAPINFOHEADER bmih; |
| 1182 FXSYS_memset32(&bmih, 0, sizeof (BITMAPINFOHEADER)); | 1176 FXSYS_memset32(&bmih, 0, sizeof (BITMAPINFOHEADER)); |
| 1183 bmih.biSize = sizeof(BITMAPINFOHEADER); | 1177 bmih.biSize = sizeof(BITMAPINFOHEADER); |
| 1184 bmih.biBitCount = format & 0xff; | 1178 bmih.biBitCount = format & 0xff; |
| 1185 bmih.biHeight = -height; | 1179 bmih.biHeight = -height; |
| 1186 bmih.biPlanes = 1; | 1180 bmih.biPlanes = 1; |
| 1187 bmih.biWidth = width; | 1181 bmih.biWidth = width; |
| 1188 FX_LPBYTE pBuffer; | 1182 FX_LPBYTE pBuffer; |
| 1189 m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (FX_L
PVOID*)&pBuffer, NULL, 0); | 1183 m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (FX_L
PVOID*)&pBuffer, NULL, 0); |
| 1190 if (m_hBitmap == NULL) { | 1184 if (m_hBitmap == NULL) { |
| 1191 return; | 1185 return; |
| 1192 } | 1186 } |
| 1193 CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; | 1187 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 1194 if (!pBitmap) { | |
| 1195 return; | |
| 1196 } | |
| 1197 pBitmap->Create(width, height, format, pBuffer); | 1188 pBitmap->Create(width, height, format, pBuffer); |
| 1198 SetBitmap(pBitmap); | 1189 SetBitmap(pBitmap); |
| 1199 m_hDC = ::CreateCompatibleDC(NULL); | 1190 m_hDC = ::CreateCompatibleDC(NULL); |
| 1200 m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); | 1191 m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); |
| 1201 IFX_RenderDeviceDriver* pDriver = FX_NEW CGdiDisplayDriver(m_hDC); | 1192 IFX_RenderDeviceDriver* pDriver = new CGdiDisplayDriver(m_hDC); |
| 1202 if (!pDriver) { | |
| 1203 return; | |
| 1204 } | |
| 1205 SetDeviceDriver(pDriver); | 1193 SetDeviceDriver(pDriver); |
| 1206 } | 1194 } |
| 1207 CFX_WinBitmapDevice::~CFX_WinBitmapDevice() | 1195 CFX_WinBitmapDevice::~CFX_WinBitmapDevice() |
| 1208 { | 1196 { |
| 1209 if (m_hDC) { | 1197 if (m_hDC) { |
| 1210 SelectObject(m_hDC, m_hOldBitmap); | 1198 SelectObject(m_hDC, m_hOldBitmap); |
| 1211 DeleteDC(m_hDC); | 1199 DeleteDC(m_hDC); |
| 1212 } | 1200 } |
| 1213 if (m_hBitmap) { | 1201 if (m_hBitmap) { |
| 1214 DeleteObject(m_hBitmap); | 1202 DeleteObject(m_hBitmap); |
| 1215 } | 1203 } |
| 1216 delete GetBitmap(); | 1204 delete GetBitmap(); |
| 1217 } | 1205 } |
| 1218 #endif | 1206 #endif |
| OLD | NEW |