X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fgdi%2Fgfbdc.cpp;h=eda5bf21d478470871c59954739e81c9599240a8;hp=7130b0c71f161d3bf796aeb1770baaa016286010;hb=HEAD;hpb=e93336d428081eb1646146c546f2fee527cb888c diff --git a/lib/gdi/gfbdc.cpp b/lib/gdi/gfbdc.cpp index 7130b0c..eda5bf2 100644 --- a/lib/gdi/gfbdc.cpp +++ b/lib/gdi/gfbdc.cpp @@ -2,43 +2,31 @@ #include #include -#include -gFBDC *gFBDC::instance; +#include + +#include +#ifdef USE_LIBVUGLES2 +#include +#endif gFBDC::gFBDC() { - instance=this; fb=new fbClass; if (!fb->Available()) eFatal("no framebuffer available"); - fb->SetMode(720, 576, 8); + surface.clut.data = 0; + setResolution(720, 576); // default res - for (int y=0; y<576; y++) // make whole screen transparent - memset(fb->lfb+y*fb->Stride(), 0x00, fb->Stride()); - - surface.type = 0; - surface.x = 720; - surface.y = 576; - surface.bpp = 8; - surface.bypp = 1; - surface.stride = fb->Stride(); - surface.data = fb->lfb; - surface.clut.colors=256; - surface.clut.data=new gRGB[surface.clut.colors]; - - m_pixmap = new gPixmap(&surface); - - memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors); reloadSettings(); } gFBDC::~gFBDC() { delete fb; - instance=0; + delete[] surface.clut.data; } void gFBDC::calcRamp() @@ -58,7 +46,7 @@ void gFBDC::calcRamp() if (d > 255) d=255; ramp[i]=d; - + rampalpha[i]=i*alpha/256; } #endif @@ -84,20 +72,18 @@ void gFBDC::setPalette() { if (!surface.clut.data) return; - + for (int i=0; i<256; ++i) { fb->CMAP()->red[i]=ramp[surface.clut.data[i].r]<<8; fb->CMAP()->green[i]=ramp[surface.clut.data[i].g]<<8; fb->CMAP()->blue[i]=ramp[surface.clut.data[i].b]<<8; fb->CMAP()->transp[i]=rampalpha[surface.clut.data[i].a]<<8; - if (!fb->CMAP()->red[i]) - fb->CMAP()->red[i]=0x100; } fb->PutCMAP(); } -void gFBDC::exec(gOpcode *o) +void gFBDC::exec(const gOpcode *o) { switch (o->opcode) { @@ -107,6 +93,91 @@ void gFBDC::exec(gOpcode *o) setPalette(); break; } + case gOpcode::flip: + { + if (m_enable_double_buffering) + { + gSurface s(surface); + surface = surface_back; + surface_back = s; + + fb->setOffset(surface_back.offset); + } + break; + } + case gOpcode::waitVSync: + { + static timeval l; + static int t; + timeval now; + + if (t == 1000) + { + gettimeofday(&now, 0); + + int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000; + eDebug("%d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1)); + l = now; + t = 0; + } + + ++t; + + fb->blit(); + fb->waitVSync(); + break; + } + case gOpcode::flush: +#ifdef USE_LIBVUGLES2 + if (gles_is_animation()) + gles_do_animation(); + else + fb->blit(); + + gles_flush(); +#else + fb->blit(); +#endif + break; + case gOpcode::sendShow: + { +#ifdef USE_LIBVUGLES2 + gles_set_buffer((unsigned int *)surface.data); + gles_set_animation(1, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height()); +#endif + delete o->parm.setShowHideInfo; + break; + } + case gOpcode::sendHide: + { +#ifdef USE_LIBVUGLES2 + gles_set_buffer((unsigned int *)surface.data); + gles_set_animation(0, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height()); +#endif + delete o->parm.setShowHideInfo; + break; + } +#ifdef USE_LIBVUGLES2 + case gOpcode::sendShowItem: + { + gles_set_buffer((unsigned int *)surface.data); + gles_set_animation_listbox(o->parm.setShowItemInfo->dir, o->parm.setShowItemInfo->point.x(), o->parm.setShowItemInfo->point.y(), o->parm.setShowItemInfo->size.width(), o->parm.setShowItemInfo->size.height()); + delete o->parm.setShowItemInfo; + break; + } + case gOpcode::setFlush: + { + gles_set_flush(o->parm.setFlush->enable); + delete o->parm.setFlush; + break; + } + case gOpcode::setView: + { + gles_viewport(o->parm.setViewInfo->size.width(), o->parm.setViewInfo->size.height(), fb->Stride()); + delete o->parm.setViewInfo; + break; + } +#endif default: gDC::exec(o); break; @@ -137,28 +208,78 @@ void gFBDC::setGamma(int g) setPalette(); } +void gFBDC::setResolution(int xres, int yres) +{ + if ((m_xres == xres) && (m_yres == yres)) + return; + + m_xres = xres; m_yres = yres; + + fb->SetMode(m_xres, m_yres, 32); + + for (int y=0; ylfb+y*fb->Stride(), 0x00, fb->Stride()); + + surface.type = 0; + surface.x = m_xres; + surface.y = m_yres; + surface.bpp = 32; + surface.bypp = 4; + surface.stride = fb->Stride(); + surface.data = fb->lfb; + surface.offset = 0; + + surface.data_phys = fb->getPhysAddr(); + + int fb_size = surface.stride * surface.y; + + if (fb->getNumPages() > 1) + { + m_enable_double_buffering = 1; + surface_back.type = 0; + surface_back.x = m_xres; + surface_back.y = m_yres; + surface_back.bpp = 32; + surface_back.bypp = 4; + surface_back.stride = fb->Stride(); + surface_back.offset = surface.y; + surface_back.data = fb->lfb + fb_size; + surface_back.data_phys = surface.data_phys + fb_size; + + fb_size *= 2; + } else + m_enable_double_buffering = 0; + + eDebug("%dkB available for acceleration surfaces.", (fb->Available() - fb_size)/1024); + eDebug("resolution: %d x %d x %d (stride: %d)", surface.x, surface.y, surface.bpp, fb->Stride()); + + if (gAccel::getInstance()) + gAccel::getInstance()->setAccelMemorySpace(fb->lfb + fb_size, surface.data_phys + fb_size, fb->Available() - fb_size); + + if (!surface.clut.data) + { + surface.clut.colors = 256; + surface.clut.data = new gRGB[surface.clut.colors]; + memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors); + } + + surface_back.clut = surface.clut; + + m_pixmap = new gPixmap(&surface); +} + void gFBDC::saveSettings() { - eConfig::getInstance()->setKey("/ezap/osd/alpha", alpha); - eConfig::getInstance()->setKey("/ezap/osd/gamma", gamma); - eConfig::getInstance()->setKey("/ezap/osd/brightness", brightness); } void gFBDC::reloadSettings() { - if (eConfig::getInstance()->getKey("/ezap/osd/alpha", alpha)) - alpha=255; - if (eConfig::getInstance()->getKey("/ezap/osd/gamma", gamma)) - gamma=128; - if (eConfig::getInstance()->getKey("/ezap/osd/brightness", brightness)) - brightness=128; + alpha=255; + gamma=128; + brightness=128; calcRamp(); setPalette(); } -// eAutoInitPtr init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); -#ifndef SDLDC eAutoInitPtr init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); -#endif -