From 538965b4ef3758b95e649462f8b129927983d964 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 5 Jun 2016 16:07:40 -0400 Subject: [PATCH] Fixed the MinGW ABI stuff again... --- windows/areautil.cpp | 2 +- windows/colordialog.cpp | 19 +++++++++++++++---- windows/d2dscratch.cpp | 2 +- windows/fontdialog.cpp | 4 ++-- windows/uipriv_windows.hpp | 2 ++ windows/winutil.cpp | 16 ++++++++++++++++ 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/windows/areautil.cpp b/windows/areautil.cpp index 8d2d7fc8..9dc72fbb 100644 --- a/windows/areautil.cpp +++ b/windows/areautil.cpp @@ -11,7 +11,7 @@ void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *heigh if (!a->scrolling) { if (rt == NULL) rt = a->rt; - size = rt->GetSize(); + size = realGetSize(rt); *width = size.width; *height = size.height; } diff --git a/windows/colordialog.cpp b/windows/colordialog.cpp index a8beca30..2efe72c8 100644 --- a/windows/colordialog.cpp +++ b/windows/colordialog.cpp @@ -309,7 +309,18 @@ static void drawGrid(ID2D1RenderTarget *rt, D2D1_RECT_F *fillRect) // mind the divisions; they represent the fact the original uses a viewport size.width = 100 / 10; size.height = 100 / 10; + // yay more ABI bugs +#ifdef _MSC_VER pformat = rt->GetPixelFormat(); +#else + { + typedef D2D1_PIXEL_FORMAT *(__stdcall ID2D1RenderTarget::* GetPixelFormatF)(D2D1_PIXEL_FORMAT *); + GetPixelFormatF gpf; + + gpf = (GetPixelFormatF) (&(rt->GetPixelFormat)); + (rt->*gpf)(&pformat); + } +#endif hr = rt->CreateCompatibleRenderTarget(&size, NULL, &pformat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &brt); @@ -383,7 +394,7 @@ static void drawSVChooser(struct colorDialog *c, ID2D1RenderTarget *rt) ID2D1SolidColorBrush *markerBrush; HRESULT hr; - size = rt->GetSize(); + size = realGetSize(rt); rect.left = 0; rect.top = 0; rect.right = size.width; @@ -625,7 +636,7 @@ static void drawHSlider(struct colorDialog *c, ID2D1RenderTarget *rt) D2D1_POINT_2F center; HRESULT hr; - size = rt->GetSize(); + size = realGetSize(rt); rect.left = size.width / 6; // leftmost sixth for arrow rect.top = 0; rect.right = size.width; @@ -712,7 +723,7 @@ static void drawPreview(struct colorDialog *c, ID2D1RenderTarget *rt) ID2D1SolidColorBrush *brush; HRESULT hr; - size = rt->GetSize(); + size = realGetSize(rt); rect.left = 0; rect.top = 0; rect.right = size.width; @@ -769,7 +780,7 @@ static void drawOpacitySlider(struct colorDialog *c, ID2D1RenderTarget *rt) D2D1_POINT_2F center; HRESULT hr; - size = rt->GetSize(); + size = realGetSize(rt); rect.left = 0; rect.top = 0; rect.right = size.width; diff --git a/windows/d2dscratch.cpp b/windows/d2dscratch.cpp index 63218adc..6dc2ba5f 100644 --- a/windows/d2dscratch.cpp +++ b/windows/d2dscratch.cpp @@ -56,7 +56,7 @@ static void d2dScratchDoLButtonDown(HWND hwnd, ID2D1RenderTarget *rt, LPARAM lPa pos.x = (xpix * 96) / dpix; pos.y = (ypix * 96) / dpiy; - size = rt->GetSize(); + size = realGetSize(rt); SendMessageW(hwnd, msgD2DScratchLButtonDown, (WPARAM) (&pos), (LPARAM) (&size)); } diff --git a/windows/fontdialog.cpp b/windows/fontdialog.cpp index c30230f0..603a17db 100644 --- a/windows/fontdialog.cpp +++ b/windows/fontdialog.cpp @@ -386,8 +386,8 @@ static void fontDialogDrawSampleText(struct fontDialog *f, ID2D1RenderTarget *rt rect.left = 0; rect.top = 0; - rect.right = rt->GetSize().width; - rect.bottom = rt->GetSize().height; + rect.right = realGetSize(rt).width; + rect.bottom = realGetSize(rt).height; rt->DrawText(sample, wcslen(sample), format, &rect, diff --git a/windows/uipriv_windows.hpp b/windows/uipriv_windows.hpp index 1a00bada..d33203f3 100644 --- a/windows/uipriv_windows.hpp +++ b/windows/uipriv_windows.hpp @@ -151,6 +151,8 @@ extern void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font); // graphemes.cpp extern size_t *graphemes(WCHAR *msg); +// TODO move into a dedicated file abibugs.cpp when we rewrite the drawing code +extern D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt); diff --git a/windows/winutil.cpp b/windows/winutil.cpp index 2faf8192..7f7716ac 100644 --- a/windows/winutil.cpp +++ b/windows/winutil.cpp @@ -136,3 +136,19 @@ void invalidateRect(HWND hwnd, RECT *r, BOOL erase) if (InvalidateRect(hwnd, r, erase) == 0) logLastError(L"error invalidating window rect"); } + +// that damn ABI bug is never going to escape me is it +D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt) +{ +#ifdef _MSC_VER + return rt->GetSize(); +#else + D2D1_SIZE_F size; + typedef D2D1_SIZE_F *(__stdcall ID2D1RenderTarget::* GetSizeF)(D2D1_SIZE_F *); + GetSizeF gs; + + gs = (GetSizeF) (&(rt->GetSize)); + (rt->*gs)(&size); + return size; +#endif +}