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

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

Issue 2197513004: Refactor fxge/fx_apple and fx_win header files (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fixing nits Created 4 years, 4 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 | « core/fxge/win32/cfx_windowsdib.h ('k') | core/fxge/win32/fx_win32_dib.cpp » ('j') | 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/fxge/include/fx_ge.h" 7 #include "core/fxge/include/fx_ge.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 13 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
14 #include <crtdbg.h> 14 #include <crtdbg.h>
15 15
16 #include "core/fxcodec/include/fx_codec.h" 16 #include "core/fxcodec/include/fx_codec.h"
17 #include "core/fxcrt/include/fx_memory.h" 17 #include "core/fxcrt/include/fx_memory.h"
18 18
19 #ifndef _SKIA_SUPPORT_ 19 #ifndef _SKIA_SUPPORT_
20 #include "core/fxge/agg/fx_agg_driver.h" 20 #include "core/fxge/agg/fx_agg_driver.h"
21 #endif 21 #endif
22 22
23 #include "core/fxge/dib/dib_int.h" 23 #include "core/fxge/dib/dib_int.h"
24 #include "core/fxge/ge/cfx_folderfontinfo.h" 24 #include "core/fxge/ge/cfx_folderfontinfo.h"
25 #include "core/fxge/ge/fx_text_int.h" 25 #include "core/fxge/ge/fx_text_int.h"
26 #include "core/fxge/include/cfx_fontmapper.h" 26 #include "core/fxge/include/cfx_fontmapper.h"
27 #include "core/fxge/include/cfx_windowsdevice.h"
27 #include "core/fxge/include/ifx_systemfontinfo.h" 28 #include "core/fxge/include/ifx_systemfontinfo.h"
28 #include "core/fxge/include/fx_font.h" 29 #include "core/fxge/include/fx_font.h"
29 #include "core/fxge/include/fx_freetype.h" 30 #include "core/fxge/include/fx_freetype.h"
30 #include "core/fxge/include/fx_ge_win32.h" 31 #include "core/fxge/win32/cfx_windowsdib.h"
31 #include "core/fxge/win32/dwrite_int.h" 32 #include "core/fxge/win32/dwrite_int.h"
32 #include "core/fxge/win32/win32_int.h" 33 #include "core/fxge/win32/win32_int.h"
33 #include "third_party/base/stl_util.h" 34 #include "third_party/base/stl_util.h"
34 35
35 namespace { 36 namespace {
36 37
37 const struct { 38 const struct {
38 const FX_CHAR* m_pFaceName; 39 const FX_CHAR* m_pFaceName;
39 const FX_CHAR* m_pVariantName; 40 const FX_CHAR* m_pVariantName;
40 } g_VariantNames[] = { 41 } g_VariantNames[] = {
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { 1383 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) {
1383 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1384 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1384 int obj_type = ::GetObjectType(hDC); 1385 int obj_type = ::GetObjectType(hDC);
1385 bool use_printer = device_type == DT_RASPRINTER || 1386 bool use_printer = device_type == DT_RASPRINTER ||
1386 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; 1387 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC;
1387 if (use_printer) 1388 if (use_printer)
1388 return new CGdiPrinterDriver(hDC); 1389 return new CGdiPrinterDriver(hDC);
1389 return new CGdiDisplayDriver(hDC); 1390 return new CGdiDisplayDriver(hDC);
1390 } 1391 }
1391 1392
1392 CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width,
1393 int height,
1394 FXDIB_Format format) {
1395 BITMAPINFOHEADER bmih;
1396 FXSYS_memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
1397 bmih.biSize = sizeof(BITMAPINFOHEADER);
1398 bmih.biBitCount = format & 0xff;
1399 bmih.biHeight = -height;
1400 bmih.biPlanes = 1;
1401 bmih.biWidth = width;
1402 void* pBufferPtr;
1403 m_hBitmap = CreateDIBSection(nullptr, reinterpret_cast<BITMAPINFO*>(&bmih),
1404 DIB_RGB_COLORS, &pBufferPtr, nullptr, 0);
1405 if (!m_hBitmap)
1406 return;
1407
1408 uint8_t* pBuffer = static_cast<uint8_t*>(pBufferPtr);
1409 CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
1410 pBitmap->Create(width, height, format, pBuffer);
1411 SetBitmap(pBitmap);
1412 m_hDC = ::CreateCompatibleDC(nullptr);
1413 m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap);
1414 SetDeviceDriver(WrapUnique(new CGdiDisplayDriver(m_hDC)));
1415 }
1416
1417 CFX_WinBitmapDevice::~CFX_WinBitmapDevice() {
1418 if (m_hDC) {
1419 SelectObject(m_hDC, m_hOldBitmap);
1420 DeleteDC(m_hDC);
1421 }
1422 if (m_hBitmap)
1423 DeleteObject(m_hBitmap);
1424 delete GetBitmap();
1425 }
1426
1427 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1393 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
OLDNEW
« no previous file with comments | « core/fxge/win32/cfx_windowsdib.h ('k') | core/fxge/win32/fx_win32_dib.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698