diff options
Diffstat (limited to 'backends/graphics/surfacesdl/surfacesdl-graphics.h')
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 165 |
1 files changed, 87 insertions, 78 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 85f63cb61a..c1e49b953a 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -40,7 +40,6 @@ #endif #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) -// Uncomment this to enable the 'on screen display' code. #define USE_OSD 1 #endif @@ -80,76 +79,71 @@ public: SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource, SdlWindow *window); virtual ~SurfaceSdlGraphicsManager(); - virtual void activateManager(); - virtual void deactivateManager(); + virtual void activateManager() override; + virtual void deactivateManager() override; - virtual bool hasFeature(OSystem::Feature f); - virtual void setFeatureState(OSystem::Feature f, bool enable); - virtual bool getFeatureState(OSystem::Feature f); + virtual bool hasFeature(OSystem::Feature f) const override; + virtual void setFeatureState(OSystem::Feature f, bool enable) override; + virtual bool getFeatureState(OSystem::Feature f) const override; - virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; - virtual int getDefaultGraphicsMode() const; - virtual bool setGraphicsMode(int mode); - virtual int getGraphicsMode() const; - virtual void resetGraphicsScale(); + virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override; + virtual int getDefaultGraphicsMode() const override; + virtual bool setGraphicsMode(int mode) override; + virtual int getGraphicsMode() const override; + virtual void resetGraphicsScale() override; #ifdef USE_RGB_COLOR - virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } - virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; + virtual Graphics::PixelFormat getScreenFormat() const override { return _screenFormat; } + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override; #endif - virtual const OSystem::GraphicsMode *getSupportedShaders() const; - virtual int getShader() const; - virtual bool setShader(int id); - virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); - virtual int getScreenChangeID() const { return _screenChangeCount; } + virtual const OSystem::GraphicsMode *getSupportedShaders() const override; + virtual int getShader() const override; + virtual bool setShader(int id) override; + virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL) override; + virtual int getScreenChangeID() const override { return _screenChangeCount; } - virtual void beginGFXTransaction(); - virtual OSystem::TransactionError endGFXTransaction(); + virtual void beginGFXTransaction() override; + virtual OSystem::TransactionError endGFXTransaction() override; - virtual int16 getHeight(); - virtual int16 getWidth(); + virtual int16 getHeight() const override; + virtual int16 getWidth() const override; protected: // PaletteManager API - virtual void setPalette(const byte *colors, uint start, uint num); - virtual void grabPalette(byte *colors, uint start, uint num); + virtual void setPalette(const byte *colors, uint start, uint num) override; + virtual void grabPalette(byte *colors, uint start, uint num) const override; public: - virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); - virtual Graphics::Surface *lockScreen(); - virtual void unlockScreen(); - virtual void fillScreen(uint32 col); - virtual void updateScreen(); - virtual void setShakePos(int shakeOffset); - virtual void setFocusRectangle(const Common::Rect& rect); - virtual void clearFocusRectangle(); - - virtual void showOverlay(); - virtual void hideOverlay(); - virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } - virtual void clearOverlay(); - virtual void grabOverlay(void *buf, int pitch); - virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); - virtual int16 getOverlayHeight() { return _videoMode.overlayHeight; } - virtual int16 getOverlayWidth() { return _videoMode.overlayWidth; } - - virtual bool showMouse(bool visible); - virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL); - virtual void setCursorPalette(const byte *colors, uint start, uint num); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override; + virtual Graphics::Surface *lockScreen() override; + virtual void unlockScreen() override; + virtual void fillScreen(uint32 col) override; + virtual void updateScreen() override; + virtual void setShakePos(int shakeOffset) override; + virtual void setFocusRectangle(const Common::Rect& rect) override; + virtual void clearFocusRectangle() override; + + virtual Graphics::PixelFormat getOverlayFormat() const override { return _overlayFormat; } + virtual void clearOverlay() override; + virtual void grabOverlay(void *buf, int pitch) const override; + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override; + virtual int16 getOverlayHeight() const override { return _videoMode.overlayHeight; } + virtual int16 getOverlayWidth() const override { return _videoMode.overlayWidth; } + + virtual bool showMouse(bool visible) override; + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) override; + virtual void setCursorPalette(const byte *colors, uint start, uint num) override; #ifdef USE_OSD - virtual void displayMessageOnOSD(const char *msg); - virtual void displayActivityIconOnOSD(const Graphics::Surface *icon); + virtual void displayMessageOnOSD(const char *msg) override; + virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) override; #endif // Override from Common::EventObserver - bool notifyEvent(const Common::Event &event); + virtual bool notifyEvent(const Common::Event &event) override; // SdlGraphicsManager interface - virtual void notifyVideoExpose(); - virtual void notifyResize(const uint width, const uint height); - virtual void transformMouseCoordinates(Common::Point &point); - virtual void notifyMousePos(Common::Point mouse); + virtual void notifyVideoExpose() override; + virtual void notifyResize(const int width, const int height) override; protected: #ifdef USE_OSD @@ -178,8 +172,11 @@ protected: void drawOSD(); #endif - /** Hardware screen */ - SDL_Surface *_hwscreen; + virtual bool gameNeedsAspectRatioCorrection() const override { + return _videoMode.aspectRatioCorrection; + } + + virtual void handleResizeImpl(const int width, const int height) override; virtual int getGraphicsModeScale(int mode) const override; @@ -188,10 +185,7 @@ protected: * around this API to keep the code paths as close as possible. */ SDL_Renderer *_renderer; SDL_Texture *_screenTexture; - SDL_Rect _viewport; - int _windowWidth, _windowHeight; void deinitializeRenderer(); - void setWindowResolution(int width, int height); void recreateScreenTexture(); virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); @@ -218,7 +212,6 @@ protected: SDL_Surface *_tmpscreen2; SDL_Surface *_overlayscreen; - bool _overlayVisible; Graphics::PixelFormat _overlayFormat; enum { @@ -280,14 +273,11 @@ protected: uint8 _originalBitsPerPixel; #endif - /** Force full redraw on next updateScreen */ - bool _forceFull; - ScalerProc *_scalerProc; int _scalerType; int _transactionMode; - // Indicates whether it is needed to free _hwsurface in destructor + // Indicates whether it is needed to free _hwSurface in destructor bool _displayDisabled; bool _screenIsLocked; @@ -308,10 +298,6 @@ protected: int _numDirtyRects; struct MousePos { - // The mouse position, using either virtual (game) or real - // (overlay) coordinates. - int16 x, y; - // The size and hotspot of the original cursor image. int16 w, h; int16 hotX, hotY; @@ -326,14 +312,13 @@ protected: int16 vW, vH; int16 vHotX, vHotY; - MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0), + MousePos() : w(0), h(0), hotX(0), hotY(0), rW(0), rH(0), rHotX(0), rHotY(0), vW(0), vH(0), vHotX(0), vHotY(0) { } }; bool _mouseVisible; - bool _mouseNeedsRedraw; byte *_mouseData; SDL_Rect _mouseBackup; MousePos _mouseCurState; @@ -386,21 +371,45 @@ protected: virtual void unloadGFXMode(); virtual bool hotswapGFXMode(); - virtual void setFullscreenMode(bool enable); virtual void setAspectRatioCorrection(bool enable); #if SDL_VERSION_ATLEAST(2, 0, 0) - virtual void setFilteringMode(bool enable); + void setFilteringMode(bool enable); #endif - virtual int effectiveScreenHeight() const; - + virtual bool saveScreenshot(const char *filename); virtual void setGraphicsModeIntern(); - virtual bool handleScalerHotkeys(Common::KeyCode key); - virtual bool isScalerHotkey(const Common::Event &event); - virtual void setMousePos(int x, int y); - virtual void toggleFullScreen(); - virtual bool saveScreenshot(const char *filename); +private: + void setFullscreenMode(bool enable); + bool handleScalerHotkeys(Common::KeyCode key); + bool isScalerHotkey(const Common::Event &event); + void toggleFullScreen(); + + /** + * Converts the given point from the overlay's coordinate space to the + * game's coordinate space. + */ + Common::Point convertOverlayToGame(const int x, const int y) const { + if (getOverlayWidth() == 0 || getOverlayHeight() == 0) { + error("convertOverlayToGame called without a valid overlay"); + } + + return Common::Point(x * getWidth() / getOverlayWidth(), + y * getHeight() / getOverlayHeight()); + } + + /** + * Converts the given point from the game's coordinate space to the + * overlay's coordinate space. + */ + Common::Point convertGameToOverlay(const int x, const int y) const { + if (getWidth() == 0 || getHeight() == 0) { + error("convertGameToOverlay called without a valid overlay"); + } + + return Common::Point(x * getOverlayWidth() / getWidth(), + y * getOverlayHeight() / getHeight()); + } }; #endif |