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 <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/fxcrt/fx_system.h" | 13 #include "core/fxcrt/fx_system.h" |
14 #include "core/fxge/cfx_renderdevice.h" | |
15 #include "core/fxge/cfx_windowsdevice.h" | 14 #include "core/fxge/cfx_windowsdevice.h" |
16 #include "core/fxge/dib/dib_int.h" | 15 #include "core/fxge/dib/dib_int.h" |
17 #include "core/fxge/fx_freetype.h" | 16 #include "core/fxge/fx_freetype.h" |
18 #include "core/fxge/ge/fx_text_int.h" | 17 #include "core/fxge/ge/fx_text_int.h" |
| 18 #include "core/fxge/win32/cpsoutput.h" |
19 #include "core/fxge/win32/win32_int.h" | 19 #include "core/fxge/win32/win32_int.h" |
20 #include "third_party/base/ptr_util.h" | 20 #include "third_party/base/ptr_util.h" |
21 | 21 |
22 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI) | 22 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI) |
23 namespace { | 23 namespace { |
24 | 24 |
25 class ScopedState { | 25 class ScopedState { |
26 public: | 26 public: |
27 ScopedState(HDC hDC, HFONT hFont) : m_hDC(hDC) { | 27 ScopedState(HDC hDC, HFONT hFont) : m_hDC(hDC) { |
28 m_iState = SaveDC(m_hDC); | 28 m_iState = SaveDC(m_hDC); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 // Try to get the font and draw again. | 322 // Try to get the font and draw again. |
323 g_pdfium_typeface_accessible_func(&lf, wsText.c_str(), nChars); | 323 g_pdfium_typeface_accessible_func(&lf, wsText.c_str(), nChars); |
324 return !!ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(), | 324 return !!ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(), |
325 nChars, nChars > 1 ? &spacing[1] : nullptr); | 325 nChars, nChars > 1 ? &spacing[1] : nullptr); |
326 #else | 326 #else |
327 return false; | 327 return false; |
328 #endif | 328 #endif |
329 } | 329 } |
330 | 330 |
331 CPSPrinterDriver::CPSPrinterDriver(HDC hDC, int pslevel, bool bCmykOutput) { | 331 CPSPrinterDriver::CPSPrinterDriver(HDC hDC, int pslevel, bool bCmykOutput) |
332 m_hDC = hDC; | 332 : m_hDC(hDC), m_bCmykOutput(bCmykOutput) { |
333 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); | 333 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); |
334 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); | 334 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); |
335 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); | 335 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); |
336 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); | 336 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); |
337 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); | 337 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); |
338 m_pPSOutput = pdfium::MakeUnique<CPSOutput>(m_hDC); | 338 m_pPSOutput = pdfium::MakeUnique<CPSOutput>(m_hDC); |
339 m_PSRenderer.Init(m_pPSOutput.get(), pslevel, m_Width, m_Height, bCmykOutput); | 339 m_PSRenderer.Init(m_pPSOutput.get(), pslevel, m_Width, m_Height, bCmykOutput); |
340 m_bCmykOutput = bCmykOutput; | |
341 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1); | 340 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1); |
342 int ret = ::GetClipRgn(hDC, hRgn); | 341 int ret = ::GetClipRgn(hDC, hRgn); |
343 if (ret == 1) { | 342 if (ret == 1) { |
344 ret = ::GetRegionData(hRgn, 0, NULL); | 343 ret = ::GetRegionData(hRgn, 0, NULL); |
345 if (ret) { | 344 if (ret) { |
346 RGNDATA* pData = reinterpret_cast<RGNDATA*>(FX_Alloc(uint8_t, ret)); | 345 RGNDATA* pData = reinterpret_cast<RGNDATA*>(FX_Alloc(uint8_t, ret)); |
347 ret = ::GetRegionData(hRgn, ret, pData); | 346 ret = ::GetRegionData(hRgn, ret, pData); |
348 if (ret) { | 347 if (ret) { |
349 CFX_PathData path; | 348 CFX_PathData path; |
350 path.AllocPointCount(pData->rdh.nCount * 5); | 349 path.AllocPointCount(pData->rdh.nCount * 5); |
351 for (uint32_t i = 0; i < pData->rdh.nCount; i++) { | 350 for (uint32_t i = 0; i < pData->rdh.nCount; i++) { |
352 RECT* pRect = | 351 RECT* pRect = |
353 reinterpret_cast<RECT*>(pData->Buffer + pData->rdh.nRgnSize * i); | 352 reinterpret_cast<RECT*>(pData->Buffer + pData->rdh.nRgnSize * i); |
354 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom, | 353 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom, |
355 (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); | 354 (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); |
356 } | 355 } |
357 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); | 356 m_PSRenderer.SetClip_PathFill(&path, nullptr, FXFILL_WINDING); |
358 } | 357 } |
359 FX_Free(pData); | 358 FX_Free(pData); |
360 } | 359 } |
361 } | 360 } |
362 ::DeleteObject(hRgn); | 361 ::DeleteObject(hRgn); |
363 } | 362 } |
364 | 363 |
365 CPSPrinterDriver::~CPSPrinterDriver() { | 364 CPSPrinterDriver::~CPSPrinterDriver() { |
366 EndRendering(); | 365 EndRendering(); |
367 } | 366 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 const CFX_Matrix* pObject2Device, | 484 const CFX_Matrix* pObject2Device, |
486 FX_FLOAT font_size, | 485 FX_FLOAT font_size, |
487 uint32_t color) { | 486 uint32_t color) { |
488 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pObject2Device, | 487 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pObject2Device, |
489 font_size, color); | 488 font_size, color); |
490 } | 489 } |
491 | 490 |
492 void* CPSPrinterDriver::GetPlatformSurface() const { | 491 void* CPSPrinterDriver::GetPlatformSurface() const { |
493 return m_hDC; | 492 return m_hDC; |
494 } | 493 } |
OLD | NEW |