1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT GmbH
4 * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
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 ****************************************************************************/
24 #include "SurfaceList.h"
26 #include "GraphicalSurface.h"
27 #include "LayerType.h"
28 #include "LayerCapabilities.h"
29 #include "SurfaceList.h"
32 * A graphical Layerobject which contains Surfaces.
34 class Layer : public GraphicalSurface
39 Layer(int creatorPid);
40 Layer(int id, int creatorPid);
44 LayerType getLayerType() const;
45 bool setLayerType(LayerType lt);
46 bool setLayerCapabilities(unsigned int newCapabilities);
47 unsigned int getCapabilities() const;
48 bool addSurface(Surface* s);
49 bool removeSurface(Surface* s);
50 void applySurfaceTransform();
51 SurfaceList& getAllSurfaces();
52 bool removeAllSurfaces();
53 unsigned int getContainingScreenId();
54 void setContainingScreenId(unsigned int screenid);
57 unsigned int m_screenId;
58 SurfaceList m_surfaces;
59 LayerType m_layerType;
63 inline Layer::Layer(int creatorPid)
64 : GraphicalSurface(TypeLayer, creatorPid)
65 , m_screenId(INVALID_ID)
66 , m_layerType(Software_2D)
71 inline Layer::Layer(int id, int creatorPid)
72 : GraphicalSurface(id, TypeLayer, creatorPid)
73 , m_screenId(INVALID_ID)
74 , m_layerType(Software_2D)
79 inline LayerType Layer::getLayerType() const
84 inline bool Layer::setLayerType(LayerType lt)
86 if (m_layerType != lt)
89 renderPropertyChanged = true;
95 inline bool Layer::setLayerCapabilities(uint newCapabilities)
97 if (m_capabilities != newCapabilities)
99 m_capabilities = newCapabilities;
100 renderPropertyChanged = true;
106 inline uint Layer::getCapabilities() const
108 return m_capabilities;
111 inline bool Layer::addSurface(Surface* s)
113 if (s->getContainingLayerId() == INVALID_ID)
115 m_surfaces.push_back(s);
116 s->setContainingLayerId(getID());
117 renderPropertyChanged = true;
123 inline bool Layer::removeSurface(Surface* s)
125 if (s->getContainingLayerId() == getID())
127 m_surfaces.remove(s);
128 s->setContainingLayerId(INVALID_ID);
129 renderPropertyChanged = true;
135 inline SurfaceList& Layer::getAllSurfaces()
140 inline bool Layer::removeAllSurfaces()
142 SurfaceListConstIterator iter = m_surfaces.begin();
143 SurfaceListConstIterator iterEnd = m_surfaces.end();
148 for (; iter != iterEnd; ++iter)
150 (*iter)->setContainingLayerId(GraphicalObject::INVALID_ID);
153 renderPropertyChanged = true;
157 inline unsigned int Layer::getContainingScreenId()
162 inline void Layer::setContainingScreenId(unsigned int id)
167 inline void Layer::applySurfaceTransform()
169 SurfaceListConstIterator iter = m_surfaces.begin();
170 SurfaceListConstIterator iterEnd = m_surfaces.end();
173 for (; iter != iterEnd; ++iter)
175 (*iter)->calculateTargetDestination(getSourceRegion(), getDestinationRegion());
180 #endif /* _LAYER_H_ */