mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
framebuffer: Add fbCopyArea function
- Copies areas within the frame buffer - Hardware accelerated function for cs hd2 - Copying overlapping areas does not always work correctly without hardware acceleration
This commit is contained in:
@@ -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);
|
||||
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);
|
||||
@@ -123,6 +124,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);
|
||||
void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff);
|
||||
fb_pixel_t * getBackBufferPointer() const;
|
||||
|
@@ -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)
|
||||
{
|
||||
int xc, yc;
|
||||
|
@@ -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)
|
||||
{
|
||||
int xc, yc;
|
||||
|
@@ -1580,6 +1580,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*/)
|
||||
{
|
||||
int xc, yc;
|
||||
|
@@ -266,6 +266,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);
|
||||
virtual void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff);
|
||||
|
||||
|
Reference in New Issue
Block a user