1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #include "ExampleSceneProvider.h"
21 #include "ICommandExecutor.h"
22 #include "CommitCommand.h"
23 #include "LayerCreateCommand.h"
24 #include "LayerSetDestinationRectangleCommand.h"
25 #include "LayerSetSourceRectangleCommand.h"
26 #include "LayerSetVisibilityCommand.h"
27 #include "LayerSetOpacityCommand.h"
28 #include "ScreenSetRenderOrderCommand.h"
29 #include "ExampleAppIds.h"
30 #include "SurfaceCreateCommand.h"
31 #include "SurfaceSetVisibilityCommand.h"
32 #include "SurfaceSetOpacityCommand.h"
33 #include "Configuration.h"
36 ExampleSceneProvider::ExampleSceneProvider(ICommandExecutor& executor, Configuration& config)
37 : ISceneProvider(&executor)
38 , PluginBase(executor, config, SceneProvider_Api_v1)
40 , mConfiguration(config)
44 typedef struct t_layerScene
51 typedef struct t_surfaceScene
59 static layerScene gInitialLayerScene[] =
61 { LAYER_EXAMPLE_VIDEO_APPLICATIONS, true, 1.0 },
62 { LAYER_EXAMPLE_GLES_APPLICATIONS, true, 1.0 },
63 { LAYER_EXAMPLE_X_APPLICATIONS, true, 1.0 }
66 static surfaceScene gInitialSurfaceScene[] =
68 { SURFACE_EXAMPLE_EGLX11_APPLICATION, false, 1.0 },
69 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_1, false, 1.0 },
70 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_2, false, 1.0 },
71 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_3, false, 1.0 },
72 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_4, false, 1.0 },
73 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_5, false, 1.0 },
74 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_6, false, 1.0 },
75 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_7, false, 1.0 },
76 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_8, false, 1.0 },
77 { SURFACE_EXAMPLE_GDTESTENV_APPLICATION_9, false, 1.0 },
78 { SURFACE_EXAMPLE_GLXX11_APPLICATION, false, 1.0 },
79 { SURFACE_EXAMPLE_EGLRAW_APPLICATION, false, 1.0 },
80 { SURFACE_EXAMPLE_VIDEO_APPLICATION, false, 1.0 }
84 bool ExampleSceneProvider::delegateScene()
87 pid_t layermanagerPid = getpid();
89 int numberOfLayers = sizeof(gInitialLayerScene) / sizeof(layerScene);
90 int numberOfSurfaces = sizeof(gInitialSurfaceScene) / sizeof(surfaceScene);
91 unsigned int *renderOrder = new unsigned int [numberOfLayers];
92 unsigned int* screenResolution = mExecutor.getScreenResolution(0);
93 if (numberOfLayers > 0)
95 /* setup inital layer scenery */
96 for (i = 0; i<numberOfLayers; i++)
98 result &= mExecutor.execute(new LayerCreateCommand(layermanagerPid,
101 &(gInitialLayerScene[i].layer)));
102 result &= mExecutor.execute(new LayerSetSourceRectangleCommand(layermanagerPid,
103 gInitialLayerScene[i].layer,
106 screenResolution[1]));
107 result &= mExecutor.execute(new LayerSetDestinationRectangleCommand(layermanagerPid,
108 gInitialLayerScene[i].layer,
111 screenResolution[1]));
112 result &= mExecutor.execute(new LayerSetOpacityCommand(layermanagerPid,
113 gInitialLayerScene[i].layer,
114 gInitialLayerScene[i].opacity));
115 result &= mExecutor.execute(new LayerSetVisibilityCommand(layermanagerPid,
116 gInitialLayerScene[i].layer,
117 gInitialLayerScene[i].visibility));
118 result &= mExecutor.execute(new CommitCommand(layermanagerPid));
119 renderOrder[i]=gInitialLayerScene[i].layer;
121 /* Finally set the first executed renderorder */
122 result &= mExecutor.execute(new ScreenSetRenderOrderCommand(layermanagerPid, 0, renderOrder, numberOfLayers));
123 result &= mExecutor.execute(new CommitCommand(layermanagerPid));
126 if (numberOfSurfaces > 0)
128 /* setup inital surface scenery */
129 for (i = 0; i<numberOfSurfaces; i++)
131 result &= mExecutor.execute(new SurfaceCreateCommand(layermanagerPid,
132 &(gInitialSurfaceScene[i].surface)));
133 result &= mExecutor.execute(new SurfaceSetOpacityCommand(layermanagerPid,
134 gInitialSurfaceScene[i].surface,
135 gInitialSurfaceScene[i].opacity));
136 result &= mExecutor.execute(new SurfaceSetVisibilityCommand(layermanagerPid,
137 gInitialSurfaceScene[i].surface,
138 gInitialSurfaceScene[i].visibility));
139 result &= mExecutor.execute(new CommitCommand(layermanagerPid));
141 /* Finally set the first executed renderorder */
146 t_ilm_const_string ExampleSceneProvider::pluginGetName() const
148 return "ExampleSceneProvider";
151 int ExampleSceneProvider::getIterationCounter()
153 // this plugin is one-shot and is not monitored.
154 static int dummyValue = 0;
158 DECLARE_LAYERMANAGEMENT_PLUGIN(ExampleSceneProvider)