/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "SurfaceGroup.h"
#include "LayerList.h"
#include "SurfaceMap.h"
+#include "LmScreen.h"
+#include "LmScreenList.h"
/**
* \defgroup SceneAPI Layer Management Scene API
virtual bool removeSurface(Surface* surface) = 0;
/**
+ * \brief Get a screen of the scene by id.
+ * \ingroup SceneAPI
+ * \param[in] id id of the screen
+ * \return pointer to the screen with id
+ */
+ virtual LmScreen* getScreen(const uint id) const = 0;
+
+ /**
* \brief Get a layer of the scene by id.
* \ingroup SceneAPI
* \param[in] id id of the layer
/**
* \brief Get the current render order of the scene.
* \ingroup SceneAPI
+ * \param[in] id screen id
* \return reference to render order
*/
- virtual LayerList& getCurrentRenderOrder() = 0;
+ virtual LayerList& getCurrentRenderOrder(const uint id) = 0;
+
+ /**
+ * \brief Get the screen list of the scene.
+ * \ingroup SceneAPI
+ * \return reference to screen list
+ */
+ virtual LmScreenList& getScreenList() = 0;
/**
* \brief Remove a surface group from scene.
/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "LayerMap.h"
#include "ShaderMap.h"
#include "LayerList.h"
+#include "LmScreenList.h"
#include <pthread.h>
class Layer;
virtual bool removeLayer(Layer* layer);
virtual bool removeSurface(Surface* surface);
virtual void removeSurfaceNativeContent(Surface* surface);
+ virtual LmScreenList& getScreenList();
+ virtual LmScreen* getScreen(const uint id) const;
virtual Layer* getLayer(const uint id);
virtual Surface* getSurface(const uint id);
virtual SurfaceGroup* getSurfaceGroup(const uint id);
virtual void lockScene();
virtual void unlockScene();
- virtual LayerList& getCurrentRenderOrder();
+ virtual LayerList& getCurrentRenderOrder(const uint id);
virtual void removeSurfaceGroup(SurfaceGroup *surface);
virtual void removeLayerGroup(LayerGroup *layer);
virtual const SurfaceMap getAllSurfaces() const;
SurfaceGroupMap m_surfaceGroupMap;
SurfaceMap m_surfaceMap;
LayerMap m_layerMap;
- LayerList m_currentRenderOrder;
+ LayerList m_nullRenderOrder;
+ LmScreenList m_screenList;
};
inline const LayerMap Scene::getAllLayers() const
return m_layerMap;
}
-inline LayerList& Scene::getCurrentRenderOrder() // TODO: const
+inline LayerList& Scene::getCurrentRenderOrder(const uint id) // TODO: const
{
- return m_currentRenderOrder;
+ LmScreen* screen = Scene::getScreen(id);
+ if (NULL != screen)
+ {
+ return screen->getCurrentRenderOrder();
+ }
+ else
+ {
+ return m_nullRenderOrder;
+ }
+}
+
+inline LmScreenList& Scene::getScreenList()
+{
+ return m_screenList;
}
inline const SurfaceMap Scene::getAllSurfaces() const
/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
return newLayerGroup;
}
+
+LmScreen* Scene::getScreen(const uint screenId) const
+{
+ LmScreenListConstIterator iter = m_screenList.begin();
+ LmScreenListConstIterator iterEnd = m_screenList.end();
+ for (; iter != iterEnd; ++iter)
+ {
+ if (screenId == (*iter)->getID())
+ {
+ return (*iter);
+ }
+ }
+ LOG_WARNING("Scene","screen not found : id [ " << screenId << " ]");
+
+ return NULL;
+}
+
Layer* Scene::getLayer(const uint layerId)
{
Layer* layer = NULL;
bool Scene::removeLayer(Layer* layer)
{
bool result = false;
+ LmScreenListIterator iter = m_screenList.begin();
+ LmScreenListIterator iterEnd = m_screenList.end();
if (layer != NULL)
{
result = isLayerInCurrentRenderOrder(layer->getID());
layer->removeAllSurfaces();
- m_currentRenderOrder.remove(layer);
+ for (; iter != iterEnd; ++iter)
+ {
+ if (NULL == *iter)
+ {
+ LOG_WARNING("Scene", "screen invalid");
+ continue;
+ }
+ (*iter)->getCurrentRenderOrder().remove(layer);
+ }
m_layerMap.erase(layer->getID());
removeLayerFromAllLayerGroups(layer);
delete layer;
uint** array) const
{
// check if screen is valid, currently all layers are only on one screen
- if (screenID != 0) // TODO: remove hard-coded value
+ LmScreen* screen = NULL;
+ uint numOfLayers = 0;
+ uint arrayPos = 0;
+ LayerList currentRenderOrder;
+
+ screen = getScreen(screenID);
+ if (NULL == screen)
{
return false;
}
- uint numOfLayers = m_currentRenderOrder.size();
- uint arrayPos = 0;
+ currentRenderOrder = screen->getCurrentRenderOrder();
+ numOfLayers = currentRenderOrder.size();
*length = numOfLayers;
*array = new uint[numOfLayers]; // TODO: safe, if size = 0?
- LayerListConstIterator iter = m_currentRenderOrder.begin();
- LayerListConstIterator iterEnd = m_currentRenderOrder.end();
+ LayerListConstIterator iter = currentRenderOrder.begin();
+ LayerListConstIterator iterEnd = currentRenderOrder.end();
for (; iter != iterEnd; ++iter)
{
bool Scene::isLayerInCurrentRenderOrder(const uint id)
{
- LayerListConstIterator iter = m_currentRenderOrder.begin();
- LayerListConstIterator iterEnd = m_currentRenderOrder.end();
+ LmScreenListIterator iterScreen = m_screenList.begin();
+ LmScreenListIterator iterScreenEnd = m_screenList.end();
+ LayerList currentRenderOrder;
+ LayerListIterator iterLayer;
+ LayerListIterator iterLayerEnd;
- for (; iter != iterEnd; ++iter)
+ for (; iterScreen != iterScreenEnd; ++iterScreen)
{
- if ((*iter)->getID() == id)
- return true;
- }
+ currentRenderOrder = (*iterScreen)->getCurrentRenderOrder();
+ iterLayer = currentRenderOrder.begin();
+ iterLayerEnd = currentRenderOrder.end();
+ for (; iterLayer != iterLayerEnd; ++iterLayer)
+ {
+ if (id == (*iterLayer)->getID())
+ {
+ return true;
+ }
+ }
+ }
return false;
}