diff --git a/acinclude.m4 b/acinclude.m4 index 682013818..c4c51c7dc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -539,7 +539,7 @@ AC_ARG_WITH(boxmodel, *) AC_MSG_ERROR([unsupported value $withval for --with-boxmodel]) ;; - esac], [BOXMODEL="hd1"] + esac], [test "$BOXTYPE" = "coolstream" && BOXMODEL="hd1" || true] [if test "$BOXTYPE" = "dreambox" -o "$BOXTYPE" = "ipbox" && test -z "$BOXMODEL"; then AC_MSG_ERROR([Dreambox/IPBox needs --with-boxmodel]) fi]) diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 3c74544b8..2b6d016fa 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -49,7 +49,7 @@ static int screen_x, screen_y, screen_w, screen_h; //#define USE_FBPAN // FBIOPAN_DISPLAY seems to be working in current driver -unsigned char *getFBp(int *y) +fb_pixel_t *getFBp(int *y) { if (*y < (int)var_screeninfo.yres) return lfb; @@ -60,20 +60,15 @@ unsigned char *getFBp(int *y) void FillRect(int x, int y, int w, int h, int color) { - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x*4 + y * fix_screeninfo.line_length; -#if !HAVE_TRIPLEDRAGON - unsigned int col = bgra[color][3] << 24 | bgra[color][2] << 16 | bgra[color][1] << 8 | bgra[color][0]; -#else - unsigned int col = *((unsigned int*)bgra[color]); -#endif + p += x + y * stride; if (w > 0) for (int count = 0; count < h; count++) { - unsigned int * dest0 = (unsigned int *)p; + fb_pixel_t *dest0 = p; for (int i = 0; i < w; i++) - *(dest0++) = col; - p += fix_screeninfo.line_length; + *(dest0++) = bgra[color]; + p += stride; } } @@ -319,25 +314,14 @@ void setfontwidth(int newwidth) } } -#if HAVE_TRIPLEDRAGON -#define _A 0 -#define _R 1 -#define _G 2 -#define _B 3 -#else -#define _A 3 -#define _R 2 -#define _G 1 -#define _B 0 -#endif void setcolors(unsigned short *pcolormap, int offset, int number) { - int i,trans_tmp; + int i,trans_tmp,tr; int j = offset; /* index in global color table */ - - trans_tmp=25-trans_mode; - - bgra[transp2][_A]=((trans_tmp+7)<<11 | 0x7FF)>>8; + int R = var_screeninfo.red.offset; + int G = var_screeninfo.green.offset; + int B = var_screeninfo.blue.offset; + int A = var_screeninfo.transp.offset; for (i = 0; i < number; i++) { @@ -348,13 +332,17 @@ void setcolors(unsigned short *pcolormap, int offset, int number) r = (r * (0x3f+(color_mode<<3))) >> 8; g = (g * (0x3f+(color_mode<<3))) >> 8; b = (b * (0x3f+(color_mode<<3))) >> 8; - - bgra[j][_R]=r; - bgra[j][_G]=g; - bgra[j][_B]=b; - + bgra[j] = (r << R) | (g << G) | (b << B) | (0xff << A); j++; } + trans_tmp=25-trans_mode; + tr = ((trans_tmp+7)<<11 | 0x7FF)>>8; + bgra[transp2] &= ~(0xff << A); /* clear alpha */ + bgra[transp2] |= tr << A; + bgra[menu3] &= ~(0xff << A); + bgra[menu3] |= 0xc0 << A; + bgra[transp] &= ~(0xff << A); + bgra[transp] |= 0; } /* hexdump of page contents to stdout for debugging */ @@ -1666,8 +1654,8 @@ int tuxtx_main(int /*_rc*/, int pid, int page, int source) #endif CFrameBuffer *fbp = CFrameBuffer::getInstance(); - lfb = (unsigned char *)fbp->getFrameBufferPointer(); - lbb = (unsigned char *)fbp->getBackBufferPointer(); + lfb = fbp->getFrameBufferPointer(); + lbb = fbp->getBackBufferPointer(); tuxtxt_cache.vtxtpid = pid; @@ -1693,6 +1681,8 @@ int tuxtx_main(int /*_rc*/, int pid, int page, int source) #else struct fb_var_screeninfo *var; var = fbp->getScreenInfo(); + /* this is actually the length of the screen in pixels */ + stride = fbp->getStride() / sizeof(fb_pixel_t); memcpy(&var_screeninfo, var, sizeof(struct fb_var_screeninfo)); fix_screeninfo.line_length = var_screeninfo.xres * sizeof(fb_pixel_t); #endif @@ -4117,7 +4107,7 @@ void SwitchHintMode() void RenderDRCS( //FIX ME unsigned char *s, /* pointer to char data, parity undecoded */ - unsigned char *d, /* pointer to frame buffer of top left pixel */ + fb_pixel_t *d, /* pointer to frame buffer of top left pixel */ unsigned char *ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */ unsigned char fgcolor, unsigned char bgcolor) { @@ -4149,52 +4139,45 @@ void RenderDRCS( //FIX ME { // memset(d + ax[x], f1, ax[x+1] - ax[x]); for (ltmp=0 ; ltmp <= (ax[x+1]-ax[x]); ltmp++) - { - memmove(d + ax[x]*4 +ltmp*4,bgra[f1],4); - } + *(d + ax[x] + ltmp) = bgra[f1]; } if (ax[x+7] > ax[x+6]) { // memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */ for (ltmp=0 ; ltmp <= (ax[x+7]-ax[x+6]); ltmp++) - { - memmove(d + ax[x+6]*4 +ltmp*4,bgra[f2],4); - } - + *(d + ax[x+6] + ltmp) = bgra[f2]; } - d += fix_screeninfo.line_length; + d += stride; } - d -= h * fix_screeninfo.line_length; + d -= h * stride; } - d += h * fix_screeninfo.line_length; + d += h * stride; } } void DrawVLine(int x, int y, int l, int color) { - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, 0, l); - p += x*4 + y * fix_screeninfo.line_length; + p += x + y * stride; for ( ; l > 0 ; l--) { - memmove(p,bgra[color],4); - p += fix_screeninfo.line_length; + *p = bgra[color]; + p += stride; } } void DrawHLine(int x, int y, int l, int color) { int ltmp; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, l, 0); if (l > 0) { for (ltmp=0; ltmp <= l; ltmp++) - { - memmove(p + x*4 + ltmp*4 + y * fix_screeninfo.line_length, bgra[color], 4); - } + *(p + x + ltmp + y * stride) = bgra[color]; } } @@ -4209,9 +4192,9 @@ void FillRectMosaicSeparated(int x, int y, int w, int h, int fgcolor, int bgcolo void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, int color) { - unsigned char *p = getFBp(&y0); + fb_pixel_t *p = getFBp(&y0); MARK_FB(x0, y0, l0, h); - p += x0 * 4 + y0 * fix_screeninfo.line_length; + p += x0 + y0 * stride; int xoffset, l; int yoffset; @@ -4224,19 +4207,17 @@ void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, int color) if (l > 0) { for (ltmp=0; ltmp <= l; ltmp++) - { - memmove(p + xoffset*4 +ltmp*4, bgra[color], 4); - } + *(p + xoffset + ltmp) = bgra[color]; } - p += fix_screeninfo.line_length; + p += stride; } } void FlipHorz(int x, int y, int w, int h) { unsigned char *buf= new unsigned char[w*4]; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x * 4 + y * fix_screeninfo.line_length; + p += x + y * stride; int w1,h1; if(buf != NULL){ @@ -4245,9 +4226,9 @@ void FlipHorz(int x, int y, int w, int h) memmove(buf,p,w*4); for (w1 = 0 ; w1 < w ; w1++) { - memmove(p+w1*4,buf+((w-w1)*4)-4,4); + memmove(p + w1,buf+((w-w1)*4)-4,4); } - p += fix_screeninfo.line_length; + p += stride; } delete [] buf; } @@ -4255,17 +4236,17 @@ void FlipHorz(int x, int y, int w, int h) void FlipVert(int x, int y, int w, int h) { unsigned char *buf= new unsigned char[w*4]; - unsigned char *p1, *p2; - unsigned char *p = getFBp(&y); + fb_pixel_t *p1, *p2; + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x*4 + y * fix_screeninfo.line_length; + p += x + y * stride; int h1; if(buf != NULL){ for (h1 = 0 ; h1 < h/2 ; h1++) { - p1 = (p+(h1*fix_screeninfo.line_length)); - p2 = (p+(h-(h1+1))*fix_screeninfo.line_length); + p1 = (p + (h1 * stride)); + p2 = (p + (h - (h1 + 1)) * stride); memmove(buf,p1,w*4); memmove(p1,p2,w*4); memmove(p2,buf,w*4); @@ -4521,9 +4502,9 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { int x,y,f,c; y = yoffset; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(PosX, PosY, curfontwidth, fontheight); - p += PosX * 4 + PosY * fix_screeninfo.line_length; + p += PosX + PosY * stride; for (y=0; ytop + TTFShiftY); @@ -4848,18 +4829,18 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) int y = yoffset; p = getFBp(&y); - p += PosX * 4 + (PosY + Row) * fix_screeninfo.line_length; /* running pointer into framebuffer */ + p += PosX + (PosY + Row) * stride; /* running pointer into framebuffer */ for (Row = sbit->height; Row; Row--) /* row counts up, but down may be a little faster :) */ { int pixtodo = (usettf ? sbit->width : curfontwidth); - char *pstart = (char*) p; + fb_pixel_t *pstart = p; for (Bit = xfactor * (sbit->left + TTFShiftX); Bit > 0; Bit--) /* fill left margin */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[bgcolor],4);/*bgcolor*/ - p+=4; + *(p + f * stride) = bgra[bgcolor]; + p++; if (!usettf) pixtodo--; } @@ -4879,14 +4860,14 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) color = bgcolor; for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[color],4); - p+=4; + *(p + f * stride) = bgra[color]; + p++; if (xfactor > 1) /* double width */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[color],4); - p+=4; + *(p + f * stride) = bgra[color]; + p++; if (!usettf) pixtodo--; @@ -4898,11 +4879,11 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) Bit > 0; Bit--) /* fill rest of char width */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[bgcolor],4); - p+=4; + *(p + f * stride) = bgra[bgcolor]; + p++; } - p = (unsigned char*) pstart + factor*fix_screeninfo.line_length; + p = pstart + factor * stride; } Row = ascender - sbit->top + sbit->height + TTFShiftY; @@ -5612,7 +5593,7 @@ void CreateLine25() void CopyBB2FB() { - unsigned char *src, *dst, *topsrc; + fb_pixel_t *src, *dst, *topsrc; int fillcolor, i, screenwidth, swtmp; #ifdef HAVE_SPARK_HARDWARE CFrameBuffer *f = CFrameBuffer::getInstance(); @@ -5640,7 +5621,17 @@ void CopyBB2FB() #ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, 0, true); #else - memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); + if ((uint32_t)stride > var_screeninfo.xres) { + fb_pixel_t *lfb_ = lfb; + fb_pixel_t *lbb_ = lbb; + for (uint32_t i1 = 0; i1 < var_screeninfo.yres; i1++) { + memcpy(lfb_, lbb_, var_screeninfo.xres * sizeof(fb_pixel_t)); + lfb_ += stride; + lbb_ += stride; + } + } + else + memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); #endif #endif @@ -5658,8 +5649,8 @@ void CopyBB2FB() return; } - src = topsrc = lbb + StartY * fix_screeninfo.line_length; - dst = lfb + StartY * fix_screeninfo.line_length; + src = topsrc = lbb + StartY * stride; + dst = lfb + StartY * stride; #ifdef USE_FBPAN #error USE_FBPAN code is not working right now. @@ -5673,7 +5664,7 @@ void CopyBB2FB() #endif /* copy line25 in normal height */ if (!pagecatching ) - memmove(dst+(24*fontheight)*fix_screeninfo.line_length, src + (24*fontheight)*fix_screeninfo.line_length, fix_screeninfo.line_length*fontheight); + memmove(dst + (24 * fontheight) * stride, src + (24 * fontheight) * stride, stride * fontheight); if (transpmode) fillcolor = transp; @@ -5681,12 +5672,12 @@ void CopyBB2FB() fillcolor = FullScrColor; if (zoommode == 2) - src += 12*fontheight*fix_screeninfo.line_length; + src += 12 * fontheight * stride; /* copy topmenu in normal height (since PIG also keeps dimensions) */ if (screenmode == 1) { - screenwidth = ( TV43STARTX ) * 4; + screenwidth = ( TV43STARTX ); #ifdef HAVE_SPARK_HARDWARE int cx = var_screeninfo.xres - TV43STARTX; /* x start */ int cw = TV43STARTX; /* width */ @@ -5694,47 +5685,43 @@ void CopyBB2FB() int ch = 24*fontheight; f->blit2FB(lbb, cw, ch, cx, cy, cx, cy, true); #else - unsigned char *topdst = dst; - size_t width = ex * sizeof(fb_pixel_t) - screenwidth; + fb_pixel_t *topdst = dst; + size_t width = (ex - screenwidth) * sizeof(fb_pixel_t); topsrc += screenwidth; topdst += screenwidth; for (i=0; i < 24*fontheight; i++) { memmove(topdst, topsrc, width); - topdst += fix_screeninfo.line_length; - topsrc += fix_screeninfo.line_length; + topdst += stride; + topsrc += stride; } #endif } else if (screenmode == 2) - screenwidth = ( TV169FULLSTARTX ) * 4; + screenwidth = ( TV169FULLSTARTX ); else - screenwidth = fix_screeninfo.line_length;//var_screeninfo.xres; + screenwidth = stride; for (i = StartY; i>0;i--) { for (swtmp=0; swtmp<=screenwidth; swtmp++) - { - memmove(dst - i*fix_screeninfo.line_length+swtmp*4, bgra[fillcolor], 4); - } + *(dst - i * stride + swtmp) = bgra[fillcolor]; } for (i = 12*fontheight; i; i--) { - memmove(dst, src, screenwidth); - dst += fix_screeninfo.line_length; - memmove(dst, src, screenwidth); - dst += fix_screeninfo.line_length; - src += fix_screeninfo.line_length; + memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); + dst += stride; + memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); + dst += stride; + src += stride; } for (i = var_screeninfo.yres - StartY - 25*fontheight; i >= 0;i--) { for (swtmp=0; swtmp<= screenwidth;swtmp++) - { - memmove(dst + fix_screeninfo.line_length*(fontheight+i)+swtmp*4, bgra[fillcolor], 4); - } + *(dst + stride * (fontheight + i) + swtmp) = bgra[fillcolor]; } #ifdef HAVE_SPARK_HARDWARE f->mark(0, 0, var_screeninfo.xres, var_screeninfo.yres); @@ -6056,8 +6043,8 @@ void DecodePage() RenderDRCS( page_char + 20 * (DRCSCOLS * row + col + 2), lfb - + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * fix_screeninfo.line_length - + (StartX + DRCSXSPC * col)*4, + + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * stride + + (StartX + DRCSXSPC * col), ax, white, black); memset(page_char + 40, 0xff, 24*40); /* don't render any char below row 0 */ diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index 1a6974c86..b347d6420 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -247,10 +247,11 @@ const char *ObjectType[] = #define NoServicesFound 3 /* framebuffer stuff */ -static unsigned char *lfb = 0; -static unsigned char *lbb = 0; +static fb_pixel_t *lfb = 0; +static fb_pixel_t *lbb = 0; struct fb_var_screeninfo var_screeninfo; struct fb_fix_screeninfo fix_screeninfo; +int stride; /* freetype stuff */ FT_Library library; @@ -1248,33 +1249,8 @@ const unsigned short defaultcolors[] = /* 0x0bgr */ 0x420, 0x210, 0x420, 0x000, 0x000 }; -#if !HAVE_TRIPLEDRAGON -/* 32bit colortable */ -unsigned char bgra[][5] = { -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xC0", "\0\0\0\x00", -"\0\0\0\x33" }; -#else -/* actually "ARGB" */ -unsigned char bgra[][5] = { -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xC0\0\0\0", "\x00\0\0\0", -"\x33\0\0\0" }; -#endif +/* filled in setcolors() */ +fb_pixel_t bgra[SIZECOLTABLE]; /* old 8bit color table */ unsigned short rd0[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0x00<<8, 0x00<<8, 0x00<<8, 0, 0 }; diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index e1b192746..59af91ff2 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -126,11 +126,14 @@ class CFbAccelCSHD2 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 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; void setBlendMode(uint8_t); void setBlendLevel(int); int scaleFont(int size); bool fullHdAvailable(); void setOsdResolutions(); + uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); + bool needAlign4Blit() { return true; }; }; class CFbAccelGLFB @@ -173,6 +176,7 @@ class CFbAccelTD void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp); void waitForIdle(const char *func = NULL); + fb_pixel_t * getBackBufferPointer() const; void setBlendMode(uint8_t); void setBlendLevel(int); }; diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 8d49c3a0d..fd2ae8531 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -267,6 +267,11 @@ max res 1920x1080 return 0; /* dont fail because of this */ } +fb_pixel_t * CFbAccelCSHD2::getBackBufferPointer() const +{ + return backbuffer; +} + void CFbAccelCSHD2::setBlendMode(uint8_t mode) { if (ioctl(fd, FBIO_SETBLENDMODE, mode)) @@ -299,3 +304,20 @@ bool CFbAccelCSHD2::fullHdAvailable() return true; return false; } + +/* align for hw blit */ +uint32_t CFbAccelCSHD2::getWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max) +{ + uint32_t ret = _w; + if ((_x + ret) >= xRes) + ret = xRes-_x-1; + if (ret%4 == 0) + return ret; + + int add = (max) ? 3 : 0; + ret = ((ret + add) / 4) * 4; + if ((_x + ret) >= xRes) + ret -= 4; + + return ret; +} diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp index af3bf8f60..7033ed0bc 100644 --- a/src/driver/fb_accel_td.cpp +++ b/src/driver/fb_accel_td.cpp @@ -202,3 +202,8 @@ void CFbAccelTD::setBlendLevel(int level) if (level == 100) // sucks usleep(20000); } + +fb_pixel_t *CFbAccelTD::getBackBufferPointer() const +{ + return backbuffer; +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index c165894d6..fb329e32b 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -532,7 +531,7 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co #ifdef BOXMODEL_CS_HD2 if (_dx%4 != 0) { - w_align = GetWidth4FB_HW_ACC(x, _dx, true); + w_align = getWidth4FB_HW_ACC(x, _dx, true); if (w_align < _dx) _dx = w_align; offs_align = w_align - _dx; @@ -1797,3 +1796,8 @@ bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) void CFrameBuffer::mark(int , int , int , int ) { } + +uint32_t CFrameBuffer::getWidth4FB_HW_ACC(const uint32_t /*x*/, const uint32_t w, const bool /*max*/) +{ + return w; +} diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index b306fd11b..74fd9211d 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -191,10 +191,10 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? -#ifdef BOXMODEL_CS_HD1 - virtual void setupGXA() {}; - virtual void add_gxa_sync_marker() {}; -#endif + virtual void setupGXA() { return; }; // reinitialize stuff + virtual void add_gxa_sync_marker() { return; }; + virtual bool needAlign4Blit() { return false; }; + virtual uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); void setTransparency( int tr = 0 ); virtual void setBlendMode(uint8_t mode = 1); @@ -274,7 +274,7 @@ class CFrameBuffer : public sigc::trackable 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 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); + virtual void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); virtual void mark(int x, int y, int dx, int dy); virtual int scaleFont(int size) { return size; }; diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index 016e5e28a..5577b64c8 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -62,6 +62,7 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt) fd = NULL; xres = 0; yres = 0; + extra_osd = false; get_video = g_settings.screenshot_video; get_osd = g_settings.screenshot_mode; scale_to_video = g_settings.screenshot_scale; @@ -71,19 +72,91 @@ CScreenShot::~CScreenShot() { } +#ifdef BOXMODEL_CS_HD2 + +bool CScreenShot::mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData) +{ + uint8_t* d = (uint8_t *)pixel_data; + fb_pixel_t* d2; + + for (uint32_t count = 0; count < dy; count++ ) { + fb_pixel_t *pixpos = (fb_pixel_t*)&osdData[count*dx]; + d2 = (fb_pixel_t*)d; + for (uint32_t count2 = 0; count2 < dx; count2++ ) { + //don't paint backgroundcolor (*pixpos = 0x00000000) + if (*pixpos) { + fb_pixel_t pix = *pixpos; + if ((pix & 0xff000000) == 0xff000000) + *d2 = (pix & 0x00ffffff); + else { + uint8_t *in = (uint8_t *)(pixpos); + uint8_t *out = (uint8_t *)d2; + int a = in[3]; + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + } + } + d2++; + pixpos++; + } + d += dx*sizeof(fb_pixel_t); + } + return true; +} +#endif + /* try to get video frame data in ARGB format, restore GXA state */ bool CScreenShot::GetData() { +#ifdef BOXMODEL_CS_HD2 + /* Workaround for broken osd screenshot with new fb driver and 1280x720 resolution */ + CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); + fb_pixel_t* screenBuf = NULL; + uint32_t _xres = 0, _yres = 0; + if (frameBuffer->fullHdAvailable() && (frameBuffer->getScreenWidth(true) == 1280)) { + _xres = xres = 1280; + _yres = yres = 720; + get_osd = false; + extra_osd = true; + screenBuf = new fb_pixel_t[_xres*_yres*sizeof(fb_pixel_t)]; + if (screenBuf == NULL) { + printf("[%s:%s:%d] memory error\n", __path_file__, __func__, __LINE__); + return false; + } + printf("\n[%s:%s:%d] Read osd screen...", __path_file__, __func__, __LINE__); + frameBuffer->SaveScreen(0, 0, _xres, _yres, screenBuf); + printf(" done.\n"); + } +#endif + static OpenThreads::Mutex mutex; bool res = false; mutex.lock(); + #ifdef BOXMODEL_CS_HD1 CFrameBuffer::getInstance()->setActive(false); #endif if (videoDecoder->getBlank()) get_video = false; + #ifdef SCREENSHOT +#ifdef BOXMODEL_CS_HD2 + if (extra_osd && !get_video) { + uint32_t memSize = xres * yres * sizeof(fb_pixel_t) * 2; + pixel_data = (uint8_t*)cs_malloc_uncached(memSize); + if (pixel_data == NULL) { + printf("[%s:%s:%d] memory error\n", __path_file__, __func__, __LINE__); + return false; + } + memset(pixel_data, 0, memSize); + res = true; + } + else +#endif res = videoDecoder->GetScreenImage(pixel_data, xres, yres, get_video, get_osd, scale_to_video); #endif @@ -100,6 +173,14 @@ bool CScreenShot::GetData() return false; } +#ifdef BOXMODEL_CS_HD2 + if (extra_osd && screenBuf) { + printf("[%s:%s:%d] Merge osd screen to screenshot...", __path_file__, __func__, __LINE__); + mergeOsdScreen(_xres, _yres, screenBuf); + delete[] screenBuf; + printf(" done.\n \n"); + } +#endif printf("CScreenShot::GetData: data: %p %d x %d\n", pixel_data, xres, yres); return true; } diff --git a/src/driver/screenshot.h b/src/driver/screenshot.h index a4f348a8b..76a14e1a1 100644 --- a/src/driver/screenshot.h +++ b/src/driver/screenshot.h @@ -39,6 +39,7 @@ class CScreenShot : public OpenThreads::Thread unsigned char * pixel_data; int xres; int yres; + bool extra_osd; bool get_osd; bool get_video; bool scale_to_video; @@ -52,6 +53,9 @@ class CScreenShot : public OpenThreads::Thread bool SaveJpg(); bool SaveBmp(); void run(); +#ifdef BOXMODEL_CS_HD2 + bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData); +#endif public: CScreenShot(const std::string fname = "", screenshot_format_t fmt = CScreenShot::FORMAT_JPG); diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index bcaccf6c7..1870092af 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -33,7 +33,6 @@ #include "cc_item_picture.h" #include #include -#include #include extern CPictureViewer * g_PicViewer; @@ -222,10 +221,9 @@ void CComponentsPicture::initCCItem() { float h_ratio = float(height)*100/(float)dy; width = int(h_ratio*(float)dx/100); -#ifdef BOXMODEL_CS_HD2 - if (do_scale && (width > 10 || height > 10)) - width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; -#endif + if (frameBuffer->needAlign4Blit() && + do_scale && (width > 10 || height > 10)) + width = frameBuffer->getWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; keep_dx_aspect = false; } if (keep_dy_aspect && dx) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index d600003ce..473246d77 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -2517,7 +2517,7 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) int xoff = (double) sub->rects[i]->x * xc; int yoff = (double) sub->rects[i]->y * yc; - int nw = GetWidth4FB_HW_ACC(xoff, (double) sub->rects[i]->w * xc); + int nw = frameBuffer->getWidth4FB_HW_ACC(xoff, (double) sub->rects[i]->w * xc); int nh = (double) sub->rects[i]->h * yc; printf("Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 32e210cec..f7f475377 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -335,12 +335,15 @@ int CNeutrinoApp::loadSetup(const char * fname) int erg = 0; configfile.clear(); - //settings laden - und dabei Defaults setzen! - if(!configfile.loadConfig(fname)) { - //file existiert nicht + // load settings; setup defaults + if (!configfile.loadConfig(fname)) + { + // file doesn't exist erg = 1; - } else { -#ifndef HAVE_GENERIC_HARDWARE + } + else + { +#if 0 /* try to detect bad / broken config file */ if (!configfile.getInt32("screen_EndX_crt_0", 0) || !configfile.getInt32("screen_EndY_crt_0", 0) || @@ -352,6 +355,7 @@ int CNeutrinoApp::loadSetup(const char * fname) #endif migrateConfig(fname); } + parentallocked = !access(NEUTRINO_PARENTALLOCKED_FILE, R_OK); //theme/color options diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 395910d81..63b2c1d48 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +//#include #include #include using namespace std; @@ -1247,6 +1247,7 @@ bool split_config_string(const std::string &str, std::map split(const std::string &s, char delim) { diff --git a/src/system/helpers.h b/src/system/helpers.h index 28e6deea7..df0e58d31 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -118,7 +118,9 @@ class CFileHelpers static uint64_t getDirSize(const std::string& dir){return getDirSize(dir.c_str());}; }; +#if 0 uint32_t GetWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max=true); +#endif #if __cplusplus < 201103L std::string to_string(int);