LayerManagerService Scene: Add controlling LmScreen
authorNobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Wed, 9 Jan 2013 01:43:09 +0000 (10:43 +0900)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Wed, 9 Jan 2013 12:50:15 +0000 (04:50 -0800)
-Add interface: getCurrentRenderOrder by screenID
-Remove LayerList for layerRenderOrder from Scene and add it to LmScreen

Signed-off-by: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
LayerManagerService/include/IScene.h
LayerManagerService/include/Scene.h
LayerManagerService/src/Scene.cpp

index 0542430..609f91a 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
  * 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");
@@ -27,6 +28,8 @@
 #include "SurfaceGroup.h"
 #include "LayerList.h"
 #include "SurfaceMap.h"
+#include "LmScreen.h"
+#include "LmScreenList.h"
 
 /**
  * \defgroup SceneAPI Layer Management Scene API
@@ -99,6 +102,14 @@ public:
     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
@@ -191,9 +202,17 @@ public:
     /**
      * \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.
index a0a960a..6a9229c 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
  * 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");
@@ -31,6 +32,7 @@
 #include "LayerMap.h"
 #include "ShaderMap.h"
 #include "LayerList.h"
+#include "LmScreenList.h"
 #include <pthread.h>
 
 class Layer;
@@ -61,6 +63,8 @@ public:
     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);
@@ -75,7 +79,7 @@ public:
     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;
@@ -95,7 +99,8 @@ private:
     SurfaceGroupMap m_surfaceGroupMap;
     SurfaceMap m_surfaceMap;
     LayerMap m_layerMap;
-    LayerList m_currentRenderOrder;
+    LayerList m_nullRenderOrder;
+    LmScreenList m_screenList;
 };
 
 inline const LayerMap Scene::getAllLayers() const
@@ -103,9 +108,22 @@ 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
index 7d11d4c..1c510c4 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
  * 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");
@@ -142,6 +143,23 @@ LayerGroup* Scene::createLayerGroup(const uint layerGroupId, int creatorPid)
     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;
@@ -215,12 +233,22 @@ void Scene::removeLayerFromAllLayerGroups(Layer* layer)
 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;
@@ -320,19 +348,25 @@ bool Scene::getLayerIDsOfScreen(const uint screenID, uint* length,
         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)
     {
@@ -398,14 +432,25 @@ void Scene::getLayerGroupIDs(uint* length, uint** array) const
 
 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;
 }