Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 1748163006: Don't load GDI+ if GDI is disabled. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/include/fxge/fx_ge.h" 7 #include "core/include/fxge/fx_ge.h"
8 8
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
10 #include <crtdbg.h> 10 #include <crtdbg.h>
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 return TRUE; 431 return TRUE;
432 } 432 }
433 FX_BOOL CFX_Win32FontInfo::GetFontCharset(void* hFont, int& charset) { 433 FX_BOOL CFX_Win32FontInfo::GetFontCharset(void* hFont, int& charset) {
434 TEXTMETRIC tm; 434 TEXTMETRIC tm;
435 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 435 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
436 ::GetTextMetrics(m_hDC, &tm); 436 ::GetTextMetrics(m_hDC, &tm);
437 ::SelectObject(m_hDC, hOldFont); 437 ::SelectObject(m_hDC, hOldFont);
438 charset = tm.tmCharSet; 438 charset = tm.tmCharSet;
439 return TRUE; 439 return TRUE;
440 } 440 }
441 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) { 441 static FX_BOOL IsGDIEnabled() {
442 // If GDI is disabled then GetDC for the desktop will fail.
442 HDC hdc = ::GetDC(NULL); 443 HDC hdc = ::GetDC(NULL);
443 if (hdc) { 444 if (hdc) {
444 ::ReleaseDC(NULL, hdc); 445 ::ReleaseDC(NULL, hdc);
446 return TRUE;
447 }
448 return FALSE;
449 }
450 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
451 if (IsGDIEnabled()) {
445 return new CFX_Win32FontInfo; 452 return new CFX_Win32FontInfo;
446 } 453 }
447 // If GDI is disabled then GetDC for the desktop will fail. Select the 454 // Select the fallback font information class if GDI is disabled.
448 // fallback font information class if GDI is disabled.
449 CFX_Win32FallbackFontInfo* pInfoFallback = new CFX_Win32FallbackFontInfo; 455 CFX_Win32FallbackFontInfo* pInfoFallback = new CFX_Win32FallbackFontInfo;
450 // Construct the font path manually, SHGetKnownFolderPath won't work under 456 // Construct the font path manually, SHGetKnownFolderPath won't work under
451 // a restrictive sandbox. 457 // a restrictive sandbox.
452 CHAR windows_path[MAX_PATH] = {}; 458 CHAR windows_path[MAX_PATH] = {};
453 DWORD path_len = ::GetWindowsDirectoryA(windows_path, MAX_PATH); 459 DWORD path_len = ::GetWindowsDirectoryA(windows_path, MAX_PATH);
454 if (path_len > 0 && path_len < MAX_PATH) { 460 if (path_len > 0 && path_len < MAX_PATH) {
455 CFX_ByteString fonts_path(windows_path); 461 CFX_ByteString fonts_path(windows_path);
456 fonts_path += "\\Fonts"; 462 fonts_path += "\\Fonts";
457 pInfoFallback->AddPath(fonts_path); 463 pInfoFallback->AddPath(fonts_path);
458 } 464 }
459 return pInfoFallback; 465 return pInfoFallback;
460 } 466 }
461 void CFX_GEModule::InitPlatform() { 467 void CFX_GEModule::InitPlatform() {
462 CWin32Platform* pPlatformData = new CWin32Platform; 468 CWin32Platform* pPlatformData = new CWin32Platform;
463 OSVERSIONINFO ver; 469 OSVERSIONINFO ver;
464 ver.dwOSVersionInfoSize = sizeof(ver); 470 ver.dwOSVersionInfoSize = sizeof(ver);
465 GetVersionEx(&ver); 471 GetVersionEx(&ver);
466 pPlatformData->m_bHalfTone = ver.dwMajorVersion >= 5; 472 pPlatformData->m_bHalfTone = ver.dwMajorVersion >= 5;
467 pPlatformData->m_GdiplusExt.Load(); 473 if (IsGDIEnabled()) {
474 pPlatformData->m_GdiplusExt.Load();
475 }
468 m_pPlatformData = pPlatformData; 476 m_pPlatformData = pPlatformData;
469 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); 477 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr));
470 } 478 }
471 void CFX_GEModule::DestroyPlatform() { 479 void CFX_GEModule::DestroyPlatform() {
472 delete (CWin32Platform*)m_pPlatformData; 480 delete (CWin32Platform*)m_pPlatformData;
473 m_pPlatformData = NULL; 481 m_pPlatformData = NULL;
474 } 482 }
475 CGdiDeviceDriver::CGdiDeviceDriver(HDC hDC, int device_class) { 483 CGdiDeviceDriver::CGdiDeviceDriver(HDC hDC, int device_class) {
476 m_hDC = hDC; 484 m_hDC = hDC;
477 m_DeviceClass = device_class; 485 m_DeviceClass = device_class;
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 SelectObject(m_hDC, m_hOldBitmap); 1364 SelectObject(m_hDC, m_hOldBitmap);
1357 DeleteDC(m_hDC); 1365 DeleteDC(m_hDC);
1358 } 1366 }
1359 if (m_hBitmap) { 1367 if (m_hBitmap) {
1360 DeleteObject(m_hBitmap); 1368 DeleteObject(m_hBitmap);
1361 } 1369 }
1362 delete GetBitmap(); 1370 delete GetBitmap();
1363 } 1371 }
1364 1372
1365 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1373 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698