LayerManagerCommands: return redraw only when absolutely required
authorRahul Singhal <rasinghal@nvidia.com>
Mon, 9 Apr 2012 05:52:44 +0000 (11:22 +0530)
committerMichael Schuldt <michael.schuldt@bmw.de>
Thu, 3 May 2012 07:20:44 +0000 (09:20 +0200)
This is a small optimization to cover a corner case where a client
may blindly keep setting the same property without changing its value
forcing a redundant composition.

Change-Id: Ie872b65c6fcbd2a2e17a9f883112c347860d90d1

35 files changed:
LayerManagerCommands/include/ShaderDestroyCommand.h
LayerManagerCommands/src/LayerAddSurfaceCommand.cpp
LayerManagerCommands/src/LayerRemoveCommand.cpp
LayerManagerCommands/src/LayerRemoveSurfaceCommand.cpp
LayerManagerCommands/src/LayerSetDestinationRectangleCommand.cpp
LayerManagerCommands/src/LayerSetDimensionCommand.cpp
LayerManagerCommands/src/LayerSetOpacityCommand.cpp
LayerManagerCommands/src/LayerSetOrientationCommand.cpp
LayerManagerCommands/src/LayerSetPositionCommand.cpp
LayerManagerCommands/src/LayerSetRenderOrderCommand.cpp
LayerManagerCommands/src/LayerSetSourceRectangleCommand.cpp
LayerManagerCommands/src/LayerSetTypeCommand.cpp
LayerManagerCommands/src/LayerSetVisibilityCommand.cpp
LayerManagerCommands/src/LayergroupSetOpacityCommand.cpp
LayerManagerCommands/src/LayergroupSetVisibilityCommand.cpp
LayerManagerCommands/src/ScreenSetRenderOrderCommand.cpp
LayerManagerCommands/src/ShaderDestroyCommand.cpp
LayerManagerCommands/src/SurfaceRemoveCommand.cpp
LayerManagerCommands/src/SurfaceSetDestinationRectangleCommand.cpp
LayerManagerCommands/src/SurfaceSetDimensionCommand.cpp
LayerManagerCommands/src/SurfaceSetOpacityCommand.cpp
LayerManagerCommands/src/SurfaceSetOrientationCommand.cpp
LayerManagerCommands/src/SurfaceSetPositionCommand.cpp
LayerManagerCommands/src/SurfaceSetShaderCommand.cpp
LayerManagerCommands/src/SurfaceSetSourceRectangleCommand.cpp
LayerManagerCommands/src/SurfaceSetVisibilityCommand.cpp
LayerManagerCommands/src/SurfacegroupSetOpacityCommand.cpp
LayerManagerCommands/src/SurfacegroupSetVisibilityCommand.cpp
LayerManagerService/include/GraphicalGroup.h
LayerManagerService/include/GraphicalObject.h
LayerManagerService/include/GraphicalSurface.h
LayerManagerService/include/IScene.h
LayerManagerService/include/Layer.h
LayerManagerService/include/Scene.h
LayerManagerService/src/Scene.cpp

index d08c7ea..96ad3e3 100644 (file)
@@ -62,9 +62,9 @@ public:
 
 private:
     /// detach shader from all surfaces, surface groups, etc... from surfaces
-    void removeShaderFromAllSurfaces(const SurfaceMap & surfaceMap, Shader* shader);
+    bool removeShaderFromAllSurfaces(const SurfaceMap & surfaceMap, Shader* shader);
 
-    void removeShaderFromAllLayers(const LayerMap & layerMap, Shader *& shader);
+    bool removeShaderFromAllLayers(const LayerMap & layerMap, Shader *& shader);
 
 private:
     const unsigned int m_id;
index 4239402..e720d58 100644 (file)
@@ -38,17 +38,17 @@ ExecutionResult LayerAddSurfaceCommand::execute(ICommandExecutor* executor)
 
     if (layer != NULL && surface != NULL)
     {
-        unsigned int layer_id = surface->getContainingLayerId();
-        if (layer_id != GraphicalObject::INVALID_ID)
+        if (layer->addSurface(surface))
         {
-            LOG_WARNING("LayerAddSurfaceCommand","surface : id [ " << m_surfaceid << " ] already belongs to layer : id [ " << layer_id << " ]");
+            LOG_DEBUG("LayerAddSurfaceCommand","Adding surface(" << m_surfaceid << ")" << surface->getID() << " to layer(" << m_layerid << ") " << layer->getID());
+            LOG_DEBUG("LayerAddSurfaceCommand", "Layer now has #surfaces:" << layer->getAllSurfaces().size());
+            result = surface->hasNativeContent() ? ExecutionSuccessRedraw : ExecutionSuccess;
         }
         else
         {
-            LOG_DEBUG("LayerAddSurfaceCommand","add surface(" << m_surfaceid << ")" << surface->getID() << " to layer(" << m_layerid << ") " << layer->getID());
-            layer->addSurface(surface);
-            LOG_DEBUG("LayerAddSurfaceCommand", "Layer now has #surfaces:" << layer->getAllSurfaces().size());
-            result = ExecutionSuccessRedraw;
+            unsigned int layer_id = surface->getContainingLayerId();
+            LOG_WARNING("LayerAddSurfaceCommand","surface : id [ " << m_surfaceid << " ] already belongs to layer : id [ " << layer_id << " ]");
+            result = (m_layerid == layer_id) ? ExecutionSuccess : ExecutionFailed;
         }
     }
 
index 855db0e..ceef6a7 100644 (file)
@@ -36,13 +36,16 @@ ExecutionResult LayerRemoveCommand::execute(ICommandExecutor* executor)
     Layer* layer = scene.getLayer(m_idToRemove);
     if (layer)
     {
-        if (scene.isLayerInCurrentRenderOrder(m_idToRemove))
+        if (scene.removeLayer(layer))
         {
             IRenderer* renderer = *((executor->getRendererList())->begin());
             renderer->forceCompositionWindowSystem();
+            result = ExecutionSuccessRedraw;
+        }
+        else
+        {
+            result = ExecutionSuccess;
         }
-        scene.removeLayer(layer);
-        result = ExecutionSuccessRedraw;
     }
 
     return result;
index 12f3a27..c40b9c3 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerRemoveSurfaceCommand::execute(ICommandExecutor* executor)
 
     if (layer && surface)
     {
-        layer->removeSurface(surface);
-        result = ExecutionSuccessRedraw;
+        result = layer->removeSurface(surface) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 5cff050..5f46176 100644 (file)
@@ -42,8 +42,7 @@ ExecutionResult LayerSetDestinationRectangleCommand::execute(ICommandExecutor* e
     if (layer)
     {
         const Rectangle rectangle(m_x, m_y, m_width, m_height);
-        layer->setDestinationRegion(rectangle);
-        result = ExecutionSuccessRedraw;
+        result = layer->setDestinationRegion(rectangle) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 183d25b..707a4bb 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerSetDimensionCommand::execute(ICommandExecutor* executor)
 
     if (layer)
     {
-        layer->setDimension(m_width, m_height);
-        result = ExecutionSuccessRedraw;
+        result = layer->setDimension(m_width, m_height) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 9655fad..ca017f2 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerSetOpacityCommand::execute(ICommandExecutor* executor)
     if (layer)
     {
         LOG_DEBUG("LayerSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
-        layer->setOpacity(m_opacity);
-        result = ExecutionSuccessRedraw;
+        result = layer->setOpacity(m_opacity) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 7a31be8..8ad8d66 100644 (file)
@@ -37,8 +37,7 @@ ExecutionResult LayerSetOrientationCommand::execute(ICommandExecutor* executor)
 
     if (layer)
     {
-        layer->setOrientation(m_orientation);
-        result = ExecutionSuccessRedraw;
+        result = layer->setOrientation(m_orientation) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 6e21a47..48c218f 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerSetPositionCommand::execute(ICommandExecutor* executor)
 
     if (layer)
     {
-        layer->setPosition(m_x, m_y);
-        result = ExecutionSuccessRedraw;
+        result = layer->setPosition(m_x, m_y) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
     return result;
 }
index f97c66e..77a9b07 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerSetRenderOrderCommand::execute(ICommandExecutor* executor)
 
     if (layer)
     {
-        layer->removeAllSurfaces();
-        result = ExecutionSuccessRedraw;
+        result = layer->removeAllSurfaces() ? ExecutionSuccessRedraw : ExecutionSuccess;
 
         for (unsigned int surfaceIndex = 0; surfaceIndex < m_length; ++surfaceIndex)
         {
@@ -48,15 +47,14 @@ ExecutionResult LayerSetRenderOrderCommand::execute(ICommandExecutor* executor)
             if (surface)
             {
                 unsigned int layer_id = surface->getContainingLayerId();
-                if (layer_id != GraphicalObject::INVALID_ID)
+                if (layer->addSurface(surface))
                 {
-                    LOG_WARNING("LayerSetRenderOrderCommand","surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
+                    LOG_DEBUG("LayerSetRenderOrderCommand","Adding surface " << surface->getID() << " to renderorder of layer " << m_layerid);
+                    result = ExecutionSuccessRedraw;
                 }
                 else
                 {
-                    LOG_DEBUG("LayerSetRenderOrderCommand","add surface " << surface->getID() << " to renderorder of layer " << m_layerid);
-                    layer->addSurface(surface);
-                    result = ExecutionSuccessRedraw;
+                    LOG_WARNING("LayerSetRenderOrderCommand","surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
                 }
             }
         }
index 0a3fe4e..5045d48 100644 (file)
@@ -41,8 +41,7 @@ ExecutionResult LayerSetSourceRectangleCommand::execute(ICommandExecutor* execut
     if (layer)
     {
         const Rectangle rectangle(m_x, m_y, m_width, m_height);
-        layer->setSourceRegion(rectangle);
-        result = ExecutionSuccessRedraw;
+        result = layer->setSourceRegion(rectangle) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index fd30471..403dd5d 100644 (file)
@@ -40,8 +40,7 @@ ExecutionResult LayerSetTypeCommand::execute(ICommandExecutor* executor)
     if (layer)
     {
         LOG_DEBUG("LayerSetTypeCommand", "setting type: " << m_layerType << " of layer id " << m_idtoSet);
-        layer->setLayerType(m_layerType);
-        result = ExecutionSuccessRedraw;
+        result = layer->setLayerType(m_layerType) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 0a82749..00cf53a 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayerSetVisibilityCommand::execute(ICommandExecutor* executor)
     if (layer)
     {
         LOG_DEBUG("LayerSetVisibilityCommand", "setting visibility: " << m_visibility << " of id " << m_idtoSet);
-        layer->setVisibility(m_visibility);
-        result = ExecutionSuccessRedraw;
+        result = layer->setVisibility(m_visibility) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 26e955c..0e111b1 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayergroupSetOpacityCommand::execute(ICommandExecutor* executor)
     if (layergroup)
     {
         LOG_DEBUG("LayergroupSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
-        layergroup->setOpacity(m_opacity);
-        result = ExecutionSuccessRedraw;
+        result = layergroup->setOpacity(m_opacity) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index bc60ef6..0cfde2f 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult LayergroupSetVisibilityCommand::execute(ICommandExecutor* execut
     if (layergroup)
     {
         LOG_DEBUG("LayergroupSetVisibilityCommand", "setting visibility: " << m_visibility << " of id " << m_idtoSet);
-        layergroup->setVisibility(m_visibility);
-        result = ExecutionSuccessRedraw;
+        result = layergroup->setVisibility(m_visibility) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index f5d87d7..864de3d 100644 (file)
@@ -31,7 +31,6 @@ ExecutionResult ScreenSetRenderOrderCommand::execute(ICommandExecutor* executor)
 {
     Scene& scene = *(executor->getScene());
     ExecutionResult result = ExecutionFailed;
-    IRenderer* renderer = *((executor->getRendererList())->begin());
 
     // check for doubles
     for (unsigned int i = 0; i < m_length; i++)
@@ -56,9 +55,14 @@ ExecutionResult ScreenSetRenderOrderCommand::execute(ICommandExecutor* executor)
     //                return false;
     //        } // TODO insert again later
 
+    if (scene.getCurrentRenderOrder().size() != 0)
+    {
+        IRenderer* renderer = *((executor->getRendererList())->begin());
+        renderer->forceCompositionWindowSystem();
+        result = ExecutionSuccessRedraw;
+    }
+
     scene.getCurrentRenderOrder().clear();
-    result = ExecutionSuccessRedraw;
-    renderer->forceCompositionWindowSystem();
 
     LOG_DEBUG("ScreenSetRenderOrderCommand", "Length to set: " << m_length);
 
@@ -73,6 +77,7 @@ ExecutionResult ScreenSetRenderOrderCommand::execute(ICommandExecutor* executor)
             result = ExecutionSuccessRedraw;
         }
     }
+
     return result;
 }
 
index f234fdf..24d2460 100644 (file)
@@ -31,6 +31,7 @@ ExecutionResult ShaderDestroyCommand::execute(ICommandExecutor* executor)
 {
     Scene& scene = *(executor->getScene());
     ShaderMap& shaderMap = scene.m_shaderMap;
+    ExecutionResult result = ExecutionFailed;
 
     // get shader by its ID
     ShaderMapIterator iter = shaderMap.find(m_id);
@@ -48,10 +49,10 @@ ExecutionResult ShaderDestroyCommand::execute(ICommandExecutor* executor)
     if (shader)
     {
         const SurfaceMap& surfaceMap = scene.getAllSurfaces();
-        removeShaderFromAllSurfaces(surfaceMap, shader);
+        result = removeShaderFromAllSurfaces(surfaceMap, shader) ? ExecutionSuccessRedraw : ExecutionSuccess;
 
         const LayerMap& layerMap = scene.getAllLayers();
-        removeShaderFromAllLayers(layerMap, shader);
+        result = removeShaderFromAllLayers(layerMap, shader) ? ExecutionSuccessRedraw : result;
 
         // remove shader from global shader list
         scene.m_shaderMap.erase(iter);
@@ -60,12 +61,13 @@ ExecutionResult ShaderDestroyCommand::execute(ICommandExecutor* executor)
         delete shader;
     }
 
-    return ExecutionSuccessRedraw;
+    return result;
 }
 
 /// detach shader from all surfaces, surface groups, etc... from surfaces
-void ShaderDestroyCommand::removeShaderFromAllSurfaces(const SurfaceMap & surfaceMap, Shader* shader)
+bool ShaderDestroyCommand::removeShaderFromAllSurfaces(const SurfaceMap & surfaceMap, Shader* shader)
 {
+    bool result = false;
     SurfaceMapConstIterator iter = surfaceMap.begin();
     SurfaceMapConstIterator iterEnd = surfaceMap.end();
     for (; iter != iterEnd; ++iter)
@@ -75,12 +77,16 @@ void ShaderDestroyCommand::removeShaderFromAllSurfaces(const SurfaceMap & surfac
         if (obj && obj->getShader() == shader)
         {
             obj->setShader(NULL);
+            result = true;
         }
     }
+
+    return result;
 }
 
-void ShaderDestroyCommand::removeShaderFromAllLayers(const LayerMap & layerMap, Shader *& shader)
+bool ShaderDestroyCommand::removeShaderFromAllLayers(const LayerMap & layerMap, Shader *& shader)
 {
+    bool result = false;
     LayerMapConstIterator iter = layerMap.begin();
     LayerMapConstIterator iterEnd = layerMap.end();
     for (; iter != iterEnd; ++iter)
@@ -90,8 +96,11 @@ void ShaderDestroyCommand::removeShaderFromAllLayers(const LayerMap & layerMap,
         if (obj && obj->getShader()==shader)
         {
             obj->setShader(NULL);
+            result = true;
         }
     }
+
+    return result;
 }
 
 unsigned int ShaderDestroyCommand::getShaderID() const
index 98624f1..a0b3f4d 100644 (file)
@@ -33,12 +33,11 @@ ExecutionResult SurfaceRemoveCommand::execute(ICommandExecutor* executor)
 
     ExecutionResult result = ExecutionFailed;
 
-       Surface* surface = scene.getSurface(m_idToRemove);
-       if (surface)
-       {
-               scene.removeSurface(surface);
-               result = ExecutionSuccessRedraw;
-       }
+    Surface* surface = scene.getSurface(m_idToRemove);
+    if (surface)
+    {
+        result = scene.removeSurface(surface) ? ExecutionSuccessRedraw : ExecutionSuccess;
+    }
 
     return result;
 }
index 9db666a..dc0191a 100644 (file)
@@ -42,8 +42,7 @@ ExecutionResult SurfaceSetDestinationRectangleCommand::execute(ICommandExecutor*
     if (surface)
     {
         const Rectangle rectangle(m_x, m_y, m_width, m_height);
-        surface->setDestinationRegion(rectangle);
-        result = ExecutionSuccessRedraw;
+        result = surface->setDestinationRegion(rectangle) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 3dcef6c..850ef00 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfaceSetDimensionCommand::execute(ICommandExecutor* executor)
 
     if (surface)
     {
-        surface->setDimension(m_width, m_height);
-        result = ExecutionSuccessRedraw;
+        result = surface->setDimension(m_width, m_height) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 5e45f72..76bcb3d 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfaceSetOpacityCommand::execute(ICommandExecutor* executor)
     if (surface)
     {
         LOG_DEBUG("SurfaceSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
-        surface->setOpacity(m_opacity);
-        result = ExecutionSuccessRedraw;
+        result = surface->setOpacity(m_opacity) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 172c6fb..4f67f10 100644 (file)
@@ -37,8 +37,7 @@ ExecutionResult SurfaceSetOrientationCommand::execute(ICommandExecutor* executor
 
     if (surface)
     {
-        surface->setOrientation(m_orientation);
-        result = ExecutionSuccessRedraw;
+        result = surface->setOrientation(m_orientation) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index ce144a0..579889e 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfaceSetPositionCommand::execute(ICommandExecutor* executor)
 
     if (surface)
     {
-        surface->setPosition(m_x, m_y);
-        result = ExecutionSuccessRedraw;
+        result = surface->setPosition(m_x, m_y) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
     return result;
 }
index ea1068e..5989476 100644 (file)
@@ -64,8 +64,7 @@ ExecutionResult SurfaceSetShaderCommand::execute(ICommandExecutor* executor)
             // shaderId==0 detaches the custom shader
             // (shader is supposed to be NULL in this case)
 
-            object->setShader(shader);
-            result = ExecutionSuccessRedraw;
+            result = object->setShader(shader) ? ExecutionSuccessRedraw : ExecutionSuccess;
         }
         else
         {
index 24b4cbb..1472992 100644 (file)
@@ -41,8 +41,7 @@ ExecutionResult SurfaceSetSourceRectangleCommand::execute(ICommandExecutor* exec
     if (surface)
     {
         const Rectangle rectangle(m_x, m_y, m_width, m_height);
-        surface->setSourceRegion(rectangle);
-        result = ExecutionSuccessRedraw;
+        result = surface->setSourceRegion(rectangle) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 7ef15eb..784d95f 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfaceSetVisibilityCommand::execute(ICommandExecutor* executor)
     if (surface)
     {
         LOG_DEBUG("SurfaceSetVisibilityCommand", "setting visibility: " << m_visibility << " of id " << m_idtoSet);
-        surface->setVisibility(m_visibility);
-        result = ExecutionSuccessRedraw;
+        result = surface->setVisibility(m_visibility) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index 7f4e065..53974c1 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfacegroupSetOpacityCommand::execute(ICommandExecutor* executo
     if (surfacegroup)
     {
         LOG_DEBUG("SurfacegroupSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
-        surfacegroup->setOpacity(m_opacity);
-        result = ExecutionSuccessRedraw;
+        result = surfacegroup->setOpacity(m_opacity) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index a0bc152..72ae92e 100644 (file)
@@ -38,8 +38,7 @@ ExecutionResult SurfacegroupSetVisibilityCommand::execute(ICommandExecutor* exec
     if (surfacegroup)
     {
         LOG_DEBUG("SurfacegroupSetVisibilityCommand", "setting visibility: " << m_visibility << " of id " << m_idtoSet);
-        surfacegroup->setVisibility(m_visibility);
-        result = ExecutionSuccessRedraw;
+        result = surfacegroup->setVisibility(m_visibility) ? ExecutionSuccessRedraw : ExecutionSuccess;
     }
 
     return result;
index b0f697e..a808116 100644 (file)
@@ -48,25 +48,29 @@ public:
     /**
      * Set visibility on every element of the group
      */
-    virtual void setVisibility(bool visible)
+    virtual bool setVisibility(bool visible)
     {
+        bool result = false;
         this->visibility = visible;
         for(typename std::list<T*>::iterator it = list.begin(); it != list.end(); ++it)
         {
-            (*it)->setVisibility(visible);
+            result |= (*it)->setVisibility(visible);
         }
+        return result;
     }
 
     /**
      * Set opacity on every element of the group
      */
-    virtual void setOpacity(double opacity)
+    virtual bool setOpacity(double opacity)
     {
+        bool result = false;
         this->opacity = opacity;
         for(typename std::list<T*>::iterator it = list.begin(); it != list.end(); ++it)
         {
-            (*it)->setOpacity(opacity);
+            result |= (*it)->setOpacity(opacity);
         }
+        return result;
     }
 
     const std::list<T*> getList() const
index 3e4d408..a830696 100644 (file)
@@ -31,17 +31,19 @@ class GraphicalObject
 {
 public:
 
-       GraphicalObject(ObjectType type, double opacity, bool visibility);
+    GraphicalObject(ObjectType type, double opacity, bool visibility);
 
-       GraphicalObject(int externalId,ObjectType type, double opacity, bool visibility);
+    GraphicalObject(int externalId,ObjectType type, double opacity, bool visibility);
 
-       virtual ~GraphicalObject() {}
+    virtual ~GraphicalObject() {}
 
     /**
      * @brief Set alpha value
      * @param[in] newOpacity The new Alpha Value between 0.0 (full transparency) and 1.0 (fully visible)
+     * @return TRUE if the new Alpha Value is not equal to the current Alpha Value
+     *         FALSE if they are equal
      */
-    virtual void setOpacity(double newOpacity);
+    virtual bool setOpacity(double newOpacity);
 
     /**
      * @brief Get alpha value
@@ -49,13 +51,15 @@ public:
      */
     double getOpacity() const;
 
-       /**
-        * Set the visibility
-        * @param[in] newVisibility set this object visible (true) or invisible (false)
-        */
-       virtual void setVisibility(bool newVisibility);
+    /**
+     * Set the visibility
+     * @param[in] newVisibility set this object visible (true) or invisible (false)
+     * @return TRUE if the new visiblity value is not equal to the current visibility value
+     *         FALSE if they are equal
+     */
+    virtual bool setVisibility(bool newVisibility);
 
-       bool getVisibility() const;
+    bool getVisibility() const;
 
     /**
      * @brief Get external ID for graphical object
@@ -63,12 +67,14 @@ public:
      */
     virtual unsigned int getID();
 
-       /**
-        * Assign custom shader for rendering
-        *
-        * @param[in] s Custom shader. If NULL, default shader will be used.
-        */
-       void setShader(Shader* s);
+    /**
+     * Assign custom shader for rendering
+     *
+     * @param[in] s Custom shader. If NULL, default shader will be used.
+     * @return TRUE if the new custom shader is different from the current custom shader
+     *         FALSE if they are same
+     */
+    bool setShader(Shader* s);
 
     /**
      * @brief get the currently assigned custom shader object
@@ -79,8 +85,8 @@ public:
 public:
     static const unsigned int INVALID_ID;
     ObjectType type;
-       bool renderPropertyChanged;
-       bool damaged;
+    bool renderPropertyChanged;
+    bool damaged;
 
     ///     Pointer to currently assigned shader. If NULL, a default shader will be used.
     Shader* shader;
@@ -119,13 +125,15 @@ inline GraphicalObject::GraphicalObject(int externalId, ObjectType type, double
 {
 }
 
-inline void GraphicalObject::setOpacity(double newOpacity)
+inline bool GraphicalObject::setOpacity(double newOpacity)
 {
-       if (opacity != newOpacity)
-       {
-               renderPropertyChanged = true;
-       }
-       opacity = newOpacity;
+    if (opacity != newOpacity)
+    {
+        opacity = newOpacity;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline double GraphicalObject::getOpacity() const
@@ -133,13 +141,15 @@ inline double GraphicalObject::getOpacity() const
     return opacity;
 }
 
-inline void GraphicalObject::setVisibility(bool newVisibility)
+inline bool GraphicalObject::setVisibility(bool newVisibility)
 {
-       if (visibility != newVisibility)
-       {
-               renderPropertyChanged = true;
-       }
-       visibility = newVisibility;
+    if (visibility != newVisibility)
+    {
+        visibility = newVisibility;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline bool GraphicalObject::getVisibility() const
@@ -152,10 +162,15 @@ inline unsigned int GraphicalObject::getID()
     return graphicExternalId;
 }
 
-inline void GraphicalObject::setShader(Shader* s)
+inline bool GraphicalObject::setShader(Shader* s)
 {
-       renderPropertyChanged = true;
-       shader = s;
+    if (shader != s)
+    {
+        shader = s;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline Shader* GraphicalObject::getShader()
index 5bf915f..2392f14 100644 (file)
@@ -40,29 +40,35 @@ public:
     /**
      * @brief Set Orientation value
      * @param[in] newOrientation the new value. Multiples of 90 degrees. (0->0°, 1->90°, 2->180°,3->279°)
+     * @return TRUE if the new orientation value is not equal to the current orientation value
+     *         FALSE if they are equal
      */
-    void setOrientation(OrientationType newOrientation);
+    bool setOrientation(OrientationType newOrientation);
 
     OrientationType getOrientation() const;
 
     /**
      * @brief Set Source Viewport (only use portion of source graphics)
      * @param[in] newSource Rectangle defining position and size within surface (clip from the left)
+     * @return TRUE if the new source rectangle is not equal to the current source rectangle
+     *         FALSE if they are equal
      */
-    void setSourceRegion(const Rectangle& newSource);
+    bool setSourceRegion(const Rectangle& newSource);
 
     const Rectangle& getSourceRegion() const;
 
     /**
      * Set Destination Viewport (Scale output)
      * @param[in] newDestination Rectangle defining destination position and size
+     * @return TRUE if the new destination rectangle is not equal to the current destination rectangle
+     *         FALSE if they are equal
      */
-    void setDestinationRegion(const Rectangle& newDestination);
+    bool setDestinationRegion(const Rectangle& newDestination);
 
-    void setPosition(const unsigned int& x, const unsigned int& y);
+    bool setPosition(const unsigned int& x, const unsigned int& y);
 
     Vector2 getPosition();
-    void setDimension(const unsigned int& width, const unsigned int& height);
+    bool setDimension(const unsigned int& width, const unsigned int& height);
 
     const Rectangle& getDestinationRegion() const;
     Vector2 getDimension();
@@ -125,13 +131,15 @@ inline GraphicalSurface::GraphicalSurface(int externalId,ObjectType type)
 {
 }
 
-inline void GraphicalSurface::setOrientation(OrientationType newOrientation)
+inline bool GraphicalSurface::setOrientation(OrientationType newOrientation)
 {
-       if (m_orientation != newOrientation)
-       {
-               renderPropertyChanged = true;
-       }
-       m_orientation = newOrientation;
+    if (m_orientation != newOrientation)
+    {
+        m_orientation = newOrientation;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline OrientationType GraphicalSurface::getOrientation() const
@@ -139,34 +147,43 @@ inline OrientationType GraphicalSurface::getOrientation() const
     return m_orientation;
 }
 
-inline void GraphicalSurface::setSourceRegion(const Rectangle& newSource)
+inline bool GraphicalSurface::setSourceRegion(const Rectangle& newSource)
 {
-       if (!(m_sourceViewport == newSource))
-       {
-               renderPropertyChanged = true;
-       }
-       m_sourceViewport = newSource;}
+    if (!(m_sourceViewport == newSource))
+    {
+        m_sourceViewport = newSource;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
+}
 
 inline const Rectangle& GraphicalSurface::getSourceRegion() const
 {
     return m_sourceViewport;
 }
 
-inline void GraphicalSurface::setDestinationRegion(const Rectangle& newDestination)
+inline bool GraphicalSurface::setDestinationRegion(const Rectangle& newDestination)
 {
-       if (!(m_destinationViewport == newDestination))
-       {
-               renderPropertyChanged = true;
-       }
-       m_destinationViewport = newDestination;}
+    if (!(m_destinationViewport == newDestination))
+    {
+        m_destinationViewport = newDestination;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
+}
 
-inline void GraphicalSurface::setPosition(const unsigned int& x, const unsigned int& y)
+inline bool GraphicalSurface::setPosition(const unsigned int& x, const unsigned int& y)
 {
-       if (m_destinationViewport.x != x || m_destinationViewport.y != y)
-       {
-               renderPropertyChanged = true;
-       }
-       m_destinationViewport.x = x; m_destinationViewport.y = y;
+    if (m_destinationViewport.x != x || m_destinationViewport.y != y)
+    {
+        m_destinationViewport.x = x;
+        m_destinationViewport.y = y;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline Vector2 GraphicalSurface::getPosition()
@@ -174,13 +191,16 @@ inline Vector2 GraphicalSurface::getPosition()
     return Vector2(m_destinationViewport.x,m_destinationViewport.y);
 }
 
-inline void GraphicalSurface::setDimension(const unsigned int& width, const unsigned int& height)
+inline bool GraphicalSurface::setDimension(const unsigned int& width, const unsigned int& height)
 {
-       if (m_destinationViewport.width != width || m_destinationViewport.height != height)
-       {
-               renderPropertyChanged = true;
-       }
-       m_destinationViewport.width = width; m_destinationViewport.height = height;
+    if (m_destinationViewport.width != width || m_destinationViewport.height != height)
+    {
+        m_destinationViewport.width = width;
+        m_destinationViewport.height = height;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline const Rectangle& GraphicalSurface::getDestinationRegion() const
index 7569a87..94392c2 100644 (file)
@@ -85,14 +85,14 @@ public:
      * \ingroup SceneAPI
      * \param[in] layer pointer to layer
      */
-    virtual void removeLayer(Layer* layer) = 0;
+    virtual bool removeLayer(Layer* layer) = 0;
 
     /**
      * \brief Remove surface from scene.
      * \ingroup SceneAPI
      * \param[in] surface pointer to surface
      */
-    virtual void removeSurface(Surface* surface) = 0;
+    virtual bool removeSurface(Surface* surface) = 0;
 
     /**
      * \brief Get a layer of the scene by id.
index 6c2f5bd..2633df3 100644 (file)
@@ -41,13 +41,13 @@ public:
     virtual ~Layer() {}
 
     LayerType getLayerType() const;
-    void setLayerType(LayerType lt);
-    void setLayerCapabilities(unsigned int newCapabilities);
+    bool setLayerType(LayerType lt);
+    bool setLayerCapabilities(unsigned int newCapabilities);
     unsigned int getCapabilities() const;
-    void addSurface(Surface* s);
-    void removeSurface(Surface* s);
+    bool addSurface(Surface* s);
+    bool removeSurface(Surface* s);
     SurfaceList& getAllSurfaces();
-    void removeAllSurfaces();
+    bool removeAllSurfaces();
 
 private:
     SurfaceList m_surfaces;
@@ -74,22 +74,26 @@ inline LayerType Layer::getLayerType() const
     return m_layerType;
 }
 
-inline void Layer::setLayerType(LayerType lt)
+inline bool Layer::setLayerType(LayerType lt)
 {
-       if (m_layerType != lt)
-       {
-               renderPropertyChanged = true;
-       }
-    m_layerType = lt;
+    if (m_layerType != lt)
+    {
+        m_layerType = lt;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
-inline void Layer::setLayerCapabilities(uint newCapabilities)
+inline bool Layer::setLayerCapabilities(uint newCapabilities)
 {
-       if (m_capabilities != newCapabilities)
-       {
-               renderPropertyChanged = true;
-       }
-    m_capabilities = newCapabilities;
+    if (m_capabilities != newCapabilities)
+    {
+        m_capabilities = newCapabilities;
+        renderPropertyChanged = true;
+        return true;
+    }
+    return false;
 }
 
 inline uint Layer::getCapabilities() const
@@ -97,24 +101,28 @@ inline uint Layer::getCapabilities() const
     return m_capabilities;
 }
 
-inline void Layer::addSurface(Surface* s)
+inline bool Layer::addSurface(Surface* s)
 {
     if (s->getContainingLayerId() == INVALID_ID)
     {
         m_surfaces.push_back(s);
         s->setContainingLayerId(getID());
         renderPropertyChanged = true;
+        return true;
     }
+    return false;
 }
 
-inline void Layer::removeSurface(Surface* s)
+inline bool Layer::removeSurface(Surface* s)
 {
     if (s->getContainingLayerId() == getID())
     {
         m_surfaces.remove(s);
         s->setContainingLayerId(INVALID_ID);
         renderPropertyChanged = true;
+        return true;
     }
+    return false;
 }
 
 inline SurfaceList& Layer::getAllSurfaces()
@@ -122,16 +130,21 @@ inline SurfaceList& Layer::getAllSurfaces()
     return m_surfaces;
 }
 
-inline void Layer::removeAllSurfaces()
+inline bool Layer::removeAllSurfaces()
 {
     SurfaceListConstIterator iter = m_surfaces.begin();
     SurfaceListConstIterator iterEnd = m_surfaces.end();
+
+    if(iter == iterEnd)
+        return false;
+
     for (; iter != iterEnd; ++iter)
     {
         (*iter)->setContainingLayerId(GraphicalObject::INVALID_ID);
     }
     m_surfaces.clear();
     renderPropertyChanged = true;
+    return true;
 }
 
 #endif /* _LAYER_H_ */
index 6019993..7230486 100644 (file)
@@ -58,8 +58,8 @@ public:
     virtual LayerGroup *createLayerGroup(const uint id);
     virtual SurfaceGroup *createSurfaceGroup(const uint id);
 
-    virtual void removeLayer(Layer* layer);
-    virtual void removeSurface(Surface* surface);
+    virtual bool removeLayer(Layer* layer);
+    virtual bool removeSurface(Surface* surface);
     virtual void removeSurfaceNativeContent(Surface* surface);
     virtual Layer* getLayer(const uint id) const;
     virtual Surface* getSurface(const uint id) const;
index ff94279..f2f5c94 100644 (file)
@@ -209,16 +209,21 @@ void Scene::removeLayerFromAllLayerGroups(Layer* layer)
 }
 
 /// \brief take layer out of list of layers
-void Scene::removeLayer(Layer* layer)
+bool Scene::removeLayer(Layer* layer)
 {
+    bool result = false;
+
     if (layer != NULL)
     {
+        result = isLayerInCurrentRenderOrder(layer->getID());
         layer->removeAllSurfaces();
         m_currentRenderOrder.remove(layer);
         m_layerMap.erase(layer->getID());
         removeLayerFromAllLayerGroups(layer);
         delete layer;
     }
+
+    return result;
 }
 
 /// \brief remove surface from all surfacegroups it might be part of
@@ -235,8 +240,10 @@ void Scene::removeSurfaceFromAllSurfaceGroups(Surface* surface)
 }
 
 /// \brief take surface out of list of surfaces
-void Scene::removeSurface(Surface* surface)
+bool Scene::removeSurface(Surface* surface)
 {
+    bool result = false;
+
     if (surface != NULL)
     {
         uint surfaceId = surface->getID();
@@ -247,7 +254,7 @@ void Scene::removeSurface(Surface* surface)
             Layer* layer = getLayer(layerId);
             if (layer != NULL)
             {
-                layer->removeSurface(surface);
+                result = layer->removeSurface(surface);
             }
         }
 
@@ -256,6 +263,8 @@ void Scene::removeSurface(Surface* surface)
 
         delete surface;
     }
+
+    return result;
 }
 /// \brief take removing applied native content
 void Scene::removeSurfaceNativeContent(Surface* surface)