vdr  2.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
cPixmap Class Referenceabstract

#include <osd.h>

Public Member Functions

 cPixmap (void)
 
 cPixmap (int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
 
int Layer (void) const
 
int Alpha (void) const
 
bool Tile (void) const
 
const cRectViewPort (void) const
 
const cRectDrawPort (void) const
 
const cRectDirtyViewPort (void) const
 
const cRectDirtyDrawPort (void) const
 
virtual void SetLayer (int Layer)
 
virtual void SetAlpha (int Alpha)
 
virtual void SetTile (bool Tile)
 
virtual void SetViewPort (const cRect &Rect)
 
virtual void SetDrawPortPoint (const cPoint &Point, bool Dirty=true)
 
virtual void Clear (void)=0
 
virtual void Fill (tColor Color)=0
 
virtual void DrawImage (const cPoint &Point, const cImage &Image)=0
 
virtual void DrawImage (const cPoint &Point, int ImageHandle)=0
 
virtual void DrawPixel (const cPoint &Point, tColor Color)=0
 
virtual void DrawBitmap (const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)=0
 
virtual void DrawText (const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)=0
 
virtual void DrawRectangle (const cRect &Rect, tColor Color)=0
 
virtual void DrawEllipse (const cRect &Rect, tColor Color, int Quadrants=0)=0
 
virtual void DrawSlope (const cRect &Rect, tColor Color, int Type)=0
 
virtual void Render (const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
 
virtual void Copy (const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
 
virtual void Scroll (const cPoint &Dest, const cRect &Source=cRect::Null)=0
 
virtual void Pan (const cPoint &Dest, const cRect &Source=cRect::Null)=0
 

Static Public Member Functions

static void Lock (void)
 
static void Unlock (void)
 

Protected Member Functions

virtual ~cPixmap ()
 
void MarkViewPortDirty (const cRect &Rect)
 
void MarkViewPortDirty (const cPoint &Point)
 
void MarkDrawPortDirty (const cRect &Rect)
 
void MarkDrawPortDirty (const cPoint &Point)
 
void SetClean (void)
 
virtual void DrawPixmap (const cPixmap *Pixmap, const cRect &Dirty)
 

Private Attributes

int layer
 
int alpha
 
bool tile
 
cRect viewPort
 
cRect drawPort
 
cRect dirtyViewPort
 
cRect dirtyDrawPort
 

Static Private Attributes

static cMutex mutex
 

Friends

class cOsd
 
class cPixmapMutexLock
 

Detailed Description

Definition at line 454 of file osd.h.

Constructor & Destructor Documentation

virtual cPixmap::~cPixmap ( )
inlineprotectedvirtual

Definition at line 467 of file osd.h.

References cRect::Null.

cPixmap::cPixmap ( void  )

Definition at line 960 of file osd.c.

References ALPHA_OPAQUE.

cPixmap::cPixmap ( int  Layer,
const cRect ViewPort,
const cRect DrawPort = cRect::Null 
)

Creates a pixmap in the given Layer.

When rendering the final OSD, pixmaps are handled in ascending order of their individual layer. This is important if pixmaps overlap each other. The one with the highest layer is rendered last. The actual value of Layer doesn't matter, it is only used for defining the rendering sequence. If Layer is less than zero, this pixmap will not be rendered into the final OSD (it can be activated by a later call to SetLayer()). The value 0 is reserved for the background pixmap and shall not be used otherwise (with the sole exception of temporarily using layer 0 to have a text with transparent background rendered with alpha blending into that pixmap; see also DrawPixel()). If there are several pixmaps with the same value of Layer, their rendering sequence within that layer is undefined. In order to allow devices that can handle only a limited number of layers, the Layer parameter must be less than 8 (MAXPIXMAPLAYERS). ViewPort defines the rectangle in which this pixmap will be rendered on the OSD. If no DrawPort is given, it defaults to the same size as the ViewPort, with its upper left corner set to (0, 0). All drawing operations will be executed relative to the origin of the DrawPort rectangle, and will be clipped to the size of this rectangle. The DrawPort may have a different size than the ViewPort. If it is smaller than the ViewPort, the rest of the ViewPort is treated as fully transparent (unless this is a tiled pixmap, in which case the DrawPort is repeated horizontally and vertically to fill the entire ViewPort). If the DrawPort is larger than the ViewPort, only that portion of the DrawPort that intersects with the ViewPort will be visible on the OSD. The drawing area of a newly created cPixmap is not initialized and may contain random data.

Definition at line 967 of file osd.c.

References ALPHA_OPAQUE, esyslog, cRect::IsEmpty(), MAXPIXMAPLAYERS, and cRect::SetPoint().

Member Function Documentation

int cPixmap::Alpha ( void  ) const
inline

Definition at line 533 of file osd.h.

Referenced by cPixmapMemory::Render().

virtual void cPixmap::Clear ( void  )
pure virtual

Clears the pixmap's draw port by setting all pixels to be fully transparent.

A derived class must call Lock()/Unlock().

Implemented in cPixmapMemory.

Referenced by cTrueColorDemo::Action(), cTrueColorDemo::CreateTextPixmap(), cOsd::RenderPixmaps(), and cOsd::SetAreas().

virtual void cPixmap::Copy ( const cPixmap Pixmap,
const cRect Source,
const cPoint Dest 
)
pure virtual

Copies the part of the given Pixmap covered by Source into this pixmap at location Dest.

The Source rectangle is relative to the given Pixmap's draw port. The data from Pixmap is copied as is, no alpha handling of any kind takes place.

Implemented in cPixmapMemory.

const cRect& cPixmap::DirtyDrawPort ( void  ) const
inline

Returns the "dirty" rectangle in the draw port of this this pixmap.

This is the surrounding rectangle around all pixels that have been modified since the last time this pixmap has been rendered to the OSD. The rectangle is relative to the draw port's origin. Since this function returns a reference to a data member, the caller must use Lock()/Unlock() to make sure the data doesn't change while it is used.

Definition at line 550 of file osd.h.

References cPalette::Color(), DrawEllipse(), DrawSlope(), Font, cRect::Null, and taDefault.

const cRect& cPixmap::DirtyViewPort ( void  ) const
inline

Returns the "dirty" rectangle this pixmap causes on the OSD.

This is the surrounding rectangle around all pixels that have been modified since the last time this pixmap has been rendered to the OSD. The rectangle is relative to the OSD's origin. Since this function returns a reference to a data member, the caller must use Lock()/Unlock() to make sure the data doesn't change while it is used.

Definition at line 543 of file osd.h.

virtual void cPixmap::DrawBitmap ( const cPoint Point,
const cBitmap Bitmap,
tColor  ColorFg = 0,
tColor  ColorBg = 0,
bool  Overlay = false 
)
pure virtual

Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the Bitmap at Point.

If ColorFg or ColorBg is given, the first palette entry of the Bitmap will be mapped to ColorBg and the second palette entry will be mapped to ColorFg (palette indexes are defined so that 0 is the background and 1 is the foreground color). If Overlay is true, any pixel in Bitmap that has color index 0 will not overwrite the corresponding pixel in the target area. This function is mainly for compatibility with skins or plugins that draw bitmaps onto the OSD.

Implemented in cPixmapMemory.

virtual void cPixmap::DrawEllipse ( const cRect Rect,
tColor  Color,
int  Quadrants = 0 
)
pure virtual

Draws a filled ellipse with the given Color that fits into the given rectangle.

Quadrants controls which parts of the ellipse are actually drawn: 0 draws the entire ellipse 1..4 draws only the first, second, third or fourth quadrant, respectively 5..8 draws the right, top, left or bottom half, respectively -1..-4 draws the inverted part of the given quadrant If Quadrants is not 0, the coordinates are those of the actual area, not the full circle!

Implemented in cPixmapMemory.

Referenced by cTrueColorDemo::Action().

virtual void cPixmap::DrawImage ( const cPoint Point,
const cImage Image 
)
pure virtual

Draws the given Image into this pixmap at the given Point.

Implemented in cPixmapMemory.

virtual void cPixmap::DrawImage ( const cPoint Point,
int  ImageHandle 
)
pure virtual

Draws the image referenced by the given ImageHandle into this pixmap at the given Point.

ImageHandle must be a value that has previously been returned by a call to cOsdProvider::StoreImage(). If ImageHandle has an invalid value, nothing happens.

Implemented in cPixmapMemory.

virtual void cPixmap::DrawPixel ( const cPoint Point,
tColor  Color 
)
pure virtual

Sets the pixel at the given Point to the given Color, which is a full 32 bit ARGB value.

If the alpha value of Color is not 0xFF (fully opaque), and this is the background pixmap (layer 0), the pixel is alpha blended with the existing color at the given position in this pixmap.

Implemented in cPixmapMemory.

Referenced by cFreetypeFont::DrawText().

void cPixmap::DrawPixmap ( const cPixmap Pixmap,
const cRect Dirty 
)
protectedvirtual

Draws the Dirty part of the given Pixmap into this pixmap.

If the Pixmap's layer is 0, it is copied, otherwise it is rendered into this pixmap. This function is used only to implement the tile handling in the final rendering to the OSD.

Definition at line 1177 of file osd.c.

References cRect::Bottom(), cPixmapMemory::Copy(), DrawPort(), cRect::Height(), cRect::Intersected(), cRect::IsEmpty(), Layer(), cRect::Left(), cRect::Point(), cPixmapMemory::Render(), cRect::Right(), cRect::SetPoint(), cPoint::SetX(), cPoint::Shift(), cRect::Shift(), cPoint::Shifted(), cRect::Size(), Tile(), cRect::Top(), ViewPort(), cRect::Width(), cPoint::X(), and cPoint::Y().

Referenced by cOsd::RenderPixmaps().

const cRect& cPixmap::DrawPort ( void  ) const
inline

Returns the pixmap's draw port, which is relative to the view port.

Since this function returns a reference to a data member, the caller must use Lock()/Unlock() to make sure the data doesn't change while it is used.

Definition at line 539 of file osd.h.

Referenced by cTrueColorDemo::Action(), cPixmapMemory::Clear(), cPixmapMemory::Copy(), cPixmapMemory::cPixmapMemory(), cPixmapMemory::DrawBitmap(), cPixmapMemory::DrawImage(), cPixmapMemory::DrawPixel(), DrawPixmap(), cPixmapMemory::DrawRectangle(), cFreetypeFont::DrawText(), cPixmapMemory::Fill(), cPixmapMemory::Render(), cOsd::RenderPixmaps(), and cPixmapMemory::Scroll().

virtual void cPixmap::DrawRectangle ( const cRect Rect,
tColor  Color 
)
pure virtual

Draws a filled rectangle with the given Color.

Implemented in cPixmapMemory.

Referenced by cTrueColorDemo::Action().

virtual void cPixmap::DrawSlope ( const cRect Rect,
tColor  Color,
int  Type 
)
pure virtual

Draws a "slope" with the given Color into the given rectangle.

Type controls the direction of the slope and which side of it will be drawn: 0: horizontal, rising, lower 1: horizontal, rising, upper 2: horizontal, falling, lower 3: horizontal, falling, upper 4: vertical, rising, lower 5: vertical, rising, upper 6: vertical, falling, lower 7: vertical, falling, upper

Implemented in cPixmapMemory.

virtual void cPixmap::DrawText ( const cPoint Point,
const char *  s,
tColor  ColorFg,
tColor  ColorBg,
const cFont Font,
int  Width = 0,
int  Height = 0,
int  Alignment = taDefault 
)
pure virtual

Draws the given string at Point with the given foreground and background color and font.

If Width and Height are given, the text will be drawn into a rectangle with the given size and the given Alignment (default is top-left). If ColorBg is clrTransparent, no background pixels will be drawn, which allows drawing "transparent" text.

Implemented in cPixmapMemory.

Referenced by cTrueColorDemo::Action(), and cTrueColorDemo::CreateTextPixmap().

virtual void cPixmap::Fill ( tColor  Color)
pure virtual

Fills the pixmap's draw port with the given Color.

A derived class must call Lock()/Unlock().

Implemented in cPixmapMemory.

int cPixmap::Layer ( void  ) const
inline
static void cPixmap::Lock ( void  )
inlinestatic

All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unless noted otherwise).

If several cPixmap member functions need to be called in a row, the caller must surround these calls with proper Lock()/Unlock() calls. See the LOCK_PIXMAPS macro for a convenient way of doing this.

Definition at line 525 of file osd.h.

References cMutex::Lock().

Referenced by cTrueColorDemo::Action(), cPixmapMemory::Clear(), cPixmapMemory::Copy(), cPixmapMemory::DrawBitmap(), cPixmapMemory::DrawEllipse(), cPixmapMemory::DrawImage(), cPixmapMemory::DrawPixel(), cPixmapMemory::DrawRectangle(), cPixmapMemory::DrawSlope(), cPixmapMemory::DrawText(), cPixmapMemory::Fill(), cPixmapMemory::Pan(), cPixmapMemory::Render(), and cPixmapMemory::Scroll().

void cPixmap::MarkDrawPortDirty ( const cRect Rect)
protected

Marks the given rectangle of the draw port of this pixmap as dirty.

Rect is combined with the existing dirtyDrawPort rectangle. The coordinates of Rect are relative to the pixmap's draw port. If Rect extends into the currently visible view port of this pixmap, MarkViewPortDirty() is called with the appropriate value.

Definition at line 997 of file osd.c.

References cRect::Intersected(), and cRect::Shifted().

Referenced by cPixmapMemory::Clear(), cPixmapMemory::Copy(), cPixmapMemory::DrawBitmap(), cPixmapMemory::DrawEllipse(), cPixmapMemory::DrawImage(), cPixmapMemory::DrawPixel(), cPixmapMemory::DrawRectangle(), cPixmapMemory::DrawSlope(), cPixmapMemory::DrawText(), cPixmapMemory::Fill(), cPixmapMemory::Render(), and cPixmapMemory::Scroll().

void cPixmap::MarkDrawPortDirty ( const cPoint Point)
protected

Marks the given point of the draw port of this pixmap as dirty.

Point is combined with the existing dirtyDrawPort rectangle. The coordinates of Point are relative to the pixmap's draw port. If Point is within the currently visible view port of this pixmap, MarkViewPortDirty() is called with the appropriate value.

Definition at line 1006 of file osd.c.

References cPoint::Shifted().

void cPixmap::MarkViewPortDirty ( const cRect Rect)
protected

Marks the given rectangle of the view port of this pixmap as dirty.

Rect is combined with the existing dirtyViewPort rectangle. The coordinates of Rect are given in absolute OSD values.

Definition at line 985 of file osd.c.

References cRect::Intersected().

Referenced by cOsd::DestroyPixmap().

void cPixmap::MarkViewPortDirty ( const cPoint Point)
protected

Marks the given point of the view port of this pixmap as dirty.

Point is combined with the existing dirtyViewPort rectangle. The coordinates of Point are given in absolute OSD values.

Definition at line 991 of file osd.c.

virtual void cPixmap::Pan ( const cPoint Dest,
const cRect Source = cRect::Null 
)
pure virtual

Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't get dirty if the scrolled rectangle covers the entire view port.

This may be of advantage if, e.g., there is a draw port that holds, say, 11 lines of text, while the view port displays only 10 lines. By Pan()'ing the draw port up one line, a new bottom line can be written into the draw port (without being seen through the view port), and later the draw port can be shifted smoothly, resulting in a smooth scrolling. It is the caller's responsibility to make sure that Source and Dest are given in such a way that the view port will not get dirty. No check is done whether this condition actually holds true.

Implemented in cPixmapMemory.

Referenced by cTrueColorDemo::Action().

virtual void cPixmap::Render ( const cPixmap Pixmap,
const cRect Source,
const cPoint Dest 
)
pure virtual

Renders the part of the given Pixmap covered by Source into this pixmap at location Dest.

The Source rectangle is relative to the given Pixmap's draw port. The Pixmap's alpha value is to be used when rendering.

Implemented in cPixmapMemory.

Referenced by cOsd::RenderPixmaps().

virtual void cPixmap::Scroll ( const cPoint Dest,
const cRect Source = cRect::Null 
)
pure virtual

Scrolls the data in the pixmap's draw port to the given Dest point.

If Source is given, only the data within that rectangle is scrolled. Source and Dest are relative to this pixmap's draw port.

Implemented in cPixmapMemory.

void cPixmap::SetAlpha ( int  Alpha)
virtual

Sets the alpha value of this pixmap to the given value.

Alpha is limited to the range 0 (fully transparent) to 255 (fully opaque). If a derived class reimplements this function, it needs to call the base class function.

Definition at line 1044 of file osd.c.

References ALPHA_OPAQUE, ALPHA_TRANSPARENT, and constrain().

Referenced by cTrueColorDemo::Action(), and cTrueColorDemo::CreateTextPixmap().

void cPixmap::SetClean ( void  )
protected

Resets the "dirty" rectangles of this pixmap.

Definition at line 1017 of file osd.c.

void cPixmap::SetDrawPortPoint ( const cPoint Point,
bool  Dirty = true 
)
virtual

Sets the pixmap's draw port to the given Point.

Only the origin point of the draw port can be modified, its size is fixed. By default, setting a new draw port point results in marking the relevant part of the view port as "dirty". If Dirty is set to false, the view port will not be marked as dirty. This is mainly used to implement the Pan() function. If a derived class reimplements this function, it needs to call the base class function.

Definition at line 1083 of file osd.c.

Referenced by cTrueColorDemo::Action(), and cPixmapMemory::Scroll().

void cPixmap::SetLayer ( int  Layer)
virtual

Sets the layer of this pixmap to the given value.

If the new layer is greater than zero, the pixmap will be visible. If it is less than zero, it will be invisible. A value of 0 will be silently ignored. If a derived class reimplements this function, it needs to call the base class function.

Definition at line 1022 of file osd.c.

References esyslog, and MAXPIXMAPLAYERS.

Referenced by cTrueColorDemo::Action().

void cPixmap::SetTile ( bool  Tile)
virtual

Sets the tile property of this pixmap to the given value.

If Tile is true, the pixmaps data will be repeated horizontally and vertically if necessary to fill the entire view port. If a derived class reimplements this function, it needs to call the base class function.

Definition at line 1055 of file osd.c.

Referenced by cTrueColorDemo::Action().

void cPixmap::SetViewPort ( const cRect Rect)
virtual

Sets the pixmap's view port to the given Rect.

If a derived class reimplements this function, it needs to call the base class function.

Definition at line 1066 of file osd.c.

Referenced by cTrueColorDemo::Action().

bool cPixmap::Tile ( void  ) const
inline

Definition at line 534 of file osd.h.

Referenced by DrawPixmap().

static void cPixmap::Unlock ( void  )
inlinestatic
const cRect& cPixmap::ViewPort ( void  ) const
inline

Returns the pixmap's view port, which is relative to the OSD's origin.

Since this function returns a reference to a data member, the caller must use Lock()/Unlock() to make sure the data doesn't change while it is used.

Definition at line 535 of file osd.h.

Referenced by cTrueColorDemo::Action(), cOsd::DestroyPixmap(), DrawPixmap(), and cOsd::RenderPixmaps().

Friends And Related Function Documentation

friend class cOsd
friend

Definition at line 455 of file osd.h.

Referenced by cOsdProvider::NewOsd().

friend class cPixmapMutexLock
friend

Definition at line 456 of file osd.h.

Member Data Documentation

int cPixmap::alpha
private

Definition at line 460 of file osd.h.

cRect cPixmap::dirtyDrawPort
private

Definition at line 465 of file osd.h.

cRect cPixmap::dirtyViewPort
private

Definition at line 464 of file osd.h.

cRect cPixmap::drawPort
private

Definition at line 463 of file osd.h.

int cPixmap::layer
private

Definition at line 459 of file osd.h.

cMutex cPixmap::mutex
staticprivate

Definition at line 458 of file osd.h.

Referenced by cRect::Combine(), cOsd::cOsd(), and cOsd::~cOsd().

bool cPixmap::tile
private

Definition at line 461 of file osd.h.

cRect cPixmap::viewPort
private

Definition at line 462 of file osd.h.


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