Previous 199869 Revisions Next

r36114 Friday 27th February, 2015 at 00:42:50 UTC by Couriersud
Fixed windows baseline build.
More osd_dim use. (nw)
[src/osd/modules]osdwindow.h
[src/osd/sdl]draw13.c drawogl.c drawsdl.c video.h window.c window.h
[src/osd/windows]video.h window.c window.h

trunk/src/osd/modules/osdwindow.h
r244625r244626
5454   virtual osd_dim get_size() = 0;
5555
5656#ifdef OSD_SDL
57   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
57   virtual osd_dim blit_surface_size() = 0;
5858   virtual sdl_monitor_info *monitor() const = 0;
5959#if (SDLMAME_SDL2)
6060   virtual SDL_Window *sdl_window() = 0;
trunk/src/osd/sdl/draw13.c
r244625r244626
146146   : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL),
147147      m_last_hofs(0), m_last_vofs(0),
148148      m_width(0), m_height(0),
149      m_blitwidth(0), m_blitheight(0),
149      m_blit_dim(0,0),
150150      m_last_blit_time(0), m_last_blit_pixels(0)
151151   {}
152152
r244625r244626
156156   /* virtual */ void destroy();
157157   /* virtual */ render_primitive_list *get_primitives()
158158   {
159      int nw = 0; int nh = 0;
160      window().blit_surface_size(nw, nh);
161      if (nw != m_blitwidth || nh != m_blitheight)
159      osd_dim nd = window().blit_surface_size();
160      if (nd != m_blit_dim)
162161      {
163         m_blitwidth = nw; m_blitheight = nh;
162         m_blit_dim = nd;
164163         notify_changed();
165164      }
166      window().target()->set_bounds(m_blitwidth, m_blitheight, window().aspect());
165      window().target()->set_bounds(m_blit_dim.width(), m_blit_dim.height(), window().aspect());
167166      return &window().target()->get_primitives();
168167   }
169168
r244625r244626
193192   int             m_width;
194193   int             m_height;
195194
196   int             m_blitwidth;
197   int             m_blitheight;
195   osd_dim         m_blit_dim;
198196
199197   // Stats
200198   INT64           m_last_blit_time;
r244625r244626
649647{
650648   *xt = x - m_last_hofs;
651649   *yt = y - m_last_vofs;
652   if (*xt<0 || *xt >= m_blitwidth)
650   if (*xt<0 || *xt >= m_blit_dim.width())
653651      return 0;
654   if (*yt<0 || *yt >= m_blitheight)
652   if (*yt<0 || *yt >= m_blit_dim.height())
655653      return 0;
656654   return 1;
657655}
r244625r244626
724722
725723      if (video_config.centerv)
726724      {
727         vofs = (ch - m_blitheight) / 2.0f;
725         vofs = (ch - m_blit_dim.height()) / 2.0f;
728726      }
729727      if (video_config.centerh)
730728      {
731         hofs = (cw - m_blitwidth) / 2.0f;
729         hofs = (cw - m_blit_dim.width()) / 2.0f;
732730      }
733731   }
734732
trunk/src/osd/sdl/drawogl.c
r244625r244626
487487   sdl_info_ogl(osd_window *window)
488488   : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0),
489489      m_width(0), m_height(0),
490      m_blitwidth(0), m_blitheight(0),
490      m_blit_dim(0, 0),
491491      m_gl_context(NULL),
492492      m_initialized(0),
493493      m_last_blendmode(0),
r244625r244626
519519   /* virtual */ void destroy();
520520   /* virtual */ render_primitive_list *get_primitives()
521521   {
522      int nw = 0; int nh = 0;
523522#ifdef OSD_WINDOWS
524      window().get_size(nw, nh);
523      osd_dim nd = window().get_size();
525524#else
526      window().blit_surface_size(nw, nh);
525      osd_dim nd = window().blit_surface_size();
527526#endif
528      if (nw != m_blitwidth || nh != m_blitheight)
527      if (nd != m_blit_dim)
529528      {
530         m_blitwidth = nw; m_blitheight = nh;
529         m_blit_dim = nd;
531530         notify_changed();
532531      }
533      window().target()->set_bounds(m_blitwidth, m_blitheight, window().aspect());
532      window().target()->set_bounds(m_blit_dim.width(), m_blit_dim.height(), window().aspect());
534533      return &window().target()->get_primitives();
535534   }
536535
r244625r244626
562561   INT32           m_blittimer;
563562   int             m_width;
564563   int             m_height;
565   int             m_blitwidth;
566   int             m_blitheight;
564   osd_dim         m_blit_dim;
567565
568566   osd_gl_context   *m_gl_context;
569567
r244625r244626
10701068{
10711069   *xt = x - m_last_hofs;
10721070   *yt = y - m_last_vofs;
1073   if (*xt<0 || *xt >= m_blitwidth)
1071   if (*xt<0 || *xt >= m_blit_dim.width())
10741072      return 0;
1075   if (*yt<0 || *yt >= m_blitheight)
1073   if (*yt<0 || *yt >= m_blit_dim.height())
10761074      return 0;
10771075   return 1;
10781076}
r244625r244626
16121610
16131611      if (video_config.centerv)
16141612      {
1615         vofs = (ch - m_blitheight) / 2.0f;
1613         vofs = (ch - m_blit_dim.height()) / 2.0f;
16161614      }
16171615      if (video_config.centerh)
16181616      {
1619         hofs = (cw - m_blitwidth) / 2.0f;
1617         hofs = (cw - m_blit_dim.width()) / 2.0f;
16201618      }
16211619   }
16221620#else
r244625r244626
21852183{
21862184   int uniform_location;
21872185   int i;
2188   int surf_w_pow2  = get_valid_pow2_value (m_blitwidth, texture->texpow2);
2189   int surf_h_pow2  = get_valid_pow2_value (m_blitheight, texture->texpow2);
2186   int surf_w_pow2  = get_valid_pow2_value (m_blit_dim.width(), texture->texpow2);
2187   int surf_h_pow2  = get_valid_pow2_value (m_blit_dim.height(), texture->texpow2);
21902188
21912189   assert ( texture->type==TEXTURE_TYPE_SHADER );
21922190
r244625r244626
22332231      pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0]));
22342232      GL_CHECK_ERROR_NORMAL();
22352233
2236      GLfloat screen_texture_sz[2] = { (GLfloat) m_blitwidth, (GLfloat) m_blitheight };
2234      GLfloat screen_texture_sz[2] = { (GLfloat) m_blit_dim.width(), (GLfloat) m_blit_dim.height() };
22372235      uniform_location = pfn_glGetUniformLocationARB(m_glsl_program[i], "screen_texture_sz");
22382236      pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0]));
22392237      GL_CHECK_ERROR_NORMAL();
trunk/src/osd/sdl/drawsdl.c
r244625r244626
6464   //m_hw_scale_height(0),
6565   m_last_hofs(0),
6666   m_last_vofs(0),
67   m_blitwidth(0),
68   m_blitheight(0),
69   m_last_width(0),
70   m_last_height(0)
67   m_blit_dim(0, 0),
68   m_last_dim(0, 0)
7169   { }
7270
7371   /* virtual */ int create();
r244625r244626
7674   /* virtual */ void destroy();
7775   /* virtual */ render_primitive_list *get_primitives()
7876   {
79      int nw = 0; int nh = 0;
80      window().blit_surface_size(nw, nh);
81      if (nw != m_blitwidth || nh != m_blitheight)
77      osd_dim nd = window().blit_surface_size();
78      if (nd != m_blit_dim)
8279      {
83         m_blitwidth = nw; m_blitheight = nh;
80         m_blit_dim = nd;
8481         notify_changed();
8582      }
86      window().target()->set_bounds(m_blitwidth, m_blitheight, window().aspect());
83      window().target()->set_bounds(m_blit_dim.width(), m_blit_dim.height(), window().aspect());
8784      return &window().target()->get_primitives();
8885   }
8986
r244625r244626
9188   void destroy_all_textures();
9289   void yuv_init();
9390#if (SDLMAME_SDL2)
94   void setup_texture(int tempwidth, int tempheight);
91   void setup_texture(const osd_dim &size);
9592#endif
9693   void yuv_lookup_set(unsigned int pen, unsigned char red,
9794            unsigned char green, unsigned char blue);
r244625r244626
118115
119116   int                 m_last_hofs;
120117   int                 m_last_vofs;
121   int                 m_blitwidth;
122   int                 m_blitheight;
123   int                 m_last_width;
124   int                 m_last_height;
118   osd_dim             m_blit_dim;
119   osd_dim             m_last_dim;
125120};
126121
127122struct sdl_scale_mode
r244625r244626
269264//============================================================
270265
271266#if (SDLMAME_SDL2)
272void sdl_info::setup_texture(int tempwidth, int tempheight)
267void sdl_info::setup_texture(const osd_dim &size)
273268{
274269   const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
275270   SDL_DisplayMode mode;
r244625r244626
288283
289284   if (sdl_sm->is_scale)
290285   {
291      int m_hw_scale_width =0;
286      int m_hw_scale_width = 0;
292287      int m_hw_scale_height = 0;
293288
294289      window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height);
r244625r244626
312307   else
313308   {
314309      m_texture_id = SDL_CreateTexture(m_sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
315            tempwidth, tempheight);
310            size.width(), size.height());
316311   }
317312}
318313#endif
r244625r244626
523518{
524519   *xt = x - m_last_hofs;
525520   *yt = y - m_last_vofs;
526   if (*xt<0 || *xt >= m_blitwidth)
521   if (*xt<0 || *xt >= m_blit_dim.width())
527522      return 0;
528   if (*yt<0 || *yt >= m_blitheight)
523   if (*yt<0 || *yt >= m_blit_dim.height())
529524      return 0;
530525   return 1;
531526}
r244625r244626
571566   }
572567
573568   osd_dim wdim = window().get_size();
574   if (has_flags(FI_CHANGED) || (wdim.width() != m_last_width) || (wdim.height() != m_last_height))
569   if (has_flags(FI_CHANGED) || (wdim != m_last_dim))
575570   {
576571      destroy_all_textures();
577572      clear_flags(FI_CHANGED);
578573      m_blittimer = 3;
579      m_last_width = wdim.width();
580      m_last_height = wdim.height();
574      m_last_dim = wdim;
581575#if (SDLMAME_SDL2)
582576      SDL_RenderSetViewport(m_sdl_renderer, NULL);
583577      if (m_texture_id != NULL)
584578         SDL_DestroyTexture(m_texture_id);
585      setup_texture(m_blitwidth, m_blitheight);
579      setup_texture(m_blit_dim);
586580      m_blittimer = 3;
587581#else
588582      const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
r244625r244626
665659#endif
666660   // get ready to center the image
667661   vofs = hofs = 0;
668   blitwidth = m_blitwidth;
669   blitheight = m_blitheight;
662   blitwidth = m_blit_dim.width();
663   blitheight = m_blit_dim.height();
670664
671665   ch = wdim.height();
672666   cw = wdim.width();
r244625r244626
678672   }
679673   else if (video_config.centerv)
680674   {
681      vofs = (ch - m_blitheight) / 2;
675      vofs = (ch - m_blit_dim.height()) / 2;
682676   }
683677
684678   if (blitwidth > cw)
r244625r244626
687681   }
688682   else if (video_config.centerh)
689683   {
690      hofs = (cw - m_blitwidth) / 2;
684      hofs = (cw - m_blit_dim.width()) / 2;
691685   }
692686
693687   m_last_hofs = hofs;
trunk/src/osd/sdl/video.h
r244625r244626
6969   int width() const { return m_w; }
7070   int height() const { return m_h; }
7171
72   bool operator!=(const osd_dim &other) { return (m_w != other.width()) || (m_h != other.height()); }
73   bool operator==(const osd_dim &other) { return (m_w == other.width()) && (m_h == other.height()); }
7274private:
7375   int m_w;
7476   int m_h;
r244625r244626
126128
127129   const UINT64 handle() { return m_handle; }
128130   const osd_rect position_size() { refresh(); return SDL_Rect_to_osd_rect(m_dimensions); }
131   const osd_rect usuable_position_size() { refresh(); return SDL_Rect_to_osd_rect(m_dimensions); }
129132
130133   const char *devicename() { refresh(); return m_name[0] ? m_name : "UNKNOWN"; }
131134
132135   float aspect();
133136
134   void set_aspect(const float aspect) { m_aspect = aspect; }
137   void set_aspect(const float a) { m_aspect = a; }
135138
136139   // STATIC
137140   static void init();
trunk/src/osd/sdl/window.c
r244625r244626
382382   return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1;
383383}
384384
385void sdl_window_info::blit_surface_size(int &blitwidth, int &blitheight)
385osd_dim sdl_window_info::blit_surface_size()
386386{
387387   osd_dim window_dim = get_size();
388388
r244625r244626
455455      && (video_config.scale_mode == VIDEO_SCALE_MODE_NONE ))
456456      newwidth = window_dim.width();
457457
458   blitwidth = newwidth;
459   blitheight = newheight;
458   return osd_dim(newwidth, newheight);
460459}
461460
462461
r244625r244626
735734   m_target = m_machine.render().target_alloc();
736735
737736   // set the specific view
738   set_starting_view(m_machine, m_index, options.view(), options.view(m_index));
737   set_starting_view(m_index, options.view(), options.view(m_index));
739738
740739   // make the window title
741740   if (video_config.numscreens == 1)
r244625r244626
10091008
10101009      // see if the games video mode has changed
10111010      m_target->compute_minimum_size(tempwidth, tempheight);
1012      if (tempwidth != m_minwidth || tempheight != m_minheight)
1011      if (osd_dim(tempwidth, tempheight) != m_minimum_dim)
10131012      {
1014         m_minwidth = tempwidth;
1015         m_minheight = tempheight;
1013         m_minimum_dim = osd_dim(tempwidth, tempheight);
10161014
10171015         if (!this->m_fullscreen)
10181016         {
r244625r244626
10501048//  (main thread)
10511049//============================================================
10521050
1053void sdl_window_info::set_starting_view(running_machine &machine, int index, const char *defview, const char *view)
1051void sdl_window_info::set_starting_view(int index, const char *defview, const char *view)
10541052{
10551053   int viewindex;
10561054
r244625r244626
13941392   INT32 viswidth, visheight;
13951393   INT32 adjwidth, adjheight;
13961394   float pixel_aspect;
1395   sdl_monitor_info *monitor = m_monitor;
13971396
13981397   // get the pixel aspect ratio for the target monitor
1399   pixel_aspect = m_monitor->aspect();
1398   pixel_aspect = monitor->aspect();
14001399
14011400   // determine the proposed width/height
14021401   propwidth = rect.width() - extrawidth;
r244625r244626
14351434   // clamp against the maximum (fit on one screen for full screen mode)
14361435   if (m_fullscreen)
14371436   {
1438      maxwidth = m_monitor->position_size().width() - extrawidth;
1439      maxheight = m_monitor->position_size().height() - extraheight;
1437      maxwidth = monitor->position_size().width() - extrawidth;
1438      maxheight = monitor->position_size().height() - extraheight;
14401439   }
14411440   else
14421441   {
1443      maxwidth = m_monitor->position_size().width() - extrawidth;
1444      maxheight = m_monitor->position_size().height() - extraheight;
1442      maxwidth = monitor->usuable_position_size().width() - extrawidth;
1443      maxheight = monitor->usuable_position_size().height() - extraheight;
14451444
14461445      // further clamp to the maximum width/height in the window
14471446      if (m_win_config.width != 0)
trunk/src/osd/sdl/window.h
r244625r244626
4444      m_resize_height(0),
4545      m_last_resize(0),
4646#endif
47      m_minwidth(0), m_minheight(0),
47      m_minimum_dim(0,0),
4848      m_windowed_dim(0,0),
4949      m_rendered_event(0), m_target(0),
5050#if (SDLMAME_SDL2)
r244625r244626
104104   SDL_Surface *sdl_surface() { return m_sdlsurf; }
105105#endif
106106
107   void blit_surface_size(int &blitwidth, int &blitheight);
107   osd_dim blit_surface_size();
108108   int prescale() const { return m_prescale; }
109109
110110   // Pointer to next window
r244625r244626
122122   char                m_title[256];
123123   int                 m_startmaximized;
124124
125   // diverse flags
126   int                 m_minwidth, m_minheight;
125   // dimensions
126   osd_dim             m_minimum_dim;
127127   osd_dim             m_windowed_dim;
128128
129129   // rendering info
r244625r244626
153153private:
154154   int wnd_extra_width();
155155   int wnd_extra_height();
156   void set_starting_view(running_machine &machine, int index, const char *defview, const char *view);
156   void set_starting_view(int index, const char *defview, const char *view);
157157   osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);
158158   osd_dim get_min_bounds(int constrain);
159159   osd_dim get_max_bounds(int constrain);
trunk/src/osd/windows/video.h
r244625r244626
4545   int width() const { return m_w; }
4646   int height() const { return m_h; }
4747
48   bool operator!=(const osd_dim &other) { return (m_w != other.width()) || (m_h != other.height()); }
49   bool operator==(const osd_dim &other) { return (m_w == other.width()) && (m_h == other.height()); }
4850private:
4951   int m_w;
5052   int m_h;
trunk/src/osd/windows/window.c
r244625r244626
677677
678678   // set the specific view
679679   windows_options &options = downcast<windows_options &>(machine.options());
680   window->set_starting_view(index, options.view(index));
681680
681   const char *defview = options.view();
682   window->set_starting_view(index, defview, options.view(index));
683
682684   // remember the current values in case they change
683685   window->m_targetview = window->m_target->view();
684686   window->m_targetorient = window->m_target->orientation();
r244625r244626
898900//  (main thread)
899901//============================================================
900902
901void win_window_info::set_starting_view(int index, const char *view)
903void win_window_info::set_starting_view(int index, const char *defview, const char *view)
902904{
903   const char *defview = downcast<windows_options &>(machine().options()).view();
904905   int viewindex;
905906
906907   assert(GetCurrentThreadId() == main_threadid);
r244625r244626
910911      view = defview;
911912
912913   // query the video system to help us pick a view
913   viewindex = m_target->configured_view(view, index, video_config.numscreens);
914   viewindex = target()->configured_view(view, index, video_config.numscreens);
914915
915916   // set the view
916   m_target->set_view(viewindex);
917   target()->set_view(viewindex);
917918}
918919
919920
920
921921//============================================================
922922//  winwindow_ui_pause_from_main_thread
923923//  (main thread)
r244625r244626
15151515
15161516osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int adjustment)
15171517{
1518   win_monitor_info *monitor = winwindow_video_window_monitor(&rect);
15191518   INT32 extrawidth = wnd_extra_width();
15201519   INT32 extraheight = wnd_extra_height();
15211520   INT32 propwidth, propheight;
r244625r244626
15241523   INT32 viswidth, visheight;
15251524   INT32 adjwidth, adjheight;
15261525   float pixel_aspect;
1526   win_monitor_info *monitor = winwindow_video_window_monitor(&rect);
15271527
15281528   assert(GetCurrentThreadId() == window_threadid);
15291529
trunk/src/osd/windows/window.h
r244625r244626
5353      return GetMenu(m_hwnd) ? true : false;
5454   }
5555
56   /* virtual */ void get_size(int &w, int &h)
56   /* virtual */ osd_dim get_size()
5757   {
5858      RECT client;
5959      GetClientRect(m_hwnd, &client);
60      w = client.right - client.left;
61      h = client.bottom - client.top;
60      return osd_dim(client.right - client.left, client.bottom - client.top);
6261   }
6362
6463   win_monitor_info *monitor() const { return m_monitor; }
r244625r244626
110109private:
111110   void draw_video_contents(HDC dc, int update);
112111   int complete_create();
113   void set_starting_view(int index, const char *view);
112   void set_starting_view(int index, const char *defview, const char *view);
114113   int wnd_extra_width();
115114   int wnd_extra_height();
116115   osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team