LayerManagerService: added support for client specific command queues
[profile/ivi/layer-management.git] / LayerManagerService / include / Scene.h
1 /***************************************************************************
2  *
3  * Copyright 2010,2011 BMW Car IT GmbH
4  * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
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 #ifndef _SCENE_H_
21 #define _SCENE_H_
22
23 #include "IScene.h"
24 #include "Layermanager.h"
25 #include "CommandList.h"
26 #include "ShaderMap.h"
27 #include "LayerGroup.h"
28 #include "LayerGroupMap.h"
29 #include "SurfaceGroup.h"
30 #include "SurfaceGroupMap.h"
31 #include "SurfaceMap.h"
32 #include "LayerMap.h"
33 #include "ShaderMap.h"
34 #include "LayerList.h"
35 #include "LmScreenList.h"
36 #include <pthread.h>
37
38 class Layer;
39 class Surface;
40
41 /*
42  * Represents a list of Layers which contain the Surfaces.
43  */
44 class Scene: public IScene
45 {
46     // TODO: these should use public interface instead
47     friend class Layermanager;
48     friend class CommitCommand;
49     friend class ShaderCreateCommand;
50     friend class ShaderDestroyCommand;
51     friend class SurfaceSetShaderCommand;
52     friend class ShaderSetUniformsCommand;
53
54 public:
55     Scene();
56     virtual ~Scene();
57
58     virtual Layer* createLayer(const uint id, int creatorPid);
59     virtual Surface *createSurface(const uint id, int creatorPid);
60     virtual LayerGroup *createLayerGroup(const uint id, int creatorPid);
61     virtual SurfaceGroup *createSurfaceGroup(const uint id, int creatorPid);
62
63     virtual bool removeLayer(Layer* layer);
64     virtual bool removeSurface(Surface* surface);
65     virtual void removeSurfaceNativeContent(Surface* surface);
66     virtual LmScreenList& getScreenList();
67     virtual LmScreen* getScreen(const uint id) const;
68     virtual Layer* getLayer(const uint id);
69     virtual Surface* getSurface(const uint id);
70     virtual SurfaceGroup* getSurfaceGroup(const uint id);
71     virtual LayerGroup* getLayerGroup(const uint id);
72
73     virtual void getLayerIDs(uint* length, uint** array) const;
74     virtual bool getLayerIDsOfScreen(const uint screenID, uint* length, uint** array) const;
75     virtual void getSurfaceGroupIDs(uint* length, uint** array) const;
76     virtual void getLayerGroupIDs(uint* length, uint** array) const;
77     virtual void getSurfaceIDs(uint* length, uint** array) const;
78
79     virtual void lockScene();
80     virtual void unlockScene();
81
82     virtual LayerList& getCurrentRenderOrder(const uint id);
83     virtual void removeSurfaceGroup(SurfaceGroup *surface);
84     virtual void removeLayerGroup(LayerGroup *layer);
85     virtual const SurfaceMap getAllSurfaces() const;
86     virtual bool isLayerInCurrentRenderOrder(const uint id);
87
88     const LayerMap getAllLayers() const;
89
90 private:
91     void removeLayerFromAllLayerGroups(Layer* layer);
92     void removeSurfaceFromAllSurfaceGroups(Surface* surface);
93
94 private:
95     ShaderMap m_shaderMap;
96     pthread_mutex_t m_layerListMutex;
97     LayerGroupMap m_layerGroupMap;
98     SurfaceGroupMap m_surfaceGroupMap;
99     SurfaceMap m_surfaceMap;
100     LayerMap m_layerMap;
101     LayerList m_nullRenderOrder;
102     LmScreenList m_screenList;
103 };
104
105 inline const LayerMap Scene::getAllLayers() const
106 {
107     return m_layerMap;
108 }
109
110 inline LayerList& Scene::getCurrentRenderOrder(const uint id) // TODO: const
111 {
112     LmScreen* screen = Scene::getScreen(id);
113     if (NULL != screen)
114     {
115         return screen->getCurrentRenderOrder();
116     }
117     else
118     {
119         return m_nullRenderOrder;
120     }
121 }
122
123 inline LmScreenList& Scene::getScreenList()
124 {
125     return m_screenList;
126 }
127
128 inline const SurfaceMap Scene::getAllSurfaces() const
129 {
130     return m_surfaceMap;
131 }
132
133 inline void Scene::lockScene()
134 {
135     pthread_mutex_lock(&m_layerListMutex);
136 }
137
138 inline void Scene::unlockScene()
139 {
140     pthread_mutex_unlock(&m_layerListMutex);
141 }
142
143 #endif /* _SCENE_H_ */