diff options
author | tsepez <tsepez@chromium.org> | 2016-10-28 11:16:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-28 11:16:44 -0700 |
commit | 159ba95782e0610b217c42a60bbfbd99737e0771 (patch) | |
tree | 8bd78d9b3e5ad86ca28c54b776fcffad536d17cd | |
parent | 71ba5883dd00145b2256935635492cbcc8d94bac (diff) | |
download | pdfium-159ba95782e0610b217c42a60bbfbd99737e0771.tar.xz |
Stop casting function pointers to data pointers in fx_win32_gdipext.cpp.
Only bad people do that, since it's prohibited by the C standards.
Review-Url: https://codereview.chromium.org/2459603004
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 31 | ||||
-rw-r--r-- | core/fxge/win32/win32_int.h | 16 |
2 files changed, 27 insertions, 20 deletions
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 927f0a32e2..3dce58ffe3 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -434,28 +434,23 @@ typedef GpStatus(WINGDIPAPI* FuncType_GdipSetPenTransform)(GpPen* pen, GpMatrix* matrix); #define CallFunc(funcname) \ ((FuncType_##funcname)GdiplusExt.m_Functions[FuncId_##funcname]) -typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, - DWORD cbFont, - PVOID pdv, - DWORD* pcFonts); -typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); + void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, uint32_t size, void* pdv, uint32_t* num_face) { - if (m_pGdiAddFontMemResourceEx) { - return ((FuncType_GdiAddFontMemResourceEx)m_pGdiAddFontMemResourceEx)( - (PVOID)pFontdata, (DWORD)size, (PVOID)pdv, (DWORD*)num_face); - } - return nullptr; + if (!m_pGdiAddFontMemResourceEx) + return nullptr; + + return m_pGdiAddFontMemResourceEx((PVOID)pFontdata, (DWORD)size, (PVOID)pdv, + (DWORD*)num_face); } + FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { - if (m_pGdiRemoveFontMemResourseEx) { - return ((FuncType_GdiRemoveFontMemResourceEx)m_pGdiRemoveFontMemResourseEx)( - (HANDLE)handle); - } - return FALSE; + return m_pGdiRemoveFontMemResourseEx && + m_pGdiRemoveFontMemResourseEx((HANDLE)handle); } + static GpBrush* _GdipCreateBrush(DWORD argb) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -709,9 +704,11 @@ void CGdiplusExt::Load() { return; } m_pGdiAddFontMemResourceEx = - GetProcAddress(m_GdiModule, "AddFontMemResourceEx"); + reinterpret_cast<FuncType_GdiAddFontMemResourceEx>( + GetProcAddress(m_GdiModule, "AddFontMemResourceEx")); m_pGdiRemoveFontMemResourseEx = - GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx"); + reinterpret_cast<FuncType_GdiRemoveFontMemResourceEx>( + GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx")); } CGdiplusExt::~CGdiplusExt() {} LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 0cea52b908..1f2bc50f42 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -7,6 +7,8 @@ #ifndef CORE_FXGE_WIN32_WIN32_INT_H_ #define CORE_FXGE_WIN32_WIN32_INT_H_ +#include <windows.h> + #include "core/fxge/cfx_pathdata.h" #include "core/fxge/ifx_renderdevicedriver.h" #include "core/fxge/win32/dwrite_int.h" @@ -14,6 +16,12 @@ struct FXTEXT_CHARPOS; struct WINDIB_Open_Args_; +typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, + DWORD cbFont, + PVOID pdv, + DWORD* pcFonts); +typedef BOOL(__stdcall* FuncType_GdiRemoveFontMemResourceEx)(HANDLE handle); + class CGdiplusExt { public: CGdiplusExt(); @@ -92,15 +100,17 @@ class CGdiplusExt { void* pdv, uint32_t* num_face); FX_BOOL GdiRemoveFontMemResourceEx(void* handle); - void* m_Functions[100]; - void* m_pGdiAddFontMemResourceEx; - void* m_pGdiRemoveFontMemResourseEx; CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); + FARPROC m_Functions[100]; + FuncType_GdiAddFontMemResourceEx m_pGdiAddFontMemResourceEx; + FuncType_GdiRemoveFontMemResourceEx m_pGdiRemoveFontMemResourseEx; + protected: HMODULE m_hModule; HMODULE m_GdiModule; }; + class CWin32Platform { public: FX_BOOL m_bHalfTone; |