diff options
author | couriersud <couriersud@arcor.de> | 2015-02-22 16:39:25 +0100 |
---|---|---|
committer | couriersud <couriersud@arcor.de> | 2015-02-22 16:39:25 +0100 |
commit | 996a15bbd72c6eafcbf78c354cb2c3f426acd258 (patch) | |
tree | 02ef3cee44e398e3cf9708171a1f470b33f9cdba | |
parent | 9cb20c78aa0f17dc743749cf2404c838b8fd971d (diff) |
More alignment of code:
- HDC is passed differently to gdi renderer (the only one using it).
- Merged sdl_window_config and win_window_config into osd_window_config.
- Use osd_window_config instead of replicating individual member
variables in osd_window.
-rw-r--r-- | src/osd/sdl/draw13.c | 4 | ||||
-rw-r--r-- | src/osd/sdl/drawogl.c | 13 | ||||
-rw-r--r-- | src/osd/sdl/drawsdl.c | 4 | ||||
-rw-r--r-- | src/osd/sdl/video.c | 8 | ||||
-rw-r--r-- | src/osd/sdl/video.h | 8 | ||||
-rw-r--r-- | src/osd/sdl/window.c | 45 | ||||
-rw-r--r-- | src/osd/sdl/window.h | 25 | ||||
-rw-r--r-- | src/osd/windows/drawbgfx.c | 4 | ||||
-rw-r--r-- | src/osd/windows/drawd3d.c | 6 | ||||
-rw-r--r-- | src/osd/windows/drawd3d.h | 2 | ||||
-rw-r--r-- | src/osd/windows/drawdd.c | 8 | ||||
-rw-r--r-- | src/osd/windows/drawgdi.c | 6 | ||||
-rw-r--r-- | src/osd/windows/drawnone.c | 4 | ||||
-rw-r--r-- | src/osd/windows/video.c | 4 | ||||
-rw-r--r-- | src/osd/windows/video.h | 9 | ||||
-rw-r--r-- | src/osd/windows/window.c | 49 | ||||
-rw-r--r-- | src/osd/windows/window.h | 22 | ||||
-rw-r--r-- | src/osd/windows/winmenu.c | 2 |
18 files changed, 106 insertions, 117 deletions
diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index eb74488a78b..25579aa57c3 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -151,7 +151,7 @@ public: {} /* virtual */ int create(); - /* virtual */ int draw(const UINT32 dc, const int update); + /* virtual */ int draw(const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy(); /* virtual */ render_primitive_list *get_primitives() @@ -677,7 +677,7 @@ void sdl_info13::destroy_all_textures() // sdl_info::draw //============================================================ -int sdl_info13::draw(UINT32 dc, int update) +int sdl_info13::draw(int update) { render_primitive *prim; texture_info *texture=NULL; diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index e10900ea7a1..47dacb01aa9 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -290,11 +290,8 @@ public: } /* virtual */ int create(); -#ifdef OSD_WINDOWS - /* virtual */ int draw(const HDC dc, const int update); -#else - /* virtual */ int draw(const UINT32 dc, const int update); -#endif + /* virtual */ int draw(const int update); + /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy(); /* virtual */ render_primitive_list *get_primitives() @@ -1327,11 +1324,7 @@ void sdl_info_ogl::loadGLExtensions() // sdl_info::draw //============================================================ -#ifdef OSD_WINDOWS -int sdl_info_ogl::draw(const HDC dc, const int update) -#else -int sdl_info_ogl::draw(const UINT32 dc, const int update) -#endif +int sdl_info_ogl::draw(const int update) { render_primitive *prim; texture_info *texture=NULL; diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c index 8d5ab1199b8..1c626696ce4 100644 --- a/src/osd/sdl/drawsdl.c +++ b/src/osd/sdl/drawsdl.c @@ -71,7 +71,7 @@ public: { } /* virtual */ int create(); - /* virtual */ int draw(const UINT32 dc, const int update); + /* virtual */ int draw(const int update); /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); /* virtual */ void destroy(); /* virtual */ render_primitive_list *get_primitives() @@ -555,7 +555,7 @@ void sdl_info::destroy_all_textures() // sdl_info::draw //============================================================ -int sdl_info::draw(UINT32 dc, int update) +int sdl_info::draw(int update) { const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; UINT8 *surfptr; diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index a3cabd43f3d..a5d3310bb25 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -83,7 +83,7 @@ sdl_monitor_info *sdl_monitor_info::list = NULL; static void check_osd_inputs(running_machine &machine); static float get_aspect(const char *defdata, const char *data, int report_error); -static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error); +static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error); //============================================================ @@ -110,7 +110,7 @@ bool sdl_osd_interface::video_init() // create the windows for (index = 0; index < video_config.numscreens; index++) { - sdl_window_config conf; + osd_window_config conf; memset(&conf, 0, sizeof(conf)); get_resolution(options().resolution(), options().resolution(index), &conf, TRUE); @@ -215,7 +215,7 @@ void sdl_monitor_info::refresh() static int first_call=0; static int cw = 0, ch = 0; - SDL_VideoDriverName(m_monitor_device, ARRAY_LENGTH(m_name) - 1); + SDL_VideoDriverName(m_name, ARRAY_LENGTH(m_name) - 1); if (first_call==0) { const char *dimstr = osd_getenv(SDLENV_DESKTOPDIM); @@ -779,7 +779,7 @@ static float get_aspect(const char *defdata, const char *data, int report_error) // get_resolution //============================================================ -static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error) +static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error) { config->width = config->height = config->depth = config->refresh = 0; if (strcmp(data, OSDOPTVAL_AUTO) == 0) diff --git a/src/osd/sdl/video.h b/src/osd/sdl/video.h index a8e4e0d4794..fc601eb48ce 100644 --- a/src/osd/sdl/video.h +++ b/src/osd/sdl/video.h @@ -108,12 +108,14 @@ private: }; -struct sdl_window_config +struct osd_window_config { - float aspect; // decoded aspect ratio + osd_window_config() : aspect(0.0f), width(0), height(0), depth(0), refresh(0) {} + + float aspect; // decoded aspect ratio FIXME: not used on windows int width; // decoded width int height; // decoded height - int depth; // decoded depth + int depth; // decoded depth - only SDL int refresh; // decoded refresh }; diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 13cc5f84e1f..3ec98f5787d 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -894,12 +894,12 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight) size_score *= 0.1f; // if we're looking for a particular mode, that's a winner - if (mode.w == m_maxwidth && mode.h == m_maxheight) + if (mode.w == m_win_config.width && mode.h == m_win_config.height) size_score = 2.0f; // refresh adds some points - if (m_refresh) - size_score *= 1.0f / (1.0f + fabsf(m_refresh - mode.refresh_rate) / 10.0f); + if (m_win_config.refresh) + size_score *= 1.0f / (1.0f + fabsf(m_win_config.refresh - mode.refresh_rate) / 10.0f); osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score); @@ -953,8 +953,8 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight) } else if (modes == (SDL_Rect **)-1) // all modes are possible { - *fswidth = m_maxwidth; - *fsheight = m_maxheight; + *fswidth = m_win_config.width; + *fsheight = m_win_config.height; } else { @@ -972,7 +972,7 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight) size_score *= 0.1f; // if we're looking for a particular mode, that's a winner - if (modes[i]->w == m_maxwidth && modes[i]->h == m_maxheight) + if (modes[i]->w == m_win_config.width && modes[i]->h == m_win_config.height) size_score = 2.0f; osd_printf_verbose("%4dx%4d -> %f\n", (int)modes[i]->w, (int)modes[i]->h, size_score); @@ -1120,8 +1120,8 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt ) instead of letting sdlwindow_blit_surface_size() resize it this stops the window from "flashing" from the wrong aspect size to the right one at startup. */ - tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640; - tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480; + tempwidth = (window->m_win_config.width != 0) ? window->m_win_config.width : 640; + tempheight = (window->m_win_config.height != 0) ? window->m_win_config.height : 480; window->get_min_bounds(&tempwidth, &tempheight, video_config.keepaspect ); } @@ -1187,8 +1187,8 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt ) window->m_original_mode = mode; mode.w = tempwidth; mode.h = tempheight; - if (window->m_refresh) - mode.refresh_rate = window->m_refresh; + if (window->m_win_config.refresh) + mode.refresh_rate = window->m_win_config.refresh; SDL_SetWindowDisplayMode(window->sdl_window(), &mode); // Try to set mode #ifndef SDLMAME_WIN32 @@ -1266,7 +1266,7 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt ) // (window thread) //============================================================ -void sdl_window_info::measure_fps(UINT32 dc, int update) +void sdl_window_info::measure_fps(int update) { const unsigned long frames_skip4fps = 100; static int64_t lastTime=0, sumdt=0, startTime=0; @@ -1281,7 +1281,7 @@ void sdl_window_info::measure_fps(UINT32 dc, int update) t0 = osd_ticks(); - renderer().draw(dc, update); + renderer().draw(update); frames++; currentTime = osd_ticks(); @@ -1310,7 +1310,6 @@ void sdl_window_info::measure_fps(UINT32 dc, int update) OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt ) { - UINT32 dc = 0; int update = 1; worker_param *wp = (worker_param *) param; sdl_window_info *window = wp->window(); @@ -1357,9 +1356,9 @@ OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt ) else { if( video_config.perftest ) - window->measure_fps(dc, update); + window->measure_fps(update); else - window->renderer().draw(dc, update); + window->renderer().draw(update); } /* all done, ready for next */ @@ -1432,10 +1431,10 @@ void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_h else { // further clamp to the maximum width/height in the window - if (this->m_maxwidth != 0) - maxwidth = MIN(maxwidth, this->m_maxwidth + extrawidth); - if (this->m_maxheight != 0) - maxheight = MIN(maxheight, this->m_maxheight + extraheight); + if (this->m_win_config.width != 0) + maxwidth = MIN(maxwidth, this->m_win_config.width + extrawidth); + if (this->m_win_config.height != 0) + maxheight = MIN(maxheight, this->m_win_config.height + extraheight); } // clamp to the maximum @@ -1514,15 +1513,15 @@ void sdl_window_info::get_max_bounds(int *window_width, int *window_height, int maxheight = m_monitor->position_size().h; // clamp to the window's max - if (this->m_maxwidth != 0) + if (this->m_win_config.width != 0) { - int temp = this->m_maxwidth + WINDOW_DECORATION_WIDTH; + int temp = this->m_win_config.width + WINDOW_DECORATION_WIDTH; if (temp < maxwidth) maxwidth = temp; } - if (this->m_maxheight != 0) + if (this->m_win_config.height != 0) { - int temp = this->m_maxheight + WINDOW_DECORATION_HEIGHT; + int temp = this->m_win_config.height + WINDOW_DECORATION_HEIGHT; if (temp < maxheight) maxheight = temp; } diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 5460789702b..8c10c9130e8 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -49,9 +49,7 @@ public: : #ifdef OSD_SDL #else - m_hwnd(0), m_focus_hwnd(0), m_resize_state(0), - m_maxwidth(0), m_maxheight(0), - m_refresh(0), + m_hwnd(0), m_dc(0), m_focus_hwnd(0), m_resize_state(0), #endif m_prescale(1), m_primlist(NULL) @@ -84,15 +82,15 @@ public: // window handle and info HWND m_hwnd; + HDC m_dc; // only used by GDI renderer! // FIXME: this is the same as win_window_list->m_hwnd, i.e. first window. // During modularization, this should be passed in differently HWND m_focus_hwnd; int m_resize_state; - int m_maxwidth, m_maxheight; - int m_refresh; #endif + osd_window_config m_win_config; int m_prescale; render_primitive_list *m_primlist; }; @@ -106,11 +104,9 @@ public: static const int FLAG_NEEDS_OPENGL = 0x0001; static const int FLAG_HAS_VECTOR_SCREEN = 0x0002; -#if (!(SDLMAME_SDL2)) /* SDL 1.2 flags */ static const int FLAG_NEEDS_DOUBLEBUF = 0x0100; static const int FLAG_NEEDS_ASYNCBLIT = 0x0200; -#endif osd_renderer(osd_window *window, const int flags) : m_window(window), m_flags(flags) { } @@ -130,11 +126,10 @@ public: virtual int create() = 0; virtual render_primitive_list *get_primitives() = 0; + virtual int draw(const int update) = 0; #ifdef OSD_SDL - 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; #else - virtual int draw(HDC dc, int update) = 0; virtual void save() = 0; virtual void record() = 0; virtual void toggle_fsfx() = 0; @@ -158,7 +153,7 @@ class sdl_window_info : public osd_window { public: sdl_window_info(running_machine &a_machine, int index, sdl_monitor_info *a_monitor, - const sdl_window_config *config) + const osd_window_config *config) : osd_window(), m_next(NULL), // Following three are used by input code to defer resizes #if (SDLMAME_SDL2) @@ -176,10 +171,7 @@ public: #endif m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0) { - m_maxwidth = config->width; - m_maxheight = config->height; - m_depth = config->depth; - m_refresh = config->refresh; + m_win_config = *config; m_index = index; //FIXME: these should be per_window in config-> or even better a bit set @@ -247,9 +239,6 @@ private: // diverse flags int m_minwidth, m_minheight; - int m_maxwidth, m_maxheight; - int m_refresh; - int m_depth; int m_windowed_width; int m_windowed_height; @@ -303,7 +292,7 @@ private: static OSDWORK_CALLBACK( notify_changed_wt ); static OSDWORK_CALLBACK( update_cursor_state_wt ); - void measure_fps(UINT32 dc, int update); + void measure_fps(int update); }; diff --git a/src/osd/windows/drawbgfx.c b/src/osd/windows/drawbgfx.c index b6d18f088a3..9457981052a 100644 --- a/src/osd/windows/drawbgfx.c +++ b/src/osd/windows/drawbgfx.c @@ -32,7 +32,7 @@ public: virtual int create(); virtual render_primitive_list *get_primitives(); - virtual int draw(HDC dc, int update); + virtual int draw(int update); virtual void save() {}; virtual void record() {}; virtual void toggle_fsfx() {}; @@ -134,7 +134,7 @@ render_primitive_list *renderer_bgfx::get_primitives() // drawbgfx_window_draw //============================================================ -int renderer_bgfx::draw(HDC dc, int update) +int renderer_bgfx::draw(int update) { RECT client; GetClientRect(window().m_hwnd, &client); diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 69dd4f9d28e..d1d209a101c 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -287,7 +287,7 @@ int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks) // drawd3d_window_draw //============================================================ -int d3d::renderer::draw(HDC dc, int update) +int d3d::renderer::draw(const int update) { int check = pre_window_draw_check(); if (check >= 0) @@ -1334,7 +1334,7 @@ void renderer::pick_best_mode() size_score *= 0.1f; // if we're looking for a particular mode, that's a winner - if (mode.Width == window().m_maxwidth && mode.Height == window().m_maxheight) + if (mode.Width == window().m_win_config.width && mode.Height == window().m_win_config.height) size_score = 2.0f; // compute refresh score @@ -1345,7 +1345,7 @@ void renderer::pick_best_mode() refresh_score *= 0.1f; // if we're looking for a particular refresh, make sure it matches - if (mode.RefreshRate == window().m_refresh) + if (mode.RefreshRate == window().m_win_config.refresh) refresh_score = 2.0f; // weight size and refresh equally diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h index a7f7d0ea5fc..146e8d4a385 100644 --- a/src/osd/windows/drawd3d.h +++ b/src/osd/windows/drawd3d.h @@ -104,7 +104,7 @@ public: virtual int create(); virtual render_primitive_list *get_primitives(); - virtual int draw(HDC dc, int update); + virtual int draw(const int update); virtual void save(); virtual void record(); virtual void toggle_fsfx(); diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c index fae3c9ebf14..195a3190573 100644 --- a/src/osd/windows/drawdd.c +++ b/src/osd/windows/drawdd.c @@ -65,7 +65,7 @@ public: virtual int create(); virtual render_primitive_list *get_primitives(); - virtual int draw(HDC dc, int update); + virtual int draw(const int update); virtual void save() {}; virtual void record() {}; virtual void toggle_fsfx() {}; @@ -310,7 +310,7 @@ render_primitive_list *renderer_dd::get_primitives() // drawdd_window_draw //============================================================ -int renderer_dd::draw(HDC dc, int update) +int renderer_dd::draw(const int update) { render_primitive *prim; int usemembuffer = FALSE; @@ -1226,7 +1226,7 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) size_score *= 0.1f; // if we're looking for a particular mode, that's a winner - if (desc->dwWidth == einfo->window->m_maxwidth && desc->dwHeight == einfo->window->m_maxheight) + if (desc->dwWidth == einfo->window->m_win_config.width && desc->dwHeight == einfo->window->m_win_config.height) size_score = 2.0f; // compute refresh score @@ -1237,7 +1237,7 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) refresh_score *= 0.1f; // if we're looking for a particular refresh, make sure it matches - if (desc->dwRefreshRate == einfo->window->m_refresh) + if (desc->dwRefreshRate == einfo->window->m_win_config.refresh) refresh_score = 2.0f; // weight size and refresh equally diff --git a/src/osd/windows/drawgdi.c b/src/osd/windows/drawgdi.c index b06c4fad45c..86baf429202 100644 --- a/src/osd/windows/drawgdi.c +++ b/src/osd/windows/drawgdi.c @@ -32,7 +32,7 @@ public: virtual int create(); virtual render_primitive_list *get_primitives(); - virtual int draw(HDC dc, int update); + virtual int draw(const int update); virtual void save() {}; virtual void record() {}; virtual void toggle_fsfx() {}; @@ -143,7 +143,7 @@ render_primitive_list *renderer_gdi::get_primitives() // drawgdi_window_draw //============================================================ -int renderer_gdi::draw(HDC dc, int update) +int renderer_gdi::draw(const int update) { int width, height, pitch; RECT bounds; @@ -178,7 +178,7 @@ int renderer_gdi::draw(HDC dc, int update) bminfo.bmiHeader.biHeight = -height; // blit to the screen - StretchDIBits(dc, 0, 0, width, height, + StretchDIBits(window().m_dc, 0, 0, width, height, 0, 0, width, height, bmdata, &bminfo, DIB_RGB_COLORS, SRCCOPY); return 0; diff --git a/src/osd/windows/drawnone.c b/src/osd/windows/drawnone.c index 7221d82cd19..ee7bc229935 100644 --- a/src/osd/windows/drawnone.c +++ b/src/osd/windows/drawnone.c @@ -27,7 +27,7 @@ public: virtual int create(); virtual render_primitive_list *get_primitives(); - virtual int draw(HDC dc, int update); + virtual int draw(const int update); virtual void save() { }; virtual void record() { }; virtual void toggle_fsfx() { }; @@ -116,7 +116,7 @@ render_primitive_list *renderer_none::get_primitives() // drawnone_window_draw //============================================================ -int renderer_none::draw(HDC dc, int update) +int renderer_none::draw(const int update) { return 0; } diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index adcb8a04918..5db095cff99 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -56,7 +56,7 @@ static win_monitor_info *pick_monitor(windows_options &options, int index); static void check_osd_inputs(running_machine &machine); static float get_aspect(const char *defdata, const char *data, int report_error); -static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error); +static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error); @@ -443,7 +443,7 @@ static float get_aspect(const char *defdata, const char *data, int report_error) // get_resolution //============================================================ -static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error) +static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error) { config->width = config->height = config->refresh = 0; if (strcmp(data, OSDOPTVAL_AUTO) == 0) diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index 1f218f27f08..5cd54455213 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -68,11 +68,14 @@ private: }; -struct win_window_config +struct osd_window_config { - float aspect; // decoded aspect ratio FIXME:Not used! + osd_window_config() : aspect(0.0f), width(0), height(0), depth(0), refresh(0) {} + + float aspect; // decoded aspect ratio FIXME: not used on windows int width; // decoded width int height; // decoded height + int depth; // decoded depth - only SDL int refresh; // decoded refresh }; @@ -87,7 +90,7 @@ struct win_video_config render_layer_config layerconfig; // default configuration of layers // per-window configuration - win_window_config window[MAX_WINDOWS]; // configuration data per-window + osd_window_config window[MAX_WINDOWS]; // configuration data per-window // hardware options int mode; // output mode diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 336feb5cc1c..5ff7669cd9a 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -121,7 +121,6 @@ static HANDLE window_thread_ready_event; //============================================================ static void winwindow_video_window_destroy(win_window_info *window); -static void draw_video_contents(win_window_info *window, HDC dc, int update); static unsigned __stdcall thread_entry(void *param); static int complete_create(win_window_info *window); @@ -660,7 +659,7 @@ void winwindow_update_cursor_state(running_machine &machine) // (main thread) //============================================================ -void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const win_window_config *config) +void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const osd_window_config *config) { win_window_info *window, *win; @@ -669,9 +668,7 @@ void winwindow_video_window_create(running_machine &machine, int index, win_moni // allocate a new window object window = global_alloc(win_window_info(machine)); //printf("%d, %d\n", config->width, config->height); - window->m_maxwidth = config->width; - window->m_maxheight = config->height; - window->m_refresh = config->refresh; + window->m_win_config = *config; window->m_monitor = monitor; window->m_fullscreen = !video_config.windowed; @@ -1213,8 +1210,8 @@ static int complete_create(win_window_info *window) return 0; // adjust the window position to the initial width/height - tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640; - tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480; + tempwidth = (window->m_win_config.width != 0) ? window->m_win_config.width : 640; + tempheight = (window->m_win_config.height != 0) ? window->m_win_config.height : 480; SetWindowPos(window->m_hwnd, NULL, monitorbounds.left + 20, monitorbounds.top + 20, monitorbounds.left + tempwidth + wnd_extra_width(window), monitorbounds.top + tempheight + wnd_extra_height(window), @@ -1252,7 +1249,7 @@ static int complete_create(win_window_info *window) // (window thread) //============================================================ -LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) +LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) { LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA); win_window_info *window = (win_window_info *)ptr; @@ -1272,7 +1269,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar { PAINTSTRUCT pstruct; HDC hdc = BeginPaint(wnd, &pstruct); - draw_video_contents(window, hdc, TRUE); + window->draw_video_contents(hdc, TRUE); if (window->win_has_menu()) DrawMenuBar(window->m_hwnd); EndPaint(wnd, &pstruct); @@ -1421,7 +1418,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW begin"); window->m_primlist = (render_primitive_list *)lparam; - draw_video_contents(window, hdc, FALSE); + window->draw_video_contents(hdc, FALSE); mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW end"); ReleaseDC(wnd, hdc); @@ -1470,36 +1467,38 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar // (window thread) //============================================================ -static void draw_video_contents(win_window_info *window, HDC dc, int update) +void win_window_info::draw_video_contents(HDC dc, int update) { assert(GetCurrentThreadId() == window_threadid); mtlog_add("draw_video_contents: begin"); mtlog_add("draw_video_contents: render lock acquire"); - osd_lock_acquire(window->m_render_lock); + osd_lock_acquire(m_render_lock); mtlog_add("draw_video_contents: render lock acquired"); // if we're iconic, don't bother - if (window->m_hwnd != NULL && !IsIconic(window->m_hwnd)) + if (m_hwnd != NULL && !IsIconic(m_hwnd)) { // if no bitmap, just fill - if (window->m_primlist == NULL) + if (m_primlist == NULL) { RECT fill; - GetClientRect(window->m_hwnd, &fill); + GetClientRect(m_hwnd, &fill); FillRect(dc, &fill, (HBRUSH)GetStockObject(BLACK_BRUSH)); } // otherwise, render with our drawing system else { - window->m_renderer->draw(dc, update); + // update DC + m_dc = dc; + m_renderer->draw(update); mtlog_add("draw_video_contents: drawing finished"); } } - osd_lock_release(window->m_render_lock); + osd_lock_release(m_render_lock); mtlog_add("draw_video_contents: render lock released"); mtlog_add("draw_video_contents: end"); @@ -1575,10 +1574,10 @@ static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int a maxheight = rect_height(&monitor->usuable_position_size()) - extraheight; // further clamp to the maximum width/height in the window - if (window->m_maxwidth != 0) - maxwidth = MIN(maxwidth, window->m_maxwidth + extrawidth); - if (window->m_maxheight != 0) - maxheight = MIN(maxheight, window->m_maxheight + extraheight); + if (window->m_win_config.width != 0) + maxwidth = MIN(maxwidth, window->m_win_config.width + extrawidth); + if (window->m_win_config.height != 0) + maxheight = MIN(maxheight, window->m_win_config.height + extraheight); } // clamp to the maximum @@ -1703,15 +1702,15 @@ static void get_max_bounds(win_window_info *window, RECT *bounds, int constrain) maximum = window->m_monitor->usuable_position_size(); // clamp to the window's max - if (window->m_maxwidth != 0) + if (window->m_win_config.width != 0) { - int temp = window->m_maxwidth + wnd_extra_width(window); + int temp = window->m_win_config.width + wnd_extra_width(window); if (temp < rect_width(&maximum)) maximum.right = maximum.left + temp; } - if (window->m_maxheight != 0) + if (window->m_win_config.height != 0) { - int temp = window->m_maxheight + wnd_extra_height(window); + int temp = window->m_win_config.height + wnd_extra_height(window); if (temp < rect_height(&maximum)) maximum.bottom = maximum.top + temp; } diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index 55cb074babb..882f0aef00d 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -49,9 +49,7 @@ public: : #ifdef OSD_SDL #else - m_hwnd(0), m_focus_hwnd(0), m_resize_state(0), - m_maxwidth(0), m_maxheight(0), - m_refresh(0), + m_hwnd(0), m_dc(0), m_focus_hwnd(0), m_resize_state(0), #endif m_prescale(1), m_primlist(NULL) @@ -84,15 +82,15 @@ public: // window handle and info HWND m_hwnd; + HDC m_dc; // only used by GDI renderer! // FIXME: this is the same as win_window_list->m_hwnd, i.e. first window. // During modularization, this should be passed in differently HWND m_focus_hwnd; int m_resize_state; - int m_maxwidth, m_maxheight; - int m_refresh; #endif + osd_window_config m_win_config; int m_prescale; render_primitive_list * m_primlist; }; @@ -128,11 +126,10 @@ public: virtual int create() = 0; virtual render_primitive_list *get_primitives() = 0; + virtual int draw(const int update) = 0; #ifdef OSD_SDL - 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; #else - virtual int draw(HDC dc, int update) = 0; virtual void save() = 0; virtual void record() = 0; virtual void toggle_fsfx() = 0; @@ -180,6 +177,12 @@ public: win_monitor_info *monitor() const { return m_monitor; } + // static callbacks + + static LRESULT CALLBACK video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); + + // member variables + win_window_info * m_next; volatile int m_init_state; @@ -212,6 +215,8 @@ public: osd_renderer * m_renderer; private: + void draw_video_contents(HDC dc, int update); + running_machine & m_machine; }; @@ -237,12 +242,11 @@ extern win_window_info *win_window_list; //============================================================ // creation/deletion of windows -void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const win_window_config *config); +void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const osd_window_config *config); BOOL winwindow_has_focus(void); void winwindow_update_cursor_state(running_machine &machine); -LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); void winwindow_toggle_full_screen(void); diff --git a/src/osd/windows/winmenu.c b/src/osd/windows/winmenu.c index b73e7b567ac..a1f6aab2427 100644 --- a/src/osd/windows/winmenu.c +++ b/src/osd/windows/winmenu.c @@ -21,7 +21,7 @@ LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) { - return winwindow_video_window_proc(wnd, message, wparam, lparam); + return win_window_info::video_window_proc(wnd, message, wparam, lparam); } //============================================================ |