1 #include <lib/gdi/gfbdc.h>
3 #include <lib/base/init.h>
4 #include <lib/base/init_num.h>
5 #include <lib/base/econfig.h>
7 #include <lib/gdi/accel.h>
11 gFBDC *gFBDC::instance;
19 eFatal("no framebuffer available");
21 fb->SetMode(720, 576, 32);
23 for (int y=0; y<576; y++) // make whole screen transparent
24 memset(fb->lfb+y*fb->Stride(), 0x00, fb->Stride());
31 surface.stride = fb->Stride();
32 surface.data = fb->lfb;
35 surface.data_phys = 50*1024*1024; // FIXME
37 int fb_size = surface.stride * surface.y;
39 if (fb->getNumPages() > 1)
41 m_enable_double_buffering = 1;
42 surface_back.type = 0;
45 surface_back.bpp = 32;
46 surface_back.bypp = 4;
47 surface_back.stride = fb->Stride();
48 surface_back.offset = surface.y;
49 surface_back.data = fb->lfb + fb_size;
50 surface_back.data_phys = surface.data_phys + fb_size;
54 m_enable_double_buffering = 0;
56 eDebug("%dkB available for acceleration surfaces.", (fb->Available() - fb_size)/1024);
58 if (gAccel::getInstance())
59 gAccel::getInstance()->setAccelMemorySpace(fb->lfb + fb_size, surface.data_phys + fb_size, fb->Available() - fb_size);
61 surface.clut.colors = 256;
62 surface.clut.data = new gRGB[surface.clut.colors];
64 surface_back.clut = surface.clut;
66 m_pixmap = new gPixmap(&surface);
68 memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors);
76 delete[] surface.clut.data;
80 void gFBDC::calcRamp()
83 float fgamma=gamma ? gamma : 1;
86 for (int i=0; i<256; i++)
88 float raw=i/255.0; // IIH, float.
89 float corr=pow(raw, fgamma) * 256.0;
91 int d=corr * (float)(256-brightness) / 256 + brightness;
98 rampalpha[i]=i*alpha/256;
101 for (int i=0; i<256; i++)
105 d=(d-128)*(gamma+64)/(128+64)+128;
106 d+=brightness-128; // brightness correction
113 rampalpha[i]=i*alpha/256;
116 rampalpha[255]=255; // transparent BLEIBT bitte so.
119 void gFBDC::setPalette()
121 if (!surface.clut.data)
124 for (int i=0; i<256; ++i)
126 fb->CMAP()->red[i]=ramp[surface.clut.data[i].r]<<8;
127 fb->CMAP()->green[i]=ramp[surface.clut.data[i].g]<<8;
128 fb->CMAP()->blue[i]=ramp[surface.clut.data[i].b]<<8;
129 fb->CMAP()->transp[i]=rampalpha[surface.clut.data[i].a]<<8;
134 void gFBDC::exec(gOpcode *o)
138 case gOpcode::setPalette:
146 if (m_enable_double_buffering)
149 surface = surface_back;
152 fb->setOffset(surface_back.offset);
156 case gOpcode::waitVSync:
164 gettimeofday(&now, 0);
166 int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000;
167 eDebug("%d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1));
183 void gFBDC::setAlpha(int a)
191 void gFBDC::setBrightness(int b)
199 void gFBDC::setGamma(int g)
207 void gFBDC::saveSettings()
209 eConfig::getInstance()->setKey("/ezap/osd/alpha", alpha);
210 eConfig::getInstance()->setKey("/ezap/osd/gamma", gamma);
211 eConfig::getInstance()->setKey("/ezap/osd/brightness", brightness);
214 void gFBDC::reloadSettings()
216 if (eConfig::getInstance()->getKey("/ezap/osd/alpha", alpha))
218 if (eConfig::getInstance()->getKey("/ezap/osd/gamma", gamma))
220 if (eConfig::getInstance()->getKey("/ezap/osd/brightness", brightness))
227 // eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
229 eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");