From 5f6e20d6a61bebb59252220cc056d10320ddb94b Mon Sep 17 00:00:00 2001 From: couriersud Date: Sat, 9 Apr 2016 22:19:17 +0200 Subject: [PATCH] Fix SDL build on linux: - removed inclusion of SDL headers in all headers. - replaced those by forward declarations and in one case by a wrapper class (for a typedef struct). - added -Wno-strict-prototypes to 7z build (gmake target) --- scripts/src/3rdparty.lua | 1 + src/osd/modules/osdwindow.h | 4 +- src/osd/modules/render/sdlglcontext.h | 1 + src/osd/sdl/osdsdl.h | 2 - src/osd/sdl/video.cpp | 5 +++ src/osd/sdl/video.h | 5 --- src/osd/sdl/window.cpp | 58 +++++++++++++++++++++++++-- src/osd/sdl/window.h | 41 ++++--------------- 8 files changed, 72 insertions(+), 45 deletions(-) diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index 662138a72e5..a404872fde4 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -327,6 +327,7 @@ project "7z" configuration { "gmake" } buildoptions_c { "-Wno-undef", + "-Wno-strict-prototypes", } configuration { "mingw*" } diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index 1031b4bce42..adb2c73b639 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -14,8 +14,8 @@ #include "osdhelper.h" #ifdef OSD_SDL -// standard SDL headers -#include "sdlinc.h" +// forward declaration +class SDL_Window; #endif //============================================================ diff --git a/src/osd/modules/render/sdlglcontext.h b/src/osd/modules/render/sdlglcontext.h index 5a284ef289d..9a3194582ac 100644 --- a/src/osd/modules/render/sdlglcontext.h +++ b/src/osd/modules/render/sdlglcontext.h @@ -13,6 +13,7 @@ #ifndef __SDL_GL_CONTEXT__ #define __SDL_GL_CONTEXT__ +#include "sdlinc.h" #include "modules/opengl/osd_opengl.h" class sdl_gl_context : public osd_gl_context diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index e0683980e75..e260846f2e8 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -3,8 +3,6 @@ #ifndef _osdsdl_h_ #define _osdsdl_h_ -#include "sdlinc.h" - #include "watchdog.h" #include "clifront.h" #include "modules/lib/osdobj_common.h" diff --git a/src/osd/sdl/video.cpp b/src/osd/sdl/video.cpp index 65d80d77432..ee58d7f7813 100644 --- a/src/osd/sdl/video.cpp +++ b/src/osd/sdl/video.cpp @@ -116,6 +116,11 @@ void sdl_osd_interface::video_exit() // sdlvideo_monitor_refresh //============================================================ +inline osd_rect SDL_Rect_to_osd_rect(const SDL_Rect &r) +{ + return osd_rect(r.x, r.y, r.w, r.h); +} + void sdl_monitor_info::refresh() { SDL_DisplayMode dmode; diff --git a/src/osd/sdl/video.h b/src/osd/sdl/video.h index 0d9d66a5e61..1c6993c0c0b 100644 --- a/src/osd/sdl/video.h +++ b/src/osd/sdl/video.h @@ -18,11 +18,6 @@ // TYPE DEFINITIONS //============================================================ -inline osd_rect SDL_Rect_to_osd_rect(const SDL_Rect &r) -{ - return osd_rect(r.x, r.y, r.w, r.h); -} - class sdl_monitor_info : public osd_monitor_info { public: diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index 18274b6ecb2..3c06b75333f 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -89,6 +89,14 @@ sdl_window_info *sdl_window_list; static sdl_window_info **last_window_ptr; +class SDL_DM_Wrapper +{ +public: + SDL_DisplayMode mode; +}; + + + // event handling static SDL_threadID main_threadid; static SDL_threadID window_threadid; @@ -488,7 +496,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_toggle_full_screen_wt ) if (window->fullscreen() && (video_config.switchres || is_osx)) { SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode - SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode + SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode->mode); // Try to set mode SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode } SDL_DestroyWindow(window->sdl_window()); @@ -673,7 +681,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt ) if (window->fullscreen() && video_config.switchres) { SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode - SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode + SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode->mode); // Try to set mode SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode } SDL_DestroyWindow(window->sdl_window()); @@ -967,7 +975,7 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt ) SDL_DisplayMode mode; //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode); SDL_GetWindowDisplayMode(window->sdl_window(), &mode); - window->m_original_mode = mode; + window->m_original_mode->mode = mode; mode.w = temp.width(); mode.h = temp.height(); if (window->m_win_config.refresh) @@ -1319,6 +1327,16 @@ osd_dim sdl_window_info::get_min_bounds(int constrain) return osd_dim(minwidth, minheight); } +//============================================================ +// get_size +//============================================================ + +osd_dim sdl_window_info::get_size() +{ + int w=0; int h=0; + SDL_GetWindowSize(m_sdl_window, &w, &h); + return osd_dim(w,h); +} //============================================================ @@ -1361,3 +1379,37 @@ osd_dim sdl_window_info::get_max_bounds(int constrain) return maximum.dim(); } + +//============================================================ +// construction and destruction +//============================================================ + +sdl_window_info::sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor, + const osd_window_config *config) +: osd_window(), m_next(NULL), + // Following three are used by input code to defer resizes + m_resize_width(0), + m_resize_height(0), + m_last_resize(0), + m_minimum_dim(0,0), + m_windowed_dim(0,0), + m_rendered_event(0), m_target(0), + m_sdl_window(NULL), + m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0) +{ + m_win_config = *config; + m_index = index; + + //FIXME: these should be per_window in config-> or even better a bit set + m_fullscreen = !video_config.windowed; + m_prescale = video_config.prescale; + + m_windowed_dim = osd_dim(config->width, config->height); + m_original_mode = global_alloc(SDL_DM_Wrapper); +} + +sdl_window_info::~sdl_window_info() +{ + global_free(m_renderer); + global_free(m_original_mode); +} diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 5e3e58f92ed..83b09e038cf 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -11,7 +11,6 @@ #ifndef __SDLWINDOW__ #define __SDLWINDOW__ -#include "sdlinc.h" #include "osdsdl.h" #include "video.h" @@ -24,6 +23,10 @@ // TYPE DEFINITIONS //============================================================ +// forward of SDL_DisplayMode not possible (typedef struct) - define wrapper + +class SDL_DM_Wrapper; + typedef uintptr_t HashT; #define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid) @@ -32,32 +35,9 @@ class sdl_window_info : public osd_window { public: sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor, - const osd_window_config *config) - : osd_window(), m_next(NULL), - // Following three are used by input code to defer resizes - m_resize_width(0), - m_resize_height(0), - m_last_resize(0), - m_minimum_dim(0,0), - m_windowed_dim(0,0), - m_rendered_event(0), m_target(0), - m_sdl_window(NULL), - m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0) - { - m_win_config = *config; - m_index = index; + const osd_window_config *config); - //FIXME: these should be per_window in config-> or even better a bit set - m_fullscreen = !video_config.windowed; - m_prescale = video_config.prescale; - - m_windowed_dim = osd_dim(config->width, config->height); - } - - ~sdl_window_info() - { - global_free(m_renderer); - } + ~sdl_window_info(); int window_init(); @@ -69,12 +49,7 @@ public: void notify_changed(); - osd_dim get_size() override - { - int w=0; int h=0; - SDL_GetWindowSize(m_sdl_window, &w, &h); - return osd_dim(w,h); - } + osd_dim get_size() override; int xy_to_render_target(int x, int y, int *xt, int *yt); @@ -112,7 +87,7 @@ private: // Needs to be here as well so we can identify window SDL_Window *m_sdl_window; // Original display_mode - SDL_DisplayMode m_original_mode; + SDL_DM_Wrapper *m_original_mode; int m_extra_flags;