1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT GmbH
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 ****************************************************************************/
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"
32 #include "ShaderMap.h"
33 #include "LayerList.h"
40 * Represents a list of Layers which contain the Surfaces.
42 class Scene: public IScene
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;
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);
61 virtual void removeLayer(Layer* layer);
62 virtual void 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;
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;
75 virtual void lockScene();
76 virtual void unlockScene();
79 // TODO: should be private -> not in ILayerList; clients should use only the interface
80 LayerList& getCurrentRenderOrder();
81 void removeSurfaceGroup(SurfaceGroup *surface);
82 void removeLayerGroup(LayerGroup *layer);
83 const SurfaceMap getAllSurfaces() const;
84 Surface* getSurfaceAt(unsigned int *x, unsigned int *y, double minOpacity);
85 bool isLayerInCurrentRenderOrder(const uint id);
88 const LayerMap getAllLayers() const;
89 void removeLayerFromAllLayerGroups(Layer* layer);
90 void removeSurfaceFromAllSurfaceGroups(Surface* surface);
93 CommandList m_toBeCommittedList;
94 ShaderMap m_shaderMap;
95 pthread_mutex_t m_layerListMutex;
96 LayerGroupMap m_layerGroupMap;
97 SurfaceGroupMap m_surfaceGroupMap;
98 SurfaceMap m_surfaceMap;
100 LayerList m_currentRenderOrder;
103 inline const LayerMap Scene::getAllLayers() const
108 inline LayerList& Scene::getCurrentRenderOrder() // TODO: const
110 return m_currentRenderOrder;
113 inline const SurfaceMap Scene::getAllSurfaces() const
118 inline void Scene::lockScene()
120 pthread_mutex_lock(&m_layerListMutex);
123 inline void Scene::unlockScene()
125 pthread_mutex_unlock(&m_layerListMutex);
128 #endif /* _SCENE_H_ */