From b1140c4f886035e6529bab16a13b119905ffa896 Mon Sep 17 00:00:00 2001 From: Michael Schuldt Date: Mon, 29 Aug 2011 10:53:22 +0200 Subject: [PATCH] Bugfix and SceneProviderExample added Bugfix : fixes an issue during startup, if no compositing controller are found. SceneProvider Example Implementation added. Execution of LayerManagerClientExample is no longer needed to start EGLX11ApplicationExample or GLX11ApplicationExample. Additional Build Option WITH_CLIENTEXAMPLE introduced to disable the build of client examples. --- CMakeLists.txt | 12 +++- .../LayerSceneDescriptionExample/CMakeLists.txt | 28 ++++++++ .../include/LayerSceneProvider.h | 51 +++++++++++++++ .../src/LayerSceneProvider.cpp | 76 ++++++++++++++++++++++ LayerManagerService/src/Layermanager.cpp | 17 +++-- 5 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 LayerManagerExamples/LayerSceneDescriptionExample/CMakeLists.txt create mode 100644 LayerManagerExamples/LayerSceneDescriptionExample/include/LayerSceneProvider.h create mode 100644 LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 70a4423..1c4e23c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,10 @@ option (WITH_X11_GLES option (WITH_DESKTOP "Build for Desktop / GLX" OFF) +option (WITH_CLIENTEXAMPLES + "Build client examples " ON) + + option (WITH_EGL_EXAMPLE "Build EGL_EXAMPLE " ON) @@ -94,8 +98,6 @@ add_subdirectory (LayerManagerClient/ilmClient) add_subdirectory (LayerManagerUtils) add_subdirectory (LayerManagerCommands) add_subdirectory (LayerManagerService) -add_subdirectory (LayerManagerExamples/LayerManagerClientExample) -add_subdirectory (LayerManagerExamples/LayerManagerToolBox) if (WITH_DESKTOP) set (WITH_GLX_LIB ON CACHE STRING "" FORCE) @@ -124,6 +126,12 @@ if (WITH_GLX_EXAMPLE) add_subdirectory (LayerManagerExamples/GLXApplicationExample) endif(WITH_GLX_EXAMPLE) +if (WITH_CLIENTEXAMPLES) +add_subdirectory (LayerManagerExamples/LayerManagerClientExample) +add_subdirectory (LayerManagerExamples/LayerManagerToolBox) +add_subdirectory (LayerManagerExamples/LayerSceneDescriptionExample) +endif(WITH_CLIENTEXAMPLES) + # enable ctest if building with tests # run 'make test' after build to run all tests # be aware that some tests require a running layermanager diff --git a/LayerManagerExamples/LayerSceneDescriptionExample/CMakeLists.txt b/LayerManagerExamples/LayerSceneDescriptionExample/CMakeLists.txt new file mode 100644 index 0000000..36bad55 --- /dev/null +++ b/LayerManagerExamples/LayerSceneDescriptionExample/CMakeLists.txt @@ -0,0 +1,28 @@ +############################################################################ +# +# 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_directories ("include") +include_directories ("../../LayerManagerCommands/include") +include_directories ("../../LayerManagerService/include") + +add_library(LayerScene SHARED src/LayerSceneProvider.cpp) + +target_link_libraries(LayerScene ${LIBS}) + +install (TARGETS LayerScene DESTINATION lib/layermanager) diff --git a/LayerManagerExamples/LayerSceneDescriptionExample/include/LayerSceneProvider.h b/LayerManagerExamples/LayerSceneDescriptionExample/include/LayerSceneProvider.h new file mode 100644 index 0000000..faba930 --- /dev/null +++ b/LayerManagerExamples/LayerSceneDescriptionExample/include/LayerSceneProvider.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * + * 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_PROVIDER_H_ +#define _LAYERSCENE_PROVIDER_H_ + +#include +#include "ICommandExecutor.h" +#include "ISceneProvider.h" +#include "CommitCommand.h" +#include "CreateCommand.h" +#include "SetDestinationRectangleCommand.h" +#include "SetSourceRectangleCommand.h" +#include "SetVisibilityCommand.h" +#include "SetOpacityCommand.h" +#include "SetLayerOrderCommand.h" +#include "ObjectType.h" +#include "LayerScene.h" +/** + * scene Providers to setup a inital layer scenary on target platform + */ +class LayerSceneProvider : public ISceneProvider +{ +public: + + LayerSceneProvider(ICommandExecutor* executor); + /** + * Delegate Scene : this method will be called on LayerManager startup + * to delegate a initial scene description of Layers on the target Platform + */ + bool delegateScene(); +}; + + +#endif /* _LAYERSCENE_PROVIDER_H_ */ diff --git a/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp b/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp new file mode 100644 index 0000000..7b5bef9 --- /dev/null +++ b/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * + * 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" + +LayerSceneProvider::LayerSceneProvider(ICommandExecutor* executor) +: ISceneProvider(executor) +{ +} + +typedef struct t_layerScene +{ + unsigned int layer; + bool visibility; + float opacity; +} layerScene; + +static layerScene gInitialLayerScene[] = +{ + { LAYER_EXAMPLE_VIDEO_APPLICATIONS, true, 1.0 }, + { LAYER_EXAMPLE_GLES_APPLICATIONS, true, 1.0 }, + { LAYER_EXAMPLE_X_APPLICATIONS, true, 1.0 } +}; + +bool LayerSceneProvider::delegateScene() +{ + bool result = true; + int i = 0; + int numberOfLayers = sizeof(gInitialLayerScene) / sizeof (layerScene); + unsigned int *renderOrder = new unsigned int [numberOfLayers]; + unsigned int* screenResolution = m_executor->getScreenResolution(0); + if ( numberOfLayers > 0 ) + { + /* setup inital layer scenery */ + for (i = 0;iexecute(new CreateCommand(0, TypeLayer, PIXELFORMAT_R8, screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer))); + m_executor->execute(new SetSourceRectangleCommand(gInitialLayerScene[i].layer, TypeLayer, 0, 0, screenResolution[0], screenResolution[1])); + m_executor->execute(new SetDestinationRectangleCommand(gInitialLayerScene[i].layer, TypeLayer, 0, 0, screenResolution[0], screenResolution[1])); + m_executor->execute(new SetOpacityCommand(gInitialLayerScene[i].layer,TypeLayer,gInitialLayerScene[i].opacity) ); + m_executor->execute(new SetVisibilityCommand(gInitialLayerScene[i].layer,TypeLayer,gInitialLayerScene[i].visibility) ); + m_executor->execute(new CommitCommand()); + renderOrder[i]=gInitialLayerScene[i].layer; + } + /* Finally set the first executed renderorder */ + m_executor->execute(new SetLayerOrderCommand(renderOrder,numberOfLayers)); + m_executor->execute(new CommitCommand()); + } + return result; +} + +extern "C" ISceneProvider* createLayerScene(ICommandExecutor* executor) +{ + return new LayerSceneProvider(executor); +} + +extern "C" void destroyLayerScene(LayerSceneProvider* p) +{ + delete p; +} diff --git a/LayerManagerService/src/Layermanager.cpp b/LayerManagerService/src/Layermanager.cpp index 7b1024d..f7d7ae5 100644 --- a/LayerManagerService/src/Layermanager.cpp +++ b/LayerManagerService/src/Layermanager.cpp @@ -258,21 +258,20 @@ bool Layermanager::execute(ICommand* commandToBeExecuted) bool Layermanager::startAllRenderers(const int width, const int height, const char *displayName) { - bool allStarted = true; + bool allStarted = false; RendererListIterator iter = m_pRendererList->begin(); RendererListIterator iterEnd = m_pRendererList->end(); - for (; iter != iterEnd; ++iter) { IRenderer* renderer = *iter; if (renderer) { - allStarted &= renderer->start(width, height, displayName); + allStarted = renderer->start(width, height, displayName); } - else + if (renderer == NULL || allStarted == false) { - allStarted = false; + break; } } if (!allStarted) @@ -339,7 +338,13 @@ bool Layermanager::startManagement(const int width, const int height, { bool renderersStarted = startAllRenderers(width, height, displayName); bool communicatorsStarted = startAllCommunicators(); - delegateScene(); + /* only call the initial layerscenery if all needed plugins are + * successfully started */ + + if (renderersStarted && communicatorsStarted) + { + delegateScene(); + } return renderersStarted && communicatorsStarted; } -- 2.7.4