There is no more fixed limit to the maximum number of cPixmap objects an OSD can create

This commit is contained in:
Klaus Schmidinger 2013-02-08 10:29:32 +01:00
parent 7f66e1573e
commit 245ae52d36
3 changed files with 31 additions and 34 deletions

View File

@ -7578,3 +7578,7 @@ Video Disk Recorder Revision History
available and has the same effect as --dirnames=250,40,1. available and has the same effect as --dirnames=250,40,1.
- The macro MaxFileName is now obsolete and may be removed in future versions. Use - The macro MaxFileName is now obsolete and may be removed in future versions. Use
NAME_MAX directly instead. NAME_MAX directly instead.
- There is no more fixed limit to the maximum number of cPixmap objects an OSD can
create. However, a particular device may still be unable to create an arbitrary
number of pixmaps, due to limited resources. So it's always a good idea to use
as few pixmaps as possible.

44
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 2.34 2013/01/24 11:37:58 kls Exp $ * $Id: osd.c 2.35 2013/02/08 10:16:47 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -1631,7 +1631,6 @@ cOsd::cOsd(int Left, int Top, uint Level)
savedBitmap = NULL; savedBitmap = NULL;
numBitmaps = 0; numBitmaps = 0;
savedPixmap = NULL; savedPixmap = NULL;
numPixmaps = 0;
left = Left; left = Left;
top = Top; top = Top;
width = height = 0; width = height = 0;
@ -1653,7 +1652,7 @@ cOsd::~cOsd()
delete bitmaps[i]; delete bitmaps[i];
delete savedBitmap; delete savedBitmap;
delete savedPixmap; delete savedPixmap;
for (int i = 0; i < numPixmaps; i++) for (int i = 0; i < pixmaps.Size(); i++)
delete pixmaps[i]; delete pixmaps[i];
for (int i = 0; i < Osds.Size(); i++) { for (int i = 0; i < Osds.Size(); i++) {
if (Osds[i] == this) { if (Osds[i] == this) {
@ -1702,15 +1701,11 @@ void cOsd::DestroyPixmap(cPixmap *Pixmap)
{ {
if (isTrueColor) { if (isTrueColor) {
LOCK_PIXMAPS; LOCK_PIXMAPS;
for (int i = 1; i < numPixmaps; i++) { // begin at 1 - don't let the background pixmap be destroyed! for (int i = 1; i < pixmaps.Size(); i++) { // begin at 1 - don't let the background pixmap be destroyed!
if (pixmaps[i] == Pixmap) { if (pixmaps[i] == Pixmap) {
pixmaps[0]->MarkViewPortDirty(Pixmap->ViewPort()); pixmaps[0]->MarkViewPortDirty(Pixmap->ViewPort());
delete Pixmap; delete Pixmap;
while (i < numPixmaps - 1) { pixmaps[i] = NULL;
pixmaps[i] = pixmaps[i + 1];
i++;
}
numPixmaps--;
return; return;
} }
} }
@ -1722,12 +1717,13 @@ cPixmap *cOsd::AddPixmap(cPixmap *Pixmap)
{ {
if (Pixmap) { if (Pixmap) {
LOCK_PIXMAPS; LOCK_PIXMAPS;
if (numPixmaps < MAXOSDPIXMAPS) for (int i = 0; i < pixmaps.Size(); i++) {
return pixmaps[numPixmaps++] = Pixmap; if (!pixmaps[i])
else return pixmaps[i] = Pixmap;
esyslog("ERROR: too many OSD pixmaps requested (maximum is %d)", MAXOSDPIXMAPS); }
pixmaps.Append(Pixmap);
} }
return NULL; return Pixmap;
} }
cPixmapMemory *cOsd::RenderPixmaps(void) cPixmapMemory *cOsd::RenderPixmaps(void)
@ -1737,12 +1733,13 @@ cPixmapMemory *cOsd::RenderPixmaps(void)
LOCK_PIXMAPS; LOCK_PIXMAPS;
// Collect overlapping dirty rectangles: // Collect overlapping dirty rectangles:
cRect d; cRect d;
for (int i = 0; i < numPixmaps; i++) { for (int i = 0; i < pixmaps.Size(); i++) {
cPixmap *pm = pixmaps[i]; if (cPixmap *pm = pixmaps[i]) {
if (!pm->DirtyViewPort().IsEmpty()) { if (!pm->DirtyViewPort().IsEmpty()) {
if (d.IsEmpty() || d.Intersects(pm->DirtyViewPort())) { if (d.IsEmpty() || d.Intersects(pm->DirtyViewPort())) {
d.Combine(pm->DirtyViewPort()); d.Combine(pm->DirtyViewPort());
pm->SetClean(); pm->SetClean();
}
} }
} }
} }
@ -1758,10 +1755,11 @@ cPixmapMemory *cOsd::RenderPixmaps(void)
Pixmap->Clear(); Pixmap->Clear();
// Render the individual pixmaps into the resulting pixmap: // Render the individual pixmaps into the resulting pixmap:
for (int Layer = 0; Layer < MAXPIXMAPLAYERS; Layer++) { for (int Layer = 0; Layer < MAXPIXMAPLAYERS; Layer++) {
for (int i = 0; i < numPixmaps; i++) { for (int i = 0; i < pixmaps.Size(); i++) {
cPixmap *pm = pixmaps[i]; if (cPixmap *pm = pixmaps[i]) {
if (pm->Layer() == Layer) if (pm->Layer() == Layer)
Pixmap->DrawPixmap(pm, d); Pixmap->DrawPixmap(pm, d);
}
} }
} }
#ifdef DebugDirty #ifdef DebugDirty

17
osd.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.h 2.18 2012/12/03 13:49:02 kls Exp $ * $Id: osd.h 2.19 2013/02/08 09:47:56 kls Exp $
*/ */
#ifndef __OSD_H #ifndef __OSD_H
@ -701,7 +701,6 @@ public:
}; };
#define MAXOSDAREAS 16 #define MAXOSDAREAS 16
#define MAXOSDPIXMAPS 64
/// The cOsd class is the interface to the "On Screen Display". /// The cOsd class is the interface to the "On Screen Display".
/// An actual output device needs to derive from this class and implement /// An actual output device needs to derive from this class and implement
@ -725,8 +724,7 @@ private:
cBitmap *bitmaps[MAXOSDAREAS]; cBitmap *bitmaps[MAXOSDAREAS];
int numBitmaps; int numBitmaps;
cPixmapMemory *savedPixmap; cPixmapMemory *savedPixmap;
cPixmap *pixmaps[MAXOSDPIXMAPS]; cVector<cPixmap *> pixmaps;
int numPixmaps;
int left, top, width, height; int left, top, width, height;
uint level; uint level;
bool active; bool active;
@ -755,14 +753,10 @@ protected:
virtual void SetActive(bool On) { active = On; } virtual void SetActive(bool On) { active = On; }
///< Sets this OSD to be the active one. ///< Sets this OSD to be the active one.
///< A derived class must call cOsd::SetActive(On). ///< A derived class must call cOsd::SetActive(On).
const cPixmap * const *Pixmaps(void) { return pixmaps; }
///< Returns the list of currently active pixmaps in this OSD.
int NumPixmaps(void) { return numPixmaps; }
///< Returns the number of currently active pixmaps in this OSD.
cPixmap *AddPixmap(cPixmap *Pixmap); cPixmap *AddPixmap(cPixmap *Pixmap);
///< Adds the given Pixmap to the list of currently active pixmaps in this OSD. ///< Adds the given Pixmap to the list of currently active pixmaps in this OSD.
///< Returns Pixmap if the operation was successful, or NULL if the maximum ///< Returns Pixmap if the operation was successful, or NULL if for some reason
///< number of pixmaps has been exceeded. ///< the pixmap could not be added to the list.
///< A derived class that implements its own cPixmap class must call AddPixmap() ///< A derived class that implements its own cPixmap class must call AddPixmap()
///< in order to add a newly created pixmap to the OSD's list of pixmaps. ///< in order to add a newly created pixmap to the OSD's list of pixmaps.
cPixmapMemory *RenderPixmaps(void); cPixmapMemory *RenderPixmaps(void);
@ -824,7 +818,8 @@ public:
///< The caller must not delete the returned object, it will be deleted when ///< The caller must not delete the returned object, it will be deleted when
///< the OSD is deleted. DestroyPixmap() can be called if a pixmap shall be ///< the OSD is deleted. DestroyPixmap() can be called if a pixmap shall be
///< destroyed before the OSD is deleted. ///< destroyed before the OSD is deleted.
///< If this is not a true color OSD, this function returns NULL. ///< If this is not a true color OSD, or if the pixmap could not be created
///< due to limited resources, this function returns NULL.
virtual void DestroyPixmap(cPixmap *Pixmap); virtual void DestroyPixmap(cPixmap *Pixmap);
///< Destroys the given Pixmap, which has previously been created by a call to ///< Destroys the given Pixmap, which has previously been created by a call to
///< CreatePixmap(). When the OSD is deleted, all pixmaps are destroyed ///< CreatePixmap(). When the OSD is deleted, all pixmaps are destroyed