1 /***************************************************************************
3 * Copyright (c) 2013 DirectFB integrated media GmbH
4 * Copyright (c) 2013 Renesas Solutions Corp.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ****************************************************************************/
21 #ifndef _DFBWINDOWSYSTEM_H_
22 #define _DFBWINDOWSYSTEM_H_
24 #include "GraphicSystems/DFBGraphicSystem.h"
25 #include "GraphicSystems/GLESGraphicSystem.h"
26 #include "WindowSystems/BaseWindowSystem.h"
28 #include "PlatformSurfaces/EglDFBPlatformSurface.h"
29 #include "ScreenShotType.h"
32 #include <direct/hash.h>
35 class DFBWindowSystem: public BaseWindowSystem {
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);
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();
51 ScreenShotType takeScreenshot;
52 std::string screenShotFile;
53 uint screenShotSurfaceID;
54 uint screenShotLayerID;
55 uint screenShotScreenID;
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;
76 IDirectFBDisplayLayer *m_layer;
77 DFBDisplay dfbDisplay;
78 IDirectFBSurface *m_primary;
79 DirectHash window_map;
80 DirectHash surface_map;
81 pthread_t renderThread;
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);
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);
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);
117 friend class DFBGraphicSystem;