From 2a3825d73df1896665eead66a6cccd95bbc7da88 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 15 Sep 2012 12:39:18 +0200 Subject: [PATCH] Remove pixel based apis, preparation for vector based osd --- GNUmakefile | 2 +- boxx.cc | 10 +++++++++- boxx.h | 8 ++++++-- defines.h | 1 + objects.mk | 2 +- surface.cc | 24 ++++++++++++++++++++++++ surface.h | 8 ++++++-- surfacedirectfb.h | 6 ++++-- surfacemvp.h | 6 ++++-- surfaceopengl.h | 6 ++++-- surfacewin.h | 5 +++-- vopts.cc | 4 +++- vscreensaver.cc | 6 +++--- vvideolivetv.cc | 8 ++++++-- vvideolivetv.h | 8 ++++++-- vvideorec.cc | 7 ++++++- vvideorec.h | 10 +++++++--- wsymbol.cc | 5 +++-- wwss.cc | 6 +++--- wwss.h | 2 +- 20 files changed, 101 insertions(+), 33 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index f15195c..81931d1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -45,7 +45,7 @@ $(info MVP flags) LDFLAGS = -Wall -static LIBS = -lpthread -lrt -OBJECTS += main.o threadp.o remotemvp.o ledmvp.o mtdmvp.o videomvp.o audiomvp.o osdmvp.o surfacemvp.o vmedialist.o vcolourtuner.o vmediaview.o vvideomedia.o mediafile.o +OBJECTS += wwss.o main.o threadp.o remotemvp.o ledmvp.o mtdmvp.o videomvp.o audiomvp.o osdmvp.o surfacemvp.o vmedialist.o vcolourtuner.o vmediaview.o vvideomedia.o mediafile.o TIOBJECT = ticonfig.o CROSSLIBS = ../jpeg/jpeg-6b/libjpeg.a INCLUDES = -I../jpeg/jpeg-6b -DVOMP_PLATTFORM_MVP diff --git a/boxx.cc b/boxx.cc index e10d2ad..e8ca58a 100644 --- a/boxx.cc +++ b/boxx.cc @@ -351,7 +351,8 @@ void Boxx::drawTextCentre(const char* text, int x, int y, const Colour& colour) if (parent) parent->drawTextCentre(text, area.x + x, area.y + y, colour); else surface->drawTextCentre(text, x, y, colour.rgba()); } - +// Now deprecated +/* void Boxx::drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw) { if (parent) parent->drawPixelAlpha(area.x + x, area.y + y, colour,fastdraw); @@ -379,6 +380,7 @@ void Boxx::drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw) surface->drawPixel(x, y, c,fastdraw); } } +*/ void Boxx::drawTTChar(int ox, int oy,int x, int y, cTeletextChar c) { @@ -399,6 +401,12 @@ void Boxx::drawJpeg(const char *fileName,int x, int y,int *width, int *height) else if (surface) surface->drawJpeg(fileName,x,y,width,height); } +void Boxx::drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, Colour& nextColour) +{ + if (parent) parent->drawMonoBitmap(base, area.x +dx,area.y +dy, height,width, nextColour); + else if (surface) surface->drawMonoBitmap(base, dx,dy, height,width, nextColour); +} + int Boxx::getFontHeight() { if (parent) return parent->getFontHeight(); diff --git a/boxx.h b/boxx.h index 5a4da51..02f8f5f 100644 --- a/boxx.h +++ b/boxx.h @@ -37,6 +37,7 @@ class Bitmap; class Boxx { + friend class Wwss; public: Boxx(); virtual ~Boxx(); @@ -100,14 +101,17 @@ class Boxx void drawText(const char* text, int x, int y, int width, const Colour& colour); void drawTextRJ(const char* text, int x, int y, const Colour& colour); void drawTextCentre(const char* text, int x, int y, const Colour& colour); - void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false); + //Now deprecated + //void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false); void drawBitmap(UINT x, UINT y, const Bitmap& bm); - void drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw=false); + //Now deprecated + // void drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw=false); int getFontHeight(); void drawJpeg(const char *fileName,int x, int y,int *width, int *height); void drawTTChar(int ox, int oy,int x, int y, cTeletextChar c); + void drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, Colour& nextColour); /* This is for system which need a locking of the drawing surface to speed up drawing */ void startFastDraw(); diff --git a/defines.h b/defines.h index 2c8174a..7a801fd 100644 --- a/defines.h +++ b/defines.h @@ -123,6 +123,7 @@ long long getTimeMS(); #define Audio_TYPE AudioMVP #define Video_TYPE VideoMVP #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ + #define PAL_WSS #endif #ifdef VOMP_PLATTFORM_NMT // This was the attempt to port vomp to nmt, it failed but maybe the code is useful at some time diff --git a/objects.mk b/objects.mk index 0ce596e..b1436c4 100644 --- a/objects.mk +++ b/objects.mk @@ -10,7 +10,7 @@ OBJECTS1 = command.o tcp.o dsock.o thread.o timers.o i18n.o \ vchannellist.o vwelcome.o vvideorec.o vepgsettimer.o \ vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o \ vradiorec.o vaudioselector.o vscreensaver.o vopts.o \ - wselectlist.o wjpeg.o wsymbol.o wbutton.o wtextbox.o wwss.o \ + wselectlist.o wjpeg.o wsymbol.o wbutton.o wtextbox.o \ woptionpane.o woptionbox.o wremoteconfig.o wtabbar.o \ fonts/helvB24.o fonts/helvB18.o \ remote.o led.o mtd.o osd.o surface.o \ diff --git a/surface.cc b/surface.cc index d8a98da..6860cfa 100644 --- a/surface.cc +++ b/surface.cc @@ -292,3 +292,27 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) } + +void Surface::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, + unsigned int width, Colour& nextColour) { + startFastDraw(); + int x, y; + unsigned int bytesIn, bitsIn; + int widthBytes=width/8; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + bytesIn = (y * widthBytes) + (int) (x / 8); + bitsIn = x % 8; + + if ((base[bytesIn] >> (7 - bitsIn)) & 0x01) { + drawPixel(dx+x, dy+y, nextColour, true); + } + } + } + endFastDraw(); +} + +void Surface::drawPoint(int x, int y, Colour& c, bool fastdraw) +{ + drawPixel(x,y,c,fastdraw); +} diff --git a/surface.h b/surface.h index cbf9924..9d5aad6 100644 --- a/surface.h +++ b/surface.h @@ -48,6 +48,7 @@ class Bitmap; class Surface { + friend class Wwss; public: Surface(int id = 0); virtual ~Surface(); @@ -67,11 +68,11 @@ class Surface virtual void display()=0; virtual int fillblt(int x, int y, int width, int height, unsigned int c)=0; - virtual void drawPixel(int x, int y, unsigned int c, bool fastdraw=false)=0; - virtual void drawPixel(int x, int y, Colour& c, bool fastdraw=false)=0; virtual void drawHorzLine(int x1, int x2, int y, unsigned int c)=0; virtual void drawVertLine(int x, int y1, int y2, unsigned int c)=0; virtual void drawBitmap(int x, int y, const Bitmap& bm)=0; + virtual void drawPoint(int x, int y, Colour& c, bool fastdraw=false); // This draws a point, must not be a pixel + virtual void drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height,unsigned int width, Colour& nextColour); virtual int updateToScreen(int sx, int sy, int w, int h, int dx, int dy)=0; virtual void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b)=0; virtual void screenShot(const char* fileName)=0; @@ -96,6 +97,9 @@ class Surface static osd_font_t* font; Colour enumTeletextColorToCoulour(enumTeletextColor ttcol); + virtual void drawPixel(int x, int y, unsigned int c, bool fastdraw=false)=0; // deprecated preparation for vector based drawing, only allowed to be called inside implementation + virtual void drawPixel(int x, int y, Colour& c, bool fastdraw=false)=0; // deprecated preparation for vector based drawing, only allowed to be called inside implementation + }; #endif diff --git a/surfacedirectfb.h b/surfacedirectfb.h index 74c307b..9fc9b79 100644 --- a/surfacedirectfb.h +++ b/surfacedirectfb.h @@ -50,8 +50,7 @@ class SurfaceDirectFB : public Surface void display(); int fillblt(int x, int y, int width, int height, unsigned int rgba); - void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); - void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + void drawHorzLine(int x1, int x2, int y, unsigned int c); void drawVertLine(int x, int y1, int y2, unsigned int c); void drawBitmap(int x, int y, const Bitmap& bm); @@ -66,6 +65,9 @@ class SurfaceDirectFB : public Surface private: IDirectFBSurface *surface; + void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); + void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + }; diff --git a/surfacemvp.h b/surfacemvp.h index 394cede..a2d2626 100644 --- a/surfacemvp.h +++ b/surfacemvp.h @@ -161,8 +161,7 @@ class SurfaceMVP : public Surface unsigned long getSurfaceHandle(); int fillblt(int x, int y, int width, int height, unsigned int rgba); - void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); - void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + void drawHorzLine(int x1, int x2, int y, unsigned int c); void drawVertLine(int x, int y1, int y2, unsigned int c); void drawBitmap(int x, int y, const Bitmap& bm); @@ -242,6 +241,9 @@ class SurfaceMVP : public Surface static int conv_BV[256]; static int conv_GV[256]; static int conv_RV[256]; + protected: + void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); + void drawPixel(int x, int y, Colour& c, bool fastdraw=false); }; diff --git a/surfaceopengl.h b/surfaceopengl.h index 6bec52a..48b3509 100644 --- a/surfaceopengl.h +++ b/surfaceopengl.h @@ -39,8 +39,7 @@ class SurfaceOpenGL : public Surface void endFastDraw(); int fillblt(int x, int y, int width, int height, unsigned int c); - void drawPixel(int x, int y, Colour& c, bool fastdraw=false); - void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); + void drawHorzLine(int x1, int x2, int y, unsigned int c); void drawVertLine(int x, int y1, int y2, unsigned int c); void drawBitmap(int x, int y, const Bitmap& bm); @@ -64,6 +63,9 @@ class SurfaceOpenGL : public Surface Mutex srf_mutex; + protected: + void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); }; diff --git a/surfacewin.h b/surfacewin.h index 9949972..2058308 100644 --- a/surfacewin.h +++ b/surfacewin.h @@ -39,8 +39,6 @@ class SurfaceWin : public Surface void endFastDraw(); int fillblt(int x, int y, int width, int height, unsigned int c); - void drawPixel(int x, int y, Colour& c, bool fastdraw=false); - void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); void drawHorzLine(int x1, int x2, int y, unsigned int c); void drawVertLine(int x, int y1, int y2, unsigned int c); void drawBitmap(int x, int y, const Bitmap& bm); @@ -60,6 +58,9 @@ class SurfaceWin : public Surface D3DLOCKED_RECT lockrect; UINT sheight,swidth; HANDLE event; + protected: + void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); }; #endif diff --git a/vopts.cc b/vopts.cc index 393aa79..64d1bd2 100644 --- a/vopts.cc +++ b/vopts.cc @@ -163,9 +163,11 @@ VOpts::VOpts() option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13); options.push_back(option); wop->addOptionLine(option); +#ifdef PAL_WSS option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14); options.push_back(option); - wop->addOptionLine(option); + wop->addOptionLine(option); +#endif Remote::getInstance()->addOptionsToPanes(2,&options,wop); Video::getInstance()->addOptionsToPanes(2,&options,wop); diff --git a/vscreensaver.cc b/vscreensaver.cc index ec04f6a..2c6c86b 100644 --- a/vscreensaver.cc +++ b/vscreensaver.cc @@ -90,8 +90,8 @@ void VScreensaver::threadMethod() tail = head + 1; if (tail == h) tail = 0; - // Undraw oldest pixel - if (x[tail] != -1) surface->drawPixel(x[tail], y[tail], Colour::BLACK.rgba()); + // Undraw oldest point + if (x[tail] != -1) surface->drawPoint(x[tail], y[tail], Colour::BLACK);// was rgba dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation; direction += dd; @@ -110,7 +110,7 @@ void VScreensaver::threadMethod() x[head] = (int)fx; y[head] = (int)fy; - surface->drawPixel(x[head], y[head], Colour::SELECTHIGHLIGHT.rgba()); + surface->drawPoint(x[head], y[head], Colour::SELECTHIGHLIGHT); // was rgba MILLISLEEP(10); } } diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 0e49830..af5ac6d 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -95,7 +95,7 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V createBuffer(); Colour transparent(0, 0, 0, 0); setBackgroundColour(transparent); - +#ifdef PAL_WSS dowss = false; char* optionWSS = vdr->configLoad("General", "WSS"); if (optionWSS) @@ -116,7 +116,7 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V wssRegion.w = video->getScreenWidth(); wssRegion.h = 2; } - +#endif // This variable is set to true if the user pressed OK to bring the OSD on screen // This is only used on old remotes to stop up/down buttons being used for osd-epg scrolling okTriggeredOSD = false; @@ -1047,6 +1047,7 @@ void VVideoLiveTV::processMessage(Message* m) case PlayerLiveTV::ASPECT43: { +#ifdef PAL_WSS if ((video->getTVsize() == Video::ASPECT16X9) && dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); @@ -1054,6 +1055,7 @@ void VVideoLiveTV::processMessage(Message* m) wss.draw(); BoxStack::getInstance()->update(this, &wssRegion); } +#endif sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43; sAspectRatio.setVisible(true); @@ -1068,6 +1070,7 @@ void VVideoLiveTV::processMessage(Message* m) } case PlayerLiveTV::ASPECT169: { +#ifdef PAL_WSS if ((video->getTVsize() == Video::ASPECT16X9) && dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); @@ -1075,6 +1078,7 @@ void VVideoLiveTV::processMessage(Message* m) wss.draw(); BoxStack::getInstance()->update(this, &wssRegion); } +#endif sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169; sAspectRatio.setVisible(true); diff --git a/vvideolivetv.h b/vvideolivetv.h index 0ff6e84..7473086 100644 --- a/vvideolivetv.h +++ b/vvideolivetv.h @@ -27,7 +27,6 @@ #include "boxx.h" #include "region.h" -#include "wwss.h" #include "vdr.h" #include "wtextbox.h" #include "wselectlist.h" @@ -36,6 +35,10 @@ #include "wprogressbar.h" #include "osdreceiver.h" +#ifdef PAL_WSS +#include "wwss.h" +#endif + class VChannelList; class Video; class VChannelList; @@ -118,10 +121,11 @@ class VVideoLiveTV : public Boxx, public TimerReceiver, public OSDReceiver void showUnavailable(); VAudioSelector* vas; - +#ifdef PAL_WSS Wwss wss; Region wssRegion; bool dowss; +#endif Boxx osd; WTextbox clock; diff --git a/vvideorec.cc b/vvideorec.cc index 4b39235..faafb65 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -109,7 +109,7 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264) barGenHold = false; barScanHold = false; barVasHold = false; - +#ifdef PAL_WSS dowss = false; char* optionWSS = vdr->configLoad("General", "WSS"); if (optionWSS) @@ -130,6 +130,7 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264) wssRegion.w = video->getScreenWidth(); wssRegion.h = 300; } +#endif } void VVideoRec::preDelete() @@ -538,6 +539,7 @@ void VVideoRec::processMessage(Message* m) } case Player::ASPECT43: { +#ifdef PAL_WSS if (dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); @@ -545,10 +547,12 @@ void VVideoRec::processMessage(Message* m) wss.draw(); boxstack->update(this, &wssRegion); } +#endif break; } case Player::ASPECT169: { +#ifdef PAL_WSS if (dowss) { Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); @@ -556,6 +560,7 @@ void VVideoRec::processMessage(Message* m) wss.draw(); boxstack->update(this, &wssRegion); } +#endif break; } } diff --git a/vvideorec.h b/vvideorec.h index 3f10acf..383b8ef 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -25,13 +25,16 @@ #include "boxx.h" #include "timerreceiver.h" -#include "wwss.h" #include "region.h" #include "colour.h" #include "osdreceiver.h" #include "video.h" +#ifdef PAL_WSS +#include "wwss.h" +#endif + class VDR; class Timers; class Player; @@ -51,7 +54,7 @@ class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver { public: VVideoRec(Recording* rec, bool ish264); - ~VVideoRec(); + virtual ~VVideoRec(); void preDelete(); int handleCommand(int command); void go(bool resume); @@ -102,10 +105,11 @@ class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver UINT startMargin; UINT endMargin; - +#ifdef PAL_WSS Wwss wss; Region wssRegion; bool dowss; +#endif VInfo* vsummary; }; diff --git a/wsymbol.cc b/wsymbol.cc index 903f1e6..6d4035f 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -1078,7 +1078,8 @@ void WSymbol::draw() int x, y, bytesIn, bitsIn; - startFastDraw(); + drawMonoBitmap(base,0,0,sHeight,widthBits, nextColour); + /* startFastDraw(); for (y = 0; y < sHeight; y++) { for (x = 0; x < widthBits; x++) @@ -1092,7 +1093,7 @@ void WSymbol::draw() } } } - endFastDraw(); + endFastDraw();*/ } bool WSymbol::mouseLBDOWN(int x, int y) diff --git a/wwss.cc b/wwss.cc index a8579b6..ef9793b 100644 --- a/wwss.cc +++ b/wwss.cc @@ -121,7 +121,7 @@ void Wwss::drawPAL() { value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value c.set(value, value, value); - drawPixel(q, 6, c); + getSurface()->drawPixel(q, 6, c); } } @@ -189,7 +189,7 @@ static UCHAR src[22] = {1,0, 0,0,0,0,1,1, 0,0,0,0, 0,0,0,0, 0,0,1,0,0,1 }; { value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value c.set(value, value, value); - drawPixel(q, 6, c); + getSurface()->drawPixel(q, 6, c); } */ @@ -200,7 +200,7 @@ for(int yy = 0; yy < 100; yy++) { value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value c.set(value, value, value); - drawPixel(q+0, yy, c); + getSurface()->drawPixel(q+0, yy, c); } } diff --git a/wwss.h b/wwss.h index 50c2a0d..0928735 100644 --- a/wwss.h +++ b/wwss.h @@ -31,7 +31,7 @@ class Wwss : public Boxx { public: Wwss(); - ~Wwss(); + virtual ~Wwss(); void draw(); void setWide(bool wide); void setFormat(UCHAR tformat); -- 2.39.5