ScummVM API documentation
SurfaceSdlGraphicsManager Class Reference

#include <surfacesdl-graphics.h>

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

Classes

class  AspectRatio
 
struct  MousePos
 
struct  TransactionDetails
 
struct  VideoState
 

Public Member Functions

 SurfaceSdlGraphicsManager (SdlEventSource *sdlEventSource, SdlWindow *window)
 
bool hasFeature (OSystem::Feature f) const override
 
void setFeatureState (OSystem::Feature f, bool enable) override
 
bool getFeatureState (OSystem::Feature f) const override
 
const OSystem::GraphicsModegetSupportedGraphicsModes () const override
 
int getDefaultGraphicsMode () const override
 
bool setGraphicsMode (int mode, uint flags=OSystem::kGfxModeNoFlags) override
 
int getGraphicsMode () const override
 
uint getDefaultScaler () const override
 
uint getDefaultScaleFactor () const override
 
bool setScaler (uint mode, int factor) override
 
uint getScaler () const override
 
uint getScaleFactor () const override
 
void initSize (uint w, uint h, const Graphics::PixelFormat *format=NULL) override
 
int getScreenChangeID () const override
 
void beginGFXTransaction () override
 
OSystem::TransactionError endGFXTransaction () override
 
int16 getHeight () const override
 
int16 getWidth () const override
 
void copyRectToScreen (const void *buf, int pitch, int x, int y, int w, int h) override
 
Graphics::SurfacelockScreen () override
 
void unlockScreen () override
 
void fillScreen (uint32 col) override
 
void fillScreen (const Common::Rect &r, uint32 col) override
 
void updateScreen () override
 
void setFocusRectangle (const Common::Rect &rect) override
 
void clearFocusRectangle () override
 
Graphics::PixelFormat getOverlayFormat () const override
 
void clearOverlay () override
 
void grabOverlay (Graphics::Surface &surface) const override
 
void copyRectToOverlay (const void *buf, int pitch, int x, int y, int w, int h) override
 
int16 getOverlayHeight () const override
 
int16 getOverlayWidth () const override
 
void setMouseCursor (const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=NULL, const byte *mask=NULL) override
 
void setCursorPalette (const byte *colors, uint start, uint num) override
 
bool notifyEvent (const Common::Event &event) override
 
void notifyVideoExpose () override
 
void notifyResize (const int width, const int height) override
 
- Public Member Functions inherited from SdlGraphicsManager
 SdlGraphicsManager (SdlEventSource *source, SdlWindow *window)
 
virtual void activateManager ()
 
virtual void deactivateManager ()
 
virtual bool notifyMousePosition (Common::Point &mouse)
 
virtual bool showMouse (bool visible) override
 
bool lockMouse (bool lock) override
 
void saveScreenshot () 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 setShader (const Common::Path &fileName)
 
virtual const OSystem::GraphicsModegetSupportedStretchModes () const
 
virtual int getDefaultStretchMode () const
 
virtual bool setStretchMode (int mode)
 
virtual int getStretchMode () const
 
virtual float getHiDPIScreenFactor () const
 
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  { kTransactionNone = 0, kTransactionActive = 1, kTransactionRollback = 2 }
 
enum  { NUM_DIRTY_RECT = 100, MAX_SCALING = 3 }
 
- Protected Types inherited from SdlGraphicsManager
enum  CustomEventAction {
  kActionToggleFullscreen = 100, kActionToggleMouseCapture, kActionSaveScreenshot, kActionToggleAspectRatioCorrection,
  kActionToggleFilteredScaling, kActionCycleStretchMode, kActionIncreaseScaleFactor, kActionDecreaseScaleFactor,
  kActionNextScaleFilter, kActionPreviousScaleFilter
}
 

Protected Member Functions

void setPalette (const byte *colors, uint start, uint num) override
 
void grabPalette (byte *colors, uint start, uint num) const override
 
virtual void initGraphicsSurface ()
 
Graphics::PixelFormat convertSDLPixelFormat (SDL_PixelFormat *in) const
 
bool gameNeedsAspectRatioCorrection () const override
 
int getGameRenderScale () const override
 
void handleResizeImpl (const int width, const int height) override
 
virtual void setupHardwareSize ()
 
void fixupResolutionForAspectRatio (AspectRatio desiredAspectRatio, int &width, int &height) const
 
virtual void addDirtyRect (int x, int y, int w, int h, bool inOverlay, bool realCoordinates=false)
 
virtual void drawMouse ()
 
virtual void undrawMouse ()
 
virtual void blitCursor ()
 
virtual void internUpdateScreen ()
 
virtual void updateScreen (SDL_Rect *dirtyRectList, int actualDirtyRects)
 
virtual bool loadGFXMode ()
 
virtual void unloadGFXMode ()
 
virtual bool hotswapGFXMode ()
 
virtual void setAspectRatioCorrection (bool enable)
 
void setFilteringMode (bool enable)
 
void setVSync (bool enable)
 
bool saveScreenshot (const Common::Path &filename) const override
 
virtual void setGraphicsModeIntern ()
 
virtual void getDefaultResolution (uint &w, uint &h)
 
- Protected Member Functions inherited from SdlGraphicsManager
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
 
- Protected Member Functions inherited from WindowedGraphicsManager
Common::Point convertVirtualToWindow (const int x, const int y) const
 
Common::Point convertWindowToVirtual (int x, int y) const
 
frac_t getDesiredGameAspectRatio () 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)
 

Static Protected Member Functions

static AspectRatio getDesiredAspectRatio ()
 

Protected Attributes

SDL_Surface * _screen
 
Graphics::PixelFormat _screenFormat
 
Graphics::PixelFormat _cursorFormat
 
SDL_Surface * _tmpscreen
 
SDL_Surface * _tmpscreen2
 
SDL_Surface * _overlayscreen
 
bool _useOldSrc
 
Graphics::PixelFormat _overlayFormat
 
bool _isDoubleBuf
 
bool _isHwPalette
 
TransactionDetails _transactionDetails
 
VideoState _videoMode
 
VideoState _oldVideoMode
 
int _transactionMode
 
bool _displayDisabled
 
const PluginList_scalerPlugins
 
ScalerPluginObject_scalerPlugin
 
Scaler_scaler
 
Scaler_mouseScaler
 
uint _maxExtraPixels
 
uint _extraPixels
 
bool _screenIsLocked
 
Graphics::Surface _framebuffer
 
int _screenChangeCount
 
SDL_Rect _dirtyRectList [2 *NUM_DIRTY_RECT]
 
int _numDirtyRects
 
SDL_Rect _prevDirtyRectList [NUM_DIRTY_RECT]
 
int _numPrevDirtyRects
 
SDL_Rect _mouseLastRect
 
SDL_Rect _mouseNextRect
 
MousePos _mouseCurState
 
byte _mouseKeyColor
 
byte _mappedMouseKeyColor
 
bool _cursorDontScale
 
bool _cursorPaletteDisabled
 
SDL_Surface * _mouseOrigSurface
 
SDL_Surface * _mouseSurface
 
int _currentShakeXOffset
 
int _currentShakeYOffset
 
SDL_Color * _currentPalette
 
uint _paletteDirtyStart
 
uint _paletteDirtyEnd
 
SDL_Color * _overlayPalette
 
bool _isInOverlayPalette
 
SDL_Color * _cursorPalette
 
Common::Mutex _graphicsMutex
 
bool _enableFocusRectDebugCode
 
bool _enableFocusRect
 
Common::Rect _focusRect
 
- Protected Attributes inherited from SdlGraphicsManager
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

SDL graphics manager

Member Function Documentation

◆ setPalette()

void SurfaceSdlGraphicsManager::setPalette ( const byte *  colors,
uint  start,
uint  num 
)
overrideprotectedvirtual

Replace the specified range of the palette with new colors. The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.

The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...

Parameters
colorsthe new palette data, in interleaved RGB format
startthe first palette entry to be updated
numthe number of palette entries to be updated
Note
It is an error if start+num exceeds 256, behavior is undefined in that case (the backend may ignore it silently or assert).
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implements GraphicsManager.

◆ grabPalette()

void SurfaceSdlGraphicsManager::grabPalette ( byte *  colors,
uint  start,
uint  num 
) const
overrideprotectedvirtual

Grabs a specified part of the currently active palette. The format is the same as for setPalette.

This should return exactly the same RGB data as was setup via previous setPalette calls.

For example, for every valid value of start and num of the following code:

byte origPal[num*3]; // Setup origPal's data however you like g_system->setPalette(origPal, start, num); byte obtainedPal[num*3]; g_system->grabPalette(obtainedPal, start, num);

the following should be true:

memcmp(origPal, obtainedPal, num*3) == 0

See also
setPalette
Parameters
colorsthe palette data, in interleaved RGB format
startthe first platte entry to be read
numthe number of palette entries to be read
Note
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implements GraphicsManager.

◆ convertSDLPixelFormat()

Graphics::PixelFormat SurfaceSdlGraphicsManager::convertSDLPixelFormat ( SDL_PixelFormat *  in) const
protected

Convert from the SDL pixel format to Graphics::PixelFormat

Parameters
inThe SDL pixel format to convert
outA pixel format to be written to

◆ notifyEvent()

bool SurfaceSdlGraphicsManager::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.

Reimplemented from SdlGraphicsManager.

◆ notifyVideoExpose()

void SurfaceSdlGraphicsManager::notifyVideoExpose ( )
overridevirtual

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.

Implements SdlGraphicsManager.

◆ notifyResize()

void SurfaceSdlGraphicsManager::notifyResize ( const int  width,
const int  height 
)
overridevirtual

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 from SdlGraphicsManager.

◆ gameNeedsAspectRatioCorrection()

bool SurfaceSdlGraphicsManager::gameNeedsAspectRatioCorrection ( ) const
inlineoverrideprotectedvirtual
Returns
whether or not the game screen must have aspect ratio correction applied for correct rendering.

Implements WindowedGraphicsManager.

◆ getGameRenderScale()

int SurfaceSdlGraphicsManager::getGameRenderScale ( ) const
inlineoverrideprotectedvirtual
Returns
the scale used between the game size and the surface on which it is rendered.

Reimplemented from WindowedGraphicsManager.

◆ handleResizeImpl()

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

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

Reimplemented from SdlGraphicsManager.

Member Data Documentation

◆ _screen

SDL_Surface* SurfaceSdlGraphicsManager::_screen
protected

Unseen game screen

◆ _tmpscreen

SDL_Surface* SurfaceSdlGraphicsManager::_tmpscreen
protected

Temporary screen (for scalers)

◆ _tmpscreen2

SDL_Surface* SurfaceSdlGraphicsManager::_tmpscreen2
protected

Temporary screen (for scalers)

◆ _graphicsMutex

Common::Mutex SurfaceSdlGraphicsManager::_graphicsMutex
protected

Mutex which prevents multiple threads from interfering with each other when accessing the screen.


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