int BoxStack::addVideoDisplay(Boxx* box,VideoDisplay vd)
{
+ boxLock.Lock();
videoStack.push(pair<Boxx*,VideoDisplay>(box,vd));
+ boxLock.Unlock();
Video::getInstance()->setVideoDisplay(vd);
return 1;
}
return 0;
}
boxes[numBoxes++] = v;
+ boxLock.Unlock();
VideoDisplay vd;
if (v->getVideoDisplay(vd)) {
Log::getInstance()->log("BoxStack", Log::DEBUG, "Add video display");
addVideoDisplay(v,vd);
}
- boxLock.Unlock();
+
Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for add");
numBoxxes--;
Log::getInstance()->log("Boxx", Log::DEBUG, "Destruct, now %u", numBoxxes);
}
-
+#include <typeinfo>
void Boxx::draw()
{
//Log::getInstance()->log("Boxx", Log::DEBUG, "Draw this %p surface %p", this, surface);
for (j = children.begin(); j != children.end(); j++)
{
currentBoxx = *j;
- // Log::getInstance()->log("Boxx", Log::DEBUG, "Draw child %d %d", count,currentBoxx);
+ //Log::getInstance()->log("Boxx", Log::DEBUG, "Draw child %d %d %s", count,currentBoxx,typeid(*currentBoxx).name());
if (currentBoxx->getVisible()) currentBoxx->draw();
+ //Log::getInstance()->log("Boxx", Log::DEBUG, "Draw child %d %d end", count,currentBoxx);
// count++;
}
// Log::getInstance()->log("Boxx", Log::DEBUG, "Draw this %p surface %p End", this, surface);
Log::getInstance()->log("Boxx", Log::ERR, "Remove child box called, child %p not found", oldChild);
}
-bool Boxx::overlapsVisibleChilds(Region & r)
+void Boxx::removeVisibleChilds(Region & r)
{
for(vector<Boxx*>::iterator i = children.begin(); i != children.end(); i++)
- {
- if ((*i)->getVisible() && r.intersects((*i)->getRegionR()))
- {
- return true;
- }
- }
- return false;
+ {
+ if ((*i)->getVisible())
+ {
+ Region temp=(*i)->getRegionR();
+ if (r.intersects(temp)) {
+ r=r.subtract(temp);
+ }
+ }
+ }
}
void Boxx::setParent(Boxx* newParent)
{
char line[256];
int lineHeight = getFontHeight() + paraVSpace;
-
float lineWidth;
float thisCharWidth;
int textPos;
+ int textLength;
int linePos;
int ypos;
int printLine;
int drawLinePos=-skiplines;
textPos = 0;
+ textLength = strlen(text);
ypos = y;
Region tester;
- tester.h = lineHeight;
+
bool haschildren = true;
if ( children.size() == 0) haschildren = false;
+ bool mchar=false;
+ Osd *osd=Osd::getInstance();
+ if (osd->charSet()!=1) mchar=true;
+ OsdVector *osdv=dynamic_cast<OsdVector*>(osd);
+ float *charwidtharray=NULL;
+ if (osdv) charwidtharray=osdv->getCharWidthArray();
+
+ mbstate_t state;
+ memset((void*)&state,0,sizeof(state));
while(1)
{
linePos = 0;
lineWidth = 0;
+ // tester reinit
+ tester.h = lineHeight;
tester.y=ypos;
+ tester.x = x;
+ tester.w = area.w - (2 * paraMargin);
+
+ if (haschildren) removeVisibleChilds(tester);
+
while(1)
{
printLine = 0;
- UINT cur_length = 1;
- wchar_t cur_char = getWChar(text + textPos, &cur_length);
+ int cur_length = 1;
+ wchar_t cur_char;
+ if (*(text + textPos) == '\0') break;
+ if (mchar) {
+ cur_length = mbrtowc(&cur_char, text + textPos, textLength-textPos, &state);
+ if (cur_length <= 0){
+ cur_char='?';
+ cur_length=1;
+ }
+ } else cur_char= *(text + textPos);
+
if (cur_char == '\0') break;
printLine = 1;
break;
}
- thisCharWidth = charWidth(cur_char);
- tester.x = lineWidth + x;
- tester.w = thisCharWidth + 10;
+ if (charwidtharray) {
+ thisCharWidth=charwidtharray[cur_char & 0xFF];
+ if (cur_char && 0xFFFFFF00) thisCharWidth=osdv->getCharWidth(cur_char);
+ } else thisCharWidth = charWidth(cur_char);
+
+
+
- if ((lineWidth + thisCharWidth + x) > (int)(area.w - (2 * paraMargin))
- || (haschildren && overlapsVisibleChilds(tester)))
+
+ if ((lineWidth + thisCharWidth + x) > tester.w)
{
// this character would break the right margin
if (cur_char == ' ')
while ((cur_char != ' ') && (linePos >= 0))
{
textPos -= cur_length;
- cur_char = getWChar(text + textPos, &cur_length);
+ if (mchar) {
+ cur_length = mbrtowc(&cur_char, text + textPos, textLength-textPos, &state);
+ if (cur_length <= 0){
+ cur_char='?';
+ cur_length=1;
+ }
+ } else cur_char= *(text + textPos);
linePos--;
}
// Now take the space we just found
break;
}
}
- for (UINT n = 0; n < cur_length; n++) line[linePos++] = text[textPos + n];
+ for (int n = 0; n < cur_length; n++) line[linePos++] = text[textPos + n];
lineWidth += thisCharWidth;
textPos += cur_length;
}
else return 16.; //?
}
-wchar_t Boxx::getWChar(const char* str, UINT *length)
-{
- if (parent) return parent->getWChar(str, length);
- else if (surface) return surface->getWChar(str, length);
- else return '?'; //?
-}
Surface* Boxx::getSurface()
{
void endFastDraw();
float charWidth(wchar_t c);
- wchar_t getWChar(const char* str, unsigned int *length);
void add(Boxx*); // a boxx has a set of child boxxs
void remove(Boxx*);
void setParent(Boxx*);
void blt(Region& r);
- bool overlapsVisibleChilds(Region & r);
+ void removeVisibleChilds(Region & r);
static const int paraMargin = 10;
UINT paraVSpace;
ft=Color;ct=Global;
}
+ DrawStyle(const Colour &c)
+ {
+ red = c.red;
+ green = c.green;
+ blue = c.blue;
+ alpha = c.alpha;
+ ft=Color;ct=Global;
+ }
+
enum FillType {
Color,
GradientLinear,
};
+#define COMPARE_TEST(x) if (rhs.x!=lhs.x) { \
+ return rhs.x < lhs.x; \
+ }
+
+inline bool operator<(const DrawStyle& rhs, const DrawStyle& lhs)
+{
+ COMPARE_TEST(rgba())
+ COMPARE_TEST(ft)
+
+ if (rhs.ft==DrawStyle::Color) return false;
+
+ COMPARE_TEST(num_colors)
+ COMPARE_TEST(x1)
+ COMPARE_TEST(x2)
+ COMPARE_TEST(y1)
+ COMPARE_TEST(y2)
+ if (rhs.ft==DrawStyle::GradientRadial) COMPARE_TEST(r)
+
+
+ for (int i=0;i<lhs.num_colors; i++) {
+ COMPARE_TEST(grad_col[i].rgba())
+ if (i>0) COMPARE_TEST(grad_pos[i-1])
+ }
+ COMPARE_TEST(ct)
+
+ return false;
+}
+
+
+#undef COMPARE_TEST
+
+#define COMPARE_TEST(x) if (rhs.x!=lhs.x) return true;
+
+
+inline bool operator!=(const DrawStyle& rhs, const DrawStyle& lhs)
+{
+ COMPARE_TEST(rgba())
+ COMPARE_TEST(ft)
+
+ if (rhs.ft==DrawStyle::Color) return false;
+
+ COMPARE_TEST(num_colors)
+ COMPARE_TEST(x1)
+ COMPARE_TEST(x2)
+ COMPARE_TEST(y1)
+ COMPARE_TEST(y2)
+ if (rhs.ft==DrawStyle::GradientRadial) COMPARE_TEST(r)
+
+
+ for (int i=0;i<lhs.num_colors; i++) {
+ COMPARE_TEST(grad_col[i].rgba())
+ if (i>0) COMPARE_TEST(grad_pos[i-1])
+ }
+ COMPARE_TEST(ct)
+
+ return false;
+}
+
+#undef COMPARE_TEST
+
+
class SkinFactory {
public:
static int getNumberofSkins();
setAID(channelinfo.dpids[selected].pid,1,channelinfo.dpids[selected].type,false);
Audio::getInstance()->setStreamType(Audio::MPEG2_PES);
} else {
- setAID(channelinfo.dpids[selected].pid,0,channelinfo.apids[selected].type,false);
+ setAID(channelinfo.apids[selected].pid,0,channelinfo.apids[selected].type,false);
Audio::getInstance()->setStreamType(Audio::MPEG2_PES);
}
}
*/
#include "mutex.h"
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
Mutex::Mutex() {
#ifndef WIN32
pthread_mutex_init(&my_mutex, NULL);
#else
my_mutex=CreateMutex(NULL,FALSE,NULL);
#endif
+ my_cur_thread=0;
+ num_locks=0;
}
Mutex::~Mutex() {
}
void Mutex::Lock() {
+ if (num_locks> 0) {
+#ifndef WIN32
+ if (my_cur_thread==(pid_t) syscall(SYS_gettid)) {
+#else
+ if (my_cur_thread==GetCurrentThreadId()) {
+#endif
+ num_locks++;
+ return;
+ }
+ }
#ifndef WIN32
pthread_mutex_lock(&my_mutex);
+ my_cur_thread=syscall(SYS_gettid);
#else
WaitForSingleObject(my_mutex, INFINITE );
+ my_cur_thread=GetCurrentThreadId();
#endif
+ num_locks++;
+
}
void Mutex::Unlock() {
#ifndef WIN32
- pthread_mutex_unlock(&my_mutex);
+ if (my_cur_thread==syscall(SYS_gettid)) num_locks--;
+#else
+ if (my_cur_thread==GetCurrentThreadId()) num_locks--;
+#endif
+ if (num_locks==0) {
+ my_cur_thread=0;
+#ifndef WIN32
+ pthread_mutex_unlock(&my_mutex);
#else
- ReleaseMutex(my_mutex);
+ ReleaseMutex(my_mutex);
#endif
+ }
}
#ifndef WIN32
#include <pthread.h>
+#include <sys/types.h>
#else
#include <winsock2.h>
#include <windows.h>
protected:
#ifndef WIN32
pthread_mutex_t my_mutex;
+ pid_t my_cur_thread;
#else
HANDLE my_mutex;
+ DWORD my_cur_thread;
#endif
+ int num_locks;
};
#endif
}
float OsdOpenVG::getCharWidth(wchar_t c)
{
+ if (c<256) return byte_char_width[c];
unsigned int glyph_index=FT_Get_Char_Index(ft_face,c);
return font_exp_x[glyph_index];
}
}
cur_char = FT_Get_Next_Char(ft_face,cur_char,&glyph);
}
+ for (int i=0;i<256;i++) {
+ unsigned int glyph_index=FT_Get_Char_Index(ft_face,i);
+ byte_char_width[i]=font_exp_x[glyph_index];
+ }
return 1;
}
return putOpenVGCommand(comm,true);
}
-unsigned int OsdOpenVG::createColorRef(const Colour &c)
-{
- unsigned int col=c.rgba();
- struct OpenVGCommand comm;
- comm.task=OVGcreateColorRef;
- comm.param1=col<<8 | (col &0xff000000)>>24;
- comm.data=&c;
- return putOpenVGCommand(comm,true);
-}
+
void createPicture(struct PictureInfo& pict_inf);
void destroyStyleRef(unsigned int index);
unsigned int createStyleRef(const DrawStyle &c);
- unsigned int createColorRef(const Colour &c);
bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
void drawSetTrans(SurfaceCommands & sc);
reader.addDecoder(new MagickDecoder(&reader));
#endif
+ for (int i=0;i<256;i++) {
+ byte_char_width[i]=0.f;
+ }
+ styles_lastit_valid=styles_ref_lastit_valid=false;
+
}
OsdVector::~OsdVector()
list<SurfaceCommands>::iterator curdraw=scommands.begin();
while (curdraw!=scommands.end()) {
(*curdraw).commands.clear();
+ (*curdraw).commands.reserve(2048);
curdraw++;
}
//also clear all handles, they are now invalid, no need to release them
//jpegs.clear();
styles.clear();
styles_ref.clear();
+ styles_lastit_valid=styles_ref_lastit_valid=false;
palettepics.clear();
tvmedias.clear();
list<SurfaceCommands*>::iterator curdraw=todraw.begin();
while (curdraw!=todraw.end()) {
drawSetTrans(*(*curdraw));
- list<SVGCommand>::iterator commands=(*(*curdraw)).commands.begin();
- list<SVGCommand>::iterator end=(*(*curdraw)).commands.end();
+ std::vector<SVGCommand>::iterator commands=(*(*curdraw)).commands.begin();
+ std::vector<SVGCommand>::iterator end=(*(*curdraw)).commands.end();
while (commands!=end) {
// update any images loaded in the mean time
if ((*commands).instr==DrawImageLoading) {
}
void OsdVector::updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,
- list<SVGCommand>& commands)
+ std::vector<SVGCommand>& commands)
{
surfaces_mutex.Lock();
//First determine it is already in our system
itty=scommands.insert(itty,new_sc);
}
// update any images loaded in the mean time
- list<SVGCommand>::iterator ilitty=commands.begin();
+ std::vector<SVGCommand>::iterator ilitty=commands.begin();
while (ilitty!=commands.end())
{
}
-void OsdVector::dereferenceSVGCommand(list<SVGCommand>& commands )
+void OsdVector::dereferenceSVGCommand(std::vector<SVGCommand>& commands )
{
- list<SVGCommand>::iterator sitty = commands.begin();
+ std::vector<SVGCommand>::iterator sitty = commands.begin();
while (sitty != commands.end()) {
removeStyleRef((*sitty).getRef());
ImageIndex ii = (*sitty).getImageIndex();
}
}
-void OsdVector::referenceSVGCommand(list<SVGCommand>& commands )
+void OsdVector::referenceSVGCommand(std::vector<SVGCommand>& commands )
{
- list<SVGCommand>::iterator sitty=commands.begin();
+ std::vector<SVGCommand>::iterator sitty=commands.begin();
while (sitty!=commands.end())
{
incStyleRef((*sitty).getRef());
}
- map<pair<Colour*,unsigned int>,unsigned int>::iterator sitty=styles.begin();
+ map<DrawStyle,unsigned int>::iterator sitty=styles.begin();
while (sitty!=styles.end()) {
map<unsigned int,int>::iterator curitty=styles_ref.find((*sitty).second);
int count=(*curitty).second;
unsigned int ref=(*curitty).first;
styles.erase(sitty++);
styles_ref.erase(curitty++);
+ styles_lastit_valid=styles_ref_lastit_valid=false;
destroyStyleRef(ref);
} else ++sitty;
void OsdVector::incStyleRef(unsigned int index)
{
- if (styles_ref.find(index)==styles_ref.end()) {
- styles_ref[index]=1;
+ if (!styles_ref_lastit_valid || (*styles_ref_lastit).first!=index) {
+ styles_ref_lastit_valid=false;
+ styles_ref_lastit=styles_ref.find(index);
+ }
+ if (styles_ref_lastit==styles_ref.end()) {
+ styles_ref_lastit=styles_ref.insert(std::pair<unsigned int,int>(index,1)).first;
} else {
- styles_ref[index]++;
+ (*styles_ref_lastit).second++;
}
+ styles_ref_lastit_valid=true;
}
void OsdVector::removeStyleRef(unsigned int index)
{
- styles_ref[index]--;
+ if (!styles_ref_lastit_valid || (*styles_ref_lastit).first!=index) {
+ styles_ref_lastit_valid=false;
+ styles_ref_lastit=styles_ref.find(index);
+ }
+ if (styles_ref_lastit!=styles_ref.end()) {
+ styles_ref_lastit_valid=true;
+ (*styles_ref_lastit).second--;
+ }
}
unsigned int OsdVector::getStyleRef(const DrawStyle &c)
{
surfaces_mutex.Lock();
unsigned int style_handle=0;
- if (styles.find(pair<Colour*,unsigned int>((Colour*)&c,c.rgba()))==styles.end())
+ if (!styles_lastit_valid || (*styles_lastit).first!=c) {
+ styles_lastit_valid=false;
+ styles_lastit=styles.find(c);
+ }
+
+ if (styles_lastit==styles.end())
{
surfaces_mutex.Unlock();
style_handle=createStyleRef(c);
surfaces_mutex.Lock();
- styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())]=style_handle;
+ styles_lastit=styles.insert(std::pair<DrawStyle,unsigned int>(c,style_handle)).first;
} else {
- style_handle=styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())];
+
+ style_handle=(*styles_lastit).second;
//Now check if the handle is valid
- if (styles_ref.find(style_handle)==styles_ref.end()) {
- //invalid handle recreate
- surfaces_mutex.Unlock();
- style_handle=createStyleRef(c);
- surfaces_mutex.Lock();
- styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())]=style_handle;
+ if (!styles_ref_lastit_valid || (*styles_ref_lastit).first!=style_handle) {
+ styles_ref_lastit_valid=false;
+ styles_ref_lastit=styles_ref.find(style_handle);
}
- }
- incStyleRef(style_handle);
- surfaces_mutex.Unlock();
- return style_handle;
-}
-unsigned int OsdVector::getColorRef(const Colour &c)
-{
- surfaces_mutex.Lock();
- unsigned int style_handle=0;
- if (styles.find(pair<Colour*,unsigned int>((Colour*)&c,c.rgba()))==styles.end())
- {
- surfaces_mutex.Unlock();
- style_handle=createColorRef(c);
- surfaces_mutex.Lock();
- styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())]=style_handle;
- } else {
- style_handle=styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())];
- if (styles_ref.find(style_handle)==styles_ref.end()) {
+ if (styles_ref_lastit==styles_ref.end()) {
//invalid handle recreate
surfaces_mutex.Unlock();
- style_handle=createColorRef(c);
+ style_handle=createStyleRef(c);
surfaces_mutex.Lock();
- styles[pair<Colour*,unsigned int>((Colour*)&c,c.rgba())]=style_handle;
- }
+ (*styles_lastit).second=style_handle;
+ } else styles_ref_lastit_valid=true;
}
+ styles_lastit_valid=true;
incStyleRef(style_handle);
surfaces_mutex.Unlock();
return style_handle;
}
+
+
int OsdVector::getStyleRef(unsigned int index)
{
- if (styles_ref.find(index)==styles_ref.end()) {
+ if (!styles_ref_lastit_valid || (*styles_ref_lastit).first!=index) {
+ styles_ref_lastit_valid=false;
+ styles_ref_lastit=styles_ref.find(index);
+ }
+ if (styles_ref_lastit==styles_ref.end()) {
return -1;
} else {
- return styles_ref[index];
+ styles_ref_lastit_valid=true;
+ return (*styles_ref_lastit).second;
}
}
#include "colour.h"
#include <set>
#include <list>
+#include <vector>
#include <map>
#include <queue>
#include <string>
x=y=w=h=reference=0;
};
- static SVGCommand PaintPath(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)
+ inline static SVGCommand PaintPath(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)
{
SVGCommand nc;
nc.instr=DrawPath;
return nc;
};
- static SVGCommand PaintImageLoading(LoadIndex load_in,float ix, float iy,float iw,float ih,unsigned int ref, Corner corner=TopLeft)
+ inline static SVGCommand PaintImageLoading(LoadIndex load_in,float ix, float iy,float iw,float ih,unsigned int ref, Corner corner=TopLeft)
{
SVGCommand nc;
nc.instr=DrawImageLoading;
return nc;
};
- static SVGCommand PaintImage(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref, Corner corner=TopLeft)
+ inline static SVGCommand PaintImage(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref, Corner corner=TopLeft)
{
SVGCommand nc;
nc.instr=DrawImage;
- static SVGCommand PaintTTchar(float ix, float iy,float iw,float ih,unsigned int ttchar_in)
+ inline static SVGCommand PaintTTchar(float ix, float iy,float iw,float ih,unsigned int ttchar_in)
{
SVGCommand nc;
nc.instr=DrawTTchar;
nc.corner=TopLeft;
return nc;
};
- static SVGCommand PaintClipping(float ix, float iy,float iw,float ih)
+ inline static SVGCommand PaintClipping(float ix, float iy,float iw,float ih)
{
SVGCommand nc;
nc.instr=DrawClipping;
};
- static SVGCommand PaintGlyph(float ix, float iy,wchar_t char_in,unsigned int ref)
+ inline static void PaintGlyph(SVGCommand& nc, float ix, float iy,wchar_t char_in,unsigned int ref)
{
- SVGCommand nc;
nc.instr=DrawGlyph;
nc.x=ix;
nc.y=iy;
nc.h=0;
nc.reference=ref;
nc.target.textchar=char_in;
- return nc;
};
bool Test(float tx,float ty,float tw, float th)
};
SVGCommandInstr instr;
+ Corner corner;
float x,y,w,h;
unsigned int reference;
union {
unsigned int ttchar;
LoadIndex loadindex;
} target;
- Corner corner;
+
};
struct SurfaceCommands{
const SurfaceVector* surf;
- list<SVGCommand> commands;
+ vector<SVGCommand> commands;
float x,y,w,h;
};
void Blank();
void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,
- list<SVGCommand>& commands);
+ std::vector<SVGCommand>& commands);
void removeSurface(const SurfaceVector *surf);
virtual float getFontHeight()=0;
virtual float getCharWidth(wchar_t c)=0;
+ float *getCharWidthArray() {return byte_char_width;};
//virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia,ImageIndex& image);
void removeImageRef(const ImageIndex ref);
void removeLoadIndexRef(const LoadIndex ref);
- unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef
unsigned int getStyleRef(const DrawStyle &c);
virtual void removeStyleRef(unsigned int ref);
virtual void getScreenSize(int &width, int &height)=0;
void incStyleRef(unsigned int index);
- int getStyleRef(ImageIndex index);
+ int getStyleRef(unsigned int index);
virtual void destroyStyleRef(unsigned int index)=0;
- map<pair<Colour*,unsigned int>,unsigned int> styles;
+
+
+ map<DrawStyle,unsigned int> styles;
map<unsigned int,int> styles_ref;
+ map<DrawStyle,unsigned int>::iterator styles_lastit;
+ bool styles_lastit_valid;
+ map<unsigned int,int>::iterator styles_ref_lastit;
+ bool styles_ref_lastit_valid;
+
virtual unsigned int createStyleRef(const DrawStyle &c)=0;
- virtual unsigned int createColorRef(const Colour &c)=0;
- void dereferenceSVGCommand(list<SVGCommand>& commands );
- void referenceSVGCommand(list<SVGCommand>& commands );
+ void dereferenceSVGCommand(std::vector<SVGCommand>& commands );
+ void referenceSVGCommand(std::vector<SVGCommand>& commands );
void cleanupOrphanedRefs();
- list<SurfaceCommands> scommands;
+ std::list<SurfaceCommands> scommands;
Mutex surfaces_mutex;
+ float byte_char_width[256];
+
void drawSurfaces();
};
}
-/*
+
Region Region::subtract(Region& other)
{
- OK printf("This: %i %i %i %i\n", x, y, w, h);
- OK printf("Subtract this: %i %i %i %i\n", other.x, other.y, other.w, other.h);
+ //OK printf("This: %i %i %i %i\n", x, y, w, h);
+ //OK printf("Subtract this: %i %i %i %i\n", other.x, other.y, other.w, other.h);
Region s;
if (x < other.x)
{
-OK printf("Case 1\n");
+//OK printf("Case 1\n");
s.x = x;
s.y = y;
s.w = other.x - x;
}
else if (x2() > other.x2())
{
-OK printf("Case 2\n");
+//OK printf("Case 2\n");
s.x = other.x2()+1;
s.y = y;
s.w = w - s.x;
}
else if (y < other.y)
{
-OK printf("Case 3\n");
+//OK printf("Case 3\n");
s.x = x;
s.y = y;
s.w = w;
}
else if (y2() > other.y2())
{
-OK printf("Case 4\n");
+//OK printf("Case 4\n");
s.x = x;
s.y = other.y2()+1;
s.w = w;
s.w = 0;
s.h = 0;
}
- OK printf("Result: %i %i %i %i\n", s.x, s.y, s.w, s.h);
+ //OK printf("Result: %i %i %i %i\n", s.x, s.y, s.w, s.h);
return s;
}
-*/
+
//i.x = (x >= other.x ? x : other.x);
//i.y = (y >= other.y ? y : other.y);
public:
Region();
bool overlappedBy(Region& doesthisOverlap);
-// Region subtract(Region& other);
+ Region subtract(Region& other);
Region operator + (Region& other);
inline bool intersects(Region test) {
return !((test.x+test.w) < x || (x + w) < test.x
}
#endif
- wchar_t Surface::getWChar(const char* str, unsigned int *length)
- {
- *length=1;
- return *str;
- }
-
//Moved from Teletext view in order to allow device depend optimizations
Colour Surface::enumTeletextColorToCoulour(enumTeletextColor ttcol)
virtual ~Surface();
static Surface* getScreen();
- virtual wchar_t getWChar(const char* str, unsigned int *length);
#ifdef GRADIENT_DRAWING
virtual int getFontHeight()=0;
{
osd=vosd;
+ commands.reserve(2048);
}
SurfaceVector::~SurfaceVector()
{
osd->removeSurface(this);
- list<SVGCommand>::iterator itty=commands.begin();
+ vector<SVGCommand>::iterator itty=commands.begin();
while (itty!=commands.end())
{
osd->removeStyleRef((*itty).getRef()); // We remove the Style reference, so that osd can free stuff
return osd->getCharWidth(c);
}
-wchar_t SurfaceVector::getWChar(const char* str, unsigned int *length)
-{
- int mlength=0;
- int max_length=4;
- wchar_t tempo[1];
- size_t num_bytes=1;
- if (str[0]=='\0') {
- *length=1;
- return '\0';
- } else if (str[1]=='\0'){
- max_length=2;
- } else if (str[2]=='\0'){
- max_length=3;
- }
- mbstate_t state;
- memset((void*)&state,0,sizeof(state));
- num_bytes=mbrtowc(tempo, str, max_length, &state);
- if (num_bytes!=((size_t) -1) && num_bytes!=((size_t) -2))
- {
- *length=num_bytes;
- return *tempo;
- }
- *length=1;
- return '?';
-}
-
int SurfaceVector::drawText(const char* text, int x, int y, const DrawStyle& c){
return drawText(text, x, y, 0, c);
float shift=0.;
const char *run=text;
mbstate_t state;
- wchar_t tempo[1];
+ wchar_t tempo;
size_t num_bytes=1;
size_t length=strlen(text);
memset((void*)&state,0,sizeof(state));
+
command_mutex.Lock();
- num_bytes=mbrtowc(tempo, run, length, &state);
+ num_bytes=mbrtowc(&tempo, run, length, &state);
+ unsigned int ref=osd->getStyleRef(c);
+ float *charwidtharray=osd->getCharWidthArray();
+
+ int commands_size=commands.size();
+ int chars=0;
+ commands.resize(commands_size+strlen(text));
+
while (num_bytes!=((size_t) -1) && num_bytes!=((size_t) -2) && length>0)
{
- unsigned int ref=osd->getStyleRef(c);
- commands.push_back(SVGCommand::PaintGlyph(x+shift,y,*tempo,ref));
- shift+=osd->getCharWidth(*tempo);
+ SVGCommand::PaintGlyph(commands[commands_size+chars],x+shift,y,tempo,ref);
+ chars++;
+
+ float cur_shift=charwidtharray[tempo & 0xFF];
+ if (tempo && 0xFFFFFF00) cur_shift=osd->getCharWidth(tempo);
+ shift+=cur_shift;
length -= num_bytes;
run += num_bytes;
if (shift>width && width >0) {
command_mutex.Unlock();
return 1;
}
- num_bytes=mbrtowc(tempo, run, length, &state);
+ num_bytes=mbrtowc(&tempo, run, length, &state);
}
+ commands.resize(commands_size+chars);
command_mutex.Unlock();
return 1;
int SurfaceVector::removeCommands(float x,float y,float width,float height)
{
// we iterate through all old commands in order to remove commands hidden by this rectangle
- list<SVGCommand>::iterator itty=commands.begin();
+ vector<SVGCommand>::iterator itty=commands.begin();
+ vector<SVGCommand>::iterator remstart;
+ bool remove=false;
while (itty!=commands.end())
{
if ((*itty).Test(x,y,width,height) && (*itty).instr != DrawClipping) {
if (ii) osd->removeImageRef(ii);
LoadIndex li=(*itty).getLoadIndex();
if (li) osd->removeLoadIndexRef(li);
- itty=commands.erase(itty);
+ if (!remove) {
+ remstart=itty;
+ remove=true;
+ }
} else {
- itty++;
+ if (remove) {
+ itty=commands.erase(remstart,itty);
+ remove=false;
+ }
}
+ itty++;
+ }
+ if (remove) {
+ itty=commands.erase(remstart,itty);
}
return 1;
void SurfaceVector::drawTTChar(int ox, int oy,int x, int y, cTeletextChar c)
{
command_mutex.Lock();
- list<SVGCommand>::iterator itty=commands.begin();
+ vector<SVGCommand>::iterator itty=commands.begin();
while (itty!=commands.end())
{
if ((*itty).TTTest(ox,oy,x,y) ) {
#include "surface.h"
#include "osdvector.h"
-#include <list>
+#include <vector>
class SurfaceVector : public Surface
int getFontHeight();
float getCharWidth(wchar_t c);
- wchar_t getWChar(const char* str, unsigned int *length);
int drawText(const char* text, int x, int y, const DrawStyle& c);
int drawText(const char* text, int x, int y, int width, const DrawStyle& c);
int removeCommands(float x,float y,float width,float height);
- list<SVGCommand> commands;
+ std::vector<SVGCommand> commands;
int swidth, sheight;
Mutex command_mutex;
OsdVector* osd;
void TBBoxx::draw()
{
//Log::getInstance()->log("TBBoxx", Log::DEBUG, "Draw: %d",this);
-
+
fillColour(DrawStyle::VIEWBACKGROUND);
if (borderOn)
primary_id=channel;
}
-bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
-{
- if (rhs.type==lhs.type) {
- if (rhs.primary_id==lhs.primary_id) {
- if (rhs.static_fallback==lhs.static_fallback) {
- if (rhs.secondary_id==lhs.secondary_id) {
- if (rhs.type_pict==lhs.type_pict) {
- if (rhs.container==lhs.container) {
- if (rhs.primary_name== lhs.primary_name) {
- return rhs.container_member < lhs.container_member;
- } else {
- return rhs.primary_name < lhs.primary_name;
- }
- } else {
- return rhs.container<lhs.container;
- }
-
-
- } else {
- return rhs.type_pict<lhs.type_pict;
- }
-
- } else {
- return rhs.secondary_id<lhs.secondary_id;
- }
- } else {
- return rhs.static_fallback<lhs.static_fallback;
- }
-
- } else {
- return rhs.primary_id<lhs.primary_id;
- }
-
-
- } else {
- return rhs.type < lhs.type;
- }
-}
-bool operator==(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
-{
- return (rhs.type==lhs.type) && (rhs.primary_id==lhs.primary_id) && (rhs.static_fallback==lhs.static_fallback) &&
- (rhs.secondary_id==lhs.secondary_id) && (rhs.type_pict==lhs.type_pict) &&
- (rhs.container==lhs.container) && (rhs.primary_name== lhs.primary_name)
- && (rhs.container_member == lhs.container_member);
-}
typedef std::vector<Actor> Actors;
+
+inline bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
+{
+ if (rhs.type==lhs.type) {
+ if (rhs.primary_id==lhs.primary_id) {
+ if (rhs.static_fallback==lhs.static_fallback) {
+ if (rhs.secondary_id==lhs.secondary_id) {
+ if (rhs.type_pict==lhs.type_pict) {
+ if (rhs.container==lhs.container) {
+ if (rhs.primary_name== lhs.primary_name) {
+ return rhs.container_member < lhs.container_member;
+ } else {
+ return rhs.primary_name < lhs.primary_name;
+ }
+ } else {
+ return rhs.container<lhs.container;
+ }
+
+
+ } else {
+ return rhs.type_pict<lhs.type_pict;
+ }
+
+ } else {
+ return rhs.secondary_id<lhs.secondary_id;
+ }
+ } else {
+ return rhs.static_fallback<lhs.static_fallback;
+ }
+
+ } else {
+ return rhs.primary_id<lhs.primary_id;
+ }
+
+
+ } else {
+ return rhs.type < lhs.type;
+ }
+}
+
+inline bool operator==(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
+{
+ return (rhs.type==lhs.type) && (rhs.primary_id==lhs.primary_id) && (rhs.static_fallback==lhs.static_fallback) &&
+ (rhs.secondary_id==lhs.secondary_id) && (rhs.type_pict==lhs.type_pict) &&
+ (rhs.container==lhs.container) && (rhs.primary_name== lhs.primary_name)
+ && (rhs.container_member == lhs.container_member);
+}
+
#endif
float textWidth = 0;
unsigned int cur_length=1;
unsigned int text_max=strlen(tt);
+ bool mchar=false;
+ if (Osd::getInstance()->charSet()!=1) mchar=true;
+ mbstate_t state;
+ memset((void*)&state,0,sizeof(state));
+
UINT textPos;
for (textPos = 0; textPos <text_max; textPos+=cur_length)
{
- wchar_t cur_char=getWChar(tt+textPos,&cur_length);
+ wchar_t cur_char;
+ if (mchar) {
+ cur_length = mbrtowc(&cur_char, tt + textPos, text_max-textPos, &state);
+ if (cur_length <= 0){
+ break;
+ }
+ } else cur_char= *(tt+textPos);
float thisCharWidth = charWidth(cur_char);
if (textWidth + thisCharWidth > w) // text will not fit in cell
{