ScummVM API documentation
SdlGraphicsManager Class Referenceabstract

#include <sdl-graphics.h>

Inheritance diagram for SdlGraphicsManager:
WindowedGraphicsManager Common::EventObserver GraphicsManager PaletteManager Common::NonCopyable OpenGLSdlGraphicsManager SurfaceSdlGraphicsManager MiyooMiniGraphicsManager OpenDinguxGraphicsManager OPGraphicsManager RISCOSSdlGraphicsManager

Classes

struct  State
 

Public Member Functions

 SdlGraphicsManager (SdlEventSource *source, SdlWindow *window)
 
virtual void activateManager ()
 
virtual void deactivateManager ()
 
virtual void notifyVideoExpose ()=0
 
virtual void notifyResize (const int width, const int height)
 
virtual bool notifyMousePosition (Common::Point &mouse)
 
virtual bool showMouse (bool visible) override
 
bool lockMouse (bool lock) override
 
virtual bool saveScreenshot (const Common::Path &filename) const
 
void saveScreenshot () override
 
bool notifyEvent (const Common::Event &event) override
 
State getState () const
 
bool setState (const State &state)
 
SdlWindowgetWindow () const
 
void initSizeHint (const Graphics::ModeList &modes) override
 
Common::KeymapgetKeymap ()
 
- Public Member Functions inherited from WindowedGraphicsManager
void showOverlay (bool inGUI) override
 
void hideOverlay () override
 
bool isOverlayVisible () const override
 
void setShakePos (int shakeXOffset, int shakeYOffset) override
 
int getWindowWidth () const
 
int getWindowHeight () const
 
- Public Member Functions inherited from GraphicsManager
virtual bool hasFeature (OSystem::Feature f) const =0
 
virtual void setFeatureState (OSystem::Feature f, bool enable)=0
 
virtual bool getFeatureState (OSystem::Feature f) const =0
 
virtual const OSystem::GraphicsModegetSupportedGraphicsModes () const
 
virtual int getDefaultGraphicsMode () const
 
virtual bool setGraphicsMode (int mode, uint flags=OSystem::kGfxModeNoFlags)
 
virtual int getGraphicsMode () const
 
virtual bool setShader (const Common::Path &fileName)
 
virtual const OSystem::GraphicsModegetSupportedStretchModes () const
 
virtual int getDefaultStretchMode () const
 
virtual bool setStretchMode (int mode)
 
virtual int getStretchMode () const
 
virtual uint getDefaultScaler () const
 
virtual uint getDefaultScaleFactor () const
 
virtual bool setScaler (uint mode, int factor)
 
virtual uint getScaler () const
 
virtual uint getScaleFactor () const
 
virtual void initSize (uint width, uint height, const Graphics::PixelFormat *format=NULL)=0
 
virtual int getScreenChangeID () const =0
 
virtual void beginGFXTransaction ()=0
 
virtual OSystem::TransactionError endGFXTransaction ()=0
 
virtual int16 getHeight () const =0
 
virtual int16 getWidth () const =0
 
virtual void setPalette (const byte *colors, uint start, uint num)=0
 
virtual void grabPalette (byte *colors, uint start, uint num) const =0
 
virtual void copyRectToScreen (const void *buf, int pitch, int x, int y, int w, int h)=0
 
virtual Graphics::SurfacelockScreen ()=0
 
virtual void unlockScreen ()=0
 
virtual void fillScreen (uint32 col)=0
 
virtual void fillScreen (const Common::Rect &r, uint32 col)=0
 
virtual void updateScreen ()=0
 
virtual void setFocusRectangle (const Common::Rect &rect)=0
 
virtual void clearFocusRectangle ()=0
 
virtual Graphics::PixelFormat getOverlayFormat () const =0
 
virtual void clearOverlay ()=0
 
virtual void grabOverlay (Graphics::Surface &surface) const =0
 
virtual void copyRectToOverlay (const void *buf, int pitch, int x, int y, int w, int h)=0
 
virtual int16 getOverlayHeight () const =0
 
virtual int16 getOverlayWidth () const =0
 
virtual float getHiDPIScreenFactor () const
 
virtual void setMouseCursor (const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=nullptr, const byte *mask=nullptr)=0
 
virtual void setCursorPalette (const byte *colors, uint start, uint num)=0
 
virtual void displayMessageOnOSD (const Common::U32String &msg)
 
virtual void displayActivityIconOnOSD (const Graphics::Surface *icon)
 
- Public Member Functions inherited from Common::EventObserver
virtual void notifyPoll ()
 

Protected Types

enum  CustomEventAction {
  kActionToggleFullscreen = 100, kActionToggleMouseCapture, kActionSaveScreenshot, kActionToggleAspectRatioCorrection,
  kActionToggleFilteredScaling, kActionCycleStretchMode, kActionIncreaseScaleFactor, kActionDecreaseScaleFactor,
  kActionNextScaleFilter, kActionPreviousScaleFilter
}
 

Protected Member Functions

Common::Rect getPreferredFullscreenResolution ()
 
bool defaultGraphicsModeConfig () const
 
void getWindowSizeFromSdl (int *width, int *height) const
 
virtual void showSystemMouseCursor (bool visible)
 
void setSystemMousePosition (const int x, const int y) override
 
void notifyActiveAreaChanged () override
 
void handleResizeImpl (const int width, const int height) override
 
- Protected Member Functions inherited from WindowedGraphicsManager
virtual bool gameNeedsAspectRatioCorrection () const =0
 
Common::Point convertVirtualToWindow (const int x, const int y) const
 
Common::Point convertWindowToVirtual (int x, int y) const
 
frac_t getDesiredGameAspectRatio () const
 
virtual int getGameRenderScale () const
 
void handleResize (const int width, const int height)
 
virtual void recalculateDisplayAreas ()
 
bool showMouse (bool visible) override
 
void warpMouse (int x, int y) override
 
void setMousePosition (int x, int y)
 

Protected Attributes

SDL_Surface * _hwScreen
 
SdlEventSource_eventSource
 
SdlWindow_window
 
- Protected Attributes inherited from WindowedGraphicsManager
int _windowWidth
 
int _windowHeight
 
int _screenAlign
 
bool _overlayVisible
 
bool _overlayInGUI
 
int _gameScreenShakeXOffset
 
int _gameScreenShakeYOffset
 
Common::Rect _gameDrawRect
 
Common::Rect _overlayDrawRect
 
DisplayArea _activeArea
 
bool _forceRedraw
 
bool _cursorVisible
 
bool _cursorNeedsRedraw
 
bool _cursorLastInActiveArea
 
int _cursorX
 
int _cursorY
 

Detailed Description

Base class for a SDL based graphics manager.

Member Function Documentation

◆ activateManager()

virtual void SdlGraphicsManager::activateManager ( )
virtual

Makes this graphics manager active. That means it should be ready to process inputs now. However, even without being active it should be able to query the supported modes and other bits.

◆ deactivateManager()

virtual void SdlGraphicsManager::deactivateManager ( )
virtual

Makes this graphics manager inactive. This should allow another graphics manager to become active again.

◆ notifyVideoExpose()

virtual void SdlGraphicsManager::notifyVideoExpose ( )
pure virtual

Notify the graphics manager that the graphics needs to be redrawn, since the application window was modified.

This is basically called when SDL_VIDEOEXPOSE was received.

Implemented in SurfaceSdlGraphicsManager, and OpenGLSdlGraphicsManager.

◆ notifyResize()

virtual void SdlGraphicsManager::notifyResize ( const int  width,
const int  height 
)
inlinevirtual

Notify the graphics manager about a resize event.

It is noteworthy that the requested width/height should actually be set up as is and not changed by the graphics manager, since otherwise it may lead to odd behavior for certain window managers.

It is only required to overwrite this method in case you want a resizable window. The default implementation just does nothing.

Parameters
widthRequested window width.
heightRequested window height.

Reimplemented in SurfaceSdlGraphicsManager, and OpenGLSdlGraphicsManager.

◆ notifyMousePosition()

virtual bool SdlGraphicsManager::notifyMousePosition ( Common::Point mouse)
virtual

Notifies the graphics manager about a mouse position change.

The passed point must be converted from window coordinates to virtual coordinates in order for the event to be processed correctly by the game engine. Just use convertWindowToVirtual for this unless you need to do something special.

Parameters
mouseThe mouse position in window coordinates, which must be converted synchronously to virtual coordinates.
Returns
true if the mouse was in a valid position for the game and should cause the event to be sent to the game.

◆ notifyEvent()

bool SdlGraphicsManager::notifyEvent ( const Common::Event event)
overridevirtual

Notify the observer of an incoming event.

An observer is supposed to 'eat' the event, with returning true, when it wants to prevent other observers from receiving the event. A usage example here is the keymapper: If it processes an Event, it should 'eat' it and create a new event, which the EventDispatcher will then catch.

Parameters
eventThe event that is incoming.
Return values
trueIf the event should not be passed to other observers, false otherwise.

Implements Common::EventObserver.

Reimplemented in SurfaceSdlGraphicsManager.

◆ getState()

State SdlGraphicsManager::getState ( ) const

Gets the current state of the graphics manager.

◆ setState()

bool SdlGraphicsManager::setState ( const State state)

Sets up a basic state of the graphics manager.

◆ getWindow()

SdlWindow* SdlGraphicsManager::getWindow ( ) const
inline
Returns
the SDL window.

◆ getPreferredFullscreenResolution()

Common::Rect SdlGraphicsManager::getPreferredFullscreenResolution ( )
protected

Obtain the user configured fullscreen resolution, or default to the desktop resolution

◆ getWindowSizeFromSdl()

void SdlGraphicsManager::getWindowSizeFromSdl ( int *  width,
int *  height 
) const
inlineprotected

Gets the dimensions of the window directly from SDL instead of from the values stored by the graphics manager.

◆ setSystemMousePosition()

void SdlGraphicsManager::setSystemMousePosition ( const int  x,
const int  y 
)
overrideprotectedvirtual

Sets the position of the hardware mouse cursor in the host system, relative to the window.

Parameters
xX coordinate in window coordinates.
yY coordinate in window coordinates.

Implements WindowedGraphicsManager.

◆ notifyActiveAreaChanged()

void SdlGraphicsManager::notifyActiveAreaChanged ( )
overrideprotectedvirtual

Called whenever the active area has changed.

Reimplemented from WindowedGraphicsManager.

◆ handleResizeImpl()

void SdlGraphicsManager::handleResizeImpl ( const int  width,
const int  height 
)
overrideprotectedvirtual

Backend-specific implementation for updating internal surfaces that need to reflect the new window size.

Implements WindowedGraphicsManager.

Reimplemented in SurfaceSdlGraphicsManager.


The documentation for this class was generated from the following file: