From 0c56de98010ddf9655c0bab3afcfa5bad6eac550 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 24 May 2013 22:28:22 +0200 Subject: [PATCH] framebuffer-ng: implement new framebuffer functions --- src/driver/framebuffer_ng.cpp | 111 +++++++++++++++++++++++++++++++--- src/driver/framebuffer_ng.h | 51 ++++++++++++++-- 2 files changed, 151 insertions(+), 11 deletions(-) diff --git a/src/driver/framebuffer_ng.cpp b/src/driver/framebuffer_ng.cpp index a24201cd6..7bef976f1 100644 --- a/src/driver/framebuffer_ng.cpp +++ b/src/driver/framebuffer_ng.cpp @@ -43,6 +43,7 @@ extern GLFramebuffer *glfb; #endif +#include #include #include #include @@ -68,7 +69,7 @@ extern CPictureViewer * g_PicViewer; /*******************************************************************************/ -void CFrameBuffer::waitForIdle(void) +void CFrameBuffer::waitForIdle(const char *) { accel->waitForIdle(); } @@ -276,15 +277,25 @@ unsigned int CFrameBuffer::getScreenHeight(bool real) return g_settings.screen_EndY - g_settings.screen_StartY; } -unsigned int CFrameBuffer::getScreenWidthRel() + +unsigned int CFrameBuffer::getScreenPercentRel(bool force_small) { - // always reduce a possible detailline - return (g_settings.screen_EndX - g_settings.screen_StartX - 2*ConnectLineBox_Width) * (g_settings.big_windows ? 100 : NON_BIG_WINDOWS) / 100; + if (force_small || !g_settings.big_windows) + return NON_BIG_WINDOWS; + return 100; } -unsigned int CFrameBuffer::getScreenHeightRel() +unsigned int CFrameBuffer::getScreenWidthRel(bool force_small) { - return (g_settings.screen_EndY - g_settings.screen_StartY) * (g_settings.big_windows ? 100 : NON_BIG_WINDOWS) / 100; + int percent = getScreenPercentRel(force_small); + // always reduce a possible detailline + return (g_settings.screen_EndX - g_settings.screen_StartX - 2*ConnectLineBox_Width) * percent / 100; +} + +unsigned int CFrameBuffer::getScreenHeightRel(bool force_small) +{ + int percent = getScreenPercentRel(force_small); + return (g_settings.screen_EndY - g_settings.screen_StartY) * percent / 100; } unsigned int CFrameBuffer::getScreenX() @@ -906,7 +917,8 @@ void CFrameBuffer::loadPal(const std::string & filename, const unsigned char off close(lfd); } -void CFrameBuffer::paintBoxFrame(const int sx, const int sy, const int dx, const int dy, const int px, const fb_pixel_t col, const int rad) + +void CFrameBuffer::paintBoxFrame(const int sx, const int sy, const int dx, const int dy, const int px, const fb_pixel_t col, const int rad, int type) { if (!getActive()) return; @@ -1213,3 +1225,88 @@ void CFrameBuffer::paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, boo paintBackgroundBoxRel(ax, ay, dx, dy); blit(); } + +void CFrameBuffer::setFbArea(int element, int _x, int _y, int _dx, int _dy) +{ + if (_x == 0 && _y == 0 && _dx == 0 && _dy == 0) { + // delete area + for (fbarea_iterator_t it = v_fbarea.begin(); it != v_fbarea.end(); ++it) { + if (it->element == element) { + v_fbarea.erase(it); + break; + } + } + if (v_fbarea.empty()) { + fbAreaActiv = false; + } + } + else { + // change area + bool found = false; + for (unsigned int i = 0; i < v_fbarea.size(); i++) { + if (v_fbarea[i].element == element) { + v_fbarea[i].x = _x; + v_fbarea[i].y = _y; + v_fbarea[i].dx = _dx; + v_fbarea[i].dy = _dy; + found = true; + break; + } + } + // set new area + if (!found) { + fb_area_t area; + area.x = _x; + area.y = _y; + area.dx = _dx; + area.dy = _dy; + area.element = element; + v_fbarea.push_back(area); + } + fbAreaActiv = true; + } +} + +int CFrameBuffer::checkFbAreaElement(int _x, int _y, int _dx, int _dy, fb_area_t *area) +{ + if (fb_no_check) + return FB_PAINTAREA_MATCH_NO; + + if (_y > area->y + area->dy) + return FB_PAINTAREA_MATCH_NO; + if (_x + _dx < area->x) + return FB_PAINTAREA_MATCH_NO; + if (_x > area->x + area->dx) + return FB_PAINTAREA_MATCH_NO; + if (_y + _dy < area->y) + return FB_PAINTAREA_MATCH_NO; + return FB_PAINTAREA_MATCH_OK; +} + +bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) +{ + if (v_fbarea.empty()) + return true; + + for (unsigned int i = 0; i < v_fbarea.size(); i++) { + int ret = checkFbAreaElement(_x, _y, _dx, _dy, &v_fbarea[i]); + if (ret == FB_PAINTAREA_MATCH_OK) { + switch (v_fbarea[i].element) { + case FB_PAINTAREA_MUTEICON1: + if (!do_paint_mute_icon) + break; + fb_no_check = true; + if (prev) + CAudioMute::getInstance()->hide(true); + else + CAudioMute::getInstance()->paint(); + fb_no_check = false; + break; + default: + break; + } + } + } + + return true; +} diff --git a/src/driver/framebuffer_ng.h b/src/driver/framebuffer_ng.h index f6bec2c6e..7fe46d39d 100644 --- a/src/driver/framebuffer_ng.h +++ b/src/driver/framebuffer_ng.h @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -175,8 +176,9 @@ class CFrameBuffer unsigned int getStride() const; // size of a single line in the framebuffer (in bytes) unsigned int getScreenWidth(bool real = false); unsigned int getScreenHeight(bool real = false); - unsigned int getScreenWidthRel(); - unsigned int getScreenHeightRel(); + unsigned int getScreenPercentRel(bool force_small); + unsigned int getScreenWidthRel(bool force_small = false); + unsigned int getScreenHeightRel(bool force_small = false); unsigned int getScreenX(); unsigned int getScreenY(); @@ -204,7 +206,7 @@ class CFrameBuffer inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col) { paintBoxRel(xa, ya, xb - xa, yb - ya, col); } inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col, int radius, int type) { paintBoxRel(xa, ya, xb - xa, yb - ya, col, radius, type); } - void paintBoxFrame(const int x, const int y, const int dx, const int dy, const int px, const fb_pixel_t col, const int rad = 0); + void paintBoxFrame(const int x, const int y, const int dx, const int dy, const int px, const fb_pixel_t col, const int rad = 0, int type = CORNER_ALL); void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); void paintVLine(int x, int ya, int yb, const fb_pixel_t col); @@ -251,7 +253,7 @@ class CFrameBuffer bool Lock(void); void Unlock(void); bool Locked(void) { return locked; }; - void waitForIdle(void); + void waitForIdle(const char *func = NULL); void* convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp = 0xFF); void* convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y); void displayRGB(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, bool clearfb = true, int transp = 0xFF); @@ -271,6 +273,47 @@ class CFrameBuffer }; void SetTransparent(int t){ m_transparent = t; } void SetTransparentDefault(){ m_transparent = m_transparent_default; } + +// ## AudioMute / Clock ###################################### + private: + enum { + FB_PAINTAREA_MATCH_NO, + FB_PAINTAREA_MATCH_OK + }; + + typedef struct fb_area_t + { + int x; + int y; + int dx; + int dy; + int element; + } fb_area_struct_t; + + bool fbAreaActiv; + typedef std::vector v_fbarea_t; + typedef v_fbarea_t::iterator fbarea_iterator_t; + v_fbarea_t v_fbarea; + bool fb_no_check; + bool do_paint_mute_icon; + + bool _checkFbArea(int _x, int _y, int _dx, int _dy, bool prev); + int checkFbAreaElement(int _x, int _y, int _dx, int _dy, fb_area_t *area); + + public: + enum { + FB_PAINTAREA_INFOCLOCK, + FB_PAINTAREA_MUTEICON1, + FB_PAINTAREA_MUTEICON2, + + FB_PAINTAREA_MAX + }; + + inline bool checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) { return (fbAreaActiv && !fb_no_check) ? _checkFbArea(_x, _y, _dx, _dy, prev) : true; } + + void setFbArea(int element, int _x=0, int _y=0, int _dx=0, int _dy=0); + void fbNoCheck(bool noCheck) { fb_no_check = noCheck; } + void doPaintMuteIcon(bool mode) { do_paint_mute_icon = mode; } }; #endif