openMSX
Public Member Functions | Protected Member Functions | List of all members
openmsx::OutputSurface Class Referenceabstract

A frame buffer where pixels can be written to. More...

#include <OutputSurface.hh>

Inheritance diagram for openmsx::OutputSurface:
Inheritance graph
[legend]

Public Member Functions

 OutputSurface (const OutputSurface &)=delete
 
OutputSurfaceoperator= (const OutputSurface &)=delete
 
virtual ~OutputSurface ()=default
 
int getWidth () const
 
int getHeight () const
 
gl::ivec2 getLogicalSize () const
 
gl::ivec2 getPhysicalSize () const
 
gl::ivec2 getViewOffset () const
 
gl::ivec2 getViewSize () const
 
gl::vec2 getViewScale () const
 
bool isViewScaled () const
 
const SDL_PixelFormat & getSDLFormat () const
 
SDL_Surface * getSDLSurface () const
 
SDL_Renderer * getSDLRenderer () const
 
unsigned mapRGB (gl::vec3 rgb)
 Returns the pixel value for the given RGB color. More...
 
unsigned mapRGB255 (gl::ivec3 rgb)
 Same as mapRGB, but RGB components are in range [0..255]. More...
 
template<typename Pixel >
Pixel getKeyColor () const
 Returns the color key for this output surface. More...
 
template<typename Pixel >
Pixel getKeyColorClash () const
 Returns a color that is visually very close to the key color. More...
 
template<typename Pixel >
Pixel mapKeyedRGB255 (gl::ivec3 rgb)
 Returns the pixel value for the given RGB color. More...
 
template<typename Pixel >
Pixel mapKeyedRGB (gl::vec3 rgb)
 Returns the pixel value for the given RGB color. More...
 
void lock ()
 Lock this OutputSurface. More...
 
void unlock ()
 Unlock this OutputSurface. More...
 
bool isLocked () const
 Is this OutputSurface currently locked? More...
 
template<typename Pixel >
PixelgetLinePtrDirect (unsigned y)
 Returns a pointer to the requested line in the pixel buffer. More...
 
virtual void flushFrameBuffer ()
 Copy frame buffer to display buffer. More...
 
virtual void saveScreenshot (const std::string &filename)=0
 Save the content of this OutputSurface to a PNG file. More...
 
virtual void clearScreen ()
 Clear frame buffer (paint it black). More...
 

Protected Member Functions

 OutputSurface ()=default
 
void calculateViewPort (gl::ivec2 physSize)
 
void setSDLSurface (SDL_Surface *surface_)
 
void setSDLRenderer (SDL_Renderer *r)
 
void setSDLFormat (const SDL_PixelFormat &format)
 
void setBufferPtr (char *data, unsigned pitch)
 

Detailed Description

A frame buffer where pixels can be written to.

It could be an in-memory buffer or a video buffer visible to the user (see VisibleSurface subclass).

Definition at line 15 of file OutputSurface.hh.

Constructor & Destructor Documentation

◆ OutputSurface() [1/2]

openmsx::OutputSurface::OutputSurface ( const OutputSurface )
delete

◆ ~OutputSurface()

virtual openmsx::OutputSurface::~OutputSurface ( )
virtualdefault

◆ OutputSurface() [2/2]

openmsx::OutputSurface::OutputSurface ( )
protecteddefault

Referenced by getLinePtrDirect().

Member Function Documentation

◆ calculateViewPort()

void openmsx::OutputSurface::calculateViewPort ( gl::ivec2  physSize)
protected

◆ clearScreen()

void openmsx::OutputSurface::clearScreen ( )
virtual

Clear frame buffer (paint it black).

The default implementation does nothing.

Definition at line 75 of file OutputSurface.cc.

Referenced by getLinePtrDirect(), and openmsx::FBPostProcessor< Pixel >::paint().

◆ flushFrameBuffer()

void openmsx::OutputSurface::flushFrameBuffer ( )
virtual

Copy frame buffer to display buffer.

The default implementation does nothing.

Definition at line 71 of file OutputSurface.cc.

Referenced by getLinePtrDirect(), openmsx::SDLSnow< Pixel >::paint(), and openmsx::FBPostProcessor< Pixel >::paint().

◆ getHeight()

int openmsx::OutputSurface::getHeight ( ) const
inline

◆ getKeyColor()

template<typename Pixel >
Pixel openmsx::OutputSurface::getKeyColor ( ) const
inline

Returns the color key for this output surface.

Definition at line 55 of file OutputSurface.hh.

Referenced by openmsx::V9990SDLRasterizer< Pixel >::setPalette(), and openmsx::SDLRasterizer< Pixel >::setTransparency().

◆ getKeyColorClash()

template<typename Pixel >
Pixel openmsx::OutputSurface::getKeyColorClash ( ) const
inline

Returns a color that is visually very close to the key color.

The returned color can be used as an alternative for pixels that would otherwise have the key color.

Definition at line 66 of file OutputSurface.hh.

◆ getLinePtrDirect()

template<typename Pixel >
Pixel* openmsx::OutputSurface::getLinePtrDirect ( unsigned  y)
inline

Returns a pointer to the requested line in the pixel buffer.

Not all implementations support this operation, e.g. in SDLGL you don't have direct access to a pixel buffer.

Definition at line 119 of file OutputSurface.hh.

References calculateViewPort(), clearScreen(), openmsx::filename, flushFrameBuffer(), isLocked(), OutputSurface(), and saveScreenshot().

Referenced by openmsx::DirectScalerOutput< Pixel >::acquireLine(), openmsx::DirectScalerOutput< Pixel >::fillLine(), and openmsx::SDLSnow< Pixel >::paint().

◆ getLogicalSize()

gl::ivec2 openmsx::OutputSurface::getLogicalSize ( ) const
inline

◆ getPhysicalSize()

gl::ivec2 openmsx::OutputSurface::getPhysicalSize ( ) const
inline

◆ getSDLFormat()

const SDL_PixelFormat& openmsx::OutputSurface::getSDLFormat ( ) const
inline

◆ getSDLRenderer()

SDL_Renderer* openmsx::OutputSurface::getSDLRenderer ( ) const
inline

◆ getSDLSurface()

SDL_Surface* openmsx::OutputSurface::getSDLSurface ( ) const
inline

◆ getViewOffset()

gl::ivec2 openmsx::OutputSurface::getViewOffset ( ) const
inline

◆ getViewScale()

gl::vec2 openmsx::OutputSurface::getViewScale ( ) const
inline

Definition at line 30 of file OutputSurface.hh.

Referenced by openmsx::GLScopedClip::GLScopedClip().

◆ getViewSize()

gl::ivec2 openmsx::OutputSurface::getViewSize ( ) const
inline

◆ getWidth()

int openmsx::OutputSurface::getWidth ( ) const
inline

◆ isLocked()

bool openmsx::OutputSurface::isLocked ( ) const
inline

Is this OutputSurface currently locked?

Definition at line 112 of file OutputSurface.hh.

Referenced by getLinePtrDirect(), lock(), and unlock().

◆ isViewScaled()

bool openmsx::OutputSurface::isViewScaled ( ) const
inline

Definition at line 31 of file OutputSurface.hh.

Referenced by openmsx::GLPostProcessor::paint().

◆ lock()

void openmsx::OutputSurface::lock ( )

Lock this OutputSurface.

Direct pixel access is only allowed on a locked surface. Locking an already locked surface has no effect.

Definition at line 7 of file OutputSurface.cc.

References isLocked().

Referenced by mapKeyedRGB(), openmsx::SDLSnow< Pixel >::paint(), and openmsx::FBPostProcessor< Pixel >::paint().

◆ mapKeyedRGB()

template<typename Pixel >
Pixel openmsx::OutputSurface::mapKeyedRGB ( gl::vec3  rgb)
inline

Returns the pixel value for the given RGB color.

It is guaranteed that the returned pixel value is different from the color key for this output surface.

Definition at line 94 of file OutputSurface.hh.

References lock(), and unlock().

Referenced by openmsx::SDLRasterizer< Pixel >::setTransparency().

◆ mapKeyedRGB255()

template<typename Pixel >
Pixel openmsx::OutputSurface::mapKeyedRGB255 ( gl::ivec3  rgb)
inline

Returns the pixel value for the given RGB color.

It is guaranteed that the returned pixel value is different from the color key for this output surface.

Definition at line 77 of file OutputSurface.hh.

References mapRGB255().

Referenced by openmsx::V9990SDLRasterizer< Pixel >::drawDisplay(), and openmsx::SDLRasterizer< Pixel >::setTransparency().

◆ mapRGB()

unsigned openmsx::OutputSurface::mapRGB ( gl::vec3  rgb)
inline

Returns the pixel value for the given RGB color.

No effort is made to ensure that the returned pixel value is not the color key for this output surface.

Definition at line 41 of file OutputSurface.hh.

References mapRGB255().

Referenced by openmsx::V9990SDLRasterizer< Pixel >::drawDisplay().

◆ mapRGB255()

unsigned openmsx::OutputSurface::mapRGB255 ( gl::ivec3  rgb)
inline

Same as mapRGB, but RGB components are in range [0..255].

Definition at line 48 of file OutputSurface.hh.

Referenced by mapKeyedRGB255(), mapRGB(), and openmsx::SDLSnow< Pixel >::SDLSnow().

◆ operator=()

OutputSurface& openmsx::OutputSurface::operator= ( const OutputSurface )
delete

◆ saveScreenshot()

virtual void openmsx::OutputSurface::saveScreenshot ( const std::string &  filename)
pure virtual

Save the content of this OutputSurface to a PNG file.

Exceptions
MSXExceptionIf creating the PNG file fails.

Referenced by getLinePtrDirect().

◆ setBufferPtr()

void openmsx::OutputSurface::setBufferPtr ( char *  data,
unsigned  pitch 
)
protected

◆ setSDLFormat()

void openmsx::OutputSurface::setSDLFormat ( const SDL_PixelFormat &  format)
protected

◆ setSDLRenderer()

void openmsx::OutputSurface::setSDLRenderer ( SDL_Renderer *  r)
inlineprotected

◆ setSDLSurface()

void openmsx::OutputSurface::setSDLSurface ( SDL_Surface *  surface_)
inlineprotected

◆ unlock()

void openmsx::OutputSurface::unlock ( )

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