openMSX
Public Member Functions | Protected Member Functions | Friends | 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]
Collaboration diagram for openmsx::OutputSurface:
Collaboration graph
[legend]

Public Member Functions

virtual ~OutputSurface ()
 
unsigned getWidth () const
 
unsigned getHeight () const
 
int getX () const
 
int getY () const
 
const SDL_PixelFormat & getSDLFormat () const
 
SDL_Surface * getSDLSurface () const
 
unsigned mapRGB (double dr, double dg, double db)
 Returns the pixel value for the given RGB color. 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 mapKeyedRGB (int r8, int g8, int b8)
 Returns the pixel value for the given RGB color. More...
 
template<typename Pixel >
Pixel mapKeyedRGB (double dr, double dg, double db)
 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 ()
 For SDLGL-FB-nn, copy frame buffer to OpenGL display. More...
 
virtual void saveScreenshot (const std::string &filename)=0
 Save the content of this OutputSurface to a PNG file. More...
 
virtual void clearScreen ()=0
 Clear screen (paint it black). More...
 

Protected Member Functions

 OutputSurface ()
 
void setPosition (int x, int y)
 
void setSDLSurface (SDL_Surface *surface_)
 
void setSDLFormat (const SDL_PixelFormat &format)
 
void setBufferPtr (char *data, unsigned pitch)
 
- Protected Member Functions inherited from openmsx::OutputRectangle
virtual ~OutputRectangle ()
 

Friends

class SDLGLOutputSurface
 

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 16 of file OutputSurface.hh.

Constructor & Destructor Documentation

openmsx::OutputSurface::~OutputSurface ( )
virtual

Definition at line 12 of file OutputSurface.cc.

openmsx::OutputSurface::OutputSurface ( )
protected

Definition at line 7 of file OutputSurface.cc.

Member Function Documentation

virtual void openmsx::OutputSurface::clearScreen ( )
pure virtual

Clear screen (paint it black).

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

void openmsx::OutputSurface::flushFrameBuffer ( )
virtual

For SDLGL-FB-nn, copy frame buffer to OpenGL display.

The default implementation does nothing.

Definition at line 78 of file OutputSurface.cc.

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

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

Returns the color key for this output surface.

Definition at line 37 of file OutputSurface.hh.

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 48 of file OutputSurface.hh.

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 (non FB version) you don't have direct access to a pixel buffer.

Definition at line 104 of file OutputSurface.hh.

References isLocked().

Referenced by openmsx::SDLSnow< Pixel >::paint().

const SDL_PixelFormat& openmsx::OutputSurface::getSDLFormat ( ) const
inline
SDL_Surface* openmsx::OutputSurface::getSDLSurface ( ) const
inline
unsigned openmsx::OutputSurface::getWidth ( ) const
inline
int openmsx::OutputSurface::getX ( ) const
inline
int openmsx::OutputSurface::getY ( ) const
inline
bool openmsx::OutputSurface::isLocked ( ) const
inline

Is this OutputSurface currently locked?

Definition at line 97 of file OutputSurface.hh.

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

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 16 of file OutputSurface.cc.

References isLocked().

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

template<typename Pixel >
Pixel openmsx::OutputSurface::mapKeyedRGB ( int  r8,
int  g8,
int  b8 
)
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 59 of file OutputSurface.hh.

template<typename Pixel >
Pixel openmsx::OutputSurface::mapKeyedRGB ( double  dr,
double  dg,
double  db 
)
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 76 of file OutputSurface.hh.

unsigned openmsx::OutputSurface::mapRGB ( double  dr,
double  dg,
double  db 
)

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.cc.

Referenced by openmsx::SDLSnow< Pixel >::SDLSnow().

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.
void openmsx::OutputSurface::setBufferPtr ( char *  data,
unsigned  pitch 
)
protected
void openmsx::OutputSurface::setPosition ( int  x,
int  y 
)
protected

Definition at line 35 of file OutputSurface.cc.

Referenced by openmsx::SDLGLVisibleSurface::SDLGLVisibleSurface().

void openmsx::OutputSurface::setSDLFormat ( const SDL_PixelFormat &  format)
protected
void openmsx::OutputSurface::setSDLSurface ( SDL_Surface *  surface_)
inlineprotected
void openmsx::OutputSurface::unlock ( )

Unlock this OutputSurface.

See Also
lock().

Definition at line 26 of file OutputSurface.cc.

References isLocked().

Referenced by openmsx::SDLImage::draw().

Friends And Related Function Documentation

friend class SDLGLOutputSurface
friend

Definition at line 142 of file OutputSurface.hh.


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