WindowSystems: Added support for DirectFB
[profile/ivi/layer-management.git] / LayerManagerPlugins / Renderers / Graphic / include / WindowSystems / DFBWindowSystem.h
1 /***************************************************************************
2  *
3  * Copyright (c) 2013 DirectFB integrated media GmbH
4  * Copyright (c) 2013 Renesas Solutions Corp.
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20
21 #ifndef _DFBWINDOWSYSTEM_H_
22 #define _DFBWINDOWSYSTEM_H_
23
24 #include "GraphicSystems/DFBGraphicSystem.h"
25 #include "GraphicSystems/GLESGraphicSystem.h"
26 #include "WindowSystems/BaseWindowSystem.h"
27 #include "Surface.h"
28 #include "PlatformSurfaces/EglDFBPlatformSurface.h"
29 #include "ScreenShotType.h"
30
31 extern "C" {
32 #include <direct/hash.h>
33 }
34
35 class DFBWindowSystem: public BaseWindowSystem {
36 public:
37      DFBWindowSystem(int width, int height, Scene* pScene, InputManager* pInputManager, IDirectFB *dfb, IDirectFBDisplayLayer *layer);
38      virtual ~DFBWindowSystem();
39      bool init(BaseGraphicSystem<DFBDisplay, DFBWindow>* base, bool dfb_mode_hw);
40      bool start(int maxIterationDurationInMS);
41      void stop();
42      void signalRedrawEvent();
43      virtual void allocatePlatformSurface(Surface *surface);
44      virtual void deallocatePlatformSurface(Surface *surface);
45      void doScreenShot(std::string fileName, const uint screen_id);
46      void doScreenShotOfLayer(std::string fileName, const uint id);
47      void doScreenShotOfSurface(std::string fileName, const uint id, const uint layer_id);
48      DFBDisplay getNativeDisplayHandle();
49      int getIterationCounter();
50 private:
51      ScreenShotType takeScreenshot;
52      std::string screenShotFile;
53      uint screenShotSurfaceID;
54      uint screenShotLayerID;
55      uint screenShotScreenID;
56      int resolutionWidth;
57      int resolutionHeight;
58      bool m_running;
59      bool m_initialized;
60      bool m_checkWindows;
61      int m_primary_width;
62      int m_primary_height;
63      int m_mouse_x;
64      int m_mouse_y;
65      int m_mouse_x_min;
66      int m_mouse_y_min;
67      int m_mouse_x_max;
68      int m_mouse_y_max;
69      int m_adjusted_mouse_x;
70      int m_adjusted_mouse_y;
71      int m_iterationCounter;
72      int m_maxIterationDurationInMS;
73      std::list<int> *m_sceneLayers;
74 protected:
75      IDirectFB *m_dfb;
76      IDirectFBDisplayLayer *m_layer;
77      DFBDisplay dfbDisplay;
78      IDirectFBSurface *m_primary;
79      DirectHash window_map;
80      DirectHash surface_map;
81      pthread_t renderThread;
82      int windowWidth;
83      int windowHeight;
84      bool m_dfb_mode_hw;
85      bool m_ignore_surface_updates;
86      DFBSurfaceID CompositorSurface;
87      IDirectFBEventBuffer *m_events;
88      pthread_mutex_t run_lock;
89      pthread_mutex_t init_lock;
90      pthread_cond_t init_condition;
91      BaseGraphicSystem<DFBDisplay, DFBWindow>* m_gfx;
92      virtual void RedrawAllLayers(bool clear, bool swap);
93      virtual void renderSWLayers(LayerList layers, bool clear, bool swap);
94      virtual void renderHWLayer(Layer* layer, bool clear);
95 private:
96      void cleanup();
97      void Screenshot();
98      void Redraw(bool clear);
99      void createSurfaceForWindow(DFBWindow w);
100      void configureSurfaceWindow(DFBWindow w);
101      Surface* getSurfaceForWindow(DFBWindow w);
102      void checkForNewSurfaceNativeContent();
103      void destroy_surface(DFBWindow w);
104      void updateSurface(Surface* s, DFBWindow w, DFBPlatformSurface* dfbsurf);
105      void MapWindow(DFBWindow w);
106      void UnMapWindow(DFBWindow w);
107      bool NewWindow(Surface* s, DFBWindow w);
108      void DestroyWindow(DFBWindow w);
109      bool isWindowValid(DFBWindow w);
110      void EventLoop();
111      void ManageDFBInputEvent(InputDevice type, InputEventState state, DFBEvent *pevent);
112      bool deleteOrphanWindow(void *win);
113      int selectOutput(DFBGraphicSystem *gfx, int id);
114      friend void *startEventLoop(void *);
115      friend bool checkOrphanWindow(DirectHash *hash, unsigned long key, void *value, void *ctx);
116
117      friend class DFBGraphicSystem;
118 };
119
120 #endif
121