From 20b4356ecd0dad6d1f61357a891157fdf286d16c Mon Sep 17 00:00:00 2001 From: Eric Culp Date: Fri, 8 Jun 2012 15:34:32 -0400 Subject: [PATCH] GRAPHICS: Add AdvMame scaler plugin --- base/plugins.cpp | 1 + graphics/scaler/scalebit.cpp | 41 ++++++++++++++++++++++++++++++++++++ graphics/scaler/scalebit.h | 18 ++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/base/plugins.cpp b/base/plugins.cpp index 1bfc957fa32..b5d11f1a4e9 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -167,6 +167,7 @@ public: #ifdef USE_HQ_SCALERS LINK_PLUGIN(HQ) #endif + LINK_PLUGIN(ADVMAME) LINK_PLUGIN(SAI) LINK_PLUGIN(SUPERSAI) LINK_PLUGIN(SUPEREAGLE) diff --git a/graphics/scaler/scalebit.cpp b/graphics/scaler/scalebit.cpp index 2c79cfcd27e..ab31a90df5a 100644 --- a/graphics/scaler/scalebit.cpp +++ b/graphics/scaler/scalebit.cpp @@ -37,6 +37,7 @@ #include "graphics/scaler/scale2x.h" #include "graphics/scaler/scale3x.h" +#include "graphics/scaler/scalebit.h" #define DST(bits, num) (scale2x_uint ## bits *)dst ## num #define SRC(bits, num) (const scale2x_uint ## bits *)src ## num @@ -348,3 +349,43 @@ void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_ break; } } + +AdvMamePlugin::AdvMamePlugin() { + _factor = 2; + _factors.push_back(2); + _factors.push_back(3); +} + +void AdvMamePlugin::initialize(Graphics::PixelFormat format) { + _format = format; +} + +void AdvMamePlugin::deinitialize() { +} + +void AdvMamePlugin::scale(const uint8 *srcPtr, uint32 srcPitch, + uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { + ::scale(_factor, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, _format.bytesPerPixel, width, height); +} + +uint AdvMamePlugin::increaseFactor() { + if (_factor < 3) + ++_factor; + return _factor; +} + +uint AdvMamePlugin::decreaseFactor() { + if (_factor > 2) + --_factor; + return _factor; +} + +const char *AdvMamePlugin::getName() const { + return "advmame"; +} + +const char *AdvMamePlugin::getPrettyName() const { + return "AdvMame"; +} + +REGISTER_PLUGIN_STATIC(ADVMAME, PLUGIN_TYPE_SCALER, AdvMamePlugin); diff --git a/graphics/scaler/scalebit.h b/graphics/scaler/scalebit.h index 75f9dae455d..5c72110e012 100644 --- a/graphics/scaler/scalebit.h +++ b/graphics/scaler/scalebit.h @@ -36,7 +36,25 @@ #ifndef SCALER_SCALEBIT_H #define SCALER_SCALEBIT_H +#include "graphics/scalerplugin.h" + int scale_precondition(unsigned scale, unsigned pixel, unsigned width, unsigned height); void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height); +class AdvMamePlugin : public ScalerPluginObject { +public: + AdvMamePlugin(); + virtual void initialize(Graphics::PixelFormat format); + virtual void deinitialize(); + virtual void scale(const uint8 *srcPtr, uint32 srcPitch, + uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y); + virtual uint increaseFactor(); + virtual uint decreaseFactor(); + virtual uint getFactor() const { return _factor; } + virtual bool canDrawCursor() const { return true; } + virtual uint extraPixels() const { return 1; } + virtual const char *getName() const; + virtual const char *getPrettyName() const; +}; + #endif