diff options
| author | Andreas Oberritter <obi@opendreambox.org> | 2010-10-29 14:54:36 +0200 |
|---|---|---|
| committer | Andreas Oberritter <obi@opendreambox.org> | 2010-11-16 17:15:38 +0100 |
| commit | 059c9a03c8cc02b0c595e3a5599be04dc157f725 (patch) | |
| tree | 8ce10b7cb512ab1e1b49f4e10562aa5d83c433c0 /lib | |
| parent | e8164a09377e89aeb0c208c12b979811d5bc33fe (diff) | |
| download | enigma2-059c9a03c8cc02b0c595e3a5599be04dc157f725.tar.gz enigma2-059c9a03c8cc02b0c595e3a5599be04dc157f725.zip | |
Add abstract class gMainDC as an interface for gFBDC and gSDLDC
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gdi/Makefile.am | 10 | ||||
| -rw-r--r-- | lib/gdi/gfbdc.cpp | 16 | ||||
| -rw-r--r-- | lib/gdi/gfbdc.h | 26 | ||||
| -rw-r--r-- | lib/gdi/glcddc.cpp | 2 | ||||
| -rw-r--r-- | lib/gdi/glcddc.h | 2 | ||||
| -rw-r--r-- | lib/gdi/gmaindc.cpp | 28 | ||||
| -rw-r--r-- | lib/gdi/gmaindc.h | 33 | ||||
| -rw-r--r-- | lib/gdi/grc.cpp | 2 | ||||
| -rw-r--r-- | lib/gdi/grc.h | 10 | ||||
| -rw-r--r-- | lib/gdi/sdl.cpp | 44 | ||||
| -rw-r--r-- | lib/gdi/sdl.h | 10 | ||||
| -rw-r--r-- | lib/python/enigma_python.i | 4 |
12 files changed, 107 insertions, 80 deletions
diff --git a/lib/gdi/Makefile.am b/lib/gdi/Makefile.am index febbab22..20321f53 100644 --- a/lib/gdi/Makefile.am +++ b/lib/gdi/Makefile.am @@ -18,9 +18,9 @@ libenigma_gdi_a_SOURCES = \ fb.cpp \ font.cpp \ font_arabic.cpp \ - gfbdc.cpp \ gfont.cpp \ glcddc.cpp \ + gmaindc.cpp \ gpixmap.cpp \ grc.cpp \ lcd.cpp \ @@ -38,7 +38,6 @@ gdiinclude_HEADERS = \ esize.h \ fb.h \ font.h \ - gfbdc.h \ gfont.h \ glcddc.h \ gpixmap.h \ @@ -50,7 +49,10 @@ gdiinclude_HEADERS = \ if HAVE_LIBSDL libenigma_gdi_a_SOURCES += \ - sdl.cpp -gdiinclude_HEADERS += \ + sdl.cpp \ sdl.h +else +libenigma_gdi_a_SOURCES += \ + gfbdc.cpp \ + gfbdc.h endif diff --git a/lib/gdi/gfbdc.cpp b/lib/gdi/gfbdc.cpp index 80dd2479..a4f65ebc 100644 --- a/lib/gdi/gfbdc.cpp +++ b/lib/gdi/gfbdc.cpp @@ -7,18 +7,8 @@ #include <time.h> -gFBDC *gFBDC::instance; - -ePtr<gFBDC> NewgFBDCPtr(void) -{ - ePtr<gFBDC> ptr; - gFBDC::getInstance(ptr); - return ptr; -} - gFBDC::gFBDC() { - instance=this; fb=new fbClass; if (!fb->Available()) @@ -34,7 +24,6 @@ gFBDC::~gFBDC() { delete fb; delete[] surface.clut.data; - instance=0; } void gFBDC::calcRamp() @@ -91,7 +80,7 @@ void gFBDC::setPalette() fb->PutCMAP(); } -void gFBDC::exec(gOpcode *o) +void gFBDC::exec(const gOpcode *o) { switch (o->opcode) { @@ -242,7 +231,4 @@ void gFBDC::reloadSettings() setPalette(); } -// eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); -#ifndef WITH_SDL eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); -#endif diff --git a/lib/gdi/gfbdc.h b/lib/gdi/gfbdc.h index 23051c4f..7f76d0c9 100644 --- a/lib/gdi/gfbdc.h +++ b/lib/gdi/gfbdc.h @@ -3,17 +3,12 @@ #include "fb.h" #include "gpixmap.h" -#include "grc.h" +#include "gmaindc.h" -class gFBDC; - -SWIG_IGNORE(gFBDC); -class gFBDC: public gDC +class gFBDC: public gMainDC { -#ifndef SWIG fbClass *fb; - static gFBDC *instance; - void exec(gOpcode *opcode); + void exec(const gOpcode *opcode); unsigned char ramp[256], rampalpha[256]; // RGB ramp 0..255 int brightness, gamma, alpha; void calcRamp(); @@ -21,13 +16,8 @@ class gFBDC: public gDC gSurface surface, surface_back; int m_enable_double_buffering; int m_xres, m_yres; -#else - gFBDC(); - virtual ~gFBDC(); -#endif public: void setResolution(int xres, int yres); -#ifndef SWIG void reloadSettings(); void setAlpha(int alpha); void setBrightness(int brightness); @@ -43,17 +33,7 @@ public: gFBDC(); virtual ~gFBDC(); - static int getInstance(ePtr<gFBDC> &ptr) { if (!instance) return -1; ptr = instance; return 0; } int islocked() { return fb->islocked(); } -#endif }; -SWIG_TEMPLATE_TYPEDEF(ePtr<gFBDC>, gFBDC); -SWIG_EXTEND(ePtr<gFBDC>, - static ePtr<gFBDC> getInstance() - { - extern ePtr<gFBDC> NewgFBDCPtr(void); - return NewgFBDCPtr(); - } -); #endif diff --git a/lib/gdi/glcddc.cpp b/lib/gdi/glcddc.cpp index a593cfa3..bade53ba 100644 --- a/lib/gdi/glcddc.cpp +++ b/lib/gdi/glcddc.cpp @@ -30,7 +30,7 @@ gLCDDC::~gLCDDC() instance=0; } -void gLCDDC::exec(gOpcode *o) +void gLCDDC::exec(const gOpcode *o) { switch (o->opcode) { diff --git a/lib/gdi/glcddc.h b/lib/gdi/glcddc.h index 6d5f3834..a2b3c7f0 100644 --- a/lib/gdi/glcddc.h +++ b/lib/gdi/glcddc.h @@ -9,7 +9,7 @@ class gLCDDC: public gDC eLCD *lcd; static gLCDDC *instance; int update; - void exec(gOpcode *opcode); + void exec(const gOpcode *opcode); gSurface surface; public: gLCDDC(); diff --git a/lib/gdi/gmaindc.cpp b/lib/gdi/gmaindc.cpp new file mode 100644 index 00000000..4890027f --- /dev/null +++ b/lib/gdi/gmaindc.cpp @@ -0,0 +1,28 @@ +#include <lib/gdi/gmaindc.h> + +gMainDC *gMainDC::m_instance; + +ePtr<gMainDC> NewgMainDCPtr(void) +{ + ePtr<gMainDC> ptr; + gMainDC::getInstance(ptr); + return ptr; +} + +gMainDC::gMainDC() +{ + ASSERT(m_instance == 0); + m_instance = this; +} + +gMainDC::gMainDC(gPixmap *pixmap) : gDC(pixmap) +{ + ASSERT(m_instance == 0); + m_instance = this; +} + +gMainDC::~gMainDC() +{ + m_instance = 0; +} + diff --git a/lib/gdi/gmaindc.h b/lib/gdi/gmaindc.h new file mode 100644 index 00000000..780be2e2 --- /dev/null +++ b/lib/gdi/gmaindc.h @@ -0,0 +1,33 @@ +#ifndef __lib_gdi_gmaindc_h +#define __lib_gdi_gmaindc_h + +#include "grc.h" + +class gMainDC; + +SWIG_IGNORE(gMainDC); +class gMainDC: public gDC +{ +protected: + static gMainDC *m_instance; + + gMainDC(); + gMainDC(gPixmap *pixmap); + virtual ~gMainDC(); +public: + virtual void setResolution(int xres, int yres) = 0; +#ifndef SWIG + static int getInstance(ePtr<gMainDC> &ptr) { if (!m_instance) return -1; ptr = m_instance; return 0; } +#endif +}; + +SWIG_TEMPLATE_TYPEDEF(ePtr<gMainDC>, gMainDC); +SWIG_EXTEND(ePtr<gMainDC>, + static ePtr<gMainDC> getInstance() + { + extern ePtr<gMainDC> NewgMainDCPtr(void); + return NewgMainDCPtr(); + } +); + +#endif diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index dff6b059..a45b3b1e 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -609,7 +609,7 @@ gDC::~gDC() delete[] m_spinner_pic; } -void gDC::exec(gOpcode *o) +void gDC::exec(const gOpcode *o) { switch (o->opcode) { diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 3b8201ad..38caa107 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -286,7 +286,7 @@ protected: eRect m_spinner_pos; int m_spinner_num, m_spinner_i; public: - virtual void exec(gOpcode *opcode); + virtual void exec(const gOpcode *opcode); gDC(gPixmap *pixmap); gDC(); virtual ~gDC(); @@ -296,10 +296,10 @@ public: virtual eSize size() { return m_pixmap->size(); } virtual int islocked() { return 0; } - void enableSpinner(); - void disableSpinner(); - void incrementSpinner(); - void setSpinner(eRect pos, ePtr<gPixmap> *pic, int len); + virtual void enableSpinner(); + virtual void disableSpinner(); + virtual void incrementSpinner(); + virtual void setSpinner(eRect pos, ePtr<gPixmap> *pic, int len); }; #endif diff --git a/lib/gdi/sdl.cpp b/lib/gdi/sdl.cpp index 6dbdb67c..e816a185 100644 --- a/lib/gdi/sdl.cpp +++ b/lib/gdi/sdl.cpp @@ -1,4 +1,3 @@ -#ifdef WITH_SDL #include <lib/gdi/sdl.h> #include <lib/base/init.h> @@ -6,8 +5,6 @@ #include <SDL.h> -gSDLDC *gSDLDC::m_instance; - gSDLDC::gSDLDC() { if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -15,23 +12,12 @@ gSDLDC::gSDLDC() eWarning("Could not initialize SDL: %s", SDL_GetError()); return; } - - m_screen = SDL_SetVideoMode(720, 576, 32, SDL_HWSURFACE); - if (!m_screen) - { - eWarning("Could not create SDL surface: %s", SDL_GetError()); - return; - } - m_instance=this; - + setResolution(720, 576); + + CONNECT(m_pump.recv_msg, gSDLDC::pumpEvent); + m_surface.type = 0; - m_surface.x = m_screen->w; - m_surface.y = m_screen->h; - m_surface.bpp = m_screen->format->BitsPerPixel; - m_surface.bypp = m_screen->format->BytesPerPixel; - m_surface.stride = m_screen->pitch; - m_surface.data = m_screen->pixels; m_surface.clut.colors=256; m_surface.clut.data=new gRGB[m_surface.clut.colors]; @@ -43,7 +29,6 @@ gSDLDC::gSDLDC() gSDLDC::~gSDLDC() { SDL_Quit(); - m_instance=0; } void gSDLDC::setPalette() @@ -63,7 +48,7 @@ void gSDLDC::setPalette() fb->PutCMAP(); */ } -void gSDLDC::exec(gOpcode *o) +void gSDLDC::exec(const gOpcode *o) { switch (o->opcode) { @@ -83,6 +68,21 @@ void gSDLDC::exec(gOpcode *o) } } -eAutoInitPtr<gSDLDC> init_gSDLDC(eAutoInitNumbers::graphic-1, "gSDLDC"); +void gSDLDC::setResolution(int xres, int yres) +{ + m_screen = SDL_SetVideoMode(xres, yres, 32, SDL_HWSURFACE); + if (!m_screen) + { + eWarning("Could not create SDL surface: %s", SDL_GetError()); + return; + } + + m_surface.x = m_screen->w; + m_surface.y = m_screen->h; + m_surface.bpp = m_screen->format->BitsPerPixel; + m_surface.bypp = m_screen->format->BytesPerPixel; + m_surface.stride = m_screen->pitch; + m_surface.data = m_screen->pixels; +} -#endif +eAutoInitPtr<gSDLDC> init_gSDLDC(eAutoInitNumbers::graphic-1, "gSDLDC"); diff --git a/lib/gdi/sdl.h b/lib/gdi/sdl.h index 20ff04fa..9f86cbbd 100644 --- a/lib/gdi/sdl.h +++ b/lib/gdi/sdl.h @@ -3,25 +3,23 @@ #include "fb.h" #include "gpixmap.h" -#include "grc.h" +#include "gmaindc.h" #include <SDL.h> -class gSDLDC: public gDC +class gSDLDC: public gMainDC { SDL_Surface *m_screen; - static gSDLDC *m_instance; - void exec(gOpcode *opcode); + void exec(const gOpcode *opcode); void setPalette(); gSurface m_surface; public: + void setResolution(int xres, int yres); gSDLDC(); virtual ~gSDLDC(); - static int getInstance(ePtr<gSDLDC> &ptr) { if (!m_instance) return -1; ptr = m_instance; return 0; } int islocked() { return 0; } }; - #endif diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 43d94ac9..7c999277 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -51,7 +51,7 @@ is usually caused by not marking PSignals as immutable. #include <lib/gdi/fb.h> #include <lib/gdi/font.h> #include <lib/gdi/gpixmap.h> -#include <lib/gdi/gfbdc.h> +#include <lib/gdi/gmaindc.h> #include <lib/gui/ewidget.h> #include <lib/gui/elabel.h> #include <lib/gui/einput.h> @@ -166,7 +166,7 @@ typedef long time_t; %include <lib/gdi/fb.h> %include <lib/gdi/font.h> %include <lib/gdi/gpixmap.h> -%include <lib/gdi/gfbdc.h> +%include <lib/gdi/gmaindc.h> %include <lib/gdi/epoint.h> %include <lib/gdi/erect.h> %include <lib/gdi/esize.h> |
