2010-06-10 20:31:08 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2010-06-10 20:31:08 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2010-06-10 20:31:08 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "backends/modular-backend.h"
|
2011-02-07 17:53:15 +00:00
|
|
|
|
2019-11-30 20:22:19 +00:00
|
|
|
#include "backends/audiocd/audiocd.h"
|
2011-04-24 11:34:27 +03:00
|
|
|
#include "backends/graphics/graphics.h"
|
2019-11-30 20:22:19 +00:00
|
|
|
#include "backends/mixer/mixer.h"
|
2011-04-24 11:34:27 +03:00
|
|
|
#include "backends/mutex/mutex.h"
|
2013-05-17 00:18:09 +03:00
|
|
|
#include "gui/EventRecorder.h"
|
2011-02-07 17:53:15 +00:00
|
|
|
|
2020-05-25 20:21:05 +01:00
|
|
|
#include "common/timer.h"
|
2011-04-24 11:34:27 +03:00
|
|
|
#include "graphics/pixelformat.h"
|
2020-10-09 19:04:07 +02:00
|
|
|
#include "graphics/pixelbuffer.h"
|
2010-06-10 20:31:08 +00:00
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
ModularGraphicsBackend::ModularGraphicsBackend()
|
2010-06-10 20:31:08 +00:00
|
|
|
:
|
2020-08-01 22:51:35 +01:00
|
|
|
_graphicsManager(0) {
|
2010-06-10 20:31:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
ModularGraphicsBackend::~ModularGraphicsBackend() {
|
2010-10-13 17:58:48 +00:00
|
|
|
delete _graphicsManager;
|
2010-11-29 18:22:31 +00:00
|
|
|
_graphicsManager = 0;
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
bool ModularGraphicsBackend::hasFeature(Feature f) {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->hasFeature(f);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::setFeatureState(Feature f, bool enable) {
|
2013-06-25 21:08:55 +10:00
|
|
|
_graphicsManager->setFeatureState(f, enable);
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
bool ModularGraphicsBackend::getFeatureState(Feature f) {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getFeatureState(f);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
GraphicsManager *ModularGraphicsBackend::getGraphicsManager() {
|
2010-07-11 04:32:24 +00:00
|
|
|
assert(_graphicsManager);
|
|
|
|
return (GraphicsManager *)_graphicsManager;
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedGraphicsModes() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getSupportedGraphicsModes();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getDefaultGraphicsMode() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getDefaultGraphicsMode();
|
|
|
|
}
|
|
|
|
|
2020-10-09 19:04:07 +02:00
|
|
|
bool ModularGraphicsBackend::setGraphicsMode(int mode, uint flags) {
|
|
|
|
return _graphicsManager->setGraphicsMode(mode, flags);
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getGraphicsMode() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getGraphicsMode();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedShaders() const {
|
2017-03-01 14:00:17 -06:00
|
|
|
return _graphicsManager->getSupportedShaders();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getDefaultShader() const {
|
2020-01-31 23:11:09 +00:00
|
|
|
return _graphicsManager->getDefaultShader();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
bool ModularGraphicsBackend::setShader(int id) {
|
2017-03-01 14:00:17 -06:00
|
|
|
return _graphicsManager->setShader(id);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getShader() const {
|
2017-03-01 14:00:17 -06:00
|
|
|
return _graphicsManager->getShader();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedStretchModes() const {
|
2018-07-01 19:24:25 +01:00
|
|
|
return _graphicsManager->getSupportedStretchModes();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getDefaultStretchMode() const {
|
2018-07-01 19:24:25 +01:00
|
|
|
return _graphicsManager->getDefaultStretchMode();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
bool ModularGraphicsBackend::setStretchMode(int mode) {
|
2018-07-01 19:24:25 +01:00
|
|
|
return _graphicsManager->setStretchMode(mode);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getStretchMode() const {
|
2018-07-01 19:24:25 +01:00
|
|
|
return _graphicsManager->getStretchMode();
|
|
|
|
}
|
|
|
|
|
2010-06-10 20:31:08 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
2010-07-13 04:31:15 +00:00
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
Graphics::PixelFormat ModularGraphicsBackend::getScreenFormat() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getScreenFormat();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
Common::List<Graphics::PixelFormat> ModularGraphicsBackend::getSupportedFormats() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getSupportedFormats();
|
|
|
|
}
|
2010-07-13 04:31:15 +00:00
|
|
|
|
2010-06-10 20:31:08 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-13 22:30:39 +02:00
|
|
|
void ModularGraphicsBackend::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->initSize(w, h, format);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::initSizeHint(const Graphics::ModeList &modes) {
|
2017-10-01 16:23:22 -05:00
|
|
|
_graphicsManager->initSizeHint(modes);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int ModularGraphicsBackend::getScreenChangeID() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getScreenChangeID();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::beginGFXTransaction() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->beginGFXTransaction();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
OSystem::TransactionError ModularGraphicsBackend::endGFXTransaction() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->endGFXTransaction();
|
2010-06-11 01:55:59 +00:00
|
|
|
}
|
2010-06-10 20:31:08 +00:00
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int16 ModularGraphicsBackend::getHeight() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getHeight();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int16 ModularGraphicsBackend::getWidth() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getWidth();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
PaletteManager *ModularGraphicsBackend::getPaletteManager() {
|
2011-02-07 17:52:38 +00:00
|
|
|
return _graphicsManager;
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->copyRectToScreen(buf, pitch, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
Graphics::Surface *ModularGraphicsBackend::lockScreen() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->lockScreen();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::unlockScreen() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->unlockScreen();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::fillScreen(uint32 col) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->fillScreen(col);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::updateScreen() {
|
2013-07-06 23:54:45 -04:00
|
|
|
#ifdef ENABLE_EVENTRECORDER
|
2013-05-17 00:18:09 +03:00
|
|
|
g_eventRec.preDrawOverlayGui();
|
2013-07-06 23:54:45 -04:00
|
|
|
#endif
|
|
|
|
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->updateScreen();
|
2013-07-06 23:54:45 -04:00
|
|
|
|
|
|
|
#ifdef ENABLE_EVENTRECORDER
|
2013-05-17 00:18:09 +03:00
|
|
|
g_eventRec.postDrawOverlayGui();
|
2013-07-06 23:54:45 -04:00
|
|
|
#endif
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::setShakePos(int shakeXOffset, int shakeYOffset) {
|
2019-11-15 01:38:21 -08:00
|
|
|
_graphicsManager->setShakePos(shakeXOffset, shakeYOffset);
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::setFocusRectangle(const Common::Rect& rect) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->setFocusRectangle(rect);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::clearFocusRectangle() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->clearFocusRectangle();
|
2010-06-11 01:55:59 +00:00
|
|
|
}
|
2010-06-10 20:31:08 +00:00
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::showOverlay() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->showOverlay();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::hideOverlay() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->hideOverlay();
|
|
|
|
}
|
|
|
|
|
2020-09-14 13:11:57 +01:00
|
|
|
bool ModularGraphicsBackend::isOverlayVisible() const {
|
|
|
|
return _graphicsManager->isOverlayVisible();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
Graphics::PixelFormat ModularGraphicsBackend::getOverlayFormat() const {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getOverlayFormat();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::clearOverlay() {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->clearOverlay();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::grabOverlay(void *buf, int pitch) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->grabOverlay(buf, pitch);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->copyRectToOverlay(buf, pitch, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int16 ModularGraphicsBackend::getOverlayHeight() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getOverlayHeight();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
int16 ModularGraphicsBackend::getOverlayWidth() {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->getOverlayWidth();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
bool ModularGraphicsBackend::showMouse(bool visible) {
|
2010-06-10 20:31:08 +00:00
|
|
|
return _graphicsManager->showMouse(visible);
|
|
|
|
}
|
|
|
|
|
2020-09-03 02:01:03 +02:00
|
|
|
bool ModularGraphicsBackend::lockMouse(bool visible) {
|
2012-01-22 18:55:57 +01:00
|
|
|
return _graphicsManager->lockMouse(visible);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::warpMouse(int x, int y) {
|
2017-09-15 22:59:18 -05:00
|
|
|
_eventManager->purgeMouseEvents();
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->warpMouse(x, y);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
|
2012-06-03 02:02:57 +02:00
|
|
|
_graphicsManager->setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
|
2010-06-10 20:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularGraphicsBackend::setCursorPalette(const byte *colors, uint start, uint num) {
|
2010-06-10 20:31:08 +00:00
|
|
|
_graphicsManager->setCursorPalette(colors, start, num);
|
|
|
|
}
|
|
|
|
|
2020-08-26 01:28:20 +05:30
|
|
|
void ModularGraphicsBackend::displayMessageOnOSD(const Common::U32String &msg) {
|
2020-08-02 00:05:25 +01:00
|
|
|
_graphicsManager->displayMessageOnOSD(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModularGraphicsBackend::displayActivityIconOnOSD(const Graphics::Surface *icon) {
|
|
|
|
_graphicsManager->displayActivityIconOnOSD(icon);
|
|
|
|
}
|
|
|
|
|
2020-10-15 12:56:45 +01:00
|
|
|
void ModularGraphicsBackend::saveScreenshot() {
|
|
|
|
_graphicsManager->saveScreenshot();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
|
2019-11-30 20:22:19 +00:00
|
|
|
ModularMixerBackend::ModularMixerBackend()
|
|
|
|
:
|
|
|
|
_mixerManager(0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ModularMixerBackend::~ModularMixerBackend() {
|
|
|
|
// _audiocdManager needs to be deleted before _mixerManager to avoid a crash.
|
|
|
|
delete _audiocdManager;
|
|
|
|
_audiocdManager = 0;
|
|
|
|
delete _mixerManager;
|
|
|
|
_mixerManager = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MixerManager *ModularMixerBackend::getMixerManager() {
|
|
|
|
assert(_mixerManager);
|
|
|
|
return _mixerManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
Audio::Mixer *ModularMixerBackend::getMixer() {
|
|
|
|
assert(_mixerManager);
|
|
|
|
return getMixerManager()->getMixer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
ModularMutexBackend::ModularMutexBackend()
|
|
|
|
:
|
|
|
|
_mutexManager(0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ModularMutexBackend::~ModularMutexBackend() {
|
|
|
|
// _timerManager needs to be deleted before _mutexManager to avoid a crash.
|
|
|
|
delete _timerManager;
|
|
|
|
_timerManager = 0;
|
|
|
|
delete _mutexManager;
|
|
|
|
_mutexManager = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem::MutexRef ModularMutexBackend::createMutex() {
|
2010-06-10 20:31:08 +00:00
|
|
|
assert(_mutexManager);
|
|
|
|
return _mutexManager->createMutex();
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularMutexBackend::lockMutex(MutexRef mutex) {
|
2010-06-10 20:31:08 +00:00
|
|
|
assert(_mutexManager);
|
|
|
|
_mutexManager->lockMutex(mutex);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularMutexBackend::unlockMutex(MutexRef mutex) {
|
2010-06-10 20:31:08 +00:00
|
|
|
assert(_mutexManager);
|
|
|
|
_mutexManager->unlockMutex(mutex);
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:05:25 +01:00
|
|
|
void ModularMutexBackend::deleteMutex(MutexRef mutex) {
|
2010-06-10 20:31:08 +00:00
|
|
|
assert(_mutexManager);
|
|
|
|
_mutexManager->deleteMutex(mutex);
|
|
|
|
}
|