framebuffer: make blit2FB usable for tuxtxt

This commit is contained in:
Stefan Seyfried
2012-03-11 18:23:46 +01:00
parent 26f85435a8
commit 47f09004d8
3 changed files with 38 additions and 11 deletions

View File

@@ -460,6 +460,11 @@ fb_pixel_t * CFrameBuffer::getFrameBufferPointer() const
return (fb_pixel_t *) virtual_fb; return (fb_pixel_t *) virtual_fb;
} }
fb_pixel_t * CFrameBuffer::getBackBufferPointer() const
{
return lfb + xRes * yRes;
}
bool CFrameBuffer::getActive() const bool CFrameBuffer::getActive() const
{ {
return (active || (virtual_fb != NULL)); return (active || (virtual_fb != NULL));
@@ -1790,7 +1795,7 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns
} }
#if !HAVE_TRIPLEDRAGON #if !HAVE_TRIPLEDRAGON
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) 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, bool /*scale*/)
{ {
int xc, yc; int xc, yc;
@@ -1843,7 +1848,7 @@ void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32
#endif #endif
} }
#else #else
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) 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, bool /*scale*/)
{ {
DFBRectangle src; DFBRectangle src;
DFBResult err; DFBResult err;

View File

@@ -138,6 +138,7 @@ class CFrameBuffer
t_fb_var_screeninfo *getScreenInfo(); t_fb_var_screeninfo *getScreenInfo();
fb_pixel_t * getFrameBufferPointer() const; // pointer to framebuffer fb_pixel_t * getFrameBufferPointer() const; // pointer to framebuffer
fb_pixel_t * getBackBufferPointer() const; // pointer to backbuffer
unsigned int getStride() const; // size of a single line in the framebuffer (in bytes) unsigned int getStride() const; // size of a single line in the framebuffer (in bytes)
unsigned int getScreenWidth(bool real = false); unsigned int getScreenWidth(bool real = false);
unsigned int getScreenHeight(bool real = false); unsigned int getScreenHeight(bool real = false);
@@ -228,7 +229,7 @@ class CFrameBuffer
void* convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp = 0xFF); 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* 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); 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);
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 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, bool scale = true);
bool blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh); bool blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh);
#if HAVE_SPARK_HARDWARE #if HAVE_SPARK_HARDWARE

View File

@@ -371,6 +371,11 @@ fb_pixel_t * CFrameBuffer::getFrameBufferPointer() const
return (fb_pixel_t *) virtual_fb; return (fb_pixel_t *) virtual_fb;
} }
fb_pixel_t * CFrameBuffer::getBackBufferPointer() const
{
return backbuffer;
}
bool CFrameBuffer::getActive() const bool CFrameBuffer::getActive() const
{ {
return (active || (virtual_fb != NULL)); return (active || (virtual_fb != NULL));
@@ -1430,20 +1435,36 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns
return int_convertRGB2FB(rgbbuff, x, y, 0, true); return int_convertRGB2FB(rgbbuff, x, y, 0, true);
} }
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) 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, bool scale)
{ {
int x = scaleX(xoff); int x, y, dw, dh;
int y = scaleY(yoff); if (scale)
int dw = scaleX(width - xp); {
int dh = scaleY(height - yp); x = scaleX(xoff);
size_t mem_sz = width * height * sizeof(fb_pixel_t); y = scaleY(yoff);
dw = scaleX(width - xp);
dh = scaleY(height - yp);
}
else
{
x = xoff;
y = yoff;
dw = width - xp;
dh = height - yp;
}
memcpy(backbuffer, fbbuff, mem_sz); size_t mem_sz = width * height * sizeof(fb_pixel_t);
unsigned long ulFlags = 0;
if (transp) /* transp == true means: color "0x0" is transparent (??) */
ulFlags = BLT_OP_FLAGS_BLEND_SRC_ALPHA|BLT_OP_FLAGS_BLEND_DST_MEMORY; // we need alpha blending
if (fbbuff != backbuffer)
memmove(backbuffer, fbbuff, mem_sz);
STMFBIO_BLT_EXTERN_DATA blt_data; STMFBIO_BLT_EXTERN_DATA blt_data;
memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA));
blt_data.operation = BLT_OP_COPY; blt_data.operation = BLT_OP_COPY;
blt_data.ulFlags = BLT_OP_FLAGS_BLEND_SRC_ALPHA | BLT_OP_FLAGS_BLEND_DST_MEMORY; // we need alpha blending blt_data.ulFlags = ulFlags;
blt_data.srcOffset = 0; blt_data.srcOffset = 0;
blt_data.srcPitch = width * 4; blt_data.srcPitch = width * 4;
blt_data.dstOffset = 0; blt_data.dstOffset = 0;