Permalink
Browse files

Merge 8282cde into c8d3af3

  • Loading branch information...
sandsmark committed Aug 17, 2018
2 parents c8d3af3 + 8282cde commit b17c22350c1a79435384711688d22b8fbe403bc3

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -27,6 +27,7 @@
#include "backends/graphics/sdl/sdl-graphics.h"
#include "graphics/pixelformat.h"
#include "graphics/scaler.h"
#include "graphics/scalerplugin.h"
#include "common/events.h"
#include "common/system.h"

@@ -86,6 +87,7 @@ class SurfaceSdlGraphicsManager : public SdlGraphicsManager, public Common::Even
virtual void setFeatureState(OSystem::Feature f, bool enable) override;
virtual bool getFeatureState(OSystem::Feature f) const override;

const OSystem::GraphicsMode *supportedGraphicsModes() const;
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
virtual int getDefaultGraphicsMode() const override;
virtual bool setGraphicsMode(int mode) override;
@@ -118,6 +120,12 @@ class SurfaceSdlGraphicsManager : public SdlGraphicsManager, public Common::Even
virtual void setPalette(const byte *colors, uint start, uint num) override;
virtual void grabPalette(byte *colors, uint start, uint num) const override;

/**
* Convert from the SDL pixel format to Graphics::PixelFormat
* @param in The SDL pixel format to convert
* @param out A pixel format to be written to
*/
void convertSDLPixelFormat(SDL_PixelFormat *in, Graphics::PixelFormat *out) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
virtual Graphics::Surface *lockScreen() override;
@@ -216,10 +224,13 @@ class SurfaceSdlGraphicsManager : public SdlGraphicsManager, public Common::Even

/** Temporary screen (for scalers) */
SDL_Surface *_tmpscreen;
/** Previous frame's raw scaled screen (for scalers) */
SDL_Surface *_destbuffer;
/** Temporary screen (for scalers) */
SDL_Surface *_tmpscreen2;

SDL_Surface *_overlayscreen;
bool _useOldSrc;
Graphics::PixelFormat _overlayFormat;

enum {
@@ -283,13 +294,18 @@ class SurfaceSdlGraphicsManager : public SdlGraphicsManager, public Common::Even
uint8 _originalBitsPerPixel;
#endif

ScalerProc *_scalerProc;
int _scalerType;
int _transactionMode;

// Indicates whether it is needed to free _hwSurface in destructor
bool _displayDisabled;

const PluginList &_scalerPlugins;
ScalerPluginObject *_scalerPlugin;
ScalerPluginObject *_normalPlugin;
uint _scalerIndex;
uint _maxExtraPixels;
uint _extraPixels;

bool _screenIsLocked;
Graphics::Surface _framebuffer;

@@ -63,6 +63,22 @@
#if SDL_VERSION_ATLEAST(2, 0, 0)
#include <SDL_clipboard.h>
#endif
struct LegacyGraphicsMode {
const char *name;
const char *oldName;
};

// Table for using old names for scalers in the configuration
// to keep compatibiblity with old config files.
static const LegacyGraphicsMode s_legacyGraphicsModes[] = {
{ "supereagle2x", "supereagle" },
{ "dotmatrix2x", "dotmatrix" },
{ "sai2x", "2xsai" },
{ "normal1x", "1x" },
{ "normal2x", "2x" },
{ "normal3x", "3x" },
{ "supersai2x", "super2xsai" },
};

OSystem_SDL::OSystem_SDL()
:
@@ -233,6 +249,32 @@ void OSystem_SDL::initBackend() {
#endif
#endif

// Search for legacy gfx_mode and replace it
if (ConfMan.hasKey("gfx_mode")) {
Common::String gfxMode(ConfMan.get("gfx_mode"));
for (uint i = 0; i < ARRAYSIZE(s_legacyGraphicsModes); ++i) {
if (gfxMode == s_legacyGraphicsModes[i].oldName) {
ConfMan.set("gfx_mode", s_legacyGraphicsModes[i].name);
break;
}
}
}
// Look in all game domains as well
#if 0
Common::ConfigManager::DomainMap &dm = ConfMan.getGameDomains();
for (Common::ConfigManager::DomainMap::iterator domain = dm.begin(); domain != dm.end(); ++domain) {
Common::ConfigManager::Domain::const_iterator gm = domain->_value.find("gfx_mode");
if (gm != domain->_value.end()) {
for (uint i = 0; i < ARRAYSIZE(s_legacyGraphicsModes); ++i) {
if (gm->_value == s_legacyGraphicsModes[i].oldName) {
gm->_value = s_legacyGraphicsModes[i].name;
break;
}
}
}
}
#endif

if (_graphicsManager == 0) {
#ifdef USE_OPENGL
// Setup a list with both SDL and OpenGL graphics modes. We only do
@@ -592,7 +592,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
ConfMan.setActiveDomain("");
}

PluginManager::instance().loadAllPlugins(); // only for cached manager
PluginManager::instance().loadAllPluginsOfType(PLUGIN_TYPE_ENGINE); // only for cached manager

} else {
GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));

@@ -36,6 +36,7 @@
int pluginTypeVersions[PLUGIN_TYPE_MAX] = {
PLUGIN_TYPE_ENGINE_VERSION,
PLUGIN_TYPE_MUSIC_VERSION,
PLUGIN_TYPE_SCALER_VERSION,
};


@@ -142,6 +143,24 @@ class StaticPluginProvider : public PluginProvider {
LINK_PLUGIN(TIMIDITY)
#endif

// Scaler plugins
LINK_PLUGIN(NORMAL)
#ifdef USE_SCALERS
#ifdef USE_HQ_SCALERS
LINK_PLUGIN(HQ)
#endif
#ifdef USE_EDGE_SCALERS
LINK_PLUGIN(EDGE)
#endif
LINK_PLUGIN(ADVMAME)
LINK_PLUGIN(SAI)
LINK_PLUGIN(SUPERSAI)
LINK_PLUGIN(SUPEREAGLE)
LINK_PLUGIN(PM)
LINK_PLUGIN(DOTMATRIX)
LINK_PLUGIN(TV)
#endif

return pl;
}
};
@@ -379,6 +398,30 @@ void PluginManager::loadAllPlugins() {
}
}

void PluginManager::loadAllPluginsOfType(PluginType type) {
for (ProviderList::iterator pp = _providers.begin();
pp != _providers.end();
++pp) {
PluginList pl((*pp)->getPlugins());
for (PluginList::iterator p = pl.begin();
p != pl.end();
++p) {
if ((*p)->loadPlugin()) {
if ((*p)->getType() == type) {
addToPluginsInMemList((*p));
} else {
// Plugin is wrong type
(*p)->unloadPlugin();
delete (*p);
}
} else {
// Plugin did not load
delete (*p);
}
}
}
}

void PluginManager::unloadAllPlugins() {
for (int i = 0; i < PLUGIN_TYPE_MAX; i++)
unloadPluginsExcept((PluginType)i, NULL);
@@ -604,3 +647,28 @@ DECLARE_SINGLETON(MusicManager);
const PluginList &MusicManager::getPlugins() const {
return PluginManager::instance().getPlugins(PLUGIN_TYPE_MUSIC);
}

// Scaler plugins

#include "graphics/scalerplugin.h"

namespace Common {
DECLARE_SINGLETON(ScalerManager);
}

const PluginList &ScalerManager::getPlugins() const {
return PluginManager::instance().getPlugins(PLUGIN_TYPE_SCALER);
}

uint ScalerManager::getMaxExtraPixels() const {
uint maxPixels = 0;
PluginList plugins = getPlugins();
PluginList::iterator i = plugins.begin();
for (; i != plugins.end(); ++i) {
uint n = (*i)->get<ScalerPluginObject>().extraPixels();
if (n > maxPixels) {
maxPixels = n;
}
}
return maxPixels;
}
@@ -58,7 +58,7 @@
enum PluginType {
PLUGIN_TYPE_ENGINE = 0,
PLUGIN_TYPE_MUSIC,
/* PLUGIN_TYPE_SCALER, */ // TODO: Add graphics scaler plugins
PLUGIN_TYPE_SCALER,

PLUGIN_TYPE_MAX
};
@@ -67,6 +67,7 @@ enum PluginType {
// because of the backlinking (posibly from the checkout revision)
#define PLUGIN_TYPE_ENGINE_VERSION 1
#define PLUGIN_TYPE_MUSIC_VERSION 1
#define PLUGIN_TYPE_SCALER_VERSION 1

extern int pluginTypeVersions[PLUGIN_TYPE_MAX];

@@ -329,6 +330,7 @@ class PluginManager {

// Functions used only by the cached PluginManager
virtual void loadAllPlugins();
virtual void loadAllPluginsOfType(PluginType type);
void unloadAllPlugins();

void unloadPluginsExcept(PluginType type, const Plugin *plugin, bool deletePlugin = true);
@@ -356,7 +358,8 @@ class PluginManagerUncached : public PluginManager {
virtual bool loadPluginFromGameId(const Common::String &gameId);
virtual void updateConfigWithFileName(const Common::String &gameId);

virtual void loadAllPlugins() {} // we don't allow this
virtual void loadAllPlugins() {} // we don't allow these
virtual void loadAllPluginsOfType(PluginType type) {}
};

#endif
Oops, something went wrong.

0 comments on commit b17c223

Please sign in to comment.