| 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 | 10 |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 GDIPCONST WCHAR* str, | 427 GDIPCONST WCHAR* str, |
| 428 INT length, | 428 INT length, |
| 429 GDIPCONST GpFont* font, | 429 GDIPCONST GpFont* font, |
| 430 GDIPCONST RectF* layoutRect, | 430 GDIPCONST RectF* layoutRect, |
| 431 GDIPCONST GpStringFormat* stringFormat, | 431 GDIPCONST GpStringFormat* stringFormat, |
| 432 GDIPCONST GpBrush* brush); | 432 GDIPCONST GpBrush* brush); |
| 433 typedef GpStatus(WINGDIPAPI* FuncType_GdipSetPenTransform)(GpPen* pen, | 433 typedef GpStatus(WINGDIPAPI* FuncType_GdipSetPenTransform)(GpPen* pen, |
| 434 GpMatrix* matrix); | 434 GpMatrix* matrix); |
| 435 #define CallFunc(funcname) \ | 435 #define CallFunc(funcname) \ |
| 436 ((FuncType_##funcname)GdiplusExt.m_Functions[FuncId_##funcname]) | 436 ((FuncType_##funcname)GdiplusExt.m_Functions[FuncId_##funcname]) |
| 437 typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, | 437 |
| 438 DWORD cbFont, | |
| 439 PVOID pdv, | |
| 440 DWORD* pcFonts); | |
| 441 typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); | |
| 442 void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, | 438 void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, |
| 443 uint32_t size, | 439 uint32_t size, |
| 444 void* pdv, | 440 void* pdv, |
| 445 uint32_t* num_face) { | 441 uint32_t* num_face) { |
| 446 if (m_pGdiAddFontMemResourceEx) { | 442 if (!m_pGdiAddFontMemResourceEx) |
| 447 return ((FuncType_GdiAddFontMemResourceEx)m_pGdiAddFontMemResourceEx)( | 443 return nullptr; |
| 448 (PVOID)pFontdata, (DWORD)size, (PVOID)pdv, (DWORD*)num_face); | 444 |
| 449 } | 445 return m_pGdiAddFontMemResourceEx((PVOID)pFontdata, (DWORD)size, (PVOID)pdv, |
| 450 return nullptr; | 446 (DWORD*)num_face); |
| 451 } | 447 } |
| 448 |
| 452 FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { | 449 FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { |
| 453 if (m_pGdiRemoveFontMemResourseEx) { | 450 return m_pGdiRemoveFontMemResourseEx && |
| 454 return ((FuncType_GdiRemoveFontMemResourceEx)m_pGdiRemoveFontMemResourseEx)( | 451 m_pGdiRemoveFontMemResourseEx((HANDLE)handle); |
| 455 (HANDLE)handle); | |
| 456 } | |
| 457 return FALSE; | |
| 458 } | 452 } |
| 453 |
| 459 static GpBrush* _GdipCreateBrush(DWORD argb) { | 454 static GpBrush* _GdipCreateBrush(DWORD argb) { |
| 460 CGdiplusExt& GdiplusExt = | 455 CGdiplusExt& GdiplusExt = |
| 461 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 456 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 462 GpSolidFill* solidBrush = nullptr; | 457 GpSolidFill* solidBrush = nullptr; |
| 463 CallFunc(GdipCreateSolidFill)((ARGB)argb, &solidBrush); | 458 CallFunc(GdipCreateSolidFill)((ARGB)argb, &solidBrush); |
| 464 return solidBrush; | 459 return solidBrush; |
| 465 } | 460 } |
| 466 static CFX_DIBitmap* _StretchMonoToGray(int dest_width, | 461 static CFX_DIBitmap* _StretchMonoToGray(int dest_width, |
| 467 int dest_height, | 462 int dest_height, |
| 468 const CFX_DIBitmap* pSource, | 463 const CFX_DIBitmap* pSource, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 697 } |
| 703 uintptr_t gdiplusToken; | 698 uintptr_t gdiplusToken; |
| 704 GdiplusStartupInput gdiplusStartupInput; | 699 GdiplusStartupInput gdiplusStartupInput; |
| 705 ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])( | 700 ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])( |
| 706 &gdiplusToken, &gdiplusStartupInput, nullptr); | 701 &gdiplusToken, &gdiplusStartupInput, nullptr); |
| 707 m_GdiModule = LoadLibraryA("GDI32.DLL"); | 702 m_GdiModule = LoadLibraryA("GDI32.DLL"); |
| 708 if (!m_GdiModule) { | 703 if (!m_GdiModule) { |
| 709 return; | 704 return; |
| 710 } | 705 } |
| 711 m_pGdiAddFontMemResourceEx = | 706 m_pGdiAddFontMemResourceEx = |
| 712 GetProcAddress(m_GdiModule, "AddFontMemResourceEx"); | 707 reinterpret_cast<FuncType_GdiAddFontMemResourceEx>( |
| 708 GetProcAddress(m_GdiModule, "AddFontMemResourceEx")); |
| 713 m_pGdiRemoveFontMemResourseEx = | 709 m_pGdiRemoveFontMemResourseEx = |
| 714 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx"); | 710 reinterpret_cast<FuncType_GdiRemoveFontMemResourceEx>( |
| 711 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx")); |
| 715 } | 712 } |
| 716 CGdiplusExt::~CGdiplusExt() {} | 713 CGdiplusExt::~CGdiplusExt() {} |
| 717 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { | 714 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { |
| 718 GpFontCollection* pCollection = nullptr; | 715 GpFontCollection* pCollection = nullptr; |
| 719 CGdiplusExt& GdiplusExt = | 716 CGdiplusExt& GdiplusExt = |
| 720 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 717 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 721 CallFunc(GdipNewPrivateFontCollection)(&pCollection); | 718 CallFunc(GdipNewPrivateFontCollection)(&pCollection); |
| 722 GpStatus status = | 719 GpStatus status = |
| 723 CallFunc(GdipPrivateAddMemoryFont)(pCollection, pData, size); | 720 CallFunc(GdipPrivateAddMemoryFont)(pCollection, pData, size); |
| 724 if (status == Ok) { | 721 if (status == Ok) { |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, | 1514 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, |
| 1518 dest_pitch); | 1515 dest_pitch); |
| 1519 } | 1516 } |
| 1520 } | 1517 } |
| 1521 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( | 1518 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( |
| 1522 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); | 1519 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); |
| 1523 FX_Free(pData); | 1520 FX_Free(pData); |
| 1524 FreeDIBitmap(pInfo); | 1521 FreeDIBitmap(pInfo); |
| 1525 return pDIBitmap; | 1522 return pDIBitmap; |
| 1526 } | 1523 } |
| OLD | NEW |