spark: revert framebuffer scaling commits

we're going to use the STFB blitter instead of manually
scaling everything if the videomode is not 720p, so more
or less revert all commits regarding FB scaling:

Revert "fontrenderer: scale fonts for nonstandard FB resolutions"
Revert "neutrino: resize framebuffer on videomode change"
Revert "fontrenderer: fix issue with epgwindow font when FB is scaling"
Revert "neutrino: fix artefacts with scaling framebuffer and 1080i"
Revert "spark: draw lines 2px wide instead of 1 in full-HD mode"
Revert "spark: do not scale framebuffer for PAL mode"
Revert "spark: fix framebuffer glitches"
Revert "spark: do not sync blitter after every rectangle (improves performance)"
This commit is contained in:
Stefan Seyfried
2012-03-31 17:52:11 +02:00
parent 7a22a029d1
commit 7fcd36ed66
10 changed files with 46 additions and 197 deletions

View File

@@ -40,7 +40,6 @@ class CPrivateData
CFBWindow::CFBWindow(const int _x, const int _y, const int _dx, const int _dy)
{
int realx, realy;
x = _x ;
y = _y ;
dx = _dx;
@@ -48,9 +47,7 @@ CFBWindow::CFBWindow(const int _x, const int _y, const int _dx, const int _dy)
private_data = (void *) new CPrivateData;
((CPrivateData *)private_data)->frameBuffer = CFrameBuffer::getInstance();
realx = ((CPrivateData *)private_data)->frameBuffer->scaleX(_dx);
realy = ((CPrivateData *)private_data)->frameBuffer->scaleX(_dy);
((CPrivateData *)private_data)->Background = new fb_pixel_t [realx * realy];
((CPrivateData *)private_data)->Background = new fb_pixel_t [_dx * _dy];
if (((CPrivateData *)private_data)->Background != NULL)
((CPrivateData *)private_data)->frameBuffer->SaveScreen(_x, _y, _dx, _dy, ((CPrivateData *)private_data)->Background);

View File

@@ -37,9 +37,6 @@
#include <system/debug.h>
#include <global.h>
/* the multiplier for the SPARK scale feature */
#define SCALE_MULT 2048
/* Drawing pixels is actually faster without the GXA accelerator (wich OTOH is
faster for drawing lines, so disable it here. */
#undef USE_NEVIS_GXA
@@ -244,10 +241,6 @@ Font::Font(FBFontRenderClass *render, FTC_FaceID faceid, const int isize, const
scaler.x_res = render->xres;
scaler.y_res = render->yres;
xmult = frameBuffer->scaleX(SCALE_MULT, false);
ymult = frameBuffer->scaleY(SCALE_MULT, false);
last_xmult = xmult;
setSize(isize);
}
@@ -259,11 +252,9 @@ FT_Error Font::getGlyphBitmap(FT_ULong glyph_index, FTC_SBit *sbit)
int Font::setSize(int isize)
{
int temp = font.width;
last_size = isize;
font.width = isize * xmult / SCALE_MULT;
font.height = isize * ymult / SCALE_MULT;
scaler.width = font.width * 64;
scaler.height = font.height * 64;
font.width = font.height = isize;
scaler.width = isize * 64;
scaler.height = isize * 64;
FT_Error err = FTC_Manager_LookupSize(renderer->cacheManager, &scaler, &size);
if (err != 0)
@@ -313,17 +304,12 @@ return 0;
int Font::getWidth(void)
{
return fontwidth * SCALE_MULT / xmult;
}
int Font::getSize(void)
{
return font.width * SCALE_MULT / xmult;
return fontwidth;
}
int Font::getHeight(void)
{
return height * SCALE_MULT / ymult;
return height;
}
int Font::getDigitHeight(void)
@@ -381,24 +367,11 @@ int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on
return unicode_value;
}
void Font::RenderString(int _x, int _y, const int _width, const char *text, const unsigned char color, const int _boxheight, const bool utf8_encoded)
void Font::RenderString(int x, int y, const int width, const char *text, const unsigned char color, const int boxheight, const bool utf8_encoded)
{
if (!frameBuffer->getActive())
return;
if ((xmult = frameBuffer->scaleX(SCALE_MULT, false)) != last_xmult)
{
last_xmult = xmult;
ymult = frameBuffer->scaleY(SCALE_MULT, false);
setSize(last_size);
}
int x = _x * xmult / SCALE_MULT;
int y = _y * ymult / SCALE_MULT;
int boxheight = _boxheight * ymult / SCALE_MULT;
int width = _width * xmult / SCALE_MULT;
int step_y = height * ymult / SCALE_MULT;
pthread_mutex_lock( &renderer->render_mutex );
FT_Error err = FTC_Manager_LookupSize(renderer->cacheManager, &scaler, &size);
@@ -413,6 +386,7 @@ void Font::RenderString(int _x, int _y, const int _width, const char *text, cons
int use_kerning=FT_HAS_KERNING(face);
int left=x;
int step_y=height;
// ----------------------------------- box upper end (this is NOT a font metric, this is our method for y centering)
//
@@ -708,7 +682,7 @@ int Font::getRenderWidth(const char *text, const bool utf8_encoded)
pthread_mutex_unlock( &renderer->render_mutex );
return x * SCALE_MULT / xmult;
return x;
}
int Font::getRenderWidth(const std::string & text, const bool utf8_encoded)

View File

@@ -53,8 +53,6 @@ class Font
// these are HACKED values, because the font metrics were unusable.
int height,DigitHeight,DigitOffset,ascender,descender,upper,lower;
int fontwidth;
int xmult, ymult;
int last_xmult, last_size;
public:
enum fontmodifier
@@ -73,7 +71,7 @@ class Font
int getDigitHeight(void);
int getDigitOffset(void);
int getWidth(void);
int getSize(void);
int getSize(){return font.width;}
int setSize(int isize);
Font(FBFontRenderClass *render, FTC_FaceID faceid, const int isize, const fontmodifier _stylemodifier);

View File

@@ -1797,7 +1797,7 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns
}
#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, bool /*scale*/)
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;
@@ -1850,7 +1850,7 @@ void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32
#endif
}
#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, bool /*scale*/)
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)
{
DFBRectangle src;
DFBResult err;

View File

@@ -229,7 +229,7 @@ class CFrameBuffer
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);
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);
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 blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh);
#if HAVE_SPARK_HARDWARE

View File

@@ -64,9 +64,8 @@ static int bpafd = -1;
static fb_pixel_t *backbuffer = NULL;
static int fake_xRes = 0;
static int fake_yRes = 0;
static int fake_stride = 0;
static int backbuf_sz = 0;
static int max_backbuf_sz = 0;
static bool scaling = false;
void CFrameBuffer::waitForIdle(void)
{
@@ -156,26 +155,12 @@ void CFrameBuffer::init(const char * const fbDevice)
stride = xRes * bpp / 8;
printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
/* PAL and 720p mode is unscaled, but 1080 modes are not */
scaling = (xRes > 1280);
if (xRes > 720)
{
/* HDTV mode */
fake_xRes = DEFAULT_XRES;
fake_yRes = DEFAULT_YRES;
screeninfo.xres = DEFAULT_XRES;
screeninfo.yres = DEFAULT_YRES;
screeninfo.xres_virtual = DEFAULT_XRES;
screeninfo.yres_virtual = DEFAULT_YRES;
}
else
{
/* PAL mode */
fake_xRes = xRes;
fake_yRes = yRes;
}
screeninfo.bits_per_pixel = 32;
backbuf_sz = stride * yRes;
@@ -206,9 +191,7 @@ printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
}
BPAMemAllocMemData bpa_data;
bpa_data.bpa_part = (char *)"LMI_VID";
/* allocate maximum possibly needed amount of memory */
max_backbuf_sz = 1920 * 1080 * sizeof(fb_pixel_t);
bpa_data.mem_size = max_backbuf_sz;
bpa_data.mem_size = backbuf_sz;
int res;
res = ioctl(bpafd, BPAMEMIO_ALLOCMEM, &bpa_data);
if (res)
@@ -239,7 +222,7 @@ printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
return;
}
memset(backbuffer, 0, max_backbuf_sz);
memset(backbuffer, 0, backbuf_sz);
cache_size = 0;
/* Windows Colors */
@@ -317,7 +300,7 @@ CFrameBuffer::~CFrameBuffer()
if (backbuffer)
{
fprintf(stderr, "CFrameBuffer: unmap backbuffer\n");
munmap(backbuffer, max_backbuf_sz);
munmap(backbuffer, backbuf_sz);
}
if (bpafd != -1)
{
@@ -501,15 +484,10 @@ void CFrameBuffer::paintBoxRel(const int _x, const int _y, const int _dx, const
if (!getActive())
return;
int add = 0;
/* hack to remove artefacts caused by rounding in scaling mode */
if (scaling && col == backgroundColor)
add = 1;
int x = scaleX(_x);
int y = scaleY(_y);
int dx = scaleX(_dx + add);
int dy = scaleY(_dy + add);
int dx = scaleX(_dx);
int dy = scaleY(_dy);
int radius = scaleX(_radius);
int corner_tl = (type & CORNER_TOP_LEFT) ? 1 : 0;
@@ -615,12 +593,6 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co
if (!getActive())
return;
int d = scaleX(1);
xa = scaleX(xa);
xb = scaleX(xb);
ya = scaleY(ya);
yb = scaleY(yb);
int dx = abs (xa - xb);
int dy = abs (ya - yb);
int x;
@@ -649,10 +621,7 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co
step = yb < ya ? -1 : 1;
}
if (d == 1)
paintPixel(x, y, col);
else
blitRect(x, y, 2, 2, col);
while (x < End)
{
@@ -664,10 +633,7 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co
y += step;
p += twoDyDx;
}
if (d == 1)
paintPixel(x, y, col);
else
blitRect(x, y, 2, 2, col);
}
}
else
@@ -691,10 +657,7 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co
step = xb < xa ? -1 : 1;
}
if (d == 1)
paintPixel(x, y, col);
else
blitRect(x, y, 2, 2, col);
while (y < End)
{
@@ -706,10 +669,7 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co
x += step;
p += twoDxDy;
}
if (d == 1)
paintPixel(x, y, col);
else
blitRect(x, y, 2, 2, col);
}
}
}
@@ -726,8 +686,7 @@ void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col)
int _x = scaleX(x);
int _y = scaleY(y);
int _dy = scaleY(dy);
int w = scaleX(1);
blitRect(_x, _y, w, _dy, col);
blitRect(_x, _y, 1, _dy, col);
}
void CFrameBuffer::paintHLine(int xa, int xb, int y, const fb_pixel_t col)
@@ -741,9 +700,8 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col)
return;
int _x = scaleX(x);
int _y = scaleY(y);
int _dx = scaleX(dx);
int w = scaleY(1);
blitRect(_x, _y, _dx, w, col);
int _dx = scaleY(dx);
blitRect(_x, _y, _dx, 1, col);
}
void CFrameBuffer::setIconBasePath(const std::string & iconPath)
@@ -1277,7 +1235,7 @@ void CFrameBuffer::paintBackground()
}
else
{
paintBoxRel(0, 0, screeninfo.xres, screeninfo.yres, backgroundColor);
paintBoxRel(0, 0, xRes, yRes, backgroundColor);
}
}
@@ -1286,12 +1244,6 @@ void CFrameBuffer::SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const m
if (!getActive())
return;
/* danger: memp needs to be big enough for scaled picture...
* need to make sure all callers know this... */
x = scaleX(x);
y = scaleY(y);
dx = scaleX(dx);
dy = scaleY(dy);
uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y;
fb_pixel_t * bkpos = memp;
@@ -1324,13 +1276,6 @@ void CFrameBuffer::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * cons
if (!getActive())
return;
/* danger: memp needs to be big enough for scaled picture...
* need to make sure all callers know this... */
x = scaleX(x);
y = scaleY(y);
dx = scaleX(dx);
dy = scaleY(dy);
uint8_t * fbpos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y;
fb_pixel_t * bkpos = memp;
for (int count = 0; count < dy; count++)
@@ -1437,23 +1382,13 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns
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, bool scale)
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 x, y, dw, dh;
if (scale)
{
x = scaleX(xoff);
y = scaleY(yoff);
dw = scaleX(width - xp);
dh = scaleY(height - yp);
}
else
{
x = xoff;
y = yoff;
dw = width - xp;
dh = height - yp;
}
size_t mem_sz = width * height * sizeof(fb_pixel_t);
unsigned long ulFlags = 0;
@@ -1487,7 +1422,7 @@ void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32
blt_data.dstMemSize = stride * yRes;
// icons are so small that they will still be in cache
msync(backbuffer, mem_sz, MS_SYNC);
msync(backbuffer, backbuf_sz, MS_SYNC);
if(ioctl(fd, STMFBIO_BLT_EXTERN, &blt_data) < 0)
perror("blit2FB FBIO_BLIT");
@@ -1564,46 +1499,6 @@ void CFrameBuffer::resize(int format)
yRes = xyres[format][1];
bpp = 32;
stride = xRes * bpp / 8;
fprintf(stderr, "CFrameBuffer::resize(%d): %d x %d\n", format, xRes, yRes);
/* reacquire parameters...
* TODO: this is duplicated code from ::init() function */
if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo) < 0)
perror("FBIOGET_VSCREENINFO");
xRes = screeninfo.xres;
yRes = screeninfo.yres;
bpp = 32;
stride = xRes * bpp / 8;
scaling = (xRes > 1280);
if (xRes > 720)
{
fake_xRes = DEFAULT_XRES;
fake_yRes = DEFAULT_YRES;
screeninfo.xres = DEFAULT_XRES;
screeninfo.yres = DEFAULT_YRES;
screeninfo.xres_virtual = DEFAULT_XRES;
screeninfo.yres_virtual = DEFAULT_YRES;
}
else
{
fake_xRes = xRes;
fake_yRes = yRes;
}
printf("FB:resize %dx%dx%d line length %d. scaling: %d\n", xRes, yRes, bpp, stride, scaling);
screeninfo.bits_per_pixel = 32;
backbuf_sz = stride * yRes;
int p = (xRes > 720); /* 0 == SDTV, 1 == HDTV */
g_settings.screen_preset = p;
g_settings.screen_StartX = p ? g_settings.screen_StartX_lcd : g_settings.screen_StartX_crt;
g_settings.screen_StartY = p ? g_settings.screen_StartY_lcd : g_settings.screen_StartY_crt;
g_settings.screen_EndX = p ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt;
g_settings.screen_EndY = p ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt;
}
void CFrameBuffer::blitRect(int x, int y, int width, int height, unsigned long color)
@@ -1659,11 +1554,10 @@ void CFrameBuffer::blitIcon(int src_width, int src_height, int fb_x, int fb_y, i
blt_data.srcMemSize = backbuf_sz;
blt_data.dstMemSize = stride * yRes;
msync(backbuffer, blt_data.srcPitch * src_height, MS_SYNC);
msync(backbuffer, backbuf_sz, MS_SYNC);
if(ioctl(fd, STMFBIO_BLT_EXTERN, &blt_data) < 0)
perror("blit_icon FBIO_BLIT");
ioctl(fd, STMFBIO_SYNC_BLITTER);
}
void CFrameBuffer::update(void)
@@ -1673,8 +1567,6 @@ void CFrameBuffer::update(void)
int CFrameBuffer::scaleX(const int x, bool clamp)
{
if (!scaling)
return x;
unsigned int mul = x * xRes;
mul = mul / DEFAULT_XRES + (((mul % DEFAULT_XRES) >= (DEFAULT_XRES / 2)) ? 1 : 0);
if (clamp && mul > xRes)
@@ -1684,8 +1576,6 @@ int CFrameBuffer::scaleX(const int x, bool clamp)
int CFrameBuffer::scaleY(const int y, bool clamp)
{
if (!scaling)
return y;
unsigned int mul = y * yRes;
mul = mul / DEFAULT_YRES + (((mul % DEFAULT_YRES) >= (DEFAULT_YRES / 2)) ? 1 : 0);
if (clamp && mul > yRes)

View File

@@ -1022,12 +1022,9 @@ void CInfoViewer::showSubchan ()
y = g_settings.screen_EndY - dy - 10;
}
int x_pic = lframeBuffer->scaleX(dx + 2 * borderwidth);
int y_pic = lframeBuffer->scaleY(dy + 2 * borderwidth);
fb_pixel_t *pixbuf = new fb_pixel_t[x_pic * y_pic];
if (pixbuf)
lframeBuffer->SaveScreen(x - borderwidth, y - borderwidth,
dx + 2 * borderwidth, dy + 2 * borderwidth, pixbuf);
fb_pixel_t pixbuf[(dx + 2 * borderwidth) * (dy + 2 * borderwidth)];
lframeBuffer->SaveScreen (x - borderwidth, y - borderwidth, dx + 2 * borderwidth, dy + 2 * borderwidth, pixbuf);
// clear border
lframeBuffer->paintBackgroundBoxRel (x - borderwidth, y - borderwidth, dx + 2 * borderwidth, borderwidth);
lframeBuffer->paintBackgroundBoxRel (x - borderwidth, y + dy, dx + 2 * borderwidth, borderwidth);
@@ -1066,11 +1063,7 @@ void CInfoViewer::showSubchan ()
}
}
}
if (pixbuf) {
lframeBuffer->RestoreScreen(x - borderwidth, y - borderwidth,
dx + 2 * borderwidth, dy + 2 * borderwidth, pixbuf);
delete[] pixbuf;
}
lframeBuffer->RestoreScreen (x - borderwidth, y - borderwidth, dx + 2 * borderwidth, dy + 2 * borderwidth, pixbuf);
}
} else {
g_RCInput->postMsg (NeutrinoMessages::SHOW_INFOBAR, 0);

View File

@@ -318,7 +318,6 @@ void CVideoSettings::setupVideoSystem(bool do_ask)
{
printf("[neutrino VideoSettings] %s setup videosystem...\n", __FUNCTION__);
videoDecoder->SetVideoSystem(g_settings.video_Mode); //FIXME
frameBuffer->resize(g_settings.video_Mode);
if (do_ask)
{
@@ -329,7 +328,6 @@ void CVideoSettings::setupVideoSystem(bool do_ask)
{
g_settings.video_Mode = prev_video_mode;
videoDecoder->SetVideoSystem(g_settings.video_Mode);
frameBuffer->resize(g_settings.video_Mode);
}
}
else
@@ -493,7 +491,6 @@ void CVideoSettings::nextMode(void)
g_settings.video_Mode = VIDEOMENU_VIDEOMODE_OPTIONS[curmode].key;
//CVFD::getInstance()->ShowText(text);
videoDecoder->SetVideoSystem(g_settings.video_Mode);
frameBuffer->resize(g_settings.video_Mode);
//return;
disp_cur = 1;
}

View File

@@ -996,7 +996,7 @@ void CMenuWidget::saveScreen()
delete[] background;
background = new fb_pixel_t [frameBuffer->scaleX(full_width) * frameBuffer->scaleY(full_height)];
background = new fb_pixel_t [full_width * full_height];
if(background)
frameBuffer->SaveScreen(x, y, full_width, full_height, background);
}

View File

@@ -888,7 +888,7 @@ const char * CPLPINInput::getHint1(void)
int CPLPINInput::exec( CMenuTarget* parent, const std::string & )
{
fb_pixel_t * pixbuf = new fb_pixel_t[frameBuffer->scaleX(width+ 2* borderwidth) * frameBuffer->scaleY(height+ 2* borderwidth)];
fb_pixel_t * pixbuf = new fb_pixel_t[(width+ 2* borderwidth) * (height+ 2* borderwidth)];
if (pixbuf != NULL)
frameBuffer->SaveScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf);