GTK : Filter code cleanup

This commit is contained in:
bgk 2008-10-27 20:52:37 +00:00
parent 37f8bdf884
commit d31dc7c8d4
6 changed files with 83 additions and 95 deletions

View File

@ -33,40 +33,6 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
Gtk::Dialog(_pstDialog),
m_poConfig(0)
{
//TODO Move to filters.h
struct
{
const char * m_csName;
const EFilter2x m_eFilter;
}
astFilter[] =
{
{ "None", FilterNone },
{ "2xSaI", Filter2xSaI },
{ "Super 2xSaI", FilterSuper2xSaI },
{ "Super Eagle", FilterSuperEagle },
{ "Pixelate", FilterPixelate },
{ "AdvanceMAME Scale2x", FilterAdMame2x },
{ "Bilinear", FilterBilinear },
{ "Bilinear Plus", FilterBilinearPlus },
{ "Scanlines", FilterScanlines },
{ "TV Mode", FilterScanlinesTV },
{ "hq2x", FilterHq2x },
{ "lq2x", FilterLq2x }
};
struct
{
const char * m_csName;
const EFilterIB m_eFilterIB;
}
astFilterIB[] =
{
{ "None", FilterIBNone },
{ "Smart interframe blending", FilterIBSmart },
{ "Interframe motion blur", FilterIBMotionBlur }
};
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
refBuilder->get_widget("OutputOpenGL", m_poOutputOpenGLRadioButton);
@ -84,20 +50,20 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
for (guint i = 0; i < G_N_ELEMENTS(astFilter); i++)
for (guint i = FirstFilter; i <= LastFilter; i++)
{
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
row->set_value(0, std::string(astFilter[i].m_csName));
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
}
// Populate the interframe blending filters combobox
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
for (guint i = 0; i < G_N_ELEMENTS(astFilterIB); i++)
for (guint i = FirstFilterIB; i <= LastFilterIB; i++)
{
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
row->set_value(0, std::string(astFilterIB[i].m_csName));
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
}
}

View File

@ -18,40 +18,87 @@
#include "filters.h"
void _2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void _2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines (u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void SmartIB (u8 *, u32, int, int);
void SmartIB32 (u8 *, u32, int, int);
void MotionBlurIB (u8 *, u32, int, int);
void MotionBlurIB32(u8 *, u32, int, int);
namespace VBA
{
static const Filter2x apvFilters2x[][2] =
struct {
char m_csName[30];
int m_iEnlargeFactor;
Filter m_apvFunc[2];
}
static const astFilters[] =
{
{ NULL, NULL },
{ _2xSaI, _2xSaI32 },
{ Super2xSaI, Super2xSaI32 },
{ SuperEagle, SuperEagle32 },
{ Pixelate, Pixelate32 },
{ AdMame2x, AdMame2x32 },
{ Bilinear, Bilinear32 },
{ BilinearPlus, BilinearPlus32 },
{ Scanlines, Scanlines32 },
{ ScanlinesTV, ScanlinesTV32 },
{ hq2x, hq2x32 },
{ lq2x, lq2x32 }
{ "None", 1, { NULL, NULL } },
{ "2xSaI", 2, { _2xSaI, _2xSaI32 } },
{ "Super 2xSaI", 2, { Super2xSaI, Super2xSaI32 } },
{ "Super Eagle", 2, { SuperEagle, SuperEagle32 } },
{ "Pixelate", 2, { Pixelate, Pixelate32 } },
{ "AdvanceMAME Scale2x", 2, { AdMame2x, AdMame2x32 } },
{ "Bilinear", 2, { Bilinear, Bilinear32 } },
{ "Bilinear Plus", 2, { BilinearPlus, BilinearPlus32 } },
{ "Scanlines", 2, { Scanlines, Scanlines32 } },
{ "TV Mode", 2, { ScanlinesTV, ScanlinesTV32 } },
{ "hq2x", 2, { hq2x, hq2x32 } },
{ "lq2x", 2, { lq2x, lq2x32 } }
};
static const FilterIB apvFiltersIB[][2] =
struct {
char m_csName[30];
FilterIB m_apvFunc[2];
}
static const astFiltersIB[] =
{
{ NULL, NULL },
{ SmartIB, SmartIB32 },
{ MotionBlurIB, MotionBlurIB32 }
{ "None", { NULL, NULL } },
{ "Smart interframe blending", { SmartIB, SmartIB32 } },
{ "Interframe motion blur", { MotionBlurIB, MotionBlurIB32 } }
};
Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth)
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth)
{
return apvFilters2x[_eFilter2x][_eDepth];
return astFilters[_eFilter].m_apvFunc[_eDepth];
}
char* pcsGetFilterName(const EFilter _eFilter)
{
return (char*)astFilters[_eFilter].m_csName;
}
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
{
return apvFiltersIB[_eFilterIB][_eDepth];
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
}
char* pcsGetFilterIBName(const EFilterIB _eFilterIB)
{
return (char*)astFiltersIB[_eFilterIB].m_csName;
}
} // namespace VBA

View File

@ -24,41 +24,13 @@
int Init_2xSaI(u32);
void _2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void _2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines (u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void SmartIB (u8 *, u32, int, int);
void SmartIB32 (u8 *, u32, int, int);
void MotionBlurIB (u8 *, u32, int, int);
void MotionBlurIB32(u8 *, u32, int, int);
namespace VBA
{
typedef void (*Filter2x)(u8 *, u32, u8 *, u8 *, u32, int, int);
typedef void (*Filter)(u8 *, u32, u8 *, u8 *, u32, int, int);
typedef void (*FilterIB)(u8 *, u32, int, int);
enum EFilter2x
enum EFilter
{
FirstFilter,
FilterNone = FirstFilter,
@ -91,8 +63,11 @@ enum EFilterDepth
FilterDepth32
};
Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth);
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
char* pcsGetFilterName(const EFilter _eFilter);
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
char* pcsGetFilterIBName(const EFilterIB _eFilterIB);
} // namespace VBA

View File

@ -92,16 +92,16 @@ void ScreenArea::vSetScale(int _iScale)
if (_iScale == 1)
{
vSetFilter2x(FilterNone);
vSetFilter(FilterNone);
}
m_iScale = _iScale;
vUpdateSize();
}
void ScreenArea::vSetFilter2x(EFilter2x _eFilter2x)
void ScreenArea::vSetFilter(EFilter _eFilter)
{
m_vFilter2x = pvGetFilter2x(_eFilter2x, FilterDepth32);
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
m_iFilterScale = 1;
if (m_vFilter2x != NULL)

View File

@ -36,7 +36,7 @@ public:
void vSetSize(int _iWidth, int _iHeight);
void vSetScale(int _iScale);
void vSetFilter2x(EFilter2x _eFilter2x);
void vSetFilter(EFilter _eFilter);
void vSetFilterIB(EFilterIB _eFilterIB);
virtual void vDrawPixels(u8 * _puiData);
virtual void vDrawBlackScreen() = 0;
@ -54,7 +54,7 @@ protected:
int m_iFilterScale;
int m_iAreaWidth;
int m_iAreaHeight;
Filter2x m_vFilter2x;
Filter m_vFilter2x;
FilterIB m_vFilterIB;
u32 * m_puiPixels;
u8 * m_puiDelta;

View File

@ -971,7 +971,7 @@ void Window::vSaveConfig(const std::string & _rsFile)
void Window::vApplyConfigFilter()
{
int iFilter = m_poDisplayConfig->oGetKey<int>("filter2x");
m_poScreenArea->vSetFilter2x((EFilter2x)iFilter);
m_poScreenArea->vSetFilter((EFilter)iFilter);
if (emulating)
{
vDrawScreen();