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 "LayerSceneProvider.h"
22 LayerSceneProvider::LayerSceneProvider(ICommandExecutor* executor)
23 : ISceneProvider(executor)
27 typedef struct t_layerScene
34 static layerScene gInitialLayerScene[] =
36 { LAYER_EXAMPLE_VIDEO_APPLICATIONS, true, 1.0 },
37 { LAYER_EXAMPLE_GLES_APPLICATIONS, true, 1.0 },
38 { LAYER_EXAMPLE_X_APPLICATIONS, true, 1.0 }
41 bool LayerSceneProvider::delegateScene()
45 int numberOfLayers = sizeof(gInitialLayerScene) / sizeof (layerScene);
46 unsigned int *renderOrder = new unsigned int [numberOfLayers];
47 unsigned int* screenResolution = m_executor->getScreenResolution(0);
48 if ( numberOfLayers > 0 )
50 /* setup inital layer scenery */
51 for (i = 0;i<numberOfLayers;i++)
53 m_executor->execute(new CreateCommand(0, TypeLayer, PIXELFORMAT_R8, screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer)));
54 m_executor->execute(new SetSourceRectangleCommand(gInitialLayerScene[i].layer, TypeLayer, 0, 0, screenResolution[0], screenResolution[1]));
55 m_executor->execute(new SetDestinationRectangleCommand(gInitialLayerScene[i].layer, TypeLayer, 0, 0, screenResolution[0], screenResolution[1]));
56 m_executor->execute(new SetOpacityCommand(gInitialLayerScene[i].layer,TypeLayer,gInitialLayerScene[i].opacity) );
57 m_executor->execute(new SetVisibilityCommand(gInitialLayerScene[i].layer,TypeLayer,gInitialLayerScene[i].visibility) );
58 m_executor->execute(new CommitCommand());
59 renderOrder[i]=gInitialLayerScene[i].layer;
61 /* Finally set the first executed renderorder */
62 m_executor->execute(new SetLayerOrderCommand(renderOrder,numberOfLayers));
63 m_executor->execute(new CommitCommand());
68 extern "C" ISceneProvider* createLayerScene(ICommandExecutor* executor)
70 return new LayerSceneProvider(executor);
73 extern "C" void destroyLayerScene(LayerSceneProvider* p)