50 #ifndef SDLDEVICESCREEN_H_
51 #define SDLDEVICESCREEN_H_
55 #include "util/functions.h"
56 using namespace ::br::pucrio::telemidia::util;
59 #include "cm/IComponentManager.h"
60 using namespace ::br::pucrio::telemidia::ginga::core::cm;
63 #include "mb/interface/IDiscreteMediaProvider.h"
64 #include "mb/interface/IDeviceScreen.h"
76 #ifndef GINGA_PIXEL_FMT
77 #define GINGA_PIXEL_FMT SDL_PIXELFORMAT_RGB24
95 static const unsigned int DSA_UNKNOWN;
96 static const unsigned int DSA_4x3;
97 static const unsigned int DSA_16x9;
101 static const short SPT_NONE = 0;
102 static const short SPT_INIT = 1;
103 static const short SPT_CLEAR = 2;
104 static const short SPT_RELEASE = 3;
108 static const short SUW_SHOW = 0;
109 static const short SUW_HIDE = 1;
110 static const short SUW_RAISETOTOP = 2;
111 static const short SUW_LOWERTOBOTTOM = 3;
113 static const short SDS_FPS = 35;
114 static const int uSleepTime = (int)(1000000/SDS_FPS);
117 static bool hasRenderer;
118 static bool mutexInit;
119 static map<SDLDeviceScreen*, short> sdlScreens;
130 unsigned long winIdRefCounter;
131 map<GingaWindowID, IWindow*> windowRefs;
134 static IComponentManager* cm;
136 set<IWindow*> windowPool;
137 set<ISurface*> surfacePool;
138 set<IContinuousMediaProvider*> cmpPool;
139 set<IDiscreteMediaProvider*> dmpPool;
142 GingaWindowID uParentId;
143 GingaWindowID uEmbedId;
151 pthread_mutex_t condMutex;
158 SDL_Renderer* renderer;
162 static map<int, int> gingaToSDLCodeMap;
163 static map<int, int> sdlToGingaCodeMap;
164 static map<string, int> sdlStrToSdlCode;
166 static set<SDL_Surface*> uSurPool;
167 static set<SDL_Texture*> uTexPool;
168 static vector<ReleaseContainer*> releaseList;
169 static map<GingaScreenID, map<float, set<IWindow*>*>*> renderMap;
170 static set<IContinuousMediaProvider*> cmpRenderList;
172 static pthread_mutex_t sdlMutex;
173 static pthread_mutex_t sieMutex;
174 static pthread_mutex_t renMutex;
175 static pthread_mutex_t scrMutex;
176 static pthread_mutex_t recMutex;
177 static pthread_mutex_t winMutex;
178 static pthread_mutex_t surMutex;
179 static pthread_mutex_t proMutex;
180 static pthread_mutex_t cstMutex;
184 int numArgs,
char** args,
185 GingaScreenID myId, GingaWindowID embedId,
186 bool externalRenderer);
191 static void checkMutexInit();
194 static void lockSDL();
195 static void unlockSDL();
197 static void updateRenderMap(
198 GingaScreenID screenId,
IWindow* window,
199 float oldZIndex,
float newZIndex);
201 void releaseScreen();
205 void clearWidgetPools();
207 string getScreenName();
210 void setEmbedFromParent(
string parentCoords);
213 void setBackgroundImage(
string uri);
215 unsigned int getWidthResolution();
216 void setWidthResolution(
unsigned int wRes);
217 unsigned int getHeightResolution();
218 void setHeightResolution(
unsigned int hRes);
220 void setColorKey(
int r,
int g,
int b);
222 IWindow* getIWindowFromId(GingaWindowID winId);
223 bool mergeIds(GingaWindowID destId, vector<GingaWindowID>* srcIds);
224 void blitScreen(
ISurface* destination);
225 void blitScreen(
string fileUri);
228 void blitScreen(SDL_Surface* destination);
229 void setInitScreenFlag();
232 void refreshScreen();
237 IWindow* createWindow(
int x,
int y,
int w,
int h,
float z);
239 GingaWindowID createUnderlyingSubWindow(
240 int x,
int y,
int w,
int h,
float z);
243 GingaWindowID createUnderlyingSubWindow(
244 GingaWindowID parent,
246 int x,
int y,
int w,
int h,
float z);
249 GingaWindowID getScreenUnderlyingWindow();
251 IWindow* createWindowFrom(GingaWindowID underlyingWindow);
253 void releaseWindow(
IWindow* win);
256 ISurface* createSurface(
int w,
int h);
257 ISurface* createSurfaceFrom(
void* underlyingSurface);
265 const char* mrl,
bool* hasVisual,
bool isRemote);
267 void releaseContinuousMediaProvider(
271 const char* mrl,
int fontSize);
278 ISurface* createRenderedSurfaceFromImageFile(
const char* mrl);
283 static void createReleaseContainer(
289 static void checkSDLInit();
290 static void notifyQuit();
291 static void sdlQuit();
294 static bool notifyEvent(
300 static void* checkStdin(
void* ptr);
301 static void processCmd(
307 static bool checkEvents();
308 static void* rendererT(
void* ptr);
315 static void forceInputFocus(
322 static void releaseAll();
327 static bool blitFromWindow(
IWindow* iWin, SDL_Surface* dest);
337 IInputEvent* createInputEvent(
void* event,
const int symbol);
338 IInputEvent* createApplicationEvent(
int type,
void* data);
340 int fromMBToGinga(
int keyCode);
341 int fromGingaToMB(
int keyCode);
352 static int convertEventCodeStrToInt(
string strEvent);
353 static void initCodeMaps();
358 static void renderMapInsertWindow(
359 GingaScreenID screenId,
IWindow* iWin,
float z);
361 static void renderMapRemoveWindow(
362 GingaScreenID screenId,
IWindow* iWin,
float z);
371 static void removeFromWindowList(
372 vector<IWindow*>* windows,
IWindow* win);
375 static SDL_Window* getUnderlyingWindow(GingaWindowID winId);
378 static bool drawWindow(
379 SDL_Renderer* renderer,
380 SDL_Texture* texture,
383 static void insertWindowFromRenderList(
384 IWindow* win, vector<IWindow*>* windows);
386 static void removeWindowFromRenderList(
387 IWindow* win, vector<IWindow*>* windows);
391 static SDL_Texture* createTextureFromSurface(
392 SDL_Renderer* renderer, SDL_Surface* surface);
395 static SDL_Texture* createTexture(
396 SDL_Renderer* renderer,
int w,
int h);
399 static bool hasTexture(SDL_Texture* uTex);
400 static void releaseTexture(SDL_Texture* uTex);
402 static void addUnderlyingSurface(SDL_Surface* uSur);
403 static SDL_Surface* createUnderlyingSurface(
int width,
int height);
405 static SDL_Surface* createUnderlyingSurfaceFromTexture(
406 SDL_Texture* texture);
408 static bool hasUnderlyingSurface(SDL_Surface* uSur);
411 static void releaseUnderlyingSurface(SDL_Surface* uSur);
Definition: IMediaProvider.h:62
Definition: IContinuousMediaProvider.h:71
Definition: SDLDeviceScreen.h:93
Definition: IDeviceScreen.h:73
Definition: IEventBuffer.h:63
Definition: IInputEvent.h:61
Definition: SDLDeviceScreen.h:87
Definition: IInputManager.h:67
Definition: IImageProvider.h:64
Definition: ISurface.h:64
Definition: IFontProvider.h:62