Extrenal srt problem gst-1 solved.
[openblackhole/openblackhole-enigma2.git] / lib / gdi / glcddc.cpp
1 #include <lib/gdi/glcddc.h>
2 #include <lib/gdi/lcd.h>
3 #include <lib/gdi/fblcd.h>
4 #include <lib/base/init.h>
5 #include <lib/base/init_num.h>
6
7 gLCDDC *gLCDDC::instance;
8
9 gLCDDC::gLCDDC()
10 {
11         lcd = new eFbLCD();
12         if (!lcd->detected())
13         {
14                 delete lcd;
15                 lcd = new eDBoxLCD();
16         }
17         instance = this;
18
19         update = 1;
20
21         surface.x = lcd->size().width();
22         surface.y = lcd->size().height();
23         surface.stride = lcd->stride();
24         surface.bypp = surface.stride / surface.x;
25         surface.bpp = surface.bypp*8;
26         surface.data = lcd->buffer();
27         surface.data_phys = 0;
28         if (lcd->getLcdType() == 4)
29         {
30                 surface.clut.colors = 256;
31                 surface.clut.data = new gRGB[surface.clut.colors];
32                 memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors);
33         }
34         else
35         {
36                 surface.clut.colors = 0;
37                 surface.clut.data = 0;
38         }
39         eDebug("[gLCDDC] resolution: %dx%dx%d stride=%d", surface.x, surface.y, surface.bpp, surface.stride);
40
41         m_pixmap = new gPixmap(&surface);
42 }
43
44 gLCDDC::~gLCDDC()
45 {
46         delete lcd;
47         if (surface.clut.data)
48                 delete[] surface.clut.data;
49         instance = 0;
50 }
51
52 void gLCDDC::exec(const gOpcode *o)
53 {
54         switch (o->opcode)
55         {
56         case gOpcode::setPalette:
57         {
58                 gDC::exec(o);
59                 lcd->setPalette(surface);
60                 break;
61         }
62 #ifdef HAVE_TEXTLCD
63         case gOpcode::renderText:
64                 if (o->parm.renderText->text)
65                 {
66                         lcd->renderText(gDC::m_current_offset, o->parm.renderText->text);
67                         free(o->parm.renderText->text);
68                 }
69                 delete o->parm.renderText;
70                 break;
71 #endif
72         case gOpcode::flush:
73                 lcd->update();
74         default:
75                 gDC::exec(o);
76                 break;
77         }
78 }
79
80 void gLCDDC::setUpdate(int u)
81 {
82         update = u;
83 }
84
85 eAutoInitPtr<gLCDDC> init_gLCDDC(eAutoInitNumbers::graphic-1, "gLCD");