From 78419473dacc750ced7a2381bf2000ef3c204ea9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:09:33 +0100 Subject: [PATCH] implement getWidth4FB_HW_ACC in fb_accel class This helper to determine alignment for hardware blitting is now in system/helpers.h, where it does not really belong. Put it into the framebuffer class instead. Framebuffers that don't need it will just get a dummy function, the cs_hd2 framebuffer gets the real thing. Also add a bool function that indicates the need for alignment. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b6909fb815c9e54a7a4626f1c13139402918fe63 Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) --- src/driver/fb_accel.h | 2 ++ src/driver/fb_accel_cs_hd2.cpp | 17 +++++++++++++++++ src/driver/fb_generic.cpp | 8 ++++++-- src/driver/fb_generic.h | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 54736d331..e3eceaab5 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -127,6 +127,8 @@ class CFbAccelCSHD2 void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); void setBlendMode(uint8_t); void setBlendLevel(int); + uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); + bool needAlign4Blit() { return true; }; }; class CFbAccelGLFB diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 393e6396c..256a9c729 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -228,3 +228,20 @@ void CFbAccelCSHD2::setBlendLevel(int level) if (level == 100) // TODO: sucks. usleep(20000); } + +/* align for hw blit */ +uint32_t CFbAccelCSHD2::getWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max) +{ + uint32_t ret = _w; + if ((_x + ret) >= xRes) + ret = xRes-_x-1; + if (ret%4 == 0) + return ret; + + int add = (max) ? 3 : 0; + ret = ((ret + add) / 4) * 4; + if ((_x + ret) >= xRes) + ret -= 4; + + return ret; +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 9377d77da..1160b9c44 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -514,7 +513,7 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co #ifdef BOXMODEL_CS_HD2 if (_dx%4 != 0) { - w_align = GetWidth4FB_HW_ACC(x, _dx, true); + w_align = getWidth4FB_HW_ACC(x, _dx, true); if (w_align < _dx) _dx = w_align; offs_align = w_align - _dx; @@ -1770,3 +1769,8 @@ bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) void CFrameBuffer::mark(int , int , int , int ) { } + +uint32_t CFrameBuffer::getWidth4FB_HW_ACC(const uint32_t /*x*/, const uint32_t w, const bool /*max*/) +{ + return w; +} diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index e863528ab..fdd9cc8d5 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -185,6 +185,8 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? virtual void setupGXA() { return; }; // reinitialize stuff + virtual bool needAlign4Blit() { return false; }; + virtual uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); void setTransparency( int tr = 0 ); virtual void setBlendMode(uint8_t mode = 1);