LayerManagerCommands: added RemoveSynchronizedsurface command
authorMichael Schuldt <michael.schuldt@bmw.de>
Fri, 5 Jul 2013 10:32:45 +0000 (12:32 +0200)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Fri, 5 Jul 2013 10:40:56 +0000 (12:40 +0200)
Signed-off-by: Michael Schuldt <michael.schuldt@bmw.de>
LayerManagerCommands/include/RemoveSynchronizedSurfacesCommand.h [new file with mode: 0644]
LayerManagerCommands/src/RemoveSynchronizedSurfacesCommand.cpp [new file with mode: 0644]

diff --git a/LayerManagerCommands/include/RemoveSynchronizedSurfacesCommand.h b/LayerManagerCommands/include/RemoveSynchronizedSurfacesCommand.h
new file mode 100644 (file)
index 0000000..ec488db
--- /dev/null
@@ -0,0 +1,72 @@
+/***************************************************************************
+ *
+ * Copyright 2012, Bayerische Motorenwerke Aktiengesellschaft
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+
+#ifndef _REMOVESYNCHRONIZEDSURFACESCOMMAND_H_
+#define _REMOVESYNCHRONIZEDSURFACESCOMMAND_H_
+
+#include "ICommand.h"
+
+class RemoveSynchronizedSurfacesCommand: public ICommand
+{
+public:
+    /*!
+     * \action    This command unset the surfaces which forces a synchronized composition 
+     *            in the GENIVI LayerManagement
+     * \frequency Called to force synchronized composition on a list of surfaces .
+     * \param[in] sender process id of application that sent this command
+     * \param[in] array array of surface ids
+     * \param[in] length length of array provided in parameter array
+     * \ingroup Commands
+     */
+    RemoveSynchronizedSurfacesCommand(pid_t sender, unsigned int* array, unsigned int length)
+    : ICommand(ExecuteAsynchronous, sender)
+    , m_array(array)
+    , m_length(length)
+    {}
+
+    /**
+     * \brief default destructor
+     */
+    virtual ~RemoveSynchronizedSurfacesCommand()
+    {
+        delete [] m_array;
+    }
+
+    /**
+     * \brief Execute this command.
+     * \param[in] executor Pointer to instance executing the LayerManagement COmmands
+     * \return ExecutionSuccess: execution successful
+     * \return ExecutionSuccessRedraw: execution successful and screen needs to be redrawn
+     * \return ExecutionFailed: execution failed
+     * \return ExecutionFailedRedraw: execution unsuccessful and screen needs to be redrawn
+     */
+    virtual ExecutionResult execute(ICommandExecutor* executor);
+
+    /**
+     * \brief Get description string for this command.
+     * \return String object with description of this command object
+     */
+    virtual const std::string getString();
+
+private:
+    unsigned int* m_array;
+    const unsigned int m_length;
+};
+
+#endif /* _REMOVESYNCHRONIZEDSURFACESCOMMAND_H_ */
diff --git a/LayerManagerCommands/src/RemoveSynchronizedSurfacesCommand.cpp b/LayerManagerCommands/src/RemoveSynchronizedSurfacesCommand.cpp
new file mode 100644 (file)
index 0000000..3085a22
--- /dev/null
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *
+ * Copyright 2010,2011 BMW Car IT GmbH
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "RemoveSynchronizedSurfacesCommand.h"
+#include "ICommandExecutor.h"
+#include "Scene.h"
+#include "Log.h"
+
+ExecutionResult RemoveSynchronizedSurfacesCommand::execute(ICommandExecutor* executor)
+{
+    Scene& scene = *(executor->getScene());
+    ExecutionResult result = ExecutionFailed;
+
+    LOG_DEBUG("RemoveSynchronizedSurfacesCommand", "Length to set: " << m_length);
+
+    // First of all get all surfaces which are in the current render order.
+    for (unsigned int i = 0; i < m_length; i++)
+    {
+        Surface* surface = scene.getSurface(m_array[i]);
+        if (surface)
+        {
+            surface->setSynchronized(false);
+            LOG_DEBUG("RemoveSynchronizedSurfacesCommand", "Unsetting synchronized Surface : " << m_array[i]);
+            result = ExecutionSuccess;
+        }
+    }
+    return result;
+}
+
+const std::string RemoveSynchronizedSurfacesCommand::getString()
+{
+    std::stringstream description;
+    description << "RemoveSynchronizedSurfacesCommand("
+                << "m_array=[";
+
+    for (unsigned int i = 0; i < m_length; ++i)
+    {
+        description << m_array[i] << ",";
+    }
+    description << "], m_length=" << m_length
+                << ")";
+    return description.str();
+}