Examples: Add LayerSceneDescriptionExample as examples
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Wed, 27 Nov 2013 05:59:27 +0000 (14:59 +0900)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Wed, 27 Nov 2013 19:59:35 +0000 (20:59 +0100)
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
ivi-layermanagement-examples/LayerSceneDescriptionExample/CMakeLists.txt [new file with mode: 0644]
ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerScene.h [new file with mode: 0644]
ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerSceneProvider.h [new file with mode: 0644]
ivi-layermanagement-examples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp [new file with mode: 0644]

diff --git a/ivi-layermanagement-examples/LayerSceneDescriptionExample/CMakeLists.txt b/ivi-layermanagement-examples/LayerSceneDescriptionExample/CMakeLists.txt
new file mode 100644 (file)
index 0000000..590af2c
--- /dev/null
@@ -0,0 +1,22 @@
+############################################################################
+#
+# 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.
+#
+
+############################################################################
+
+# examples was moved to
+# <src_root>/LayerManagerPlugins/SceneProvider/ExampleSceneProvider
\ No newline at end of file
diff --git a/ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerScene.h b/ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerScene.h
new file mode 100644 (file)
index 0000000..21530b7
--- /dev/null
@@ -0,0 +1,48 @@
+/***************************************************************************
+ *
+ * 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.
+ *
+ ****************************************************************************/
+#ifndef _LAYERSCENE_H_
+#define _LAYERSCENE_H_
+
+typedef enum e_layers
+{
+    LAYER_NEW = 0,
+    LAYER_EXAMPLE_GLES_APPLICATIONS = 1000,
+    LAYER_EXAMPLE_X_APPLICATIONS = 2000,
+    LAYER_EXAMPLE_VIDEO_APPLICATIONS = 3000
+} scenelayers;
+
+typedef enum e_surfaces
+{
+    SURFACE_NEW = 0,
+    SURFACE_EXAMPLE_EGLX11_APPLICATION = 10,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_1 = 11,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_2 = 12,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_3 = 13,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_4 = 14,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_5 = 15,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_6 = 16,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_7 = 17,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_8 = 18,
+    SURFACE_EXAMPLE_GDTESTENV_APPLICATION_9 = 19,
+    SURFACE_EXAMPLE_GLXX11_APPLICATION = 20,
+    SURFACE_EXAMPLE_EGLRAW_APPLICATION = 30,
+    SURFACE_EXAMPLE_VIDEO_APPLICATION = 40
+} sceneSurfaces;
+
+#endif /* _LAYERSCENE_H_ */
diff --git a/ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerSceneProvider.h b/ivi-layermanagement-examples/LayerSceneDescriptionExample/include/LayerSceneProvider.h
new file mode 100644 (file)
index 0000000..832ac2b
--- /dev/null
@@ -0,0 +1,44 @@
+/***************************************************************************
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef _LAYERSCENEPROVIDER_H_
+#define _LAYERSCENEPROVIDER_H_
+
+#include "ISceneProvider.h"
+
+class ICommandExecutor;
+
+/**
+ * scene Providers to setup a inital layer scenary on target platform
+ */
+class ExampleSceneProvider : public ISceneProvider
+{
+public:
+
+    ExampleSceneProvider(ICommandExecutor* executor);
+    virtual ~ExampleSceneProvider() {}
+    /**
+     * Delegate Scene : this method will be called on LayerManager startup
+     * to delegate a initial scene description of Layers on the target Platform
+     */
+    virtual bool delegateScene();
+};
+
+
+#endif /* _LAYERSCENEPROVIDER_H_ */
diff --git a/ivi-layermanagement-examples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp b/ivi-layermanagement-examples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp
new file mode 100644 (file)
index 0000000..8374014
--- /dev/null
@@ -0,0 +1,130 @@
+/***************************************************************************
+ *
+ * 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 "LayerSceneProvider.h"
+#include "ICommandExecutor.h"
+#include "CommitCommand.h"
+#include "LayerCreateCommand.h"
+#include "LayerSetDestinationRectangleCommand.h"
+#include "LayerSetSourceRectangleCommand.h"
+#include "LayerSetVisibilityCommand.h"
+#include "LayerSetOpacityCommand.h"
+#include "ScreenSetRenderOrderCommand.h"
+#include "LayerScene.h"
+#include "SurfaceCreateCommand.h"
+#include "SurfaceSetVisibilityCommand.h"
+#include "SurfaceSetOpacityCommand.h"
+#include <unistd.h>
+
+ExampleSceneProvider::LayerSceneProvider(ICommandExecutor* executor)
+: ISceneProvider(executor)
+{
+}
+
+typedef struct t_layerScene
+{
+    unsigned int layer;
+    bool visibility;
+    float opacity;
+} layerScene;
+
+typedef struct t_surfaceScene
+{
+    unsigned int surface;
+    bool visibility;
+    float opacity;
+} surfaceScene;
+
+
+static layerScene gInitialLayerScene[] =
+{
+    { LAYER_EXAMPLE_VIDEO_APPLICATIONS, true, 1.0 },
+    { LAYER_EXAMPLE_GLES_APPLICATIONS, true, 1.0 },
+    { LAYER_EXAMPLE_X_APPLICATIONS, true, 1.0 }
+};
+
+static surfaceScene gInitialSurfaceScene[] =
+{
+    { SURFACE_EXAMPLE_EGLX11_APPLICATION,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_1,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_2,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_3,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_4,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_5,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_6,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_7,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_8,false,1.0 },
+    { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_9,false,1.0 },
+    { SURFACE_EXAMPLE_GLXX11_APPLICATION,false,1.0 },
+    { SURFACE_EXAMPLE_EGLRAW_APPLICATION,false,1.0 },
+    { SURFACE_EXAMPLE_VIDEO_APPLICATION,false,1.0 }
+};
+
+
+bool ExampleSceneProvider::delegateScene()
+{
+    bool result = true;
+    pid_t layermanagerPid = getpid();
+    int i = 0;
+    int numberOfLayers = sizeof(gInitialLayerScene) / sizeof (layerScene);
+    int numberOfSurfaces = sizeof(gInitialSurfaceScene) / sizeof (surfaceScene);
+    unsigned int *renderOrder = new unsigned int [numberOfLayers];
+    unsigned int* screenResolution = m_executor->getScreenResolution(0);
+    if ( numberOfLayers > 0 )
+    {
+        /* setup inital layer scenery */
+        for (i = 0;i<numberOfLayers;i++)
+        {
+            result &= m_executor->execute(new LayerCreateCommand(layermanagerPid, screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer)));
+            result &= m_executor->execute(new LayerSetSourceRectangleCommand(layermanagerPid, gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
+            result &= m_executor->execute(new LayerSetDestinationRectangleCommand(layermanagerPid, gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
+            result &= m_executor->execute(new LayerSetOpacityCommand(layermanagerPid, gInitialLayerScene[i].layer, gInitialLayerScene[i].opacity) );
+            result &= m_executor->execute(new LayerSetVisibilityCommand(layermanagerPid, gInitialLayerScene[i].layer, gInitialLayerScene[i].visibility) );
+            result &= m_executor->execute(new CommitCommand(layermanagerPid));
+            renderOrder[i]=gInitialLayerScene[i].layer;
+        }
+        /* Finally set the first executed renderorder */
+        result &= m_executor->execute(new ScreenSetRenderOrderCommand(layermanagerPid, 0, renderOrder, numberOfLayers));
+        result &= m_executor->execute(new CommitCommand(layermanagerPid));
+    }
+
+    if ( numberOfSurfaces > 0 )
+    {
+        /* setup inital surface scenery */
+        for (i = 0;i<numberOfSurfaces;i++)
+        {
+            result &= m_executor->execute(new SurfaceCreateCommand(layermanagerPid, &(gInitialSurfaceScene[i].surface)));
+            result &= m_executor->execute(new SurfaceSetOpacityCommand(layermanagerPid, gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].opacity));
+            result &= m_executor->execute(new SurfaceSetVisibilityCommand(layermanagerPid, gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].visibility));
+            result &= m_executor->execute(new CommitCommand(layermanagerPid));
+        }
+        /* Finally set the first executed renderorder */
+    }
+    return result;
+}
+
+extern "C" ISceneProvider* createLayerScene(ICommandExecutor* executor)
+{
+    return new ExampleSceneProvider(executor);
+}
+
+extern "C" void destroyLayerScene(ExampleSceneProvider* p)
+{
+    delete p;
+}