Skip to content

Commit

Permalink
SDL: Move selecting the required ScalerProc into a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Jul 26, 2019
1 parent bc85778 commit 0bea51a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 61 deletions.
19 changes: 2 additions & 17 deletions backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
Expand Up @@ -67,10 +67,8 @@ int DINGUXSdlGraphicsManager::getGraphicsModeScale(int mode) const {
return scale;
}

void DINGUXSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *DINGUXSdlGraphicsManager::getGraphicsScalerProc(int mode) const {
ScalerProc *newScalerProc = 0;

switch (_videoMode.mode) {
case GFX_NORMAL:
newScalerProc = Normal1x;
Expand All @@ -80,22 +78,9 @@ void DINGUXSdlGraphicsManager::setGraphicsModeIntern() {
newScalerProc = DownscaleAllByHalf;
break;
#endif

default:
error("Unknown gfx mode %d", _videoMode.mode);
}

_scalerProc = newScalerProc;

if (!_screen || !_hwScreen)
return;

// Blit everything to the screen
_forceRedraw = true;

// Even if the old and new scale factors are the same, we may have a
// different scaler for the cursor now.
blitCursor();
return newScalerProc;
}

void DINGUXSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
Expand Down
2 changes: 1 addition & 1 deletion backends/graphics/dinguxsdl/dinguxsdl-graphics.h
Expand Up @@ -44,7 +44,7 @@ class DINGUXSdlGraphicsManager : public SurfaceSdlGraphicsManager {
void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL) override;
const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
int getGraphicsModeScale(int mode) const override;
void setGraphicsModeIntern() override;
ScalerProc *getGraphicsScalerProc(int mode) const override;
void internUpdateScreen() override;
void showOverlay() override;
void hideOverlay() override;
Expand Down
19 changes: 2 additions & 17 deletions backends/graphics/gph/gph-graphics.cpp
Expand Up @@ -61,33 +61,18 @@ int GPHGraphicsManager::getGraphicsModeScale(int mode) const {
return scale;
}

void GPHGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *GPHGraphicsManager::getGraphicsScalerProc(int mode) const {
ScalerProc *newScalerProc = 0;

switch (_videoMode.mode) {
case GFX_NORMAL:
newScalerProc = Normal1x;
break;
case GFX_HALF:
newScalerProc = DownscaleAllByHalf;
break;

default:
error("Unknown gfx mode %d", _videoMode.mode);
}

_scalerProc = newScalerProc;

if (!_screen || !_hwScreen)
return;

// Blit everything to the screen
_forceRedraw = true;

// Even if the old and new scale factors are the same, we may have a
// different scaler for the cursor now.
blitCursor();
return newScalerProc;
}

void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
Expand Down
2 changes: 1 addition & 1 deletion backends/graphics/gph/gph-graphics.h
Expand Up @@ -43,7 +43,7 @@ class GPHGraphicsManager : public SurfaceSdlGraphicsManager {
void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL) override;
const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
int getGraphicsModeScale(int mode) const override;
void setGraphicsModeIntern() override;
ScalerProc *getGraphicsScalerProc(int mode) const override;
void internUpdateScreen() override;
void showOverlay() override;
void hideOverlay() override;
Expand Down
20 changes: 2 additions & 18 deletions backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
Expand Up @@ -71,36 +71,20 @@ int LinuxmotoSdlGraphicsManager::getGraphicsModeScale(int mode) const {
return scale;
}

void LinuxmotoSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *LinuxmotoSdlGraphicsManager::getGraphicsScalerProc(int mode) const {
ScalerProc *newScalerProc = 0;

switch (_videoMode.mode) {
case GFX_NORMAL:
newScalerProc = Normal1x;
break;
case GFX_HALF:
newScalerProc = DownscaleAllByHalf;
break;

default:
error("Unknown gfx mode %d", _videoMode.mode);
}

_scalerProc = newScalerProc;

if (!_screen || !_hwscreen)
return;

// Blit everything to the screen
_forceFull = true;

// Even if the old and new scale factors are the same, we may have a
// different scaler for the cursor now.
blitCursor();
return newScalerProc;
}


void LinuxmotoSdlGraphicsManager::initSize(uint w, uint h) {
assert(_transactionMode == kTransactionActive);

Expand Down
2 changes: 1 addition & 1 deletion backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
Expand Up @@ -33,7 +33,7 @@ class LinuxmotoSdlGraphicsManager : public SurfaceSdlGraphicsManager {
virtual void setGraphicsModeIntern() override;
virtual int getGraphicsModeScale(int mode) const override;
virtual void internUpdateScreen() override;
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
virtual ScalerProc *getGraphicsScalerProc(int mode) const override;
virtual int getDefaultGraphicsMode() const override;
virtual bool loadGFXMode() override;
virtual void drawMouse() override;
Expand Down
19 changes: 13 additions & 6 deletions backends/graphics/surfacesdl/surfacesdl-graphics.cpp
Expand Up @@ -674,12 +674,8 @@ bool SurfaceSdlGraphicsManager::setGraphicsMode(int mode) {
return true;
}

void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *SurfaceSdlGraphicsManager::getGraphicsScalerProc(int mode) const {
ScalerProc *newScalerProc = 0;

updateShader();

switch (_videoMode.mode) {
case GFX_NORMAL:
newScalerProc = Normal1x;
Expand Down Expand Up @@ -722,8 +718,19 @@ void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
newScalerProc = DotMatrix;
break;
#endif // USE_SCALERS
}

default:
return newScalerProc;
}

void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);

updateShader();

ScalerProc *newScalerProc = getGraphicsScalerProc(_videoMode.mode);

if (!newScalerProc) {
error("Unknown gfx mode %d", _videoMode.mode);
}

Expand Down
1 change: 1 addition & 0 deletions backends/graphics/surfacesdl/surfacesdl-graphics.h
Expand Up @@ -189,6 +189,7 @@ class SurfaceSdlGraphicsManager : public SdlGraphicsManager {
virtual void handleResizeImpl(const int width, const int height) override;

virtual int getGraphicsModeScale(int mode) const override;
virtual ScalerProc *getGraphicsScalerProc(int mode) const override;

#if SDL_VERSION_ATLEAST(2, 0, 0)
/* SDL2 features a different API for 2D graphics. We create a wrapper
Expand Down

0 comments on commit 0bea51a

Please sign in to comment.