diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 2b6d016fa..86c7dbb5e 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -5595,7 +5595,7 @@ void CopyBB2FB() { fb_pixel_t *src, *dst, *topsrc; int fillcolor, i, screenwidth, swtmp; -#ifdef HAVE_SPARK_HARDWARE +#if defined(HAVE_SPARK_HARDWARE) || defined(BOXMODEL_CS_HD2) CFrameBuffer *f = CFrameBuffer::getInstance(); #endif @@ -5620,6 +5620,8 @@ void CopyBB2FB() #else #ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, 0, true); +#elif defined BOXMODEL_CS_HD2 + f->fbCopyArea(var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, var_screeninfo.yres); #else if ((uint32_t)stride > var_screeninfo.xres) { fb_pixel_t *lfb_ = lfb; @@ -5678,12 +5680,16 @@ void CopyBB2FB() if (screenmode == 1) { screenwidth = ( TV43STARTX ); -#ifdef HAVE_SPARK_HARDWARE +#if defined(HAVE_SPARK_HARDWARE) || defined(BOXMODEL_CS_HD2) int cx = var_screeninfo.xres - TV43STARTX; /* x start */ int cw = TV43STARTX; /* width */ int cy = StartY; int ch = 24*fontheight; +#endif +#ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, cw, ch, cx, cy, cx, cy, true); +#elif defined BOXMODEL_CS_HD2 + f->fbCopyArea(cw, ch, cx, cy, cx, cy+var_screeninfo.yres); #else fb_pixel_t *topdst = dst; size_t width = (ex - screenwidth) * sizeof(fb_pixel_t); diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index e0e87e042..3a86c8ffb 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -100,6 +100,7 @@ class CFbAccelCSHD1 inline void paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { paintLine(x, y, x+dx, y, col); }; inline void paintVLineRel(int x, int y, int dy, const fb_pixel_t col) { paintLine(x, y, x, y+dy, col); }; void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); void waitForIdle(const char *func = NULL); @@ -124,6 +125,7 @@ class CFbAccelCSHD2 void paintHLineRel(int x, int dx, int y, const fb_pixel_t col); void paintVLineRel(int x, int y, int dy, const fb_pixel_t col); void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); fb_pixel_t * getBackBufferPointer() const; diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index 142d9d1a2..956624c5a 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -262,6 +262,17 @@ void CFbAccelCSHD1::paintBoxRel(const int x, const int y, const int dx, const in checkFbArea(x, y, dx, dy, false); } +void CFbAccelCSHD1::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y) +{ + uint32_t w_, h_; + w_ = (width > xRes) ? xRes : width; + h_ = (height > yRes) ? yRes : height; + + //printf("\033[33m>>>>\033[0m [CFbAccelCSHD1::%s:%d] fb_copyarea w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); + printf("\033[31m>>>>\033[0m [CFbAccelCSHD1::%s:%d] sw blit w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); + CFrameBuffer::fbCopyArea(width, height, dst_x, dst_y, src_x, src_y); +} + void CFbAccelCSHD1::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 45514bb5e..d3979c5f3 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -141,6 +141,28 @@ void CFbAccelCSHD2::paintBoxRel(const int x, const int y, const int dx, const in checkFbArea(x, y, dx, dy, false); } +void CFbAccelCSHD2::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y) +{ + uint32_t w_, h_; + w_ = (width > xRes) ? xRes : width; + h_ = (height > yRes) ? yRes : height; + + if(!(w_%4)) { + fb_copyarea area; + area.dx = dst_x; + area.dy = dst_y; + area.width = w_; + area.height = h_; + area.sx = src_x; + area.sy = src_y; + ioctl(fd, FBIO_COPY_AREA, &area); + //printf("\033[33m>>>>\033[0m [CFbAccelCSHD2::%s:%d] fb_copyarea w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); + return; + } + //printf("\033[31m>>>>\033[0m [CFbAccelCSHD2::%s:%d] sw blit w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); + CFrameBuffer::fbCopyArea(width, height, dst_x, dst_y, src_x, src_y); +} + void CFbAccelCSHD2::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index e522e488a..367183a03 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -1598,6 +1598,62 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns return int_convertRGB2FB(rgbbuff, x, y, 0, true); } +void CFrameBuffer::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y) +{ + uint32_t w_, h_, i; + fb_pixel_t *fromBuf = NULL, *toBuf = NULL; + fb_pixel_t *dst_p, *src_p; + fb_pixel_t * fbp = getFrameBufferPointer(); + fb_pixel_t * bbp = getBackBufferPointer(); + w_ = (width > xRes) ? xRes : width; + h_ = (height > yRes) ? yRes : height; + + if ((src_y < yRes) && (dst_y < yRes)) { /* copy within framebuffer */ + fromBuf = fbp; + toBuf = fbp; + } + else if ((src_y >= yRes) && (dst_y >= yRes)) { /* copy within backbuffer */ + fromBuf = bbp; + toBuf = bbp; + dst_y -= yRes; + src_y -= yRes; + } + else if (src_y >= yRes) { /* copy backbuffer => framebuffer */ + fromBuf = bbp; + toBuf = fbp; + src_y -= yRes; + } + else if (dst_y >= yRes) { /* copy framebuffer => backbuffer */ + fromBuf = fbp; + toBuf = bbp; + dst_y -= yRes; + } + if ((fromBuf == NULL) || (toBuf == NULL)) { + //printf(">>>>> [%s:%d] buff = NULL\n", __func__, __LINE__); + return; + } + if ((src_x == dst_x) && (src_y == dst_y) && (fromBuf == toBuf)) { /* self copy? */ + //printf(">>>>> [%s:%d] self copy?\n", __func__, __LINE__); + return; + } + + dst_p = toBuf + dst_y*stride/sizeof(fb_pixel_t); + src_p = fromBuf + src_y*stride/sizeof(fb_pixel_t); + if ((w_ == xRes) && (stride == (xRes*sizeof(fb_pixel_t)))) { /* copy full width */ + //printf(">>>>> [%s:%d] copy full width - dst_p: %p, src_p: %p\n", __func__, __LINE__, dst_p, src_p); + memcpy(dst_p, src_p, w_*h_*sizeof(fb_pixel_t)); + } + else { /* copy all other */ + //printf(">>>>> [%s:%d] copy all other - dst_p: %p, src_p: %p\n", __func__, __LINE__, dst_p, src_p); + uint32_t wMem = w_*sizeof(fb_pixel_t); + for (i = 0; i < h_; i++) { + memcpy(dst_p+dst_x, src_p+src_x, wMem); + dst_p += stride/sizeof(fb_pixel_t); + src_p += stride/sizeof(fb_pixel_t); + } + } +} + void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool /*transp*/, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 111b89aa9..ce84653b1 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -273,6 +273,7 @@ class CFrameBuffer : public sigc::trackable 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); + virtual void fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y); virtual void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI virtual void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff);