Remove previous input event management
[profile/ivi/layer-management.git] / LayerManagerService / include / Scene.h
1 /***************************************************************************
2  *
3  * Copyright 2010,2011 BMW Car IT GmbH
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  ****************************************************************************/
19 #ifndef _SCENE_H_
20 #define _SCENE_H_
21
22 #include "IScene.h"
23 #include "Layermanager.h"
24 #include "CommandList.h"
25 #include "ShaderMap.h"
26 #include "LayerGroup.h"
27 #include "LayerGroupMap.h"
28 #include "SurfaceGroup.h"
29 #include "SurfaceGroupMap.h"
30 #include "SurfaceMap.h"
31 #include "LayerMap.h"
32 #include "ShaderMap.h"
33 #include "LayerList.h"
34 #include <pthread.h>
35
36 class Layer;
37 class Surface;
38
39 /*
40  * Represents a list of Layers which contain the Surfaces.
41  */
42 class Scene: public IScene
43 {
44     // TODO: these should use public interface instead
45     friend class Layermanager;
46     friend class CommitCommand;
47     friend class ShaderCreateCommand;
48     friend class ShaderDestroyCommand;
49     friend class SurfaceSetShaderCommand;
50     friend class ShaderSetUniformsCommand;
51
52 public:
53     Scene();
54     virtual ~Scene();
55
56     virtual Layer* createLayer(const uint id);
57     virtual Surface *createSurface(const uint id);
58     virtual LayerGroup *createLayerGroup(const uint id);
59     virtual SurfaceGroup *createSurfaceGroup(const uint id);
60
61     virtual bool removeLayer(Layer* layer);
62     virtual bool removeSurface(Surface* surface);
63     virtual void removeSurfaceNativeContent(Surface* surface);
64     virtual Layer* getLayer(const uint id) const;
65     virtual Surface* getSurface(const uint id) const;
66     virtual SurfaceGroup* getSurfaceGroup(const uint id) const;
67     virtual LayerGroup* getLayerGroup(const uint id) const;
68
69     virtual void getLayerIDs(uint* length, uint** array) const;
70     virtual bool getLayerIDsOfScreen(const uint screenID, uint* length, uint** array) const;
71     virtual void getSurfaceGroupIDs(uint* length, uint** array) const;
72     virtual void getLayerGroupIDs(uint* length, uint** array) const;
73     virtual void getSurfaceIDs(uint* length, uint** array) const;
74
75     virtual void lockScene();
76     virtual void unlockScene();
77
78     virtual LayerList& getCurrentRenderOrder();
79     virtual void removeSurfaceGroup(SurfaceGroup *surface);
80     virtual void removeLayerGroup(LayerGroup *layer);
81     virtual const SurfaceMap getAllSurfaces() const;
82     virtual bool isLayerInCurrentRenderOrder(const uint id);
83
84 private:
85     const LayerMap getAllLayers() const;
86     void removeLayerFromAllLayerGroups(Layer* layer);
87     void removeSurfaceFromAllSurfaceGroups(Surface* surface);
88
89 private:
90     CommandList m_toBeCommittedList;
91     ShaderMap m_shaderMap;
92     pthread_mutex_t m_layerListMutex;
93     LayerGroupMap m_layerGroupMap;
94     SurfaceGroupMap m_surfaceGroupMap;
95     SurfaceMap m_surfaceMap;
96     LayerMap m_layerMap;
97     LayerList m_currentRenderOrder;
98 };
99
100 inline const LayerMap Scene::getAllLayers() const
101 {
102     return m_layerMap;
103 }
104
105 inline LayerList& Scene::getCurrentRenderOrder() // TODO: const
106 {
107     return m_currentRenderOrder;
108 }
109
110 inline const SurfaceMap Scene::getAllSurfaces() const
111 {
112     return m_surfaceMap;
113 }
114
115 inline void Scene::lockScene()
116 {
117     pthread_mutex_lock(&m_layerListMutex);
118 }
119
120 inline void Scene::unlockScene()
121 {
122     pthread_mutex_unlock(&m_layerListMutex);
123 }
124
125 #endif /* _SCENE_H_ */