SDL: Move all shader code into PSP2SdlGraphicsManager

This commit is contained in:
Cameron Cawley 2020-02-09 12:26:09 +00:00 committed by rsn8887
parent f2db412ba5
commit 0fbfeaf21b
4 changed files with 19 additions and 48 deletions

View File

@ -141,6 +141,17 @@ int PSP2SdlGraphicsManager::getDefaultShader() const {
return GFX_SHADER_SHARP;
}
int PSP2SdlGraphicsManager::getShader() const {
return _currentShader;
}
bool PSP2SdlGraphicsManager::setShader(int id) {
assert(id >= 0 && id < _numShaders);
_currentShader = id;
updateShader();
return true;
}
void PSP2SdlGraphicsManager::unloadGFXMode() {
if (_screen) {
SDL_FreeSurface(_screen);

View File

@ -34,16 +34,23 @@ public:
virtual OSystem::TransactionError endGFXTransaction() override;
virtual const OSystem::GraphicsMode *getSupportedShaders() const override;
virtual int getDefaultShader() const override;
virtual int getShader() const override;
virtual bool setShader(int id) override;
protected:
virtual void setGraphicsModeIntern() override;
virtual void unloadGFXMode() override;
virtual bool hotswapGFXMode() override;
virtual void updateShader() override;
virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) override;
virtual void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) override;
private:
void PSP2_UpdateFiltering();
void updateShader();
int _currentShader;
int _numShaders;
vita2d_texture *_vitatex_hwscreen;
void *_sdlpixels_hwscreen;

View File

@ -56,11 +56,6 @@
#define SDL_FULLSCREEN 0x40000000
#endif
static const OSystem::GraphicsMode s_supportedShaders[] = {
{"NONE", "Normal (no shader)", 0},
{0, 0, 0}
};
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", _s("Normal (no scaling)"), GFX_NORMAL},
#ifdef USE_SCALERS
@ -209,13 +204,6 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#if SDL_VERSION_ATLEAST(2, 0, 0)
_videoMode.stretchMode = STRETCH_FIT;
#endif
// the default backend has no shaders
// shader number 0 is the entry NONE (no shader)
// for an example on shader support,
// consult the psp2sdl backend which inherits from this class
_currentShader = 0;
_numShaders = 1;
}
SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() {
@ -730,8 +718,6 @@ ScalerProc *SurfaceSdlGraphicsManager::getGraphicsScalerProc(int mode) const {
void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
updateShader();
ScalerProc *newScalerProc = getGraphicsScalerProc(_videoMode.mode);
if (!newScalerProc) {
@ -765,21 +751,6 @@ int SurfaceSdlGraphicsManager::getGraphicsMode() const {
return _videoMode.mode;
}
const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedShaders() const {
return s_supportedShaders;
}
int SurfaceSdlGraphicsManager::getShader() const {
return _currentShader;
}
bool SurfaceSdlGraphicsManager::setShader(int id) {
assert(id >= 0 && id < _numShaders);
_currentShader = id;
updateShader();
return true;
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedStretchModes() const {
return s_supportedStretchModes;
@ -1192,17 +1163,6 @@ void SurfaceSdlGraphicsManager::updateScreen() {
internUpdateScreen();
}
void SurfaceSdlGraphicsManager::updateShader() {
// shader init code goes here
// currently only used on Vita port
// the user-selected shaderID should be obtained via ConfMan.getInt("shader")
// and the corresponding shader should then be activated here
// this way the user can combine any software scaling (scalers)
// with any hardware shading (shaders). The shaders could provide
// scanline masks, overlays, but could also serve for
// hardware-based up-scaling (sharp-bilinear-simple, etc.)
}
void SurfaceSdlGraphicsManager::internUpdateScreen() {
SDL_Surface *srcSurf, *origSurf;
int height, width;

View File

@ -91,9 +91,6 @@ public:
virtual Graphics::PixelFormat getScreenFormat() const override { return _screenFormat; }
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
#endif
virtual const OSystem::GraphicsMode *getSupportedShaders() const override;
virtual int getShader() const override;
virtual bool setShader(int id) override;
#if SDL_VERSION_ATLEAST(2, 0, 0)
virtual const OSystem::GraphicsMode *getSupportedStretchModes() const override;
virtual int getDefaultStretchMode() const override;
@ -339,9 +336,6 @@ protected:
int _screenChangeCount;
int _currentShader;
int _numShaders;
enum {
NUM_DIRTY_RECT = 100,
MAX_SCALING = 3
@ -419,7 +413,6 @@ protected:
virtual void blitCursor();
virtual void internUpdateScreen();
virtual void updateShader();
virtual bool loadGFXMode();
virtual void unloadGFXMode();