diff options
author | Max Horn | 2009-12-09 16:45:35 +0000 |
---|---|---|
committer | Max Horn | 2009-12-09 16:45:35 +0000 |
commit | 626f85ae5e9d3aea2d528cbf847aee6ec6051407 (patch) | |
tree | 7b9bf8b8528c229584fcc670c2b60d67f4ba923b /engines | |
parent | fb5e747565e28a6863190e0e837899d5177244af (diff) | |
download | scummvm-rg350-626f85ae5e9d3aea2d528cbf847aee6ec6051407.tar.gz scummvm-rg350-626f85ae5e9d3aea2d528cbf847aee6ec6051407.tar.bz2 scummvm-rg350-626f85ae5e9d3aea2d528cbf847aee6ec6051407.zip |
Move findCompatibleFormat from graphics/pixelformat.h to engines/engine.cpp
This function is used in only one place. Declaring it requires common/list.h;
by putting it into pixelformat.h, which is included by common/system.h, tons
of things suddenly included list.h for no good reason.
If we ever need to call this function in other places, we can figure out aborts
more appropriate place for it.
svn-id: r46310
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index d8aeb88278..4f908d96f6 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -220,8 +220,32 @@ void initGraphics(int width, int height, bool defaultTo1xScaler, const Graphics: } } + +using Graphics::PixelFormat; + +/** + * Determines the first matching format between two lists. + * + * @param backend The higher priority list, meant to be a list of formats supported by the backend + * @param frontend The lower priority list, meant to be a list of formats supported by the engine + * @return The first item on the backend list that also occurs on the frontend list + * or PixelFormat::createFormatCLUT8() if no matching formats were found. + */ +inline PixelFormat findCompatibleFormat(Common::List<PixelFormat> backend, Common::List<PixelFormat> frontend) { +#ifdef USE_RGB_COLOR + for (Common::List<PixelFormat>::iterator i = backend.begin(); i != backend.end(); ++i) { + for (Common::List<PixelFormat>::iterator j = frontend.begin(); j != frontend.end(); ++j) { + if (*i == *j) + return *i; + } + } +#endif + return PixelFormat::createFormatCLUT8(); +} + + void initGraphics(int width, int height, bool defaultTo1xScaler, const Common::List<Graphics::PixelFormat> &formatList) { - Graphics::PixelFormat format = Graphics::findCompatibleFormat(g_system->getSupportedFormats(), formatList); + Graphics::PixelFormat format = findCompatibleFormat(g_system->getSupportedFormats(), formatList); initGraphics(width, height, defaultTo1xScaler, &format); } |