From 65aedbbcee63a7f9dc7fc90f65f51ddd319d9e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sat, 28 Jul 2018 23:41:16 +0200 Subject: [PATCH] win_d2d: moved to dev branch and made optional + fixes --- src/win/86Box.rc | 4 +++- src/win/Makefile.mingw | 19 +++++++++++++++++-- src/win/win.c | 7 +++++-- src/win/win_d2d.cpp | 26 ++++++++++++++++++++++++-- src/win/win_ui.c | 15 +++++++++++++-- 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 119257941..99440d661 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -8,7 +8,7 @@ * * Application resource script for Windows. * - * Version: @(#)86Box.rc 1.0.38 2018/07/19 + * Version: @(#)86Box.rc 1.0.39 2018/07/28 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -65,7 +65,9 @@ BEGIN POPUP "Re&nderer" BEGIN MENUITEM "&DirectDraw", IDM_VID_DDRAW +#ifdef USE_D2D MENUITEM "Direct&2D 1.0", IDM_VID_D2D +#endif MENUITEM "Direct&3D 9", IDM_VID_D3D MENUITEM "&SDL", IDM_VID_SDL #ifdef USE_VNC diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 405349dc5..30a1a9734 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -8,7 +8,7 @@ # # Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.120 2018/07/19 +# Version: @(#)Makefile.mingw 1.0.121 2018/07/28 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -41,6 +41,9 @@ ifeq ($(DEV_BUILD), y) ifndef CRASHDUMP CRASHDUMP := y endif + ifndef D2D + D2D := y + endif ifndef I686 I686 := y endif @@ -81,6 +84,9 @@ else ifndef CRASHDUMP CRASHDUMP := n endif + ifndef D2D + D2D := n + endif ifndef I686 I686 := n endif @@ -315,6 +321,12 @@ MUNTOBJ := midi_mt32.o \ Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o endif +ifeq ($(D2D), y) +OPTS += -DUSE_D2D +RFLAGS += -DUSE_D2D +D2DLIB := -ld2d1 +endif + ifeq ($(VNC), y) OPTS += -DUSE_VNC RFLAGS += -DUSE_VNC @@ -560,8 +572,11 @@ endif LIBS := -mwindows \ -lopenal.dll \ - -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 -ld2d1\ + -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \ -lcomctl32 -lwinmm +ifeq ($(D2D), y) +LIBS += $(D2DLIB) +endif ifeq ($(VNC), y) LIBS += $(VNCLIB) -lws2_32 endif diff --git a/src/win/win.c b/src/win/win.c index 68ac81093..cd7fc270d 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.51 2018/07/19 + * Version: @(#)win.c 1.0.52 2018/07/28 * * Authors: Sarah Walker, * Miran Grca, @@ -608,9 +608,11 @@ plat_vidapi_name(int api) #endif break; +#ifdef USE_D2D case 1: name = "d2d"; break; +#endif case 2: name = "d3d"; @@ -624,7 +626,6 @@ plat_vidapi_name(int api) case 4: name = "vnc"; break; - #endif } @@ -754,9 +755,11 @@ take_screenshot(void) ddraw_take_screenshot(path); break; +#ifdef USE_D2D case 1: /* d2d */ d2d_take_screenshot(path); break; +#endif case 2: /* d3d9 */ d3d_take_screenshot(path); diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index 548a34f64..a956c6e51 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct2D. * - * Version: @(#)win_d2d.cpp 1.0.0 2018/07/19 + * Version: @(#)win_d2d.cpp 1.0.1 2018/07/28 * * Authors: David Hrdlička, * @@ -21,8 +21,10 @@ #define UNICODE #define BITMAP WINDOWS_BITMAP #include +#ifdef USE_D2D #include #include +#endif #undef BITMAP #define PNG_DEBUG 0 @@ -38,12 +40,14 @@ #include "win_d2d.h" +#ifdef USE_D2D static HWND d2d_hwnd, old_hwndMain; static ID2D1Factory *d2d_factory; static ID2D1HwndRenderTarget *d2d_hwndRT; static ID2D1BitmapRenderTarget *d2d_btmpRT; static ID2D1Bitmap *d2d_bitmap; static int d2d_width, d2d_height, d2d_screen_width, d2d_screen_height, d2d_fs; +#endif #ifdef ENABLE_D2D_LOG @@ -66,6 +70,7 @@ d2d_log(const char *fmt, ...) } +#ifdef USE_D2D static void d2d_stretch(float *w, float *h, float *x, float *y) { @@ -161,8 +166,10 @@ d2d_stretch(float *w, float *h, float *x, float *y) break; } } +#endif +#ifdef USE_D2D static void d2d_blit(int x, int y, int y1, int y2, int w, int h) { @@ -177,7 +184,7 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h) float fs_x, fs_y; float fs_w = w; - float fs_h = h; + float fs_h = h; d2d_log("Direct2D: d2d_blit(x=%d, y=%d, y1=%d, y2=%d, w=%d, h=%d)\n", x, y, y1, y2, w, h); @@ -310,6 +317,7 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h) free(srcdata); srcdata = NULL; } +#endif void @@ -317,6 +325,7 @@ d2d_close(void) { d2d_log("Direct2D: d2d_close()\n"); +#ifdef USE_D2D if (d2d_bitmap) { d2d_bitmap->Release(); @@ -349,9 +358,11 @@ d2d_close(void) d2d_hwnd = NULL; old_hwndMain = NULL; } +#endif } +#ifdef USE_D2D static int d2d_init_common(int fs) { @@ -450,13 +461,19 @@ d2d_init_common(int fs) return(1); } +#endif int d2d_init(HWND h) { d2d_log("Direct2D: d2d_init(h=0x%08lx)\n", h); + +#ifdef USE_D2D return d2d_init_common(0); +#else + return(0); +#endif } @@ -464,7 +481,12 @@ int d2d_init_fs(HWND h) { d2d_log("Direct2D: d2d_init_fs(h=0x%08lx)\n", h); + +#ifdef USE_D2D return d2d_init_common(1); +#else + return(0); +#endif } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 735baa0a5..409a898e4 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,7 +8,7 @@ * * user Interface module for WinAPI on Windows. * - * Version: @(#)win_ui.c 1.0.29 2018/07/19 + * Version: @(#)win_ui.c 1.0.30 2018/07/28 * * Authors: Sarah Walker, * Miran Grca, @@ -113,6 +113,12 @@ ResetAllMenus(void) EnableMenuItem(menuMain, IDM_CONFIG_SAVE, MF_DISABLED); #endif +#ifdef USE_D2D + /* Disable Direct2D menu option on NT5 */ + if(LOBYTE(LOWORD(GetVersion())) < 6) + EnableMenuItem(menuMain, IDM_VID_D2D, MF_GRAYED); +#endif + CheckMenuItem(menuMain, IDM_ACTION_RCTRL_IS_LALT, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_UPDATE_ICONS, MF_UNCHECKED); @@ -147,10 +153,13 @@ ResetAllMenus(void) CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED); +#ifdef USE_D2D CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED); +#endif CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED); -#ifdef USE_VNC CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED); +#ifdef USE_VNC + CheckMenuItem(menuMain, IDM_VID_DDRAW+4, MF_UNCHECKED); #endif CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED); @@ -378,7 +387,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_VID_DDRAW: +#ifdef USE_D2D case IDM_VID_D2D: +#endif case IDM_VID_D3D: case IDM_VID_SDL: #ifdef USE_VNC