| 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 "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 <windows.h> | 10 #include <windows.h> |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 typedef GpStatus(WINGDIPAPI* FuncType_GdipSetPenTransform)(GpPen* pen, | 430 typedef GpStatus(WINGDIPAPI* FuncType_GdipSetPenTransform)(GpPen* pen, |
| 431 GpMatrix* matrix); | 431 GpMatrix* matrix); |
| 432 #define CallFunc(funcname) \ | 432 #define CallFunc(funcname) \ |
| 433 ((FuncType_##funcname)GdiplusExt.m_Functions[FuncId_##funcname]) | 433 ((FuncType_##funcname)GdiplusExt.m_Functions[FuncId_##funcname]) |
| 434 typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, | 434 typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, |
| 435 DWORD cbFont, | 435 DWORD cbFont, |
| 436 PVOID pdv, | 436 PVOID pdv, |
| 437 DWORD* pcFonts); | 437 DWORD* pcFonts); |
| 438 typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); | 438 typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); |
| 439 void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, | 439 void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, |
| 440 FX_DWORD size, | 440 uint32_t size, |
| 441 void* pdv, | 441 void* pdv, |
| 442 FX_DWORD* num_face) { | 442 uint32_t* num_face) { |
| 443 if (m_pGdiAddFontMemResourceEx) { | 443 if (m_pGdiAddFontMemResourceEx) { |
| 444 return ((FuncType_GdiAddFontMemResourceEx)m_pGdiAddFontMemResourceEx)( | 444 return ((FuncType_GdiAddFontMemResourceEx)m_pGdiAddFontMemResourceEx)( |
| 445 (PVOID)pFontdata, (DWORD)size, (PVOID)pdv, (DWORD*)num_face); | 445 (PVOID)pFontdata, (DWORD)size, (PVOID)pdv, (DWORD*)num_face); |
| 446 } | 446 } |
| 447 return NULL; | 447 return NULL; |
| 448 } | 448 } |
| 449 FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { | 449 FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { |
| 450 if (m_pGdiRemoveFontMemResourseEx) { | 450 if (m_pGdiRemoveFontMemResourseEx) { |
| 451 return ((FuncType_GdiRemoveFontMemResourceEx)m_pGdiRemoveFontMemResourseEx)( | 451 return ((FuncType_GdiRemoveFontMemResourceEx)m_pGdiRemoveFontMemResourseEx)( |
| 452 (HANDLE)handle); | 452 (HANDLE)handle); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 m_GdiModule = LoadLibraryA("GDI32.DLL"); | 704 m_GdiModule = LoadLibraryA("GDI32.DLL"); |
| 705 if (!m_GdiModule) { | 705 if (!m_GdiModule) { |
| 706 return; | 706 return; |
| 707 } | 707 } |
| 708 m_pGdiAddFontMemResourceEx = | 708 m_pGdiAddFontMemResourceEx = |
| 709 GetProcAddress(m_GdiModule, "AddFontMemResourceEx"); | 709 GetProcAddress(m_GdiModule, "AddFontMemResourceEx"); |
| 710 m_pGdiRemoveFontMemResourseEx = | 710 m_pGdiRemoveFontMemResourseEx = |
| 711 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx"); | 711 GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx"); |
| 712 } | 712 } |
| 713 CGdiplusExt::~CGdiplusExt() {} | 713 CGdiplusExt::~CGdiplusExt() {} |
| 714 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, FX_DWORD size) { | 714 LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { |
| 715 GpFontCollection* pCollection = NULL; | 715 GpFontCollection* pCollection = NULL; |
| 716 CGdiplusExt& GdiplusExt = | 716 CGdiplusExt& GdiplusExt = |
| 717 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 717 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 718 CallFunc(GdipNewPrivateFontCollection)(&pCollection); | 718 CallFunc(GdipNewPrivateFontCollection)(&pCollection); |
| 719 GpStatus status = | 719 GpStatus status = |
| 720 CallFunc(GdipPrivateAddMemoryFont)(pCollection, pData, size); | 720 CallFunc(GdipPrivateAddMemoryFont)(pCollection, pData, size); |
| 721 if (status == Ok) { | 721 if (status == Ok) { |
| 722 return pCollection; | 722 return pCollection; |
| 723 } | 723 } |
| 724 CallFunc(GdipDeletePrivateFontCollection)(&pCollection); | 724 CallFunc(GdipDeletePrivateFontCollection)(&pCollection); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } else { | 802 } else { |
| 803 *size = 0; | 803 *size = 0; |
| 804 } | 804 } |
| 805 } | 805 } |
| 806 void CGdiplusExt::GdipSetTextRenderingHint(void* graphics, int mode) { | 806 void CGdiplusExt::GdipSetTextRenderingHint(void* graphics, int mode) { |
| 807 CGdiplusExt& GdiplusExt = | 807 CGdiplusExt& GdiplusExt = |
| 808 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 808 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 809 CallFunc(GdipSetTextRenderingHint)((GpGraphics*)graphics, | 809 CallFunc(GdipSetTextRenderingHint)((GpGraphics*)graphics, |
| 810 (TextRenderingHint)mode); | 810 (TextRenderingHint)mode); |
| 811 } | 811 } |
| 812 void CGdiplusExt::GdipSetPageUnit(void* graphics, FX_DWORD unit) { | 812 void CGdiplusExt::GdipSetPageUnit(void* graphics, uint32_t unit) { |
| 813 CGdiplusExt& GdiplusExt = | 813 CGdiplusExt& GdiplusExt = |
| 814 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 814 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 815 CallFunc(GdipSetPageUnit)((GpGraphics*)graphics, (GpUnit)unit); | 815 CallFunc(GdipSetPageUnit)((GpGraphics*)graphics, (GpUnit)unit); |
| 816 } | 816 } |
| 817 FX_BOOL CGdiplusExt::GdipDrawDriverString(void* graphics, | 817 FX_BOOL CGdiplusExt::GdipDrawDriverString(void* graphics, |
| 818 unsigned short* text, | 818 unsigned short* text, |
| 819 int length, | 819 int length, |
| 820 void* font, | 820 void* font, |
| 821 void* brush, | 821 void* brush, |
| 822 void* positions, | 822 void* positions, |
| 823 int flags, | 823 int flags, |
| 824 const void* matrix) { | 824 const void* matrix) { |
| 825 CGdiplusExt& GdiplusExt = | 825 CGdiplusExt& GdiplusExt = |
| 826 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 826 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 827 GpStatus status = CallFunc(GdipDrawDriverString)( | 827 GpStatus status = CallFunc(GdipDrawDriverString)( |
| 828 (GpGraphics*)graphics, (GDIPCONST UINT16*)text, (INT)length, | 828 (GpGraphics*)graphics, (GDIPCONST UINT16*)text, (INT)length, |
| 829 (GDIPCONST GpFont*)font, (GDIPCONST GpBrush*)brush, | 829 (GDIPCONST GpFont*)font, (GDIPCONST GpBrush*)brush, |
| 830 (GDIPCONST PointF*)positions, (INT)flags, (GDIPCONST GpMatrix*)matrix); | 830 (GDIPCONST PointF*)positions, (INT)flags, (GDIPCONST GpMatrix*)matrix); |
| 831 if (status == Ok) { | 831 if (status == Ok) { |
| 832 return TRUE; | 832 return TRUE; |
| 833 } | 833 } |
| 834 return FALSE; | 834 return FALSE; |
| 835 } | 835 } |
| 836 void CGdiplusExt::GdipCreateBrush(FX_DWORD fill_argb, void** pBrush) { | 836 void CGdiplusExt::GdipCreateBrush(uint32_t fill_argb, void** pBrush) { |
| 837 CGdiplusExt& GdiplusExt = | 837 CGdiplusExt& GdiplusExt = |
| 838 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 838 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 839 CallFunc(GdipCreateSolidFill)((ARGB)fill_argb, (GpSolidFill**)pBrush); | 839 CallFunc(GdipCreateSolidFill)((ARGB)fill_argb, (GpSolidFill**)pBrush); |
| 840 } | 840 } |
| 841 void CGdiplusExt::GdipDeleteBrush(void* pBrush) { | 841 void CGdiplusExt::GdipDeleteBrush(void* pBrush) { |
| 842 CGdiplusExt& GdiplusExt = | 842 CGdiplusExt& GdiplusExt = |
| 843 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 843 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 844 CallFunc(GdipDeleteBrush)((GpSolidFill*)pBrush); | 844 CallFunc(GdipDeleteBrush)((GpSolidFill*)pBrush); |
| 845 } | 845 } |
| 846 void* CGdiplusExt::GdipCreateFontFromCollection(void* pFontCollection, | 846 void* CGdiplusExt::GdipCreateFontFromCollection(void* pFontCollection, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 909 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 910 CallFunc(GdipDeleteGraphics)((GpGraphics*)graphics); | 910 CallFunc(GdipDeleteGraphics)((GpGraphics*)graphics); |
| 911 } | 911 } |
| 912 FX_BOOL CGdiplusExt::StretchBitMask(HDC hDC, | 912 FX_BOOL CGdiplusExt::StretchBitMask(HDC hDC, |
| 913 BOOL bMonoDevice, | 913 BOOL bMonoDevice, |
| 914 const CFX_DIBitmap* pBitmap, | 914 const CFX_DIBitmap* pBitmap, |
| 915 int dest_left, | 915 int dest_left, |
| 916 int dest_top, | 916 int dest_top, |
| 917 int dest_width, | 917 int dest_width, |
| 918 int dest_height, | 918 int dest_height, |
| 919 FX_DWORD argb, | 919 uint32_t argb, |
| 920 const FX_RECT* pClipRect, | 920 const FX_RECT* pClipRect, |
| 921 int flags) { | 921 int flags) { |
| 922 ASSERT(pBitmap->GetBPP() == 1); | 922 ASSERT(pBitmap->GetBPP() == 1); |
| 923 CGdiplusExt& GdiplusExt = | 923 CGdiplusExt& GdiplusExt = |
| 924 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 924 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 925 GpGraphics* pGraphics = NULL; | 925 GpGraphics* pGraphics = NULL; |
| 926 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); | 926 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); |
| 927 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); | 927 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); |
| 928 if (flags & FXDIB_NOSMOOTH) { | 928 if (flags & FXDIB_NOSMOOTH) { |
| 929 CallFunc(GdipSetInterpolationMode)(pGraphics, | 929 CallFunc(GdipSetInterpolationMode)(pGraphics, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 v2 = pair1; | 1093 v2 = pair1; |
| 1094 return TRUE; | 1094 return TRUE; |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 return FALSE; | 1097 return FALSE; |
| 1098 } | 1098 } |
| 1099 FX_BOOL CGdiplusExt::DrawPath(HDC hDC, | 1099 FX_BOOL CGdiplusExt::DrawPath(HDC hDC, |
| 1100 const CFX_PathData* pPathData, | 1100 const CFX_PathData* pPathData, |
| 1101 const CFX_Matrix* pObject2Device, | 1101 const CFX_Matrix* pObject2Device, |
| 1102 const CFX_GraphStateData* pGraphState, | 1102 const CFX_GraphStateData* pGraphState, |
| 1103 FX_DWORD fill_argb, | 1103 uint32_t fill_argb, |
| 1104 FX_DWORD stroke_argb, | 1104 uint32_t stroke_argb, |
| 1105 int fill_mode) { | 1105 int fill_mode) { |
| 1106 int nPoints = pPathData->GetPointCount(); | 1106 int nPoints = pPathData->GetPointCount(); |
| 1107 if (nPoints == 0) { | 1107 if (nPoints == 0) { |
| 1108 return TRUE; | 1108 return TRUE; |
| 1109 } | 1109 } |
| 1110 FX_PATHPOINT* pPoints = pPathData->GetPoints(); | 1110 FX_PATHPOINT* pPoints = pPathData->GetPoints(); |
| 1111 GpGraphics* pGraphics = NULL; | 1111 GpGraphics* pGraphics = NULL; |
| 1112 CGdiplusExt& GdiplusExt = | 1112 CGdiplusExt& GdiplusExt = |
| 1113 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 1113 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
| 1114 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); | 1114 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 dest_pitch); | 1509 dest_pitch); |
| 1510 } | 1510 } |
| 1511 } | 1511 } |
| 1512 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( | 1512 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( |
| 1513 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); | 1513 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); |
| 1514 FX_Free(pData); | 1514 FX_Free(pData); |
| 1515 FreeDIBitmap(pInfo); | 1515 FreeDIBitmap(pInfo); |
| 1516 return pDIBitmap; | 1516 return pDIBitmap; |
| 1517 } | 1517 } |
| 1518 #endif | 1518 #endif |
| OLD | NEW |