From 2944c3cd0eebceae0f51fac763c774411da1662d Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 21 May 2020 16:14:28 +0100 Subject: [PATCH] Clean up screenShot() - all params, return types, function names --- osd.h | 2 +- osddirectfb.cc | 4 ++-- osddirectfb.h | 2 +- osdopengl.cc | 5 +++-- osdopengl.h | 2 +- osdopenvg.cc | 4 ++-- osdopenvg.h | 2 +- osdvector.cc | 10 ++++++---- osdvector.h | 4 ++-- osdwinpixel.cc | 4 ++-- osdwinpixel.h | 2 +- osdwinvector.cc | 2 +- osdwinvector.h | 2 +- surface.h | 2 +- surfacedirectfb.cc | 5 ++--- surfacedirectfb.h | 2 +- surfaceopengl.cc | 3 ++- surfaceopengl.h | 2 +- surfacevector.h | 4 ++-- surfacewin.cc | 3 ++- surfacewin.h | 2 +- 21 files changed, 36 insertions(+), 32 deletions(-) diff --git a/osd.h b/osd.h index 003a33d..1aa473f 100644 --- a/osd.h +++ b/osd.h @@ -39,7 +39,7 @@ class Osd bool isInitted() { return initted; }; - virtual void screenShot(const char* fileName)=0; + virtual bool screenShot(const char* fileName)=0; virtual int getFontNames(const char*** /* names */,const char*** /* names_keys */) { return 0; }; virtual void setFont(const char* /* fontname */) {}; diff --git a/osddirectfb.cc b/osddirectfb.cc index 923318c..826cbf6 100644 --- a/osddirectfb.cc +++ b/osddirectfb.cc @@ -94,7 +94,7 @@ int OsdDirectFB::shutdown() return 1; } -void OsdDirectFB::screenShot(char* fileName) +bool OsdDirectFB::screenShot(const char* fileName) { - screen->screenShot(fileName); + return screen->screenShot(fileName); } diff --git a/osddirectfb.h b/osddirectfb.h index 48caf70..7814cfd 100644 --- a/osddirectfb.h +++ b/osddirectfb.h @@ -42,7 +42,7 @@ class OsdDirectFB : public Osd int init(); int shutdown(); - void screenShot(char* fileName); + bool screenShot(const char* fileName); IDirectFB* getDfb() {return dfb;}; IDirectFBDisplayLayer* getOsdLayer(){return osd_layer;}; diff --git a/osdopengl.cc b/osdopengl.cc index 9f0d9a0..f7f2643 100644 --- a/osdopengl.cc +++ b/osdopengl.cc @@ -292,11 +292,12 @@ int OsdOpenGL::shutdown() return 1; } -void OsdOpenGL::screenShot(const char* fileName) +bool OsdOpenGL::screenShot(const char* fileName) { BeginPainting(); - screen->screenShot(fileName); + bool ret = screen->screenShot(fileName); EndPainting(); + return ret; } void OsdOpenGL::threadMethod() diff --git a/osdopengl.h b/osdopengl.h index 867956e..730d0c5 100644 --- a/osdopengl.h +++ b/osdopengl.h @@ -61,7 +61,7 @@ class OsdOpenGL : public Osd, public Thread_TYPE int init(); int shutdown(); - void screenShot(const char* fileName); + bool screenShot(const char* fileName); Surface * createNewSurface(); diff --git a/osdopenvg.cc b/osdopenvg.cc index 25f1e54..c79eaa5 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -645,7 +645,7 @@ void OsdOpenVG::getRealScreenSize(int& width, int& height) height = display_height; } -bool OsdOpenVG::screenShot(void* buffer, int width, int height, bool osd /*include osd*/) +bool OsdOpenVG::screenShotInternal(void* buffer, int width, int height, bool includeOSD) { if (!initted) return false; @@ -659,7 +659,7 @@ bool OsdOpenVG::screenShot(void* buffer, int width, int height, bool osd /*inclu res = vc_dispmanx_resource_create(VC_IMAGE_RGBA32, width, height, &image_ptr); display = vc_dispmanx_display_open(0); - if (!osd) + if (!includeOSD) { vc_dispmanx_snapshot(display, res, static_cast(DISPMANX_SNAPSHOT_NO_RGB | DISPMANX_SNAPSHOT_FILL/*|DISPMANX_SNAPSHOT_PACK*/)); diff --git a/osdopenvg.h b/osdopenvg.h index 4c1b554..45e9915 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -88,7 +88,7 @@ class OsdOpenVG : public OsdVector int shutdown(); int stopUpdate(); - bool screenShot(void* buffer, int width, int height, bool osd /*include osd*/); + bool screenShotInternal(void* buffer, int width, int height, bool includeOSD); float getFontHeight(); float getCharWidth(wchar_t c); diff --git a/osdvector.cc b/osdvector.cc index 5779637..74f783f 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -119,7 +119,7 @@ OsdVector::OsdVector() #endif } -void OsdVector::screenShot(const char* fileName) +bool OsdVector::screenShot(const char* fileName) { //Do nothing, if no libmagick is there #ifdef PICTURE_DECODER_MAGICK @@ -132,11 +132,11 @@ void OsdVector::screenShot(const char* fileName) { Blob myblob; - if (!screenShot(mem, width, height, true)) + if (!screenShotInternal(mem, width, height, true)) { Log::getInstance()->log("OsdVector", Log::DEBUG, "Screenshot failed!"); free(mem); - return; + return false; } myblob.updateNoCopy(mem, length, Blob::MallocAllocator); @@ -146,10 +146,12 @@ void OsdVector::screenShot(const char* fileName) catch ( Exception& error_ ) { Log::getInstance()->log("MagickEncoder", Log::DEBUG, "Libmagick: %s", error_.what()); - + return false; } + return true; #endif + return false; } Surface* OsdVector::createNewSurface() diff --git a/osdvector.h b/osdvector.h index 713879e..34b6223 100644 --- a/osdvector.h +++ b/osdvector.h @@ -214,8 +214,8 @@ class OsdVector : public Osd int restore(); - void screenShot(const char* fileName); - virtual bool screenShot(void* buffer, int width, int height, bool osd /*include osd*/) = 0; + bool screenShot(const char* fileName); + virtual bool screenShotInternal(void* buffer, int width, int height, bool osd /*include osd*/) = 0; Surface* createNewSurface(); diff --git a/osdwinpixel.cc b/osdwinpixel.cc index e4cc117..aba06e6 100644 --- a/osdwinpixel.cc +++ b/osdwinpixel.cc @@ -84,9 +84,9 @@ int OsdWinPixel::shutdown() return 1; } -void OsdWinPixel::screenShot(const char* fileName) +bool OsdWinPixel::screenShot(const char* fileName) { - screen->screenShot(fileName); + return screen->screenShot(fileName); } LPDIRECT3DTEXTURE9 OsdWinPixel::getNextOsdTexture() diff --git a/osdwinpixel.h b/osdwinpixel.h index caf3321..190a40b 100644 --- a/osdwinpixel.h +++ b/osdwinpixel.h @@ -41,7 +41,7 @@ class OsdWinPixel : public Osd, public WindowsOsd bool isInitialized() { return initted; } - void screenShot(const char* fileName); + bool screenShot(const char* fileName); Surface * createNewSurface(); diff --git a/osdwinvector.cc b/osdwinvector.cc index 612d4d7..1f60b9e 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -1081,7 +1081,7 @@ void OsdWinVector::getRealScreenSize(int &width, int &height) height = BACKBUFFER_HEIGHT; } -bool OsdWinVector::screenShot(void *buffer, int width, int height, bool osd /*include osd*/) +bool OsdWinVector::screenShotInternal(void *buffer, int width, int height, bool includeOSD) { //screen->screenShot(fileName); return false; diff --git a/osdwinvector.h b/osdwinvector.h index 8318d96..3dea77a 100644 --- a/osdwinvector.h +++ b/osdwinvector.h @@ -53,7 +53,7 @@ class OsdWinVector : public OsdVector, public WindowsOsd float getFontHeight(); float getCharWidth(wchar_t c); - bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/); + bool screenShotInternal(void *buffer, int width, int height, bool includeOSD); int getFontNames(const char *** names, const char *** names_keys); diff --git a/surface.h b/surface.h index a826d69..ac75917 100644 --- a/surface.h +++ b/surface.h @@ -90,7 +90,7 @@ public: virtual void drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height,unsigned int width, 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 void screenShot(const char* fileName)=0; + virtual bool screenShot(const char* fileName)=0; /* This is for system which need a locking of the drawing surface to speed up drawing */ virtual void startFastDraw() {}; diff --git a/surfacedirectfb.cc b/surfacedirectfb.cc index 7bcf3eb..2a426c4 100644 --- a/surfacedirectfb.cc +++ b/surfacedirectfb.cc @@ -291,10 +291,9 @@ int SurfaceDirectFB::blt(int fd, unsigned long shandle, int sx, int sy, int widt return 0; } -void SurfaceDirectFB::screenShot(const char* fileName) +bool SurfaceDirectFB::screenShot(const char* fileName) { - return; - + return false; } void SurfaceDirectFB::readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b) diff --git a/surfacedirectfb.h b/surfacedirectfb.h index e9a3fff..373db83 100644 --- a/surfacedirectfb.h +++ b/surfacedirectfb.h @@ -56,7 +56,7 @@ class SurfaceDirectFB : public Surface void drawBitmap(int x, int y, const Bitmap& bm); int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b); - void screenShot(const char* fileName); + bool screenShot(const char* fileName); IDirectFBSurface* getSurfaceDFB(){return surface;}; diff --git a/surfaceopengl.cc b/surfaceopengl.cc index ed8fb3c..5d3d79a 100644 --- a/surfaceopengl.cc +++ b/surfaceopengl.cc @@ -243,9 +243,10 @@ int SurfaceOpenGL::blt(int fd, unsigned long shandle, int sx, int sy, int width, return 0; } -void SurfaceOpenGL::screenShot(const char* fileName) +bool SurfaceOpenGL::screenShot(const char* fileName) { //Isn't this for debugging only, so I won't implement it yet + return false; } void SurfaceOpenGL::readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b) diff --git a/surfaceopengl.h b/surfaceopengl.h index a3bec72..da67989 100644 --- a/surfaceopengl.h +++ b/surfaceopengl.h @@ -45,7 +45,7 @@ class SurfaceOpenGL : public Surface void drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegion & region); int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b); - void screenShot(const char* fileName); + bool screenShot(const char* fileName); void ReleaseSurface(); int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy); void drawJpeg(const char *fileName,int x, int y,int *width, int *height); diff --git a/surfacevector.h b/surfacevector.h index 5c23ebb..e523023 100644 --- a/surfacevector.h +++ b/surfacevector.h @@ -64,8 +64,8 @@ class SurfaceVector : public Surface void drawTTChar(int ox, int oy, int x, int y, cTeletextChar c); - void readPixel(int /* x */, int /* y */, unsigned char* /* r */, unsigned char* /* g */, unsigned char* /* b */) {}; - void screenShot(const char* /* fileName */) {}; + void readPixel(int /* x */, int /* y */, unsigned char* /* r */, unsigned char* /* g */, unsigned char* /* b */) {} + bool screenShot(const char* /* fileName */) { return false; } protected: diff --git a/surfacewin.cc b/surfacewin.cc index da1d323..126f50d 100644 --- a/surfacewin.cc +++ b/surfacewin.cc @@ -281,9 +281,10 @@ int SurfaceWin::blt(int fd, unsigned long shandle, int sx, int sy, int width, in return 0; } -void SurfaceWin::screenShot(const char* fileName) +bool SurfaceWin::screenShot(const char* fileName) { //Isn't this for debugging only, so I won't implement it yet + return false; } void SurfaceWin::readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b) diff --git a/surfacewin.h b/surfacewin.h index 5be38cf..7e5f6d5 100644 --- a/surfacewin.h +++ b/surfacewin.h @@ -44,7 +44,7 @@ class SurfaceWin : public Surface void drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegion & region); int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b); - void screenShot(const char* fileName); + bool screenShot(const char* fileName); void ReleaseSurface(); int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy); void drawJpeg(const char *fileName,int x, int y,int *width, int *height); -- 2.39.2