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 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;
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();
78 virtual LayerList& getCurrentRenderOrder();
79 virtual void removeSurfaceGroup(SurfaceGroup *surface);
80 virtual void removeLayerGroup(LayerGroup *layer);
81 virtual const SurfaceMap getAllSurfaces() const;
82 virtual Surface* getSurfaceAt(unsigned int *x, unsigned int *y, double minOpacity);
83 virtual bool isLayerInCurrentRenderOrder(const uint id);
86 const LayerMap getAllLayers() const;
87 void removeLayerFromAllLayerGroups(Layer* layer);
88 void removeSurfaceFromAllSurfaceGroups(Surface* surface);
91 CommandList m_toBeCommittedList;
92 ShaderMap m_shaderMap;
93 pthread_mutex_t m_layerListMutex;
94 LayerGroupMap m_layerGroupMap;
95 SurfaceGroupMap m_surfaceGroupMap;
96 SurfaceMap m_surfaceMap;
98 LayerList m_currentRenderOrder;
101 inline const LayerMap Scene::getAllLayers() const
106 inline LayerList& Scene::getCurrentRenderOrder() // TODO: const
108 return m_currentRenderOrder;
111 inline const SurfaceMap Scene::getAllSurfaces() const
116 inline void Scene::lockScene()
118 pthread_mutex_lock(&m_layerListMutex);
121 inline void Scene::unlockScene()
123 pthread_mutex_unlock(&m_layerListMutex);
126 #endif /* _SCENE_H_ */