Previous 199869 Revisions Next

r34974 Sunday 8th February, 2015 at 23:21:28 UTC by Couriersud
Identified window properties/variables which are used by renderers.
Althought the code in window.h is far from nice currently it now allows
to address one issue after the other. (nw)
[src/osd/sdl]window.h
[src/osd/windows]drawbgfx.c drawd3d.c drawd3d.h drawdd.c drawgdi.c drawnone.c input.c window.c window.h

trunk/src/osd/sdl/window.h
r243485r243486
3232//  TYPE DEFINITIONS
3333//============================================================
3434
35class sdl_window_info;
35class osd_window
36{
37public:
38   osd_window()
39   :      m_primlist(NULL),
40      m_start_viewscreen(0)
41       {}
42   virtual ~osd_window() { }
43#ifdef OSD_SDL
44   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
45   virtual sdl_monitor_info *monitor() const = 0;
46   virtual render_target *target() = 0;
47   virtual void get_size(int &w, int &h) = 0;
48   virtual int fullscreen() const = 0;
49   virtual int index() const = 0;
50   virtual int prescale() const = 0;
51#if (SDLMAME_SDL2)
52   virtual SDL_Window *sdl_window() = 0;
53#else
54   virtual SDL_Surface *sdl_surface() = 0;
55#endif
3656
57   virtual running_machine &machine() const = 0;
58
59   render_primitive_list *m_primlist;
60   int                 m_start_viewscreen;
61
62#endif
63};
64
3765class osd_renderer
3866{
3967public:
r243485r243486
4876   static const int FLAG_NEEDS_ASYNCBLIT       = 0x0200;
4977#endif
5078
51   osd_renderer(sdl_window_info *window, const int flags)
79   osd_renderer(osd_window *window, const int flags)
5280   : m_window(window), m_flags(flags) { }
5381
5482   virtual ~osd_renderer() { }
5583
56   sdl_window_info &window() { return *m_window; }
84   osd_window &window() { return *m_window; }
5785   int flags() const { return m_flags; }
5886   bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
5987
r243485r243486
6290   /* Interface to be implemented by render code */
6391
6492   virtual int create() = 0;
93   virtual render_primitive_list *get_primitives() = 0;
94
95#ifdef OSD_SDL
6596   virtual int draw(const UINT32 dc, const int update) = 0;
66   virtual render_primitive_list *get_primitives() = 0;
6797   virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0;
98#else
99   virtual int draw(HDC dc, int update) = 0;
100   virtual void save() = 0;
101   virtual void record() = 0;
102   virtual void toggle_fsfx() = 0;
103#endif
104
68105   virtual void destroy() = 0;
69106
70107protected:
r243485r243486
76113
77114private:
78115
79   sdl_window_info *m_window;
116   osd_window      *m_window;
80117   int m_flags;
81118};
82119
83120#define OSDWORK_CALLBACK(name)  void *name(void *param, ATTR_UNUSED int threadid)
84121
85class sdl_window_info
122class sdl_window_info : public osd_window
86123{
87124public:
88125   sdl_window_info(running_machine &a_machine, int index, sdl_monitor_info *a_monitor,
89126         const sdl_window_config *config)
90   : m_next(NULL), m_primlist(NULL),
91      m_start_viewscreen(0),
127   : osd_window(), m_next(NULL),
92128      // Following three are used by input code to defer resizes
93129#if (SDLMAME_SDL2)
94130      m_resize_width(0),
r243485r243486
164200   // Pointer to next window
165201   sdl_window_info *   m_next;
166202
167   // FIXME: renderer should deal with this
168   render_primitive_list *m_primlist;
169   int                 m_start_viewscreen;
170203#if (SDLMAME_SDL2)
171204   // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
172205   int                 m_resize_width;
trunk/src/osd/windows/drawbgfx.c
r243485r243486
3030
3131   virtual ~renderer_bgfx() { }
3232
33   virtual int init();
33   virtual int create();
3434   virtual render_primitive_list *get_primitives();
3535   virtual int draw(HDC dc, int update);
3636   virtual void save() {};
r243485r243486
8787//  drawbgfx_window_init
8888//============================================================
8989
90int renderer_bgfx::init()
90int renderer_bgfx::create()
9191{
9292   RECT client;
9393   GetClientRect(window().m_hwnd, &client);
r243485r243486
124124{
125125   RECT client;
126126   GetClientRect(window().m_hwnd, &client);
127   window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
128   return &window().m_target->get_primitives();
127   window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
128   return &window().target()->get_primitives();
129129}
130130
131131
trunk/src/osd/windows/drawd3d.c
r243485r243486
184184//  drawd3d_window_init
185185//============================================================
186186
187int d3d::renderer::init()
187int d3d::renderer::create()
188188{
189189   if (!initialize())
190190   {
r243485r243486
244244{
245245   RECT client;
246246
247   GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
247   GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
248248   if (rect_width(&client) > 0 && rect_height(&client) > 0)
249249   {
250      window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
251      window().m_target->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh());
250      window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
251      window().target()->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh());
252252   }
253   return &window().m_target->get_primitives();
253   return &window().target()->get_primitives();
254254}
255255
256256//============================================================
r243485r243486
468468   osd_printf_verbose("Direct3D: YUV format = %s\n", (m_yuv_format == D3DFMT_YUY2) ? "YUY2" : (m_yuv_format == D3DFMT_UYVY) ? "UYVY" : "RGB");
469469
470470   // set the max texture size
471   d3d->window().m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height);
471   d3d->window().target()->set_max_texture_size(m_texture_max_width, m_texture_max_height);
472472   osd_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height);
473473}
474474
r243485r243486
644644      return false;
645645
646646   // create the device immediately for the full screen case (defer for window mode)
647   if (window().m_fullscreen && device_create())
647   if (window().fullscreen() && device_create())
648648      return false;
649649
650650   return true;
r243485r243486
678678   }
679679
680680   // in window mode, we need to track the window size
681   if (!window().m_fullscreen || m_device == NULL)
681   if (!window().fullscreen() || m_device == NULL)
682682   {
683683      // if the size changes, skip this update since the render target will be out of date
684684      if (update_window_size())
r243485r243486
866866   m_presentation.MultiSampleType               = D3DMULTISAMPLE_NONE;
867867   m_presentation.SwapEffect                    = D3DSWAPEFFECT_DISCARD;
868868   m_presentation.hDeviceWindow                 = window().m_hwnd;
869   m_presentation.Windowed                      = !window().m_fullscreen || win_has_menu(&window());
869   m_presentation.Windowed                      = !window().fullscreen() || window().win_has_menu();
870870   m_presentation.EnableAutoDepthStencil        = FALSE;
871871   m_presentation.AutoDepthStencilFormat        = D3DFMT_D16;
872872   m_presentation.Flags                         = 0;
873873   m_presentation.FullScreen_RefreshRateInHz    = m_refresh;
874   m_presentation.PresentationInterval          = ((video_config.triplebuf && window().m_fullscreen) ||
874   m_presentation.PresentationInterval          = ((video_config.triplebuf && window().fullscreen()) ||
875875                                       video_config.waitvsync || video_config.syncrefresh) ?
876876                                       D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
877877
r243485r243486
899899   osd_printf_verbose("Direct3D: Device created at %dx%d\n", m_width, m_height);
900900
901901   // set the gamma if we need to
902   if (window().m_fullscreen)
902   if (window().fullscreen())
903903   {
904904      // only set the gamma if it's not 1.0f
905905      windows_options &options = downcast<windows_options &>(window().machine().options());
r243485r243486
10641064   int retval = 0;
10651065
10661066   m_shaders = global_alloc_clear(shaders);
1067   m_shaders->init(d3dintf, &window());
1067   // FIXME: Dynamic cast
1068   m_shaders->init(d3dintf, dynamic_cast<win_window_info *>(&window()));
10681069
10691070   DWORD tempcaps;
10701071   HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps);
r243485r243486
12031204   }
12041205
12051206   // choose a resolution: window mode case
1206   if (!window().m_fullscreen || !video_config.switchres || win_has_menu(&window()))
1207   if (!window().fullscreen() || !video_config.switchres || window().win_has_menu())
12071208   {
12081209      RECT client;
12091210
12101211      // bounds are from the window client rect
1211      GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
1212      GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
12121213      m_width = client.right - client.left;
12131214      m_height = client.bottom - client.top;
12141215
r243485r243486
12441245   }
12451246
12461247   // see if we can handle the device type
1247   result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().m_fullscreen);
1248   result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().fullscreen());
12481249   if (result != D3D_OK)
12491250   {
12501251      char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice);
r243485r243486
13081309   // note: technically we should not be calling this from an alternate window
13091310   // thread; however, it is only done during init time, and the init code on
13101311   // the main thread is waiting for us to finish, so it is safe to do so here
1311   window().m_target->compute_minimum_size(minwidth, minheight);
1312   window().target()->compute_minimum_size(minwidth, minheight);
13121313
13131314   // use those as the target for now
13141315   INT32 target_width = minwidth;
r243485r243486
13841385{
13851386   // get the current window bounds
13861387   RECT client;
1387   GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
1388   GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
13881389
13891390   // if we have a device and matching width/height, nothing to do
13901391   if (m_device != NULL && rect_width(&client) == m_width && rect_height(&client) == m_height)
trunk/src/osd/windows/drawd3d.h
r243485r243486
102102   renderer(win_window_info *window);
103103   virtual ~renderer();
104104
105   virtual int init();
105   virtual int create();
106106   virtual render_primitive_list *get_primitives();
107107   virtual int draw(HDC dc, int update);
108108   virtual void save();
trunk/src/osd/windows/drawdd.c
r243485r243486
6363
6464   virtual ~renderer_dd() { }
6565
66   virtual int init();
66   virtual int create();
6767   virtual render_primitive_list *get_primitives();
6868   virtual int draw(HDC dc, int update);
6969   virtual void save() {};
r243485r243486
258258//  drawdd_window_init
259259//============================================================
260260
261int renderer_dd::init()
261int renderer_dd::create()
262262{
263263   // configure the adapter for the mode we want
264264   if (config_adapter_mode())
r243485r243486
297297render_primitive_list *renderer_dd::get_primitives()
298298{
299299   compute_blit_surface_size();
300   window().m_target->set_bounds(blitwidth, blitheight, 0);
301   window().m_target->set_max_update_rate((refresh == 0) ? origmode.dwRefreshRate : refresh);
300   window().target()->set_bounds(blitwidth, blitheight, 0);
301   window().target()->set_max_update_rate((refresh == 0) ? origmode.dwRefreshRate : refresh);
302302
303   return &window().m_target->get_primitives();
303   return &window().target()->get_primitives();
304304}
305305
306306
r243485r243486
417417   if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result);
418418
419419   // sync to VBLANK
420   if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().m_fullscreen || back == NULL))
420   if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().fullscreen() || back == NULL))
421421   {
422422      result = IDirectDraw7_WaitForVerticalBlank(ddraw, DDWAITVB_BLOCKBEGIN, NULL);
423423      if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
r243485r243486
469469      osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result);
470470      goto error;
471471   }
472   result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
472   result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().fullscreen() ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
473473   if (result != DD_OK)
474474   {
475475      osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result);
r243485r243486
477477   }
478478
479479   // full screen mode: set the resolution
480   if (window().m_fullscreen && video_config.switchres)
480   if (window().fullscreen() && video_config.switchres)
481481   {
482482      result = IDirectDraw7_SetDisplayMode(ddraw, width, height, 32, refresh, 0);
483483      if (result != DD_OK)
r243485r243486
511511   primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
512512
513513   // for triple-buffered full screen mode, allocate flipping surfaces
514   if (window().m_fullscreen && video_config.triplebuf)
514   if (window().fullscreen() && video_config.triplebuf)
515515   {
516516      primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
517517      primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
r243485r243486
524524
525525   // full screen mode: get the back surface
526526   back = NULL;
527   if (window().m_fullscreen && video_config.triplebuf)
527   if (window().fullscreen() && video_config.triplebuf)
528528   {
529529      DDSCAPS2 caps = { DDSCAPS_BACKBUFFER };
530530      result = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &back);
r243485r243486
564564      goto error;
565565
566566   // create a clipper for windowed mode
567   if (!window().m_fullscreen && create_clipper())
567   if (!window().fullscreen() && create_clipper())
568568      goto error;
569569
570570   // full screen mode: set the gamma
571   if (window().m_fullscreen)
571   if (window().fullscreen())
572572   {
573573      // only set the gamma if it's not 1.0f
574574      windows_options &options = downcast<windows_options &>(window().machine().options());
r243485r243486
825825   RECT client;
826826
827827   // start with the minimum size
828   window().m_target->compute_minimum_size(newwidth, newheight);
828   window().target()->compute_minimum_size(newwidth, newheight);
829829
830830   // get the window's client rectangle
831831   GetClientRect(window().m_hwnd, &client);
r243485r243486
854854      // compute the appropriate visible area if we're trying to keepaspect
855855      if (video_config.keepaspect)
856856      {
857         win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL);
858         window().m_target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().m_target->orientation(), target_width, target_height);
857         win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
858         window().target()->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().target()->orientation(), target_width, target_height);
859859         desired_aspect = (float)target_width / (float)target_height;
860860      }
861861
r243485r243486
920920   margins->right = desc_width;
921921   margins->bottom = desc_height;
922922
923   if (win_has_menu(&window()))
923   if (window().win_has_menu())
924924   {
925925      static int height_with_menubar = 0;
926926      if (height_with_menubar == 0)
r243485r243486
944944void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
945945{
946946   IDirectDrawSurface7 *target = (back != NULL) ? back : primary;
947   win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL);
947   win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
948948   DDBLTFX blitfx = { sizeof(DDBLTFX) };
949949   RECT clear, outer, dest, source;
950950   INT32 dstwidth, dstheight;
r243485r243486
956956   source.bottom = srcheight;
957957
958958   // compute outer rect -- windowed version
959   if (!window().m_fullscreen)
959   if (!window().fullscreen())
960960   {
961961      GetClientRect(window().m_hwnd, &outer);
962962      ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[0]);
r243485r243486
999999   else if (video_config.keepaspect)
10001000   {
10011001      // compute the appropriate visible area
1002      window().m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().m_target->orientation(), dstwidth, dstheight);
1002      window().target()->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().target()->orientation(), dstwidth, dstheight);
10031003   }
10041004
10051005   // center within
r243485r243486
10621062   if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result);
10631063
10641064   // page flip if triple buffered
1065   if (window().m_fullscreen && back != NULL)
1065   if (window().fullscreen() && back != NULL)
10661066   {
10671067      result = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
10681068      if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
r243485r243486
11121112   }
11131113
11141114   // choose a resolution: full screen mode case
1115   if (window().m_fullscreen)
1115   if (window().fullscreen())
11161116   {
11171117      // default to the current mode exactly
11181118      width = origmode.dwWidth;
r243485r243486
11291129   ddraw = NULL;
11301130
11311131   // if we're not changing resolutions, make sure we have a resolution we can handle
1132   if (!window().m_fullscreen || !video_config.switchres)
1132   if (!window().fullscreen() || !video_config.switchres)
11331133   {
11341134      switch (origmode.ddpfPixelFormat.dwRBitMask)
11351135      {
r243485r243486
12681268   // note: technically we should not be calling this from an alternate window
12691269   // thread; however, it is only done during init time, and the init code on
12701270   // the main thread is waiting for us to finish, so it is safe to do so here
1271   window().m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
1271   window().target()->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
12721272
12731273   // use those as the target for now
12741274   einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
r243485r243486
12961296   }
12971297
12981298   // fill in the rest of the data
1299   einfo.window = &window();
1299   einfo.window = dynamic_cast<win_window_info *>(&window());
13001300   einfo.best_score = 0.0f;
13011301
13021302   // enumerate the modes
trunk/src/osd/windows/drawgdi.c
r243485r243486
3030
3131   virtual ~renderer_gdi() { }
3232
33   virtual int init();
33   virtual int create();
3434   virtual render_primitive_list *get_primitives();
3535   virtual int draw(HDC dc, int update);
3636   virtual void save() {};
r243485r243486
9292//  drawgdi_window_init
9393//============================================================
9494
95int renderer_gdi::init()
95int renderer_gdi::create()
9696{
9797
9898   // fill in the bitmap info header
r243485r243486
133133{
134134   RECT client;
135135   GetClientRect(window().m_hwnd, &client);
136   window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
137   return &window().m_target->get_primitives();
136   window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
137   return &window().target()->get_primitives();
138138}
139139
140140
trunk/src/osd/windows/drawnone.c
r243485r243486
2525
2626   virtual ~renderer_none() { }
2727
28   virtual int init();
28   virtual int create();
2929   virtual render_primitive_list *get_primitives();
3030   virtual int draw(HDC dc, int update);
3131   virtual void save() { };
r243485r243486
8181//  drawnone_window_init
8282//============================================================
8383
84int renderer_none::init()
84int renderer_none::create()
8585{
8686   return 0;
8787}
r243485r243486
106106{
107107   RECT client;
108108   GetClientRect(window().m_hwnd, &client);
109   window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
110   return &window().m_target->get_primitives();
109   window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
110   return &window().target()->get_primitives();
111111}
112112
113113
trunk/src/osd/windows/input.c
r243485r243486
574574      return false;
575575
576576   // if the window has a menu, no
577   if (win_window_list != NULL && win_has_menu(win_window_list))
577   if (win_window_list != NULL && win_window_list->win_has_menu())
578578      return false;
579579
580580   // otherwise, yes
r243485r243486
14881488   device_info *devinfo;
14891489   HRESULT result;
14901490
1491   if (win_window_list != NULL && win_has_menu(win_window_list)) {
1491   if (win_window_list != NULL && win_window_list->win_has_menu()) {
14921492      cooperative_level = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE;
14931493   }
14941494   // allocate and link in a new device
trunk/src/osd/windows/window.c
r243485r243486
299299win_window_info::win_window_info(running_machine &machine)
300300      : m_next(NULL),
301301      m_init_state(0),
302      m_hwnd(0),
303      m_focus_hwnd(0),
304302      m_startmaximized(0),
305303      m_isminimized(0),
306304      m_ismaximized(0),
307      m_resize_state(0),
308      m_monitor(0),
309305      m_fullscreen(0),
310306      m_fullscreen_safe(0),
311      m_maxwidth(0),
312      m_maxheight(0),
313      m_refresh(0),
314307      m_aspect(0),
315308      m_render_lock(NULL),
316309      m_target(NULL),
317310      m_targetview(0),
318311      m_targetorient(0),
319      m_primlist(NULL),
320312      m_lastclicktime(0),
321313      m_lastclickx(0),
322314      m_lastclicky(0),
r243485r243486
620612   //   2. we also hide the cursor in full screen mode and when the window doesn't have a menu
621613   //   3. we also hide the cursor in windowed mode if we're not paused and
622614   //      the input system requests it
623   if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!machine.paused() && wininput_should_hide_mouse())))
615   if (winwindow_has_focus() && ((!video_config.windowed && !win_window_list->win_has_menu()) || (!machine.paused() && wininput_should_hide_mouse())))
624616   {
625617      win_window_info *window = win_window_list;
626618      RECT bounds;
r243485r243486
849841//  (window thread)
850842//============================================================
851843
852win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed)
844win_monitor_info *win_window_info::winwindow_video_window_monitor(const RECT *proposed)
853845{
854846   win_monitor_info *monitor;
855847
856848   // in window mode, find the nearest
857   if (!window->m_fullscreen)
849   if (!m_fullscreen)
858850   {
859851      if (proposed != NULL)
860852         monitor = winvideo_monitor_from_handle(MonitorFromRect(proposed, MONITOR_DEFAULTTONEAREST));
861853      else
862         monitor = winvideo_monitor_from_handle(MonitorFromWindow(window->m_hwnd, MONITOR_DEFAULTTONEAREST));
854         monitor = winvideo_monitor_from_handle(MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST));
863855   }
864856
865857   // in full screen, just use the configured monitor
866858   else
867      monitor = window->m_monitor;
859      monitor = m_monitor;
868860
869861   // make sure we're up-to-date
870862   monitor->refresh();
r243485r243486
10461038   RECT temprect = { 100, 100, 200, 200 };
10471039   if (window->m_fullscreen)
10481040      return 0;
1049   AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
1041   AdjustWindowRectEx(&temprect, WINDOW_STYLE, window->win_has_menu(), WINDOW_STYLE_EX);
10501042   return rect_width(&temprect) - 100;
10511043}
10521044
r243485r243486
10621054   RECT temprect = { 100, 100, 200, 200 };
10631055   if (window->m_fullscreen)
10641056      return 0;
1065   AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
1057   AdjustWindowRectEx(&temprect, WINDOW_STYLE, window->win_has_menu(), WINDOW_STYLE_EX);
10661058   return rect_height(&temprect) - 100;
10671059}
10681060
r243485r243486
12331225   {
12341226      // finish off by trying to initialize DirectX; if we fail, ignore it
12351227      window->m_renderer = draw.create(window);
1236      if (window->m_renderer->init())
1228      if (window->m_renderer->create())
12371229         return 1;
12381230      ShowWindow(window->m_hwnd, SW_SHOW);
12391231   }
r243485r243486
12741266         PAINTSTRUCT pstruct;
12751267         HDC hdc = BeginPaint(wnd, &pstruct);
12761268         draw_video_contents(window, hdc, TRUE);
1277         if (win_has_menu(window))
1269         if (window->win_has_menu())
12781270            DrawMenuBar(window->m_hwnd);
12791271         EndPaint(wnd, &pstruct);
12801272         break;
r243485r243486
12821274
12831275      // non-client paint: punt if full screen
12841276      case WM_NCPAINT:
1285         if (!window->m_fullscreen || win_has_menu(window))
1277         if (!window->m_fullscreen || window->win_has_menu())
12861278            return DefWindowProc(wnd, message, wparam, lparam);
12871279         break;
12881280
r243485r243486
15151507
15161508static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int adjustment)
15171509{
1518   win_monitor_info *monitor = winwindow_video_window_monitor(window, rect);
1510   win_monitor_info *monitor = window->winwindow_video_window_monitor(rect);
15191511   INT32 extrawidth = wnd_extra_width(window);
15201512   INT32 extraheight = wnd_extra_height(window);
15211513   INT32 propwidth, propheight;
r243485r243486
18281820   // in full screen, make sure it covers the primary display
18291821   else
18301822   {
1831      win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
1823      win_monitor_info *monitor = window->winwindow_video_window_monitor(NULL);
18321824      newrect = monitor->info.rcMonitor;
18331825   }
18341826
r243485r243486
18491841}
18501842
18511843
1852
18531844//============================================================
18541845//  set_fullscreen
18551846//  (window thread)
r243485r243486
19241915      if (video_config.mode != VIDEO_MODE_NONE)
19251916         ShowWindow(window->m_hwnd, SW_SHOW);
19261917      window->m_renderer = draw.create(window);
1927      if (window->m_renderer->init())
1918      if (window->m_renderer->create())
19281919         exit(1);
19291920   }
19301921
trunk/src/osd/windows/window.h
r243485r243486
3434
3535class win_window_info;
3636
37class osd_window
38{
39public:
40   osd_window()
41   :
42#ifdef OSD_SDL
43      m_start_viewscreen(0),
44#else
45      m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0),
46      m_maxwidth(0), m_maxheight(0),
47      m_refresh(0),
48#endif
49      m_primlist(NULL)
50       {}
51   virtual ~osd_window() { }
52
53   virtual render_target *target() = 0;
54   virtual int fullscreen() const = 0;
55   virtual running_machine &machine() const = 0;
56
57#ifdef OSD_SDL
58   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
59   virtual sdl_monitor_info *monitor() const = 0;
60   virtual void get_size(int &w, int &h) = 0;
61   virtual int index() const = 0;
62   virtual int prescale() const = 0;
63#if (SDLMAME_SDL2)
64   virtual SDL_Window *sdl_window() = 0;
65#else
66   virtual SDL_Surface *sdl_surface() = 0;
67#endif
68
69   int                    m_start_viewscreen;
70
71#else
72   virtual bool win_has_menu() = 0;
73   virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0;
74
75   // window handle and info
76   HWND               m_hwnd;
77   HWND                   m_focus_hwnd;
78
79   // monitor info
80   win_monitor_info *     m_monitor;
81   int                    m_resize_state;
82   int                    m_maxwidth, m_maxheight;
83   int                    m_refresh;
84#endif
85
86   render_primitive_list *   m_primlist;
87
88};
89
3790class osd_renderer
3891{
3992public:
r243485r243486
4699   static const int FLAG_NEEDS_DOUBLEBUF       = 0x0100;
47100   static const int FLAG_NEEDS_ASYNCBLIT       = 0x0200;
48101
49   osd_renderer(win_window_info *window, const int flags)
102   osd_renderer(osd_window *window, const int flags)
50103   : m_window(window), m_flags(flags) { }
51104
52105   virtual ~osd_renderer() { }
53106
54   win_window_info &window() { return *m_window; }
107   osd_window &window() { return *m_window; }
55108   int flags() const { return m_flags; }
56   bool check_flag(const int flag) { return ((m_flags & flag)) == flag; }
109   bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
57110
58   virtual int init() = 0;
111   void notify_changed() { set_flags(FI_CHANGED); }
112
113   /* Interface to be implemented by render code */
114
115   virtual int create() = 0;
59116   virtual render_primitive_list *get_primitives() = 0;
117
118#ifdef OSD_SDL
119   virtual int draw(const UINT32 dc, const int update) = 0;
120   virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0;
121#else
60122   virtual int draw(HDC dc, int update) = 0;
61123   virtual void save() = 0;
62124   virtual void record() = 0;
63125   virtual void toggle_fsfx() = 0;
126#endif
127
64128   virtual void destroy() = 0;
65129
130protected:
131   /* Internal flags */
132   static const int FI_CHANGED                = 0x010000;
133
134   void set_flags(int aflag) { m_flags |= aflag; }
135   void clear_flags(int aflag) { m_flags &= ~aflag; }
136
66137private:
67   win_window_info *m_window;
138
139   osd_window      *m_window;
68140   int m_flags;
69141};
70142
71class win_window_info
143class win_window_info  : public osd_window
72144{
73145public:
74146   win_window_info(running_machine &machine);
r243485r243486
76148
77149   running_machine &machine() const { return m_machine; }
78150
151   render_target *target() { return m_target; }
152   int fullscreen() const { return m_fullscreen; }
153
79154   void update();
80155
156   win_monitor_info *winwindow_video_window_monitor(const RECT *proposed);
157
158   bool win_has_menu()
159   {
160      return GetMenu(m_hwnd) ? true : false;
161   }
162
81163   win_window_info *   m_next;
82164   volatile int        m_init_state;
83165
84166   // window handle and info
85   HWND                m_hwnd;
86   HWND                m_focus_hwnd;
87167   char                m_title[256];
88168   RECT                m_non_fullscreen_bounds;
89169   int                 m_startmaximized;
90170   int                 m_isminimized;
91171   int                 m_ismaximized;
92   int                 m_resize_state;
93172
94173   // monitor info
95   win_monitor_info *  m_monitor;
96174   int                 m_fullscreen;
97175   int                 m_fullscreen_safe;
98   int                 m_maxwidth, m_maxheight;
99   int                 m_refresh;
100176   float               m_aspect;
101177
102178   // rendering info
r243485r243486
105181   int                 m_targetview;
106182   int                 m_targetorient;
107183   render_layer_config m_targetlayerconfig;
108   render_primitive_list *m_primlist;
109184
110185   // input info
111186   DWORD               m_lastclicktime;
r243485r243486
145220
146221BOOL winwindow_has_focus(void);
147222void winwindow_update_cursor_state(running_machine &machine);
148win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed);
149223
150224LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
151225extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
r243485r243486
170244
171245
172246//============================================================
173//  win_has_menu
174//============================================================
175
176INLINE BOOL win_has_menu(win_window_info *window)
177{
178   return GetMenu(window->m_hwnd) ? TRUE : FALSE;
179}
180
181
182//============================================================
183247//  rect_width / rect_height
184248//============================================================
185249


Previous 199869 Revisions Next


© 1997-2024 The MAME Team