- fix when not enough framebuffer memory available
[enigma2.git] / main / enigma.cpp
index 6bf0bb9759e711a7a910859862de8f8542bcd308..f81a3c28f7ddf0a0f4ee870464599b8daa6c249b 100644 (file)
@@ -1,3 +1,8 @@
+#undef WITH_SDL
+#ifdef WITH_SDL
+#error
+#define SDLDC
+#endif
 #include <stdio.h>
 #include <libsig_comp.h>
 #include <lib/base/ebase.h>
@@ -9,6 +14,10 @@
 
 #include <lib/gdi/grc.h>
 #include <lib/gdi/gfbdc.h>
+#ifdef WITH_SDL
+#error
+#include <lib/gdi/sdl.h>
+#endif
 #include <lib/gdi/font.h> 
 
 #include <lib/gui/ewidget.h>
@@ -27,6 +36,8 @@
 
 #include <lib/actions/action.h>
 
+#include <lib/gdi/epng.h>
+
 #ifdef OBJECT_DEBUG
 int object_total_remaining;
 
@@ -41,6 +52,7 @@ void dumpRegion(const gRegion &region)
        fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", 
                region.extends.left(), region.extends.top(),
                region.extends.right(), region.extends.bottom(), region.rects.size());
+#if 0
        for (int y=0; y<region.extends.bottom(); ++y)
        {
                for (int x=0; x<region.extends.right(); ++x)
@@ -53,6 +65,8 @@ void dumpRegion(const gRegion &region)
                }
                fprintf(stderr, "\n");
        }
+#endif
+
 }
 
 eWidgetDesktop *wdsk;
@@ -86,6 +100,8 @@ void keyEvent(const eRCKey &key)
 #include <lib/dvb/idvb.h>
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/db.h>
+#include <lib/dvb/dvbtime.h>
+#include <lib/dvb/epgcache.h>
 
 class eMain: public eApplication, public Object
 {
@@ -93,9 +109,10 @@ class eMain: public eApplication, public Object
        
        ePtr<eDVBResourceManager> m_mgr;
        ePtr<eDVBDB> m_dvbdb;
-
+       ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
        ePtr<eComponentScan> m_scan;
-       
+       ePtr<eEPGCache> m_epgcache;
+
 public:
        eMain()
        {
@@ -104,7 +121,8 @@ public:
                                /* TODO: put into init */
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
-               
+               m_locale_time_handler = new eDVBLocalTimeHandler();
+               m_epgcache = new eEPGCache();
                m_mgr->setChannelList(m_dvbdb);
                
 //             m_scan = new eComponentScan();
@@ -130,36 +148,43 @@ int main(int argc, char **argv)
 
        ePython python;
        eMain main;
+       
+       int double_buffer = 0;
 
 #if 1
+#ifdef SDLDC
+       ePtr<gSDLDC> my_dc;
+       gSDLDC::getInstance(my_dc);
+#else
        ePtr<gFBDC> my_dc;
        gFBDC::getInstance(my_dc);
-
-       gPainter p(my_dc);
        
-       gRGB pal[256];
-       pal[0] = 0;
-       pal[1] = 0xff00ff;
-       pal[2] = 0xffFFff;
-       pal[3] = 0x00ff00;
-       
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x10] = 0x111111 * a;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x20] = (0x111100 * a) | 0xFF;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x30] = (0x110011 * a) | 0xFF00;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x40] = (0x001111 * a) | 0xFF0000;
-       p.setPalette(pal, 0, 256);
-
-       fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
+       double_buffer = my_dc->haveDoubleBuffering();
+#endif
+
+       fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Arial", 100);
 
        eWidgetDesktop dsk(eSize(720, 576));
        
+       if (double_buffer)
+       {
+               eDebug(" - double buffering found, enable buffered graphics mode.");
+               dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
+       }
+       
        wdsk = &dsk;
-       dsk.setBackgroundColor(gColor(0));
+
        dsk.setDC(my_dc);
+
+       ePtr<gPixmap> m_pm;
+       loadPNG(m_pm, "data/pal.png");
+       if (!m_pm)
+       {
+               eFatal("hi ghost, please copy pal.png into your ./data, thanks!");
+       } else
+               dsk.setPalette(*m_pm);
+
+       dsk.setBackgroundColor(gRGB(0,0,0,0xFF));
 #endif
 
                /* redrawing is done in an idle-timer, so we have to set the context */
@@ -171,7 +196,6 @@ int main(int argc, char **argv)
 
        python.execute("mytest", "__main__");
 
-
 //     eApp->exec();
 
        return 0;