Ginga  0.13.6
 All Classes Namespaces Functions Variables
DFBDeviceScreen.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef DFBDEVICESCREEN_H_
51 #define DFBDEVICESCREEN_H_
52 
53 #include "config.h"
54 
55 #if HAVE_COMPONENTS
56 #include "cm/IComponentManager.h"
57 using namespace ::br::pucrio::telemidia::ginga::core::cm;
58 #endif
59 
60 #include "mb/interface/IDeviceScreen.h"
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 #include <directfb.h>
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 /* macro for a safe call to DirectFB functions */
71 #ifndef DFBCHECK
72 #define DFBCHECK(x...) \
73 { \
74  DFBResult err = x; \
75  if (err != DFB_OK) { \
76  fprintf( stderr, "%s <%d>:%d\n\t", __FILE__, __LINE__, err ); \
77  } \
78 }
79 #endif /*DFBCHECK*/
80 
81 #include <pthread.h>
82 
83 #include <map>
84 #include <set>
85 #include <iostream>
86 using namespace std;
87 
88 namespace br {
89 namespace pucrio {
90 namespace telemidia {
91 namespace ginga {
92 namespace core {
93 namespace mb {
94  class DFBDeviceScreen : public IDeviceScreen {
95  public:
96  static const unsigned int DSA_UNKNOWN;
97  static const unsigned int DSA_4x3;
98  static const unsigned int DSA_16x9;
99 
100  private:
101  string aSystem;
102  unsigned int aspect;
103  unsigned int hSize;
104  unsigned int vSize;
105  unsigned int hRes;
106  unsigned int wRes;
107 
108 #if HAVE_COMPONENTS
109  static IComponentManager* cm;
110 #endif
111  set<IWindow*> windowPool;
112  vector<IWindow*> windowRenderList;
113  set<ISurface*> surfacePool;
114  set<IContinuousMediaProvider*> cmpPool;
115 
116  GingaScreenID id;
117  IInputManager* im;
118 
119  pthread_mutex_t winMutex;
120  pthread_mutex_t surMutex;
121  pthread_mutex_t cmpMutex;
122 
123  static unsigned int numOfDFBScreens;
124  static IDirectFB* dfb;
125  static IDirectFBDisplayLayer* gfxLayer;
126 
127  static pthread_mutex_t ieMutex;
128  static map<int, int> gingaToDFBCodeMap;
129  static map<int, int> dfbToGingaCodeMap;
130 
131  public:
133  int numArgs, char** args,
134  GingaScreenID myId, GingaWindowID embedId,
135  bool externalRenderer);
136 
137  virtual ~DFBDeviceScreen();
138 
139  void releaseScreen();
140  void releaseMB();
141 
142  void clearWidgetPools();
143 
144  private:
145  void setUnderlyingRootWindow(GingaWindowID embedId);
146 
147  public:
148  string getScreenName();
149  GingaWindowID getScreenUnderlyingWindow(){return NULL;};
150 
151  void setBackgroundImage(string uri);
152 
153  unsigned int getWidthResolution();
154  void setWidthResolution(unsigned int wRes);
155  unsigned int getHeightResolution();
156  void setHeightResolution(unsigned int hRes);
157 
158  void setColorKey(int r, int g, int b);
159 
160  IWindow* getIWindowFromId(GingaWindowID winId) {return NULL;};
161  bool mergeIds(GingaWindowID destId, vector<GingaWindowID>* srcIds);
162  void blitScreen(ISurface* destination);
163  void blitScreen(string fileUri);
164  void refreshScreen(){};
165 
166 
167  /* interfacing output */
168 
169  IWindow* createWindow(int x, int y, int w, int h, float z);
170 
171  GingaWindowID createUnderlyingSubWindow(
172  int x, int y, int w, int h, float z) {return NULL;};
173 
174  IWindow* createWindowFrom(GingaWindowID underlyingWindow);
175  bool hasWindow(IWindow* win);
176  void releaseWindow(IWindow* win);
177 
178  ISurface* createSurface();
179  ISurface* createSurface(int w, int h);
180  ISurface* createSurfaceFrom(void* underlyingSurface);
181  bool hasSurface(ISurface* sur);
182  bool releaseSurface(ISurface* sur);
183 
184 
185  /* interfacing content */
186 
187  IContinuousMediaProvider* createContinuousMediaProvider(
188  const char* mrl, bool* hasVisual, bool isRemote);
189 
190  void releaseContinuousMediaProvider(
191  IContinuousMediaProvider* provider);
192 
193  IFontProvider* createFontProvider(
194  const char* mrl, int fontSize);
195 
196  void releaseFontProvider(IFontProvider* provider);
197 
198  IImageProvider* createImageProvider(const char* mrl);
199  void releaseImageProvider(IImageProvider* provider);
200 
201  ISurface* createRenderedSurfaceFromImageFile(const char* mrl);
202 
203 
204  /* interfacing input */
205 
206  IInputManager* getInputManager();
207 
208  IEventBuffer* createEventBuffer();
209  IInputEvent* createInputEvent(void* event, const int symbol);
210  IInputEvent* createApplicationEvent(int type, void* data);
211  int fromMBToGinga(int keyCode);
212  int fromGingaToMB(int keyCode);
213 
214  /* interfacing underlying multimedia system */
215 
216  void* getGfxRoot();
217 
218 
219  /* libgingaccmbdfb internal use*/
220 
221  /* input */
222  static void initCodeMaps();
223 
224  /* output */
225  static IDirectFBWindow* getUnderlyingWindow(GingaWindowID winId);
226 
227  static IDirectFBWindow* createUnderlyingWindow(
228  DFBWindowDescription* desc);
229 
230  static void releaseUnderlyingWindow(IDirectFBWindow* uWin);
231 
232  static IDirectFBSurface* createUnderlyingSurface(
233  DFBSurfaceDescription* desc);
234 
235  static void releaseUnderlyingSurface(IDirectFBSurface* uSur);
236 
237  private:
238  void insertWindowFromRenderList(
239  IWindow* win, vector<IWindow*>* windows);
240 
241  void removeWindowFromRenderList(
242  IWindow* win, vector<IWindow*>* windows);
243  };
244 }
245 }
246 }
247 }
248 }
249 }
250 
251 #endif /*DFBDEVICESCREEN_H_*/