fb_generic: add swidth variable, "stride in fb_pixel_t units"

this should allow to use fb_pixel_t pointer arithmetics more often
instead of byte pointers
This commit is contained in:
Stefan Seyfried
2017-02-15 20:30:52 +01:00
parent 1d9d81d448
commit a6fc59ad6c
8 changed files with 12 additions and 9 deletions

View File

@@ -82,7 +82,6 @@ void CFbAccel::paintBoxRel(const int x, const int y, const int dx, const int dy,
void CFbAccel::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col)
{
int line = 0;
int swidth = stride / sizeof(fb_pixel_t);
fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y);
int pos;
while (line < dy)

View File

@@ -335,6 +335,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int)
return -1;
}
stride = _fix.line_length;
swidth = stride / sizeof(fb_pixel_t);
if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0)
printf("screen unblanking failed\n");
xRes = screeninfo.xres;
@@ -344,7 +345,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int)
int needmem = stride * yRes * 2;
if (available >= needmem)
{
backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes;
backbuffer = lfb + swidth * yRes;
return 0;
}
fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem);

View File

@@ -194,6 +194,7 @@ int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int)
return -1;
}
stride = _fix.line_length;
swidth = stride / sizeof(fb_pixel_t);
if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0)
printf("screen unblanking failed\n");
xRes = screeninfo.xres;
@@ -203,7 +204,7 @@ int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int)
int needmem = stride * yRes * 2;
if (available >= needmem)
{
backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes;
backbuffer = lfb + swidth * yRes;
return 0;
}
fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem);

View File

@@ -54,6 +54,7 @@ void CFbAccelGLFB::init(const char *)
}
screeninfo = glfb->getScreenInfo();
stride = 4 * screeninfo.xres;
swidth = screeninfo.xres;
available = glfb->getOSDBuffer()->size(); /* allocated in glfb constructor */
lbb = lfb = reinterpret_cast<fb_pixel_t*>(glfb->getOSDBuffer()->data());
@@ -135,7 +136,7 @@ int CFbAccelGLFB::setMode(unsigned int, unsigned int, unsigned int)
int needmem = stride * yRes * 2;
if (available >= needmem)
{
backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes;
backbuffer = lfb + swidth * yRes;
return 0;
}
fprintf(stderr, LOGTAG " not enough FB memory (have %d, need %d)\n", available, needmem);

View File

@@ -512,6 +512,7 @@ int CFbAccelSTi::setMode(unsigned int, unsigned int, unsigned int)
yRes = screeninfo.yres = screeninfo.yres_virtual = DEFAULT_YRES;
bpp = screeninfo.bits_per_pixel = DEFAULT_BPP;
stride = screeninfo.xres * screeninfo.bits_per_pixel / 8;
swidth = screeninfo.xres;
return 0;
}

View File

@@ -156,6 +156,7 @@ void CFbAccelTD::init(const char *)
lbb = lfb; /* the memory area to draw to... */
available = fix.smem_len;
stride = fix.line_length;
swidth = stride / sizeof(fb_pixel_t);
xRes = screeninfo.xres;
yRes = screeninfo.yres;
bpp = screeninfo.bits_per_pixel;
@@ -169,7 +170,7 @@ int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int)
int needmem = stride * yRes * 2;
if (available >= needmem)
{
backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes;
backbuffer = lfb + swidth * yRes;
return 0;
}
fprintf(stderr, LOGTAG " not enough FB memory (have %d, need %d)\n", available, needmem);

View File

@@ -340,6 +340,7 @@ int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsign
}
stride = _fix.line_length;
swidth = stride / sizeof(fb_pixel_t);
printf("FB: %dx%dx%d line length %d. %s accelerator.\n", xRes, yRes, bpp, stride,
"Not using graphics"
);
@@ -623,7 +624,6 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
line++;
}
} else {
int swidth = stride / sizeof(fb_pixel_t);
fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y);
int line = 0;
while (line < dy) {
@@ -934,7 +934,7 @@ void CFrameBuffer::paintPixel(const int x, const int y, const fb_pixel_t col)
return;
fb_pixel_t * pos = getFrameBufferPointer();
pos += (stride / sizeof(fb_pixel_t)) * y;
pos += swidth * y;
pos += x;
*pos = col;
@@ -1624,7 +1624,6 @@ void CFrameBuffer::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t
uint32_t xc = (width > xRes) ? (uint32_t)xRes : width;
uint32_t yc = (height > yRes) ? (uint32_t)yRes : height;
uint32_t swidth = stride / sizeof(fb_pixel_t);
fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * yoff);
fb_pixel_t* data = (fb_pixel_t*)boxBuf;

View File

@@ -112,7 +112,7 @@ class CFrameBuffer : public sigc::trackable
fb_pixel_t backgroundColor;
std::string backgroundFilename;
bool useBackgroundPaint;
unsigned int xRes, yRes, stride, bpp;
unsigned int xRes, yRes, stride, swidth, bpp;
t_fb_var_screeninfo screeninfo;
fb_cmap cmap;
__u16 red[256], green[256], blue[256], trans[256];