From 74b0be197395d68b15986fc55629034072c11b49 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 26 May 2020 15:36:28 +0100 Subject: [PATCH] DrawStyle: Add consts, add white and transparent statics --- boxx.cc | 2 +- boxx.h | 2 +- colour.cc | 2 ++ colour.h | 6 +++++- surface.cc | 4 ++-- surface.h | 6 +++--- surfacevector.cc | 6 +++--- surfacevector.h | 6 +++--- vcolourtuner.cc | 4 ++-- vcolourtuner.h | 2 +- vepg.cc | 16 ++++++---------- vradiorec.cc | 7 +++---- vradiorec.h | 1 - vscreensaver.cc | 7 ++----- vvideolivetv.cc | 7 +++---- vvideomedia.cc | 5 ++--- vvideomedia.h | 1 - vvideorec.cc | 9 ++++----- vvideorec.h | 1 - wjpegcomplex.cc | 4 ++-- wjpegcomplex.h | 2 +- 21 files changed, 46 insertions(+), 54 deletions(-) diff --git a/boxx.cc b/boxx.cc index 84e3860..c4e5735 100644 --- a/boxx.cc +++ b/boxx.cc @@ -496,7 +496,7 @@ 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, DrawStyle& nextColour) +void Boxx::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height,unsigned int width, const DrawStyle& 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); diff --git a/boxx.h b/boxx.h index c29a975..54ba03e 100644 --- a/boxx.h +++ b/boxx.h @@ -113,7 +113,7 @@ class Boxx 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, DrawStyle& nextColour); + void drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, const DrawStyle& nextColour); /* This is for system which need a locking of the drawing surface to speed up drawing */ void startFastDraw(); diff --git a/colour.cc b/colour.cc index 904097b..cf75ca8 100644 --- a/colour.cc +++ b/colour.cc @@ -20,6 +20,8 @@ #include "colour.h" #include "defines.h" +DrawStyle DrawStyle::TRANSPARENT(0, 0, 0, 0); +DrawStyle DrawStyle::WHITE(255, 255, 255); DrawStyle DrawStyle::BLACK(0, 0, 0); DrawStyle DrawStyle::RED(255, 0, 0); DrawStyle DrawStyle::GREEN(0, 255, 0); diff --git a/colour.h b/colour.h index f5d5e36..9122f1b 100644 --- a/colour.h +++ b/colour.h @@ -71,7 +71,8 @@ class DrawStyle: public Colour { red = Tred; green = Tgreen; blue = Tblue; alpha = 255 ; ft = Color; ct = Global; } DrawStyle(int Tred, int Tgreen, int Tblue, int Talpha) - { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; ft = Color; ct = Global;} + { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; ft = Color; ct = Global; } + DrawStyle(unsigned int color) { red = (color & 0x00ff0000) >> 16; @@ -96,6 +97,7 @@ class DrawStyle: public Colour GradientLinear, GradientRadial, }; + enum CoordType { Global, @@ -109,6 +111,8 @@ class DrawStyle: public Colour Colour grad_col[4]; float grad_pos[3]; //Last position is alway 1.0 and first 0.0 + static DrawStyle TRANSPARENT; + static DrawStyle WHITE; static DrawStyle BLACK; static DrawStyle RED; static DrawStyle GREEN; diff --git a/surface.cc b/surface.cc index 5782327..25fd516 100644 --- a/surface.cc +++ b/surface.cc @@ -327,7 +327,7 @@ 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, DrawStyle& nextColour) + unsigned int width, const DrawStyle& nextColour) { startFastDraw(); unsigned int x, y; @@ -351,7 +351,7 @@ void Surface::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, endFastDraw(); } -void Surface::drawPoint(int x, int y, DrawStyle& c, bool fastdraw) +void Surface::drawPoint(int x, int y, const DrawStyle& c, bool fastdraw) { drawPixel(x, y, c, fastdraw); } diff --git a/surface.h b/surface.h index bf720f8..561c28e 100644 --- a/surface.h +++ b/surface.h @@ -86,8 +86,8 @@ class Surface virtual void drawHorzLine(int x1, int x2, int y, const DrawStyle& c) = 0; virtual void drawVertLine(int x, int y1, int y2, const DrawStyle& c) = 0; virtual void drawBitmap(int x, int y, const Bitmap& bm, const DisplayRegion& region) = 0; - virtual void drawPoint(int x, int y, DrawStyle& 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, DrawStyle& nextColour); + virtual void drawPoint(int x, int y, const DrawStyle& 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, const DrawStyle& 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 bool screenShot(const char* fileName) = 0; @@ -111,7 +111,7 @@ class Surface #endif 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 + virtual void drawPixel(int x, int y, const Colour& c, bool fastdraw = false) = 0; // deprecated preparation for vector based drawing, only allowed to be called inside implementation private: void initpol_tables(); diff --git a/surfacevector.cc b/surfacevector.cc index fd18002..035cf7b 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -357,7 +357,7 @@ void SurfaceVector::drawBitmap(int x, int y, const Bitmap& bm, const DisplayRegi command_mutex.unlock(); } -void SurfaceVector::drawPoint(int x, int y, DrawStyle& c, bool fastdraw) +void SurfaceVector::drawPoint(int x, int y, const DrawStyle& c, bool fastdraw) { if (!fastdraw) command_mutex.lock(); @@ -366,7 +366,8 @@ void SurfaceVector::drawPoint(int x, int y, DrawStyle& c, bool fastdraw) if (!fastdraw) command_mutex.unlock(); } -void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, unsigned int width, DrawStyle& nextColour) + +void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, unsigned int width, const DrawStyle& nextColour) { command_mutex.lock(); ImageIndex image = osd->getMonoBitmapRef(base, width, height); @@ -376,7 +377,6 @@ void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int hei command_mutex.unlock(); } - 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 diff --git a/surfacevector.h b/surfacevector.h index e523023..ce20315 100644 --- a/surfacevector.h +++ b/surfacevector.h @@ -54,8 +54,8 @@ class SurfaceVector : public Surface void drawHorzLine(int x1, int x2, int y, const DrawStyle& c); void drawVertLine(int x, int y1, int y2, const DrawStyle& c); void drawBitmap(int x, int y, const Bitmap& bm, const DisplayRegion& region); - void drawPoint(int x, int y, DrawStyle& c, bool fastdraw = false); // This draws a point, must not be a pixel - void drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, unsigned int width, DrawStyle& nextColour); + void drawPoint(int x, int y, const DrawStyle& c, bool fastdraw = false); // This draws a point, must not be a pixel + void drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, unsigned int width, const DrawStyle& nextColour); int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); /* This is for system which need a locking of the drawing surface to speed up drawing */ @@ -77,7 +77,7 @@ class SurfaceVector : public Surface OsdVector* osd; void drawPixel(int /* x */, int /* y */, unsigned int /* c */, bool /* fastdraw */) {}; // these are not supported! - void drawPixel(int /* x */, int /* y */, Colour& /* c */, bool /* fastdraw */) {}; + void drawPixel(int /* x */, int /* y */, const Colour& /* c */, bool /* fastdraw */) {}; }; #endif diff --git a/vcolourtuner.cc b/vcolourtuner.cc index b1fc472..32507c9 100644 --- a/vcolourtuner.cc +++ b/vcolourtuner.cc @@ -58,7 +58,7 @@ VColourTuner::~VColourTuner() Log::getInstance()->log("VColourTuner",Log::DEBUG,"deleted %p",this); } -void VColourTuner::drawBox(int x, int y, int w, int h, DrawStyle &c) { +void VColourTuner::drawBox(int x, int y, int w, int h, const DrawStyle& c) { for (int row=y;rowdrawPixel(col,row,c); @@ -79,7 +79,7 @@ void VColourTuner::draw() int picx=picture.getX(); DrawStyle bc=DrawStyle(140,140,140); fillColour(bc); - bc=DrawStyle(255,255,255); + bc=DrawStyle::WHITE; drawText(tr("Colour Tuning"), x+20, y+5, DrawStyle::LIGHTTEXT); drawBox(x, y+50, bw, bh, DrawStyle::RED); drawBox(x, y+130, bw, bh, DrawStyle::GREEN); diff --git a/vcolourtuner.h b/vcolourtuner.h index c816cca..4a8c261 100644 --- a/vcolourtuner.h +++ b/vcolourtuner.h @@ -47,7 +47,7 @@ class VColourTuner : public TBBoxx //amount in +/- % void updateFactor(int color, int amount); //draw a box with the picture drawing function - void drawBox(int x, int y, int w, int h, DrawStyle &c); + void drawBox(int x, int y, int w, int h, const DrawStyle& c); static int rfactor; static int bfactor; static int gfactor; diff --git a/vepg.cc b/vepg.cc index 091a0b7..8024fdb 100644 --- a/vepg.cc +++ b/vepg.cc @@ -112,8 +112,7 @@ VEpg::VEpg(void* tparent, UINT tcurrentChannelIndex, ChannelList* tchanList) setPosition(0, 0); // beautify -// DrawStyle transparent = DrawStyle(0, 0, 0, 0); -// setBackgroundColour(transparent); +// setBackgroundColour(DrawStyle::TRANSPARENT); // progTitle.setSurface(surface); progTitle.setPosition(0,0); @@ -249,8 +248,7 @@ void VEpg::draw() { // View::draw(); // draw pallet // beautify - DrawStyle transparent = DrawStyle(0, 0, 0, 0); - fillColour(transparent); + fillColour(DrawStyle::TRANSPARENT); // Moved all the dynamic data drawing to a seperate function @@ -529,10 +527,8 @@ void VEpg::drawgrid() // redraws grid and select programme ltime = prevHour(&selTime); updateEventList(); } - // draw time scale - DrawStyle white = DrawStyle(255, 255, 255, 255); - + // draw time scale t = ltime; struct tm tms; LOCALTIME_R(&t, &tms); @@ -543,17 +539,17 @@ void VEpg::drawgrid() // redraws grid and select programme strftime(timeString, 19, "%H:%M", &tms); drawText(timeString, timex, timey, DrawStyle::LIGHTTEXT); // print left time - rectangle(155, timey + getFontHeight(), 2, 7, white); + rectangle(155, timey + getFontHeight(), 2, 7, DrawStyle::WHITE); t = t + 3600; LOCALTIME_R(&t, &tms); strftime(timeString, 19, "%H:%M", &tms); drawText(timeString, timex + 180, timey, DrawStyle::LIGHTTEXT); // print middle time - rectangle(335, timey + getFontHeight(), 2, 7, white); + rectangle(335, timey + getFontHeight(), 2, 7, DrawStyle::WHITE); t = t + 3600; LOCALTIME_R(&t, &tms); strftime(timeString, 19, "%H:%M", &tms); drawText(timeString, timex + 360, timey, DrawStyle::LIGHTTEXT); // print right time - rectangle(515, timey + getFontHeight(), 2, 7, white); + rectangle(515, timey + getFontHeight(), 2, 7, DrawStyle::WHITE); // pointer to selTime //rectangle(155 + (selTime - ltime) / 20, timey + getFontHeight(), 2, 7, DrawStyle(255, 50, 50, 255)); diff --git a/vradiorec.cc b/vradiorec.cc index df787f4..08656f6 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -74,8 +74,7 @@ VRadioRec::VRadioRec(Recording* rec) setSize(video->getScreenWidth(), video->getScreenHeight()); createBuffer(); - transparent.set(0, 0, 0, 0); - setBackgroundColour(transparent); + setBackgroundColour(DrawStyle::TRANSPARENT); setPosition(0, 0); barRegion.x = 0; @@ -113,7 +112,7 @@ VRadioRec::~VRadioRec() void VRadioRec::draw() { - fillColour(transparent); + fillColour(DrawStyle::TRANSPARENT); } void VRadioRec::go(bool resume) @@ -521,7 +520,7 @@ void VRadioRec::removeBar() if (!barShowing) return; timers->cancelTimer(this, 2); barShowing = false; - rectangle(barRegion, transparent); + rectangle(barRegion, DrawStyle::TRANSPARENT); boxstack->update(this, &barRegion); } diff --git a/vradiorec.h b/vradiorec.h index b333628..278da93 100644 --- a/vradiorec.h +++ b/vradiorec.h @@ -55,7 +55,6 @@ class VRadioRec : public Boxx, public TimerReceiver BoxStack* boxstack; DrawStyle barBlue; - DrawStyle transparent; bool playing; bool barShowing; diff --git a/vscreensaver.cc b/vscreensaver.cc index 154a368..0d8f383 100644 --- a/vscreensaver.cc +++ b/vscreensaver.cc @@ -98,9 +98,6 @@ void VScreensaver::threadMethod() fx = x[0] = 50.0; fy = y[0] = 50.0; - DrawStyle &black=DrawStyle::BLACK; - DrawStyle &light=DrawStyle::SELECTHIGHLIGHT; - while(1) { if (++head == h) head = 0; @@ -109,7 +106,7 @@ void VScreensaver::threadMethod() if (tail == h) tail = 0; // Undraw oldest point - if (x[tail] != -1) surface->drawPoint(x[tail], y[tail], black);// was rgba + if (x[tail] != -1) surface->drawPoint(x[tail], y[tail], DrawStyle::BLACK);// was rgba dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation; direction += dd; @@ -128,7 +125,7 @@ void VScreensaver::threadMethod() x[head] = static_cast(fx); y[head] = static_cast(fy); - surface->drawPoint(x[head], y[head], light); // was rgba + surface->drawPoint(x[head], y[head], DrawStyle::SELECTHIGHLIGHT); // was rgba if (threadReqStop) return; MILLISLEEP(10); diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 27c7290..46c6305 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -99,8 +99,7 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V setSize(video->getScreenWidth(), video->getScreenHeight()); createBuffer(); - DrawStyle transparent(0, 0, 0, 0); - setBackgroundColour(transparent); + setBackgroundColour(DrawStyle::TRANSPARENT); OsdVector* osdv = dynamic_cast(Osd::getInstance()); if (osdv) @@ -1352,7 +1351,7 @@ void VVideoLiveTV::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const D void VVideoLiveTV::clearOSD() { - rectangle(area, DrawStyle(0,0,0,0)); + rectangle(area, DrawStyle::TRANSPARENT); boxstack->update(this, &area); } @@ -1367,6 +1366,6 @@ void VVideoLiveTV::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, c r.y = static_cast(floor(scaley * static_cast(r.y))); r.w = static_cast(ceil(scalex * static_cast(r.w)) + 1.f); r.h = static_cast(ceil(scaley * static_cast(r.h)) + 1.f); - rectangle(r, DrawStyle(0,0,0,0)); + rectangle(r, DrawStyle::TRANSPARENT); boxstack->update(this, &r); } diff --git a/vvideomedia.cc b/vvideomedia.cc index ca02084..ccf9d7a 100644 --- a/vvideomedia.cc +++ b/vvideomedia.cc @@ -66,8 +66,7 @@ VVideoMedia::VVideoMedia(Media* media, VMediaList *p) setSize(video->getScreenWidth(), video->getScreenHeight()); createBuffer(); - transparent.set(0, 0, 0, 0); - setBackgroundColour(transparent); + setBackgroundColour(DrawStyle::TRANSPARENT); barRegion.x = 0; barRegion.y = video->getScreenHeight() - 58; // FIXME, need to be - 1? and below? @@ -671,7 +670,7 @@ void VVideoMedia::removeBar() barGenHold = false; barScanHold = false; barVasHold = false; - rectangle(barRegion, transparent); + rectangle(barRegion, DrawStyle::TRANSPARENT); BoxStack::getInstance()->update(this, &barRegion); } diff --git a/vvideomedia.h b/vvideomedia.h index da51337..dbf7a53 100644 --- a/vvideomedia.h +++ b/vvideomedia.h @@ -62,7 +62,6 @@ class VVideoMedia : public Boxx, public TimerReceiver VAudioSelector* vas; - DrawStyle transparent; DrawStyle barBlue; UCHAR videoMode; diff --git a/vvideorec.cc b/vvideorec.cc index e64c88e..efcc599 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -85,8 +85,7 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264) setSize(video->getScreenWidth(), video->getScreenHeight()); createBuffer(); - transparent.set(0, 0, 0, 0); - setBackgroundColour(transparent); + setBackgroundColour(DrawStyle::TRANSPARENT); OsdVector* osdv=dynamic_cast(Osd::getInstance()); if (osdv) @@ -1029,7 +1028,7 @@ void VVideoRec::removeBar() barGenHold = false; barScanHold = false; barVasHold = false; - rectangle(barRegion, transparent); + rectangle(barRegion, DrawStyle::TRANSPARENT); boxstack->update(this, &barRegion); player->tellSubtitlesOSDVisible(false); } @@ -1082,7 +1081,7 @@ void VVideoRec::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const Disp void VVideoRec::clearOSD() { - rectangle(area, transparent); + rectangle(area, DrawStyle::TRANSPARENT); boxstack->update(this, &area); } @@ -1097,6 +1096,6 @@ void VVideoRec::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, cons r.w = static_cast(ceil(scalex * static_cast(r.w)) + 1.f); r.h = static_cast(ceil(scaley * static_cast(r.h)) + 1.f); - rectangle(r, transparent); + rectangle(r, DrawStyle::TRANSPARENT); boxstack->update(this, &r); } diff --git a/vvideorec.h b/vvideorec.h index a5a6535..b041e08 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -70,7 +70,6 @@ class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver VAudioSelector* vas; - DrawStyle transparent; DrawStyle barBlue; int videoMode; diff --git a/wjpegcomplex.cc b/wjpegcomplex.cc index e96ccf2..2965f4f 100644 --- a/wjpegcomplex.cc +++ b/wjpegcomplex.cc @@ -607,7 +607,7 @@ void WJpegComplex::draw() #ifndef __ANDROID__ -bool WJpegComplex::drawJpeg(JpegControl * ctl,Surface * sfc,JpegReader *rdr, DrawStyle & backgroundColour) { +bool WJpegComplex::drawJpeg(JpegControl * ctl,Surface * sfc,JpegReader *rdr, const DrawStyle& backgroundColour) { Log* logger = Log::getInstance(); if (! rdr || ! sfc) { logger->log("BJpeg", Log::ERR, "JPEG error rdr=NULL or sfc=NULL"); @@ -876,7 +876,7 @@ bool WJpegComplex::drawJpeg(JpegControl * ctl,Surface * sfc,JpegReader *rdr, Dra #else -bool WJpegComplex::drawJpeg(JpegControl * ctl,Surface * sfc,JpegReader *rdr, DrawStyle & backgroundColour) { +bool WJpegComplex::drawJpeg(JpegControl * ctl,Surface * sfc,JpegReader *rdr, const DrawStyle& backgroundColour) { return true; } #endif diff --git a/wjpegcomplex.h b/wjpegcomplex.h index 64ad624..0228f98 100644 --- a/wjpegcomplex.h +++ b/wjpegcomplex.h @@ -143,7 +143,7 @@ class WJpegComplex : public WJpeg //the reader has to be initialized before //calling this function does not need a WJpeg being instantiated //it simply draws into the surface - bool static drawJpeg(JpegControl * control, Surface* sfc, JpegReader *rdr, DrawStyle & backgroundColour); + bool static drawJpeg(JpegControl * control, Surface* sfc, JpegReader *rdr, const DrawStyle& backgroundColour); private: //our drawPixel with considers rotation -- 2.39.2