Palettes are now copied during get_primlist. This should fix

multithreading related palette issues. Along the way also 
- added constructors to SDL osd structs
- changed related malloc to global_alloc
- added a copyfrom routine to dynamic_array
- minor code simplifications.
This commit is contained in:
couriersud 2015-01-01 22:13:55 +01:00
parent f0b06a5c84
commit fde220f4a7
11 changed files with 390 additions and 217 deletions

View File

@ -201,6 +201,54 @@ inline item_layer get_layer_and_blendmode(const layout_view &view, int index, in
return item_layer(layer); return item_layer(layer);
} }
//**************************************************************************
// render_texinfo
//**************************************************************************
render_texinfo &render_texinfo::operator=(const render_texinfo &src)
{
free_palette();
base = src.base;
rowpixels = src.rowpixels;
width = src.width;
height = src.height;
seqid = src.seqid;
osddata = src.osddata;
m_palette = src.m_palette;
if (m_palette != NULL)
{
m_palette->ref_count++;
}
return *this;
}
void render_texinfo::set_palette(const dynamic_array<rgb_t> *source)
{
free_palette();
if (source != NULL)
{
m_palette = global_alloc(render_palette_copy);
m_palette->palette.copyfrom(*source);
m_palette->ref_count = 1;
}
else
{
m_palette = NULL;
}
}
void render_texinfo::free_palette()
{
if (m_palette != NULL)
{
m_palette->ref_count--;
if (m_palette->ref_count == 0)
{
global_free(m_palette);
}
}
m_palette = NULL;
}
//************************************************************************** //**************************************************************************
@ -214,7 +262,25 @@ inline item_layer get_layer_and_blendmode(const layout_view &view, int index, in
void render_primitive::reset() void render_primitive::reset()
{ {
memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type)); // public state
type = INVALID;
bounds.x0 = 0;
bounds.y0 = 0;
bounds.x1 = 0;
bounds.y1 = 0;
color.a = 0;
color.r = 0;
color.g = 0;
color.b = 0;
flags = 0;
width = 0.0f;
// texcoords; FIXME
// do not clear m_next!
// memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type));
texture.set_palette(NULL);
texture = render_texinfo();
} }
@ -447,7 +513,7 @@ void render_texture::hq_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const
// get_scaled - get a scaled bitmap (if we can) // get_scaled - get a scaled bitmap (if we can)
//------------------------------------------------- //-------------------------------------------------
bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist) void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist)
{ {
// source width/height come from the source bounds // source width/height come from the source bounds
int swidth = m_sbounds.width(); int swidth = m_sbounds.width();
@ -460,7 +526,6 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
texinfo.osddata = m_osddata; texinfo.osddata = m_osddata;
// are we scaler-free? if so, just return the source bitmap // are we scaler-free? if so, just return the source bitmap
const rgb_t *palbase = (m_format == TEXFORMAT_PALETTE16 || m_format == TEXFORMAT_PALETTEA16) ? m_bitmap->palette()->entry_list_adjusted() : NULL;
if (m_scaler == NULL || (m_bitmap != NULL && swidth == dwidth && sheight == dheight)) if (m_scaler == NULL || (m_bitmap != NULL && swidth == dwidth && sheight == dheight))
{ {
// add a reference and set up the source bitmap // add a reference and set up the source bitmap
@ -469,11 +534,12 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
texinfo.rowpixels = m_bitmap->rowpixels(); texinfo.rowpixels = m_bitmap->rowpixels();
texinfo.width = swidth; texinfo.width = swidth;
texinfo.height = sheight; texinfo.height = sheight;
texinfo.palette = palbase; // will be set later
texinfo.set_palette(NULL);
texinfo.seqid = ++m_curseq; texinfo.seqid = ++m_curseq;
return true;
} }
else
{
// make sure we can recover the original argb32 bitmap // make sure we can recover the original argb32 bitmap
bitmap_argb32 dummy; bitmap_argb32 dummy;
bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy; bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
@ -523,9 +589,10 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
texinfo.rowpixels = scaled->bitmap->rowpixels(); texinfo.rowpixels = scaled->bitmap->rowpixels();
texinfo.width = dwidth; texinfo.width = dwidth;
texinfo.height = dheight; texinfo.height = dheight;
texinfo.palette = palbase; // will be set later
texinfo.set_palette(NULL);
texinfo.seqid = scaled->seqid; texinfo.seqid = scaled->seqid;
return true; }
} }
@ -534,7 +601,7 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
// palette for a texture // palette for a texture
//------------------------------------------------- //-------------------------------------------------
const rgb_t *render_texture::get_adjusted_palette(render_container &container) const dynamic_array<rgb_t> *render_texture::get_adjusted_palette(render_container &container)
{ {
// override the palette with our adjusted palette // override the palette with our adjusted palette
switch (m_format) switch (m_format)
@ -546,7 +613,7 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container)
// if no adjustment necessary, return the raw palette // if no adjustment necessary, return the raw palette
if (!container.has_brightness_contrast_gamma_changes()) if (!container.has_brightness_contrast_gamma_changes())
return m_bitmap->palette()->entry_list_adjusted(); return m_bitmap->palette()->entry_list_adjusted_darray();
// otherwise, return our adjusted palette // otherwise, return our adjusted palette
return container.bcg_lookup_table(m_format, m_bitmap->palette()); return container.bcg_lookup_table(m_format, m_bitmap->palette());
@ -582,7 +649,8 @@ render_container::render_container(render_manager &manager, screen_device *scree
m_manager(manager), m_manager(manager),
m_screen(screen), m_screen(screen),
m_overlaybitmap(NULL), m_overlaybitmap(NULL),
m_overlaytexture(NULL) m_overlaytexture(NULL),
m_bcglookup256(0x400)
{ {
// make sure it is empty // make sure it is empty
empty(); empty();
@ -722,7 +790,7 @@ float render_container::apply_brightness_contrast_gamma_fp(float value)
// given texture mode // given texture mode
//------------------------------------------------- //-------------------------------------------------
const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palette) const dynamic_array<rgb_t> *render_container::bcg_lookup_table(int texformat, palette_t *palette)
{ {
switch (texformat) switch (texformat)
{ {
@ -736,12 +804,12 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palett
recompute_lookups(); recompute_lookups();
} }
assert (palette == &m_palclient->palette()); assert (palette == &m_palclient->palette());
return m_bcglookup; return &m_bcglookup;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
case TEXFORMAT_ARGB32: case TEXFORMAT_ARGB32:
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
return m_bcglookup256; return &m_bcglookup256;
default: default:
return NULL; return NULL;
@ -1726,10 +1794,15 @@ void render_target::add_container_primitives(render_primitive_list &list, const
int height = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.x1 - prim->bounds.x0) : (prim->bounds.y1 - prim->bounds.y0); int height = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.x1 - prim->bounds.x0) : (prim->bounds.y1 - prim->bounds.y0);
width = MIN(width, m_maxtexwidth); width = MIN(width, m_maxtexwidth);
height = MIN(height, m_maxtexheight); height = MIN(height, m_maxtexheight);
if (curitem->texture()->get_scaled(width, height, prim->texture, list))
{ curitem->texture()->get_scaled(width, height, prim->texture, list);
// set the palette // set the palette
#if 1
const dynamic_array<rgb_t> *adjusted_pal = curitem->texture()->get_adjusted_palette(container);
prim->texture.set_palette(adjusted_pal);
#else
prim->texture.palette = curitem->texture()->get_adjusted_palette(container); prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
#endif
// determine UV coordinates and apply clipping // determine UV coordinates and apply clipping
prim->texcoords = oriented_texcoords[finalorient]; prim->texcoords = oriented_texcoords[finalorient];
@ -1744,7 +1817,6 @@ void render_target::add_container_primitives(render_primitive_list &list, const
else else
prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags())); prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
} }
}
else else
{ {
// adjust the color for brightness/contrast/gamma // adjust the color for brightness/contrast/gamma
@ -1778,11 +1850,10 @@ void render_target::add_container_primitives(render_primitive_list &list, const
width = render_round_nearest(prim->bounds.x1) - render_round_nearest(prim->bounds.x0); width = render_round_nearest(prim->bounds.x1) - render_round_nearest(prim->bounds.x0);
height = render_round_nearest(prim->bounds.y1) - render_round_nearest(prim->bounds.y0); height = render_round_nearest(prim->bounds.y1) - render_round_nearest(prim->bounds.y0);
bool got_scaled = container.overlay()->get_scaled( container.overlay()->get_scaled(
(container_xform.orientation & ORIENTATION_SWAP_XY) ? height : width, (container_xform.orientation & ORIENTATION_SWAP_XY) ? height : width,
(container_xform.orientation & ORIENTATION_SWAP_XY) ? width : height, prim->texture, list); (container_xform.orientation & ORIENTATION_SWAP_XY) ? width : height, prim->texture, list);
if (got_scaled)
{
// determine UV coordinates // determine UV coordinates
prim->texcoords = oriented_texcoords[container_xform.orientation]; prim->texcoords = oriented_texcoords[container_xform.orientation];
@ -1791,8 +1862,8 @@ void render_target::add_container_primitives(render_primitive_list &list, const
PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) | PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) |
PRIMFLAG_TEXFORMAT(container.overlay()->format()) | PRIMFLAG_TEXFORMAT(container.overlay()->format()) |
PRIMFLAG_TEXSHADE(1); PRIMFLAG_TEXSHADE(1);
}
list.append_or_return(*prim, !got_scaled); list.append_or_return(*prim, false);
} }
} }
@ -1830,9 +1901,9 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob
height = MIN(height, m_maxtexheight); height = MIN(height, m_maxtexheight);
// get the scaled texture and append it // get the scaled texture and append it
bool clipped = true;
if (texture->get_scaled(width, height, prim->texture, list)) texture->get_scaled(width, height, prim->texture, list);
{
// compute the clip rect // compute the clip rect
render_bounds cliprect; render_bounds cliprect;
cliprect.x0 = render_round_nearest(xform.xoffs); cliprect.x0 = render_round_nearest(xform.xoffs);
@ -1843,8 +1914,7 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob
// determine UV coordinates and apply clipping // determine UV coordinates and apply clipping
prim->texcoords = oriented_texcoords[xform.orientation]; prim->texcoords = oriented_texcoords[xform.orientation];
clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords); bool clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
}
// add to the list or free if we're clipped out // add to the list or free if we're clipped out
list.append_or_return(*prim, clipped); list.append_or_return(*prim, clipped);

View File

@ -167,7 +167,6 @@ class layout_view;
// texture scaling callback // texture scaling callback
typedef void (*texture_scaler_func)(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param); typedef void (*texture_scaler_func)(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
// render_bounds - floating point bounding rectangle // render_bounds - floating point bounding rectangle
struct render_bounds struct render_bounds
{ {
@ -210,15 +209,45 @@ struct render_quad_texuv
// render_texinfo - texture information // render_texinfo - texture information
struct render_texinfo
struct render_palette_copy
{ {
int ref_count;
dynamic_array<rgb_t> palette;
};
class render_texinfo
{
private:
render_texinfo(const render_texinfo &src) {}
public:
render_texinfo()
: base(NULL), rowpixels(0), width(0), height(0),
seqid(0), osddata(0), m_palette(NULL)
{}
~render_texinfo()
{
free_palette();
}
render_texinfo &operator=(const render_texinfo &src);
void * base; // base of the data void * base; // base of the data
UINT32 rowpixels; // pixels per row UINT32 rowpixels; // pixels per row
UINT32 width; // width of the image UINT32 width; // width of the image
UINT32 height; // height of the image UINT32 height; // height of the image
const rgb_t * palette; // palette for PALETTE16 textures, LUTs for RGB15/RGB32
UINT32 seqid; // sequence ID UINT32 seqid; // sequence ID
UINT64 osddata; // aux data to pass to osd UINT64 osddata; // aux data to pass to osd
const rgb_t * palette() const { return ((m_palette == NULL) ? NULL : &m_palette->palette[0]); }
void set_palette(const dynamic_array<rgb_t> *source);
private:
void free_palette();
render_palette_copy *m_palette; // palette for PALETTE16 textures, LUTs for RGB15/RGB32
}; };
@ -433,8 +462,8 @@ public:
private: private:
// internal helpers // internal helpers
bool get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist); void get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist);
const rgb_t *get_adjusted_palette(render_container &container); const dynamic_array<rgb_t> *get_adjusted_palette(render_container &container);
static const int MAX_TEXTURE_SCALES = 8; static const int MAX_TEXTURE_SCALES = 8;
@ -524,7 +553,7 @@ public:
bool has_brightness_contrast_gamma_changes() const { return (m_user.m_brightness != 1.0f || m_user.m_contrast != 1.0f || m_user.m_gamma != 1.0f); } bool has_brightness_contrast_gamma_changes() const { return (m_user.m_brightness != 1.0f || m_user.m_contrast != 1.0f || m_user.m_gamma != 1.0f); }
UINT8 apply_brightness_contrast_gamma(UINT8 value); UINT8 apply_brightness_contrast_gamma(UINT8 value);
float apply_brightness_contrast_gamma_fp(float value); float apply_brightness_contrast_gamma_fp(float value);
const rgb_t *bcg_lookup_table(int texformat, palette_t *palette = NULL); const dynamic_array<rgb_t> *bcg_lookup_table(int texformat, palette_t *palette = NULL);
private: private:
// an item describes a high level primitive that is added to a container // an item describes a high level primitive that is added to a container
@ -576,7 +605,7 @@ private:
render_texture * m_overlaytexture; // overlay texture render_texture * m_overlaytexture; // overlay texture
auto_pointer<palette_client> m_palclient; // client to the screen palette auto_pointer<palette_client> m_palclient; // client to the screen palette
dynamic_array<rgb_t> m_bcglookup; // full palette lookup with bcg adjustments dynamic_array<rgb_t> m_bcglookup; // full palette lookup with bcg adjustments
rgb_t m_bcglookup256[0x400]; // lookup table for brightness/contrast/gamma dynamic_array<rgb_t> m_bcglookup256; // lookup table for brightness/contrast/gamma
}; };

View File

@ -130,6 +130,7 @@ private:
static inline UINT32 get_texel_palette16(const render_texinfo &texture, INT32 curu, INT32 curv) static inline UINT32 get_texel_palette16(const render_texinfo &texture, INT32 curu, INT32 curv)
{ {
const rgb_t *palbase = texture.palette();
if (_BilinearFilter) if (_BilinearFilter)
{ {
INT32 u0 = curu >> 16; INT32 u0 = curu >> 16;
@ -144,16 +145,16 @@ private:
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base); const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
texbase += v0 * texture.rowpixels + u0; texbase += v0 * texture.rowpixels + u0;
UINT32 pix00 = texture.palette[texbase[0]]; UINT32 pix00 = palbase[texbase[0]];
UINT32 pix01 = texture.palette[texbase[u1]]; UINT32 pix01 = palbase[texbase[u1]];
UINT32 pix10 = texture.palette[texbase[v1]]; UINT32 pix10 = palbase[texbase[v1]];
UINT32 pix11 = texture.palette[texbase[u1 + v1]]; UINT32 pix11 = palbase[texbase[u1 + v1]];
return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8); return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
} }
else else
{ {
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16);
return texture.palette[texbase[0]]; return palbase[texbase[0]];
} }
} }
@ -165,6 +166,7 @@ private:
static inline UINT32 get_texel_palette16a(const render_texinfo &texture, INT32 curu, INT32 curv) static inline UINT32 get_texel_palette16a(const render_texinfo &texture, INT32 curu, INT32 curv)
{ {
const rgb_t *palbase = texture.palette();
if (_BilinearFilter) if (_BilinearFilter)
{ {
INT32 u0 = curu >> 16; INT32 u0 = curu >> 16;
@ -179,16 +181,16 @@ private:
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base); const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
texbase += v0 * texture.rowpixels + u0; texbase += v0 * texture.rowpixels + u0;
UINT32 pix00 = texture.palette[texbase[0]]; UINT32 pix00 = palbase[texbase[0]];
UINT32 pix01 = texture.palette[texbase[u1]]; UINT32 pix01 = palbase[texbase[u1]];
UINT32 pix10 = texture.palette[texbase[v1]]; UINT32 pix10 = palbase[texbase[v1]];
UINT32 pix11 = texture.palette[texbase[u1 + v1]]; UINT32 pix11 = palbase[texbase[u1 + v1]];
return rgba_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8); return rgba_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
} }
else else
{ {
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16);
return texture.palette[texbase[0]]; return palbase[texbase[0]];
} }
} }
@ -912,7 +914,7 @@ private:
static void draw_quad_yuy16_none(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_yuy16_none(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;
@ -1082,7 +1084,7 @@ private:
static void draw_quad_rgb32(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_rgb32(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;
@ -1252,7 +1254,7 @@ private:
static void draw_quad_rgb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_rgb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;
@ -1390,7 +1392,7 @@ private:
static void draw_quad_argb32_alpha(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_argb32_alpha(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;
@ -1536,7 +1538,7 @@ private:
static void draw_quad_argb32_multiply(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_argb32_multiply(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;
@ -1655,7 +1657,7 @@ private:
static void draw_quad_argb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup) static void draw_quad_argb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{ {
const rgb_t *palbase = prim.texture.palette; const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx; INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx; INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx; INT32 endx = setup.endx;

View File

@ -99,6 +99,14 @@ public:
void resize_and_clear(int count, UINT8 data = 0) { resize(count); clear(data); } void resize_and_clear(int count, UINT8 data = 0) { resize(count); clear(data); }
void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); } void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); }
// batch operations
void copyfrom(const dynamic_array<_ElementType> &source)
{
resize(source.count());
for (int i=0; i < source.count(); i++)
m_array[i] = source[i];
}
private: private:
// internal helpers // internal helpers
void expand_internal(int count) void expand_internal(int count)

View File

@ -170,6 +170,7 @@ public:
// entry list getters // entry list getters
const rgb_t *entry_list_raw() const { return m_entry_color; } const rgb_t *entry_list_raw() const { return m_entry_color; }
const dynamic_array<rgb_t> *entry_list_adjusted_darray() const { return &m_adjusted_color; }
const rgb_t *entry_list_adjusted() const { return m_adjusted_color; } const rgb_t *entry_list_adjusted() const { return m_adjusted_color; }
const rgb_t *entry_list_adjusted_rgb15() const { return m_adjusted_rgb15; } const rgb_t *entry_list_adjusted_rgb15() const { return m_adjusted_rgb15; }

View File

@ -53,47 +53,47 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
#define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000) #define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000)
#define OP_RGB32PAL_ARGB32(_src) \ #define OP_RGB32PAL_ARGB32(_src) \
(texsource->palette[0x200 + (((_src) >> 16) & 0xff) ] | \ (palbase[0x200 + (((_src) >> 16) & 0xff) ] | \
texsource->palette[0x100 + (((_src) >> 8) & 0xff) ] | \ palbase[0x100 + (((_src) >> 8) & 0xff) ] | \
texsource->palette[((_src) & 0xff) ] | 0xff000000) palbase[((_src) & 0xff) ] | 0xff000000)
#define OP_PAL16_ARGB32(_src) (0xff000000 | texsource->palette[_src]) #define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src])
#define OP_PAL16A_ARGB32(_src) (texsource->palette[_src]) #define OP_PAL16A_ARGB32(_src) (palbase[_src])
#define OP_RGB15_ARGB32(_src) (0xff000000 | ((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) | \ #define OP_RGB15_ARGB32(_src) (0xff000000 | ((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) | \
((((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) >> 5) & 0x070707)) ((((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) >> 5) & 0x070707))
#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | texsource->palette[0x40 + ((_src >> 10) & 0x1f)] | \ #define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \
texsource->palette[0x20 + ((_src >> 5) & 0x1f)] | texsource->palette[0x00 + ((_src >> 0) & 0x1f)]) palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)])
#define OP_ARGB32_RGB32(_pixel) premult32(_pixel) #define OP_ARGB32_RGB32(_pixel) premult32(_pixel)
#define OP_PAL16A_RGB32(_src) premult32(texsource->palette[_src]) #define OP_PAL16A_RGB32(_src) premult32(palbase[_src])
#define OP_PAL16_ARGB1555(_src) ((texsource->palette[_src]&0xf80000) >> 9 | \ #define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \
(texsource->palette[_src]&0x00f800) >> 6 | \ (palbase[_src]&0x00f800) >> 6 | \
(texsource->palette[_src]&0x0000f8) >> 3 | 0x8000) (palbase[_src]&0x0000f8) >> 3 | 0x8000)
#define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000) #define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000)
#define OP_RGB15PAL_ARGB1555(_src) ((texsource->palette[(_src) >> 10] & 0xf8) << 7 | \ #define OP_RGB15PAL_ARGB1555(_src) ((palbase[(_src) >> 10] & 0xf8) << 7 | \
(texsource->palette[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \ (palbase[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \
(texsource->palette[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000) (palbase[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000)
#define OP_YUV16_UYVY(_src) (_src) #define OP_YUV16_UYVY(_src) (_src)
#define OP_YUV16PAL_UYVY(_src) ((texsource->palette[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff)) #define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff))
#define OP_YUV16PAL_YVYU(_src) ((texsource->palette[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8)) #define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8))
#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8)) #define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8))
#define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \ #define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \
(((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) ) (((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) )
#define OP_YUV16PAL_YUY2(_src) ( (texsource->palette[((_src)>>8) & 0xff]) | \ #define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \
(texsource->palette[((_src)>>24) & 0xff]<<16) | \ (palbase[((_src)>>24) & 0xff]<<16) | \
(((_src)<<8)&0xff00ff00) ) (((_src)<<8)&0xff00ff00) )
#define OP_YUV16_ARGB32(_src) \ #define OP_YUV16_ARGB32(_src) \
@ -101,12 +101,12 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
| ((UINT64)ycc_to_rgb(((_src) >> 24) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) << 32) | ((UINT64)ycc_to_rgb(((_src) >> 24) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16PAL_ARGB32(_src) \ #define OP_YUV16PAL_ARGB32(_src) \
(UINT64)ycc_to_rgb(texsource->palette[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \ (UINT64)ycc_to_rgb(palbase[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \
| ((UINT64)ycc_to_rgb(texsource->palette[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32) | ((UINT64)ycc_to_rgb(palbase[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src)) #define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src))
#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), texsource->palette) #define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase)
//============================================================ //============================================================
// Copy and rotation // Copy and rotation
@ -114,6 +114,7 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
#define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \ #define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \
INLINE void texcopy_##_name (texture_info *texture, const render_texinfo *texsource) { \ INLINE void texcopy_##_name (texture_info *texture, const render_texinfo *texsource) { \
const rgb_t *palbase = texsource->palette(); \
int x, y; \ int x, y; \
/* loop over Y */ \ /* loop over Y */ \
for (y = 0; y < texsource->height; y++) { \ for (y = 0; y < texsource->height; y++) { \
@ -133,6 +134,7 @@ INLINE void texcopy_##_name (texture_info *texture, const render_texinfo *texsou
#define TEXROT( _name, _src_type, _dest_type, _op) \ #define TEXROT( _name, _src_type, _dest_type, _op) \
INLINE void texcopy_rot_##_name (texture_info *texture, const render_texinfo *texsource) { \ INLINE void texcopy_rot_##_name (texture_info *texture, const render_texinfo *texsource) { \
const rgb_t *palbase = texsource->palette(); \
int x, y; \ int x, y; \
quad_setup_data *setup = &texture->setup; \ quad_setup_data *setup = &texture->setup; \
int dudx = setup->dudx; \ int dudx = setup->dudx; \

View File

@ -60,6 +60,10 @@ enum
struct quad_setup_data struct quad_setup_data
{ {
quad_setup_data()
: dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
rotwidth(0), rotheight(0)
{}
INT32 dudx, dvdx, dudy, dvdy; INT32 dudx, dvdx, dudy, dvdy;
INT32 startu, startv; INT32 startu, startv;
INT32 rotwidth, rotheight; INT32 rotwidth, rotheight;
@ -90,6 +94,12 @@ struct copy_info {
/* texture_info holds information about a texture */ /* texture_info holds information about a texture */
struct texture_info struct texture_info
{ {
texture_info()
: next(NULL), hash(0), flags(0), rawwidth(0), rawheight(0), format(0),
pixels(NULL), pitch(0), pixels_own(0), texture_id(NULL), copyinfo(NULL),
sdl_access(0), sdl_blendmode(SDL_BLENDMODE_NONE), is_rotated(0), last_access(0)
{
}
texture_info * next; // next texture in the list texture_info * next; // next texture in the list
HashT hash; // hash value for the texture (must be >= pointer size) HashT hash; // hash value for the texture (must be >= pointer size)
@ -117,6 +127,12 @@ struct texture_info
/* sdl_info is the information about SDL for the current screen */ /* sdl_info is the information about SDL for the current screen */
struct sdl_info struct sdl_info
{ {
sdl_info()
: blittimer(0), extra_flags(0), sdl_renderer(NULL), texlist(NULL),
texture_max_width(0), texture_max_height(0), last_hofs(0), last_vofs(0),
resize_pending(0), resize_width(0), resize_height(0),
last_blit_time(0), last_blit_pixels(0)
{}
INT32 blittimer; INT32 blittimer;
UINT32 extra_flags; UINT32 extra_flags;
@ -441,7 +457,7 @@ static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32
static void add_list(copy_info **head, copy_info *element, Uint32 bm) static void add_list(copy_info **head, copy_info *element, Uint32 bm)
{ {
copy_info *newci = (copy_info *) osd_malloc(sizeof(copy_info)); copy_info *newci = global_alloc(copy_info);
*newci = *element; *newci = *element;
newci->bm_mask = bm; newci->bm_mask = bm;
@ -515,7 +531,7 @@ static void drawsdl2_exit(void)
(int) bi->perf); (int) bi->perf);
freeme = bi; freeme = bi;
bi = bi->next; bi = bi->next;
osd_free(freeme); global_free(freeme);
} }
} }
@ -543,12 +559,10 @@ static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window)
static int drawsdl2_window_create(sdl_window_info *window, int width, int height) static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
{ {
// allocate memory for our structures // allocate memory for our structures
sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl)); sdl_info *sdl = global_alloc(sdl_info);
osd_printf_verbose("Enter drawsdl2_window_create\n"); osd_printf_verbose("Enter drawsdl2_window_create\n");
memset(sdl, 0, sizeof(*sdl));
window->dxdata = sdl; window->dxdata = sdl;
sdl->extra_flags = (window->fullscreen() ? sdl->extra_flags = (window->fullscreen() ?
@ -819,7 +833,7 @@ static void drawsdl2_window_destroy(sdl_window_info *window)
SDL_DestroyWindow(window->sdl_window); SDL_DestroyWindow(window->sdl_window);
osd_free(sdl); global_free(sdl);
window->dxdata = NULL; window->dxdata = NULL;
} }
@ -879,8 +893,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture_info *texture; texture_info *texture;
// allocate a new texture // allocate a new texture
texture = (texture_info *) osd_malloc(sizeof(*texture)); texture = global_alloc(texture_info);
memset(texture, 0, sizeof(*texture));
// fill in the core data // fill in the core data
texture->hash = texture_compute_hash(texsource, flags); texture->hash = texture_compute_hash(texsource, flags);
@ -897,7 +910,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_ARGB32; texture->format = SDL_TEXFORMAT_ARGB32;
break; break;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
texture->format = texsource->palette ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32; texture->format = texsource->palette() ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32;
break; break;
case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTE16:
texture->format = SDL_TEXFORMAT_PALETTE16; texture->format = SDL_TEXFORMAT_PALETTE16;
@ -906,7 +919,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_PALETTE16A; texture->format = SDL_TEXFORMAT_PALETTE16A;
break; break;
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
texture->format = texsource->palette ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16; texture->format = texsource->palette() ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16;
break; break;
default: default:
@ -940,7 +953,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
if ( (texture->copyinfo->func != NULL) && (texture->sdl_access == SDL_TEXTUREACCESS_STATIC)) if ( (texture->copyinfo->func != NULL) && (texture->sdl_access == SDL_TEXTUREACCESS_STATIC))
{ {
texture->pixels = osd_malloc_array(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp); texture->pixels = malloc(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp);
texture->pixels_own=TRUE; texture->pixels_own=TRUE;
} }
/* add us to the texture list */ /* add us to the texture list */
@ -1135,7 +1148,7 @@ static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
SDL_DestroyTexture(texture->texture_id); SDL_DestroyTexture(texture->texture_id);
if ( texture->pixels_own ) if ( texture->pixels_own )
{ {
osd_free(texture->pixels); free(texture->pixels);
texture->pixels=NULL; texture->pixels=NULL;
texture->pixels_own=FALSE; texture->pixels_own=FALSE;
} }
@ -1147,7 +1160,7 @@ static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
sdl->texlist = NULL; sdl->texlist = NULL;
else else
p->next = texture->next; p->next = texture->next;
osd_free(texture); global_free(texture);
} }
static void drawsdl2_destroy_all_textures(sdl_window_info *window) static void drawsdl2_destroy_all_textures(sdl_window_info *window)

View File

@ -161,6 +161,25 @@ struct texture_info;
/* texture_info holds information about a texture */ /* texture_info holds information about a texture */
struct texture_info struct texture_info
{ {
texture_info()
: hash(0), flags(0), rawwidth(0), rawheight(0),
rawwidth_create(0), rawheight_create(0),
type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
data_own(0), texCoordBufferName(0)
{
for (int i=0; i<2; i++)
{
mpass_textureunit[i] = 0;
mpass_texture_mamebm[i] = 0;
mpass_fbo_mamebm[i] = 0;
mpass_texture_scrn[i] = 0;
mpass_fbo_scrn[i] = 0;
}
for (int i=0; i<8; i++)
texCoord[i] = 0.0f;
}
HashT hash; // hash value for the texture (must be >= pointer size) HashT hash; // hash value for the texture (must be >= pointer size)
UINT32 flags; // rendering flags UINT32 flags; // rendering flags
render_texinfo texinfo; // copy of the texture info render_texinfo texinfo; // copy of the texture info
@ -198,6 +217,36 @@ struct texture_info
/* sdl_info is the information about SDL for the current screen */ /* sdl_info is the information about SDL for the current screen */
struct sdl_info struct sdl_info
{ {
sdl_info()
: blittimer(0), extra_flags(0),
#if (SDLMAME_SDL2)
gl_context_id(0),
#else
sdlsurf(NULL),
#endif
initialized(0),
last_blendmode(0),
texture_max_width(0),
texture_max_height(0),
texpoweroftwo(0),
usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL),
glsl_program_num(0),
glsl_program_mb2sc(0),
usetexturerect(0),
init_context(0),
last_hofs(0.0f),
last_vofs(0.0f),
surf_w(0),
surf_h(0)
{
for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++)
texhash[i] = NULL;
for (int i=0; i < 2*GLSL_SHADER_MAX; i++)
glsl_program[i] = 0;
for (int i=0; i < 8; i++)
texVerticex[i] = 0.0f;
}
INT32 blittimer; INT32 blittimer;
UINT32 extra_flags; UINT32 extra_flags;
@ -487,8 +536,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
int has_and_allow_texturerect = 0; int has_and_allow_texturerect = 0;
// allocate memory for our structures // allocate memory for our structures
sdl = (sdl_info *) osd_malloc(sizeof(*sdl)); sdl = global_alloc(sdl_info);
memset(sdl, 0, sizeof(*sdl));
window->dxdata = sdl; window->dxdata = sdl;
@ -1612,7 +1660,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
} }
#endif #endif
osd_free(sdl); global_free(sdl);
window->dxdata = NULL; window->dxdata = NULL;
} }
@ -1654,7 +1702,7 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo
if ( texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST] && if ( texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST] &&
!texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE] && !texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE] &&
texture->xprescale == 1 && texture->yprescale == 1 && texture->xprescale == 1 && texture->yprescale == 1 &&
!texture->borderpix && !texsource->palette && !texture->borderpix && !texsource->palette() &&
texsource->rowpixels <= sdl->texture_max_width ) texsource->rowpixels <= sdl->texture_max_width )
{ {
texture->nocopy = TRUE; texture->nocopy = TRUE;
@ -2068,8 +2116,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture_info *texture; texture_info *texture;
// allocate a new texture // allocate a new texture
texture = (texture_info *) malloc(sizeof(*texture)); texture = global_alloc(texture_info);
memset(texture, 0, sizeof(*texture));
// fill in the core data // fill in the core data
texture->hash = texture_compute_hash(texsource, flags); texture->hash = texture_compute_hash(texsource, flags);
@ -2107,7 +2154,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_ARGB32; texture->format = SDL_TEXFORMAT_ARGB32;
break; break;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
if (texsource->palette != NULL) if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_RGB32_PALETTED; texture->format = SDL_TEXFORMAT_RGB32_PALETTED;
else else
texture->format = SDL_TEXFORMAT_RGB32; texture->format = SDL_TEXFORMAT_RGB32;
@ -2119,7 +2166,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_PALETTE16A; texture->format = SDL_TEXFORMAT_PALETTE16A;
break; break;
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
if (texsource->palette != NULL) if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_YUY16_PALETTED; texture->format = SDL_TEXFORMAT_YUY16_PALETTED;
else else
texture->format = SDL_TEXFORMAT_YUY16; texture->format = SDL_TEXFORMAT_YUY16;
@ -2143,7 +2190,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
{ {
if ( texture_shader_create(window, texsource, texture, flags) ) if ( texture_shader_create(window, texsource, texture, flags) )
{ {
free(texture); global_free(texture);
return NULL; return NULL;
} }
} }
@ -2229,7 +2276,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
sdl->texhash[i] = texture; sdl->texhash[i] = texture;
break; break;
} }
assert(i < HASH_SIZE + OVERFLOW_SIZE); assert_always(i < HASH_SIZE + OVERFLOW_SIZE, "texture hash exhausted ...");
} }
if(sdl->usevbo) if(sdl->usevbo)
@ -2561,23 +2608,23 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou
switch (PRIMFLAG_GET_TEXFORMAT(flags)) switch (PRIMFLAG_GET_TEXFORMAT(flags))
{ {
case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTE16:
copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale); copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_PALETTEA16: case TEXFORMAT_PALETTEA16:
copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale); copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale); copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_ARGB32: case TEXFORMAT_ARGB32:
copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale); copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale); copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break; break;
default: default:
@ -2650,7 +2697,7 @@ static int compare_texture_primitive(const texture_info *texture, const render_p
texture->texinfo.width == prim->texture.width && texture->texinfo.width == prim->texture.width &&
texture->texinfo.height == prim->texture.height && texture->texinfo.height == prim->texture.height &&
texture->texinfo.rowpixels == prim->texture.rowpixels && texture->texinfo.rowpixels == prim->texture.rowpixels &&
texture->texinfo.palette == prim->texture.palette && /* texture->texinfo.palette() == prim->texture.palette() && */
((texture->flags ^ prim->flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0) ((texture->flags ^ prim->flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0)
return 1; return 1;
else else
@ -3074,7 +3121,7 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
texture->data=NULL; texture->data=NULL;
texture->data_own=FALSE; texture->data_own=FALSE;
} }
free(texture); global_free(texture);
} }
i++; i++;
} }

View File

@ -656,6 +656,7 @@ static OSDWORK_CALLBACK( sdlwindow_update_cursor_state_wt )
sdlwindow_update_cursor_state(wp->machine(), wp->window()); sdlwindow_update_cursor_state(wp->machine(), wp->window());
osd_free(wp);
return NULL; return NULL;
} }

View File

@ -940,7 +940,7 @@ int shaders::create_resources(bool reset)
texture.rowpixels = shadow_bitmap.rowpixels(); texture.rowpixels = shadow_bitmap.rowpixels();
texture.width = shadow_bitmap.width(); texture.width = shadow_bitmap.width();
texture.height = shadow_bitmap.height(); texture.height = shadow_bitmap.height();
texture.palette = NULL; texture.set_palette(NULL);
texture.seqid = 0; texture.seqid = 0;
// now create it // now create it

View File

@ -528,7 +528,7 @@ void texture_manager::create_resources()
texture.rowpixels = m_default_bitmap.rowpixels(); texture.rowpixels = m_default_bitmap.rowpixels();
texture.width = m_default_bitmap.width(); texture.width = m_default_bitmap.width();
texture.height = m_default_bitmap.height(); texture.height = m_default_bitmap.height();
texture.palette = NULL; texture.set_palette(NULL);
texture.seqid = 0; texture.seqid = 0;
// now create it // now create it
@ -545,7 +545,7 @@ void texture_manager::create_resources()
texture.rowpixels = m_vector_bitmap.rowpixels(); texture.rowpixels = m_vector_bitmap.rowpixels();
texture.width = m_vector_bitmap.width(); texture.width = m_vector_bitmap.width();
texture.height = m_vector_bitmap.height(); texture.height = m_vector_bitmap.height();
texture.palette = NULL; texture.set_palette(NULL);
texture.seqid = 0; texture.seqid = 0;
// now create it // now create it
@ -2580,28 +2580,28 @@ void texture_info::set_data(const render_texinfo *texsource, UINT32 flags)
switch (PRIMFLAG_GET_TEXFORMAT(flags)) switch (PRIMFLAG_GET_TEXFORMAT(flags))
{ {
case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTE16:
copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break; break;
case TEXFORMAT_PALETTEA16: case TEXFORMAT_PALETTEA16:
copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break; break;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break; break;
case TEXFORMAT_ARGB32: case TEXFORMAT_ARGB32:
copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break; break;
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
if (m_texture_manager->get_yuv_format() == D3DFMT_YUY2) if (m_texture_manager->get_yuv_format() == D3DFMT_YUY2)
copyline_yuy16_to_yuy2((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_yuy16_to_yuy2((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
else if (m_texture_manager->get_yuv_format() == D3DFMT_UYVY) else if (m_texture_manager->get_yuv_format() == D3DFMT_UYVY)
copyline_yuy16_to_uyvy((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_yuy16_to_uyvy((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
else else
copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix); copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break; break;
default: default: