From 984e40296b159e41b829c0d1daecb130cc0536df Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 6 Feb 2015 01:13:55 +0100 Subject: [PATCH] Get rid of "resize" render method. (nw) --- src/osd/sdl/draw13.c | 32 +++++++------------------------- src/osd/sdl/drawbgfx.c | 10 ---------- src/osd/sdl/drawogl.c | 26 +++++++++++++------------- src/osd/sdl/drawsdl.c | 40 ++++++++++++++++++++-------------------- src/osd/sdl/window.c | 3 --- src/osd/sdl/window.h | 1 - 6 files changed, 40 insertions(+), 72 deletions(-) diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index 0faaf3009bc..2eb1b83b155 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -145,12 +145,11 @@ public: sdl_info13(sdl_window_info *w) : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL), m_last_hofs(0), m_last_vofs(0), - m_resize_pending(0), m_resize_width(0), m_resize_height(0), + m_last_width(0), m_last_height(0), m_last_blit_time(0), m_last_blit_pixels(0) {} /* virtual */ int create(const int width, const int height); - /* virtual */ void resize(const int width, const int height); /* virtual */ int draw(const UINT32 dc, const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy_all_textures(); @@ -177,11 +176,8 @@ public: float m_last_hofs; float m_last_vofs; - // resize information - - UINT8 m_resize_pending; - UINT32 m_resize_width; - UINT32 m_resize_height; + int m_last_width; + int m_last_height; // Stats INT64 m_last_blit_time; @@ -617,16 +613,6 @@ int sdl_info13::create(int width, int height) return 0; } -//============================================================ -// sdl_info::resize -//============================================================ - -void sdl_info13::resize(int width, int height) -{ - SDL_RenderSetViewport(m_sdl_renderer, NULL); - m_blittimer = 3; -} - //============================================================ // sdl_info::destroy @@ -695,17 +681,13 @@ int sdl_info13::draw(UINT32 dc, int update) return 0; } -#if 0 - if (m_resize_pending) + if ((window().width() != m_last_width) || (window().height() != m_last_height)) { - SDL_SetWindowSize(window().m_sdl_window, m_resize_width, m_resize_height); - SDL_GetWindowSize(window().m_sdl_window, &window().width(), &window().height()); - m_resize_pending = 0; + m_last_width = window().width(); + m_last_height = window().height(); SDL_RenderSetViewport(m_sdl_renderer, NULL); - //sdlvideo_monitor_refresh(window().monitor()); - + m_blittimer = 3; } -#endif //SDL_SelectRenderer(window().sdl_window); if (m_blittimer > 0) diff --git a/src/osd/sdl/drawbgfx.c b/src/osd/sdl/drawbgfx.c index 3a5a0c6fe69..2838f6e39d2 100644 --- a/src/osd/sdl/drawbgfx.c +++ b/src/osd/sdl/drawbgfx.c @@ -80,7 +80,6 @@ public: {} /* virtual */ int create(const int width, const int height); - /* virtual */ void resize(const int width, const int height); /* virtual */ int draw(const UINT32 dc, const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy_all_textures(); @@ -151,15 +150,6 @@ int sdl_info_bgfx::create(int width, int height) return 0; } -//============================================================ -// sdl_info_bgfx::resize -//============================================================ - -void sdl_info_bgfx::resize(int width, int height) -{ - m_blittimer = 3; -} - //============================================================ // drawsdl_xy_to_render_target //============================================================ diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index 930adcbc377..a0f638cd46e 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -224,6 +224,7 @@ public: sdl_info_ogl(sdl_window_info *window) : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0), m_screen_width(0), m_screen_height(0), + m_last_width(0), m_last_height(0), #if (SDLMAME_SDL2) m_gl_context_id(0), #else @@ -252,7 +253,6 @@ public: } /* virtual */ int create(const int width, const int height); - /* virtual */ void resize(const int width, int const height); /* virtual */ int draw(const UINT32 dc, const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy_all_textures(); @@ -280,6 +280,8 @@ public: INT32 m_blittimer; int m_screen_width; int m_screen_height; + int m_last_width; + int m_last_height; #if (SDLMAME_SDL2) SDL_GLContext m_gl_context_id; @@ -754,18 +756,6 @@ int sdl_info_ogl::create(int width, int height) return 0; } -//============================================================ -// sdl_info::resize -//============================================================ - -void sdl_info_ogl::resize(int width, int height) -{ -#if (SDLMAME_SDL2) - m_blittimer = 3; -#endif - m_init_context = 1; -} - //============================================================ // sdl_info::destroy @@ -1221,6 +1211,16 @@ int sdl_info_ogl::draw(UINT32 dc, int update) return 0; } + if ((window().width() != m_last_width) || (window().height() != m_last_height)) + { + m_last_width = window().width(); + m_last_height = window().height(); +#if (SDLMAME_SDL2) + m_blittimer = 3; +#endif + m_init_context = 1; + } + #if (SDLMAME_SDL2) SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); #else diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c index 840f5fa62d6..93391ef077b 100644 --- a/src/osd/sdl/drawsdl.c +++ b/src/osd/sdl/drawsdl.c @@ -65,11 +65,12 @@ public: m_last_hofs(0), m_last_vofs(0), m_old_blitwidth(0), - m_old_blitheight(0) + m_old_blitheight(0), + m_last_width(0), + m_last_height(0) { } /* virtual */ int create(const int width, const int height); - /* virtual */ void resize(const int width, const int height); /* virtual */ int draw(const UINT32 dc, const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy_all_textures(); @@ -107,6 +108,8 @@ public: int m_last_vofs; int m_old_blitwidth; int m_old_blitheight; + int m_last_width; + int m_last_height; }; struct sdl_scale_mode @@ -474,24 +477,6 @@ int sdl_info::create(int width, int height) return 0; } -//============================================================ -// sdl_info::resize -//============================================================ - -void sdl_info::resize(int width, int height) -{ -#if (SDLMAME_SDL2) - SDL_RenderSetViewport(m_sdl_renderer, NULL); -#else - const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; - if (sdl_sm->is_yuv) - { - yuv_overlay_init(); - } -#endif -} - - //============================================================ // sdl_info::destroy //============================================================ @@ -580,6 +565,21 @@ int sdl_info::draw(UINT32 dc, int update) return 0; } + if ((window().width() != m_last_width) || (window().height() != m_last_height)) + { + m_last_width = window().width(); + m_last_height = window().height(); +#if (SDLMAME_SDL2) + SDL_RenderSetViewport(m_sdl_renderer, NULL); +#else + const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; + if (sdl_sm->is_yuv) + { + yuv_overlay_init(); + } +#endif + } + // lock it if we need it #if (!SDLMAME_SDL2) diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 5bde6feecc5..95ab78b3cf4 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -491,9 +491,6 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_resize_wt ) window->m_height = window->m_sdlsurf->h; #endif - - window->renderer().resize(window->m_width, window->m_height); - window->blit_surface_size(window->m_width, window->m_height); window->clear(); diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 3c2167e6d1d..caee75265da 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -58,7 +58,6 @@ public: bool check_flag(const int flag) { return ((m_flags & flag)) == flag; } virtual int create(const int width, const int height) = 0; - virtual void resize(const int width, const int height) = 0; virtual int draw(const UINT32 dc, const int update) = 0; virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0; virtual void destroy_all_textures() = 0;