Changed osd_font to struct osd_font and removed unnecessary osdepend.h

includes.
This commit is contained in:
couriersud 2015-01-17 15:59:43 +01:00
parent 4a7c1200bd
commit 18d5da6b0b
26 changed files with 90 additions and 61 deletions

View File

@ -24,6 +24,8 @@
#include "drivenum.h" #include "drivenum.h"
#include "osdepend.h"
#include <new> #include <new>
#include <ctype.h> #include <ctype.h>

View File

@ -15,8 +15,9 @@
#include "emu.h" #include "emu.h"
#include "cliopts.h" #include "cliopts.h"
#include "osdepend.h"
// don't include osd_interface in header files
class osd_interface;
//************************************************************************** //**************************************************************************
// TYPE DEFINITIONS // TYPE DEFINITIONS

View File

@ -99,6 +99,8 @@
#include "uiinput.h" #include "uiinput.h"
#include "debug/debugcon.h" #include "debug/debugcon.h"
#include "osdepend.h"
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>

View File

@ -106,6 +106,11 @@ static char giant_string_buffer[65536] = { 0 };
// RUNNING MACHINE // RUNNING MACHINE
//************************************************************************** //**************************************************************************
osd_interface &running_machine::osd() const
{
return m_manager.osd();
}
//------------------------------------------------- //-------------------------------------------------
// running_machine - constructor // running_machine - constructor
//------------------------------------------------- //-------------------------------------------------

View File

@ -19,7 +19,8 @@
#include <time.h> #include <time.h>
// forward declaration instead of osdepend.h
class osd_interface;
//************************************************************************** //**************************************************************************
// CONSTANTS // CONSTANTS
@ -157,7 +158,7 @@ public:
const machine_config &config() const { return m_config; } const machine_config &config() const { return m_config; }
device_t &root_device() const { return m_config.root_device(); } device_t &root_device() const { return m_config.root_device(); }
const game_driver &system() const { return m_system; } const game_driver &system() const { return m_system; }
osd_interface &osd() const { return m_manager.osd(); } osd_interface &osd() const;
machine_manager &manager() const { return m_manager; } machine_manager &manager() const { return m_manager; }
resource_pool &respool() { return m_respool; } resource_pool &respool() { return m_respool; }
device_scheduler &scheduler() { return m_scheduler; } device_scheduler &scheduler() { return m_scheduler; }

View File

@ -92,6 +92,12 @@
machine_manager* machine_manager::m_manager = NULL; machine_manager* machine_manager::m_manager = NULL;
osd_interface &machine_manager::osd() const
{
return m_osd;
}
machine_manager* machine_manager::instance(emu_options &options,osd_interface &osd) machine_manager* machine_manager::instance(emu_options &options,osd_interface &osd)
{ {
if(!m_manager) if(!m_manager)

View File

@ -22,6 +22,7 @@
#include "webengine.h" #include "webengine.h"
class osd_interface;
//************************************************************************** //**************************************************************************
// CONSTANTS // CONSTANTS
@ -88,7 +89,7 @@ public:
static machine_manager *instance(); static machine_manager *instance();
~machine_manager(); ~machine_manager();
osd_interface &osd() const { return m_osd; } osd_interface &osd() const;
emu_options &options() const { return m_options; } emu_options &options() const { return m_options; }
web_engine *web() { return &m_web; } web_engine *web() { return &m_web; }
lua_engine *lua() { return &m_lua; } lua_engine *lua() { return &m_lua; }

View File

@ -46,7 +46,7 @@
#ifndef __RENDER_H__ #ifndef __RENDER_H__
#define __RENDER_H__ #define __RENDER_H__
#include "osdepend.h" //#include "osdepend.h"
#include <math.h> #include <math.h>

View File

@ -14,6 +14,7 @@
#include "emuopts.h" #include "emuopts.h"
#include <zlib.h> #include <zlib.h>
#include "osdepend.h"
#include "uismall.fh" #include "uismall.fh"

View File

@ -13,6 +13,8 @@
#include "render.h" #include "render.h"
// forward instead of include
class osd_font;
//************************************************************************** //**************************************************************************
// TYPE DEFINITIONS // TYPE DEFINITIONS
@ -91,7 +93,7 @@ private:
dynamic_array<glyph> m_glyphs[256]; // array of glyph subtables dynamic_array<glyph> m_glyphs[256]; // array of glyph subtables
dynamic_array<char> m_rawdata; // pointer to the raw data for the font dynamic_array<char> m_rawdata; // pointer to the raw data for the font
UINT64 m_rawsize; // size of the raw font data UINT64 m_rawsize; // size of the raw font data
osd_font m_osdfont; // handle to the OSD font osd_font *m_osdfont; // handle to the OSD font
// constants // constants
static const int CACHED_CHAR_SIZE = 12; static const int CACHED_CHAR_SIZE = 12;

View File

@ -12,7 +12,6 @@
#ifndef __RENDUTIL_H__ #ifndef __RENDUTIL_H__
#define __RENDUTIL_H__ #define __RENDUTIL_H__
#include "osdepend.h"
#include "render.h" #include "render.h"
#include <math.h> #include <math.h>

View File

@ -23,6 +23,7 @@
#include "ui/miscmenu.h" #include "ui/miscmenu.h"
#include "ui/filemngr.h" #include "ui/filemngr.h"
#include "osdepend.h"
/*------------------------------------------------- /*-------------------------------------------------
ui_slider_ui_handler - pushes the slider ui_slider_ui_handler - pushes the slider

View File

@ -20,7 +20,7 @@
#include "snap.lh" #include "snap.lh"
#include "osdepend.h"
//************************************************************************** //**************************************************************************
// DEBUGGING // DEBUGGING

View File

@ -16,7 +16,7 @@
#include "webengine.h" #include "webengine.h"
#include "lua.hpp" #include "lua.hpp"
#include "osdepend.h"
//************************************************************************** //**************************************************************************
// WEB ENGINE // WEB ENGINE

View File

@ -14,7 +14,6 @@
#define __COREFILE_H__ #define __COREFILE_H__
#include <stdarg.h> #include <stdarg.h>
#include "osdcore.h"
#include "astring.h" #include "astring.h"
#include "coretmpl.h" #include "coretmpl.h"

View File

@ -11,7 +11,6 @@
#ifndef __OPTIONS_H__ #ifndef __OPTIONS_H__
#define __OPTIONS_H__ #define __OPTIONS_H__
#include "osdcore.h"
#include "corefile.h" #include "corefile.h"
#include "tagmap.h" #include "tagmap.h"

View File

@ -24,7 +24,6 @@
#include "formats/basicdsk.h" #include "formats/basicdsk.h"
#include "formats/fmsx_cas.h" #include "formats/fmsx_cas.h"
#include "formats/msx_dsk.h" #include "formats/msx_dsk.h"
//#include "osdepend.h"
#include "hashfile.h" #include "hashfile.h"
#include "machine/wd_fdc.h" #include "machine/wd_fdc.h"
#include "imagedev/floppy.h" #include "imagedev/floppy.h"

View File

@ -346,7 +346,7 @@ void osd_common_t::customize_input_type_list(simple_list<input_type_entry> &type
// font with the given name // font with the given name
//------------------------------------------------- //-------------------------------------------------
osd_font osd_common_t::font_open(const char *name, int &height) osd_font *osd_common_t::font_open(const char *name, int &height)
{ {
return NULL; return NULL;
} }
@ -357,7 +357,7 @@ osd_font osd_common_t::font_open(const char *name, int &height)
// a given OSD font // a given OSD font
//------------------------------------------------- //-------------------------------------------------
void osd_common_t::font_close(osd_font font) void osd_common_t::font_close(osd_font *font)
{ {
} }
@ -370,7 +370,7 @@ void osd_common_t::font_close(osd_font font)
// pixel of a black & white font // pixel of a black & white font
//------------------------------------------------- //-------------------------------------------------
bool osd_common_t::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) bool osd_common_t::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
{ {
return false; return false;
} }

View File

@ -153,9 +153,9 @@ public:
virtual void customize_input_type_list(simple_list<input_type_entry> &typelist); virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
// font overridables // font overridables
virtual osd_font font_open(const char *name, int &height); virtual osd_font *font_open(const char *name, int &height);
virtual void font_close(osd_font font); virtual void font_close(osd_font *font);
virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
// video overridables // video overridables
virtual void *get_slider_list(); virtual void *get_slider_list();

View File

@ -53,8 +53,10 @@ static output_delegate output_cb[OSD_OUTPUT_CHANNEL_COUNT] =
output_delegate osd_set_output_channel(output_channel channel, output_delegate callback) output_delegate osd_set_output_channel(output_channel channel, output_delegate callback)
{ {
assert(channel < OSD_OUTPUT_CHANNEL_COUNT); if (!(channel < OSD_OUTPUT_CHANNEL_COUNT) || callback.isnull())
assert(!callback.isnull()); {
throw std::exception();
}
/* return the originals if requested */ /* return the originals if requested */
output_delegate prevcb = output_cb[channel]; output_delegate prevcb = output_cb[channel];

View File

@ -27,7 +27,7 @@ class input_type_entry; // FIXME: including emu.h does not work because emu.
//============================================================ //============================================================
// FIXME: We can do better than this // FIXME: We can do better than this
typedef void *osd_font; class osd_font;
// ======================> osd_interface // ======================> osd_interface
@ -53,9 +53,9 @@ public:
virtual void customize_input_type_list(simple_list<input_type_entry> &typelist) = 0; virtual void customize_input_type_list(simple_list<input_type_entry> &typelist) = 0;
// font overridables // font overridables
virtual osd_font font_open(const char *name, int &height) = 0; virtual osd_font *font_open(const char *name, int &height) = 0;
virtual void font_close(osd_font font) = 0; virtual void font_close(osd_font *font) = 0;
virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0;
// video overridables // video overridables
virtual void *get_slider_list() = 0; // FIXME: returns slider_state * virtual void *get_slider_list() = 0; // FIXME: returns slider_state *

View File

@ -134,11 +134,12 @@ public:
const HashT hash() const { return m_hash; } const HashT hash() const { return m_hash; }
const UINT32 flags() const { return m_flags; } const UINT32 flags() const { return m_flags; }
const bool is_pixels_owned() const { // do we own / allocated it ? const bool is_pixels_owned() const { // do we own / allocated it ?
return m_sdl_access == SDL_TEXTUREACCESS_STATIC return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
&& m_copyinfo->func != NULL ; && (m_copyinfo->func != NULL)) ;
} }
private: private:
Uint32 m_sdl_access;
SDL_Renderer * m_renderer; SDL_Renderer * m_renderer;
render_texinfo m_texinfo; // copy of the texture info render_texinfo m_texinfo; // copy of the texture info
HashT m_hash; // hash value for the texture (must be >= pointer size) HashT m_hash; // hash value for the texture (must be >= pointer size)
@ -149,7 +150,6 @@ private:
int m_format; // texture format int m_format; // texture format
SDL_BlendMode m_sdl_blendmode; SDL_BlendMode m_sdl_blendmode;
Uint32 m_sdl_access;
texture_info * m_next; // next texture in the list texture_info * m_next; // next texture in the list
}; };
@ -490,6 +490,7 @@ static void expand_copy_info(copy_info_t *list)
} }
} }
// FIXME: machine only used to access options.
int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks) int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
{ {
const char *stemp; const char *stemp;
@ -1007,9 +1008,9 @@ texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsour
texture_info::~texture_info() texture_info::~texture_info()
{ {
SDL_DestroyTexture(m_texture_id); if ( is_pixels_owned() && (m_pixels != NULL) )
if ( is_pixels_owned() && m_pixels != NULL )
free(m_pixels); free(m_pixels);
SDL_DestroyTexture(m_texture_id);
} }
//============================================================ //============================================================

View File

@ -111,12 +111,6 @@
#endif #endif
//============================================================
// TYPE DEFINITIONS
//============================================================
typedef void *osd_font;
//============================================================ //============================================================
// TYPE DEFINITIONS // TYPE DEFINITIONS
//============================================================ //============================================================
@ -193,9 +187,9 @@ public:
virtual void customize_input_type_list(simple_list<input_type_entry> &typelist); virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
// font overridables // font overridables
virtual osd_font font_open(const char *name, int &height); virtual osd_font *font_open(const char *name, int &height);
virtual void font_close(osd_font font); virtual void font_close(osd_font *font);
virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
virtual void video_register(); virtual void video_register();
virtual void sound_register(); virtual void sound_register();

View File

@ -717,7 +717,13 @@ void sdl_osd_interface::init(running_machine &machine)
// font with the given name // font with the given name
//------------------------------------------------- //-------------------------------------------------
osd_font sdl_osd_interface::font_open(const char *_name, int &height) class osd_font
{
public:
CTFontRef m_font;
};
osd_font *sdl_osd_interface::font_open(const char *_name, int &height)
{ {
CFStringRef font_name = NULL; CFStringRef font_name = NULL;
CTFontRef ct_font = NULL; CTFontRef ct_font = NULL;
@ -770,7 +776,9 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height)
line_height += CTFontGetLeading(ct_font); line_height += CTFontGetLeading(ct_font);
height = ceilf(line_height * EXTRA_HEIGHT); height = ceilf(line_height * EXTRA_HEIGHT);
return (osd_font)ct_font; osd_font *ret = global_alloc(osd_font);
ret->m_font = ct_font;
return ret;
} }
//------------------------------------------------- //-------------------------------------------------
@ -778,14 +786,15 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height)
// a given OSD font // a given OSD font
//------------------------------------------------- //-------------------------------------------------
void sdl_osd_interface::font_close(osd_font font) void sdl_osd_interface::font_close(osd_font *font)
{ {
CTFontRef ct_font = (CTFontRef)font; CTFontRef ct_font = font->m_font;
if( ct_font != NULL ) if( ct_font != NULL )
{ {
CFRelease( ct_font ); CFRelease( ct_font );
} }
global_free(font);
} }
//------------------------------------------------- //-------------------------------------------------
@ -796,11 +805,11 @@ void sdl_osd_interface::font_close(osd_font font)
// pixel of a black & white font // pixel of a black & white font
//------------------------------------------------- //-------------------------------------------------
bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
{ {
UniChar uni_char; UniChar uni_char;
CGGlyph glyph; CGGlyph glyph;
CTFontRef ct_font = (CTFontRef)font; CTFontRef ct_font = font->m_font;
const CFIndex count = 1; const CFIndex count = 1;
CGRect bounding_rect, success_rect; CGRect bounding_rect, success_rect;
CGContextRef context_ref; CGContextRef context_ref;
@ -1009,7 +1018,13 @@ static TTF_Font *search_font_config(astring name, bool bold, bool italic, bool u
// font with the given name // font with the given name
//------------------------------------------------- //-------------------------------------------------
osd_font sdl_osd_interface::font_open(const char *_name, int &height) class osd_font
{
public:
TTF_Font *m_font;
};
osd_font *sdl_osd_interface::font_open(const char *_name, int &height)
{ {
TTF_Font *font = (TTF_Font *)NULL; TTF_Font *font = (TTF_Font *)NULL;
bool bakedstyles = false; bool bakedstyles = false;
@ -1081,7 +1096,9 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height)
height = TTF_FontLineSkip(font); height = TTF_FontLineSkip(font);
return (osd_font)font; osd_font *ret = global_alloc(osd_font);
ret->m_font = font;
return ret;
} }
//------------------------------------------------- //-------------------------------------------------
@ -1089,13 +1106,10 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height)
// a given OSD font // a given OSD font
//------------------------------------------------- //-------------------------------------------------
void sdl_osd_interface::font_close(osd_font font) void sdl_osd_interface::font_close(osd_font *font)
{ {
TTF_Font *ttffont; TTF_CloseFont(font->m_font);
global_free(font);
ttffont = (TTF_Font *)font;
TTF_CloseFont(ttffont);
} }
//------------------------------------------------- //-------------------------------------------------
@ -1106,14 +1120,14 @@ void sdl_osd_interface::font_close(osd_font font)
// pixel of a black & white font // pixel of a black & white font
//------------------------------------------------- //-------------------------------------------------
bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
{ {
TTF_Font *ttffont; TTF_Font *ttffont;
SDL_Surface *drawsurf; SDL_Surface *drawsurf;
SDL_Color fcol = { 0xff, 0xff, 0xff }; SDL_Color fcol = { 0xff, 0xff, 0xff };
UINT16 ustr[16]; UINT16 ustr[16];
ttffont = (TTF_Font *)font; ttffont = font->m_font;
memset(ustr,0,sizeof(ustr)); memset(ustr,0,sizeof(ustr));
ustr[0] = (UINT16)chnum; ustr[0] = (UINT16)chnum;

View File

@ -719,7 +719,7 @@ void windows_osd_interface::osd_exit()
// font with the given name // font with the given name
//------------------------------------------------- //-------------------------------------------------
osd_font windows_osd_interface::font_open(const char *_name, int &height) osd_font *windows_osd_interface::font_open(const char *_name, int &height)
{ {
// accept qualifiers from the name // accept qualifiers from the name
astring name(_name); astring name(_name);
@ -751,7 +751,7 @@ osd_font windows_osd_interface::font_open(const char *_name, int &height)
// create the font // create the font
height = logfont.lfHeight; height = logfont.lfHeight;
osd_font font = reinterpret_cast<osd_font>(CreateFontIndirect(&logfont)); osd_font *font = reinterpret_cast<osd_font *>(CreateFontIndirect(&logfont));
if (font == NULL) if (font == NULL)
return NULL; return NULL;
@ -783,7 +783,7 @@ osd_font windows_osd_interface::font_open(const char *_name, int &height)
// a given OSD font // a given OSD font
//------------------------------------------------- //-------------------------------------------------
void windows_osd_interface::font_close(osd_font font) void windows_osd_interface::font_close(osd_font *font)
{ {
// delete the font ojbect // delete the font ojbect
if (font != NULL) if (font != NULL)
@ -799,7 +799,7 @@ void windows_osd_interface::font_close(osd_font font)
// pixel of a black & white font // pixel of a black & white font
//------------------------------------------------- //-------------------------------------------------
bool windows_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) bool windows_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
{ {
// create a dummy DC to work with // create a dummy DC to work with
HDC dummyDC = CreateCompatibleDC(NULL); HDC dummyDC = CreateCompatibleDC(NULL);

View File

@ -253,9 +253,9 @@ public:
virtual void customize_input_type_list(simple_list<input_type_entry> &typelist); virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
// font overridables // font overridables
virtual osd_font font_open(const char *name, int &height); virtual osd_font *font_open(const char *name, int &height);
virtual void font_close(osd_font font); virtual void font_close(osd_font *font);
virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
virtual void video_register(); virtual void video_register();
virtual void sound_register(); virtual void sound_register();