if (WITH_CLIENTEXAMPLES)
add_subdirectory (LayerManagerExamples/LayerManagerClientExample)
add_subdirectory (LayerManagerExamples/LayerManagerToolBox)
+ add_subdirectory (LayerManagerExamples/LayerManagerControl)
add_subdirectory (LayerManagerExamples/LayerSceneDescriptionExample)
endif(WITH_CLIENTEXAMPLES)
%{_bindir}/EGLX11ApplicationExample
%{_bindir}/LayerManagerClientExample
%{_bindir}/LayerManagerToolBox
+%{_bindir}/LayerManagerControl
%{_bindir}/EGLX11MockNavigation
/etc/dbus-1/session.d/LayerManagerService.conf
--- /dev/null
+############################################################################
+#
+# Copyright 2012 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.
+#
+
+############################################################################
+
+project (LayerManagerControl)
+
+# use default compiler settings here
+set (CMAKE_CXX_FLAGS "")
+
+include_directories(
+ include
+ "../../LayerManagerClient/ilmClient/include"
+ "../../LayerManagerUtils/include"
+)
+
+add_executable(${PROJECT_NAME}
+ src/main.cpp
+ src/commands.cpp
+ src/helper.cpp
+ src/Expression.cpp
+ src/ExpressionInterpreter.cpp
+)
+
+add_dependencies(${PROJECT_NAME}
+ ilmClient
+ LayerManagerUtils
+)
+
+target_link_libraries(${PROJECT_NAME} ilmClient)
+
+install (TARGETS ${PROJECT_NAME} DESTINATION bin)
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 __EXPRESSION_H__
+#define __EXPRESSION_H__
+
+#include <string>
+#include <list>
+using namespace std;
+
+class Expression;
+
+typedef void(*callback)(Expression*);
+typedef list<Expression*> ExpressionList;
+
+class Expression
+{
+public:
+ Expression(string name, Expression* parent);
+ string getName();
+
+ Expression* getPreviousExpression();
+ void addNextExpression(Expression* word);
+ Expression* getNextExpression(string text);
+
+ void setFunc(callback funcPtr);
+ void execute();
+ bool isExecutable();
+
+ bool isVar();
+ void setVarValue(string value);
+
+ string getString(string name);
+ unsigned int getUint(string name);
+ void getUintArray(string name, unsigned int** array, unsigned int* scount);
+ int getInt(string name);
+ double getDouble(string name);
+ bool getBool(string name);
+
+ void printTree(int level = 0);
+ void printList(string list = "");
+
+private:
+ string mName;
+ ExpressionList mNextWords;
+ Expression* mPreviousWord;
+ callback mFuncPtr;
+ string mVarValue;
+
+};
+
+#endif // __EXPRESSION_H__
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 __COMMANDINTERPRETER_H__
+#define __COMMANDINTERPRETER_H__
+
+#include "Expression.h"
+#include <string>
+using namespace std;
+
+enum CommandResult
+{
+ CommandSuccess,
+ CommandIncomplete,
+ CommandInvalid
+};
+
+class ExpressionInterpreter
+{
+public:
+ ExpressionInterpreter();
+ CommandResult interpretCommand(string userInput);
+ string getLastError();
+ static void printExpressionTree();
+ static void printExpressionList();
+
+ static bool addExpression(callback funcPtr, string command);
+
+private:
+ static Expression* mpRoot;
+ string mErrorText;
+};
+
+#endif // __COMMANDINTERPRETER_H__
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 "Expression.h"
+#include <iostream>
+#include <sstream>
+#include <stdio.h>
+#include <string.h> // memcpy
+
+Expression::Expression(string name, Expression* parent)
+: mName(name)
+, mPreviousWord(parent)
+, mFuncPtr(NULL)
+{
+}
+
+void Expression::setVarValue(string value)
+{
+ mVarValue = value;
+}
+
+bool Expression::isVar()
+{
+ return mName.at(0) == '<';
+}
+
+string Expression::getString(string name)
+{
+ string varName;
+ varName += "<";
+ varName += name;
+ varName += ">";
+
+ if (mName != varName)
+ {
+ if (mPreviousWord)
+ {
+ return mPreviousWord->getString(name);
+ }
+ else
+ {
+ return "";
+ }
+ }
+ return mVarValue;
+}
+
+unsigned int Expression::getUint(string name)
+{
+ string stringVal = getString(name);
+
+ unsigned int value = 0;
+ sscanf(stringVal.c_str(), "%u", &value);
+
+ if (!value)
+ {
+ sscanf(stringVal.c_str(), "0x%x", &value);
+ }
+ return value;
+}
+
+void Expression::getUintArray(string name, unsigned int** array, unsigned int* count)
+{
+ stringstream ss;
+ ss << getString(name);
+
+ unsigned int buffer[256]; // more than enough for all cases
+ *count = 0;
+
+ string stringVal;
+ while (getline( ss, stringVal, ',' ))
+ {
+ sscanf(stringVal.c_str(), "%u", &buffer[*count]);
+
+ if (!buffer[*count])
+ {
+ sscanf(stringVal.c_str(), "0x%x", &buffer[*count]);
+ }
+ ++(*count);
+ }
+
+ *array = new unsigned int[*count];
+ memcpy(*array, buffer, sizeof(unsigned int) * (*count));
+}
+
+int Expression::getInt(string name)
+{
+ string stringVal = getString(name);
+
+ int value = 0;
+ sscanf(stringVal.c_str(), "%d", &value);
+
+ if (!value)
+ {
+ sscanf(stringVal.c_str(), "0x%x", &value);
+ }
+ return value;
+}
+
+double Expression::getDouble(string name)
+{
+ string stringVal = getString(name);
+
+ double value = 0;
+ sscanf(stringVal.c_str(), "%lf", &value);
+ return value;
+}
+
+bool Expression::getBool(string name)
+{
+ string stringVal = getString(name);
+ int value = 0;
+ return sscanf(stringVal.c_str(), "%d", &value) && value;
+}
+
+string Expression::getName()
+{
+ return mName;
+}
+
+bool ExpressionCompare(Expression* a, Expression* b)
+{
+ return a->getName() < b->getName();
+}
+
+void Expression::addNextExpression(Expression* word)
+{
+ mNextWords.push_back(word);
+ mNextWords.sort(ExpressionCompare);
+}
+
+Expression* Expression::getNextExpression(string text)
+{
+ Expression* varMatch = NULL;
+ Expression* nameMatch = NULL;
+
+ ExpressionList::const_iterator iter = mNextWords.begin();
+ ExpressionList::const_iterator end = mNextWords.end();
+ for (; iter != end; ++iter)
+ {
+ Expression* expr = *iter;
+
+ if (expr->getName() == text)
+ {
+ nameMatch = expr;
+ }
+
+ if (expr->isVar())
+ {
+ varMatch = expr;
+ varMatch->setVarValue(text);
+ }
+ }
+
+ return nameMatch ? nameMatch : (varMatch ? varMatch : NULL);
+}
+
+void Expression::printTree(int level)
+{
+ for (int i = 0; i < level; ++i)
+ {
+ cout << ((i + 1 != level) ? "| " : "|--");
+ }
+
+ stringstream name;
+ name << mName;
+
+ if (isExecutable())
+ {
+ name << "*";
+ }
+
+ cout << name.str() << endl;
+
+ ExpressionList::const_iterator iter = mNextWords.begin();
+ ExpressionList::const_iterator end = mNextWords.end();
+ for (; iter != end; ++iter)
+ {
+ (*iter)->printTree(level + 1);
+ }
+}
+
+void Expression::printList(string list)
+{
+ if (mName != "[root]")
+ {
+ list += mName;
+ list += " ";
+ if (isExecutable())
+ {
+ cout << list << "\n";
+ }
+ }
+
+ ExpressionList::const_iterator iter = mNextWords.begin();
+ ExpressionList::const_iterator end = mNextWords.end();
+ for (; iter != end; ++iter)
+ {
+ (*iter)->printList(list);
+ }
+}
+
+bool Expression::isExecutable()
+{
+ return mFuncPtr;
+}
+
+void Expression::execute()
+{
+ (*mFuncPtr)(this);
+}
+
+void Expression::setFunc(callback funcPtr)
+{
+ mFuncPtr = funcPtr;
+}
+
+Expression* Expression::getPreviousExpression()
+{
+ return mPreviousWord;
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 "ExpressionInterpreter.h"
+#include "Expression.h"
+#include <string>
+#include <sstream>
+#include <algorithm> // transform
+#include <ctype.h> // tolower
+
+Expression* ExpressionInterpreter::mpRoot = NULL;
+
+ExpressionInterpreter::ExpressionInterpreter()
+: mErrorText("No error.")
+{
+}
+
+bool ExpressionInterpreter::addExpression(callback funcPtr, string command)
+{
+ bool result = false;
+
+ string text;
+ stringstream ss;
+ ss << command;
+
+ if (!mpRoot)
+ {
+ mpRoot = new Expression("[root]", NULL);
+ }
+
+ Expression* currentWord = mpRoot;
+
+ while (!ss.eof())
+ {
+ ss >> text;
+ transform(text.begin(), text.end(), text.begin(), ::tolower);
+ string name = currentWord->getName();
+
+ Expression* nextWord = currentWord->getNextExpression(text);
+
+ if (!nextWord)
+ {
+ nextWord = new Expression(text, currentWord);
+ currentWord->addNextExpression(nextWord);
+ }
+
+ currentWord = nextWord;
+ }
+
+ currentWord->setFunc(funcPtr);
+
+ return result;
+}
+
+CommandResult ExpressionInterpreter::interpretCommand(string userInput)
+{
+ CommandResult result = CommandSuccess;
+ string text;
+ stringstream ss;
+ ss << userInput;
+
+ Expression* currentWord = mpRoot;
+
+ while (result == CommandSuccess && !ss.eof())
+ {
+ ss >> text;
+ transform(text.begin(), text.end(), text.begin(), ::tolower);
+
+ Expression* nextWord = currentWord->getNextExpression(text);
+
+ if (nextWord)
+ {
+ currentWord = nextWord;
+ }
+ else
+ {
+ mErrorText = "'" + text + "' not recognized.";
+ result = CommandInvalid;
+ }
+ }
+
+ if (result == CommandSuccess)
+ {
+ if (currentWord->isExecutable())
+ {
+ currentWord->execute();
+ }
+ else
+ {
+ mErrorText = "command is incomplete.";
+ result = CommandIncomplete;
+ }
+ }
+ return result;
+}
+
+void ExpressionInterpreter::printExpressionTree()
+{
+ mpRoot->printTree();
+}
+
+void ExpressionInterpreter::printExpressionList()
+{
+ mpRoot->printList();
+}
+
+string ExpressionInterpreter::getLastError()
+{
+ string tmp = mErrorText;
+ mErrorText = "no error.";
+ return tmp;
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either inputess or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "ilm_client.h"
+#include "Expression.h"
+#include "ExpressionInterpreter.h"
+#include <iostream>
+#include <signal.h> // signal
+
+using namespace std;
+
+//=============================================================================
+// common helper functions
+//=============================================================================
+
+#define COMMAND(text) COMMAND2(__COUNTER__,text)
+
+#define COMMAND2(x,y) COMMAND3(x,y)
+
+#define COMMAND3(funcNumber, text) \
+ void func_ ## funcNumber(Expression* input); \
+ static const bool reg_ ## funcNumber = \
+ ExpressionInterpreter::addExpression(func_ ## funcNumber, text); \
+ void func_ ## funcNumber(Expression* input)
+
+void printArray(const char* text, unsigned int* array, int count);
+void printScreenProperties(unsigned int screenid, const char* prefix = "");
+void printLayerProperties(unsigned int layerid, const char* prefix = "");
+void printSurfaceProperties(unsigned int surfaceid, const char* prefix = "");
+
+//=============================================================================
+COMMAND("help")
+//=============================================================================
+{
+ (void)input;
+ cout << "help: supported commands:\n\n";
+ ExpressionInterpreter::printExpressionList();
+ cout << "\n";
+}
+
+//=============================================================================
+COMMAND("tree")
+//=============================================================================
+{
+ (void)input;
+ cout << "help: supported commands:\n\n";
+ ExpressionInterpreter::printExpressionTree();
+ cout << "\n";
+}
+
+//=============================================================================
+COMMAND("get screens")
+//=============================================================================
+{
+ (void)input;
+ unsigned int count = 0;
+ unsigned int* array = NULL;
+ ilm_getScreenIDs(&count, &array);
+ printArray("Screen", array, count);
+}
+
+//=============================================================================
+COMMAND("get layers")
+//=============================================================================
+{
+ (void)input;
+ int count = 0;
+ unsigned int* array = NULL;
+ ilm_getLayerIDs(&count, &array);
+ printArray("Layer", array, count);
+}
+
+//=============================================================================
+COMMAND("get surfaces")
+//=============================================================================
+{
+ (void)input;
+ int count = 0;
+ unsigned int* array = NULL;
+ ilm_getSurfaceIDs(&count, &array);
+ printArray("Surface", array, count);
+}
+
+//=============================================================================
+COMMAND("get screen <screenid>")
+//=============================================================================
+{
+ printScreenProperties(input->getUint("screenid"));
+}
+
+//=============================================================================
+COMMAND("get layer <layerid>")
+//=============================================================================
+{
+ printLayerProperties(input->getUint("layerid"));
+}
+
+//=============================================================================
+COMMAND("get surface <surfaceid>")
+//=============================================================================
+{
+ printSurfaceProperties(input->getUint("surfaceid"));
+}
+
+//=============================================================================
+COMMAND("dump screen <screenid> to <file>")
+//=============================================================================
+{
+ ilm_takeScreenshot(input->getUint("screenid"),
+ input->getString("file").c_str());
+}
+
+//=============================================================================
+COMMAND("dump layer <layerid> to <file>")
+//=============================================================================
+{
+ ilm_takeLayerScreenshot(input->getString("file").c_str(),
+ input->getUint("layerid"));
+}
+
+//=============================================================================
+COMMAND("dump surface <surfaceid> to <file>")
+//=============================================================================
+{
+ ilm_takeSurfaceScreenshot(input->getString("file").c_str(),
+ input->getUint("surfaceid"));
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> source region <x> <y> <w> <h>")
+//=============================================================================
+{
+ ilm_layerSetSourceRectangle(input->getUint("layerid"),
+ input->getUint("x"),
+ input->getUint("y"),
+ input->getUint("w"),
+ input->getUint("h"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> source region <x> <y> <w> <h>")
+//=============================================================================
+{
+ ilm_surfaceSetSourceRectangle(input->getUint("surfaceid"),
+ input->getUint("x"),
+ input->getUint("y"),
+ input->getUint("w"),
+ input->getUint("h"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> destination region <x> <y> <w> <h>")
+//=============================================================================
+{
+ ilm_layerSetDestinationRectangle(input->getUint("layerid"),
+ input->getUint("x"),
+ input->getUint("y"),
+ input->getUint("w"),
+ input->getUint("h"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> destination region <x> <y> <w> <h>")
+//=============================================================================
+{
+ ilm_surfaceSetDestinationRectangle(input->getUint("surfaceid"),
+ input->getUint("x"),
+ input->getUint("y"),
+ input->getUint("w"),
+ input->getUint("h"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> opacity <opacity>")
+//=============================================================================
+{
+ ilm_layerSetOpacity(input->getUint("layerid"),
+ input->getDouble("opacity"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> opacity <opacity>")
+//=============================================================================
+{
+ ilm_surfaceSetOpacity(input->getUint("surfaceid"),
+ input->getDouble("opacity"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> visibility <visibility>")
+//=============================================================================
+{
+ ilm_layerSetVisibility(input->getUint("layerid"),
+ input->getBool("visibility"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> visibility <visibility>")
+//=============================================================================
+{
+ ilm_surfaceSetVisibility(input->getUint("surfaceid"),
+ input->getBool("visibility"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> orientation <orientation>")
+//=============================================================================
+{
+ ilm_layerSetOrientation(input->getUint("layerid"),
+ (ilmOrientation)input->getInt("orientation"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> orientation <orientation>")
+//=============================================================================
+{
+ ilm_surfaceSetOrientation(input->getUint("surfaceid"),
+ (ilmOrientation)input->getInt("orientation"));
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set screen <screenid> render order <layeridarray>")
+//=============================================================================
+{
+ unsigned int count = 0;
+ unsigned int* array = NULL;
+ unsigned int screenid = input->getUint("screenid");
+ input->getUintArray("layeridarray", &array, &count);
+ ilm_displaySetRenderOrder(screenid, array, count);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set screen <screenid> render order")
+//=============================================================================
+{
+ unsigned int screenid = input->getUint("screenid");
+ ilm_displaySetRenderOrder(screenid, NULL, 0);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> render order <surfaceidarray>")
+//=============================================================================
+{
+ unsigned int count = 0;
+ unsigned int* array = NULL;
+ unsigned int layerid = input->getUint("layerid");
+ input->getUintArray("surfaceidarray", &array, &count);
+ ilm_layerSetRenderOrder(layerid, array, count);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> render order")
+//=============================================================================
+{
+ unsigned int layerid = input->getUint("layerid");
+ ilm_layerSetRenderOrder(layerid, NULL, 0);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> width <width>")
+//=============================================================================
+{
+ unsigned int dimension[2];
+ unsigned int layerid = input->getUint("layerid");
+ ilm_layerGetDimension(layerid, dimension);
+ dimension[0] = input->getUint("width");
+ ilm_layerSetDimension(layerid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> width <width>")
+//=============================================================================
+{
+ unsigned int dimension[2];
+ unsigned int surfaceid = input->getUint("layerid");
+ ilm_surfaceGetDimension(surfaceid, dimension);
+ dimension[0] = input->getUint("width");
+ ilm_surfaceSetDimension(surfaceid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> height <height>")
+//=============================================================================
+{
+ unsigned int count = 0;
+ unsigned int dimension[2];
+ unsigned int layerid = input->getUint("layerid");
+ ilm_layerGetDimension(layerid, dimension);
+ dimension[1] = input->getUint("height");
+ ilm_layerSetDimension(layerid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> height <height>")
+//=============================================================================
+{
+ unsigned int count = 0;
+ unsigned int dimension[2];
+ unsigned int surfaceid = input->getUint("surfaceid");
+ ilm_surfaceGetDimension(surfaceid, dimension);
+ dimension[1] = input->getUint("height");
+ ilm_surfaceSetDimension(surfaceid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set layer <layerid> position <x> <y>")
+//=============================================================================
+{
+ unsigned int dimension[2];
+ unsigned int layerid = input->getUint("layerid");
+ dimension[0] = input->getUint("x");
+ dimension[1] = input->getUint("y");
+ ilm_layerSetPosition(layerid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("set surface <surfaceid> position <x> <y>")
+//=============================================================================
+{
+ unsigned int dimension[2];
+ unsigned int surfaceid = input->getUint("surfaceid");
+ dimension[0] = input->getUint("x");
+ dimension[1] = input->getUint("y");
+ ilm_surfaceSetPosition(surfaceid, dimension);
+ ilm_commitChanges();
+}
+
+//=============================================================================
+COMMAND("create layer <layerid>")
+//=============================================================================
+{
+ unsigned int layerid = input->getUint("layerid");
+ ilm_layerCreate(&layerid);
+}
+
+//=============================================================================
+COMMAND("create layer <layerid> <width> <height>")
+//=============================================================================
+{
+ unsigned int layerid = input->getUint("layerid");
+ unsigned int width = input->getUint("width");
+ unsigned int height = input->getUint("height");
+ ilm_layerCreateWithDimension(&layerid, width, height);
+}
+
+//=============================================================================
+COMMAND("create surface <surfaceid> <nativehandle> <width> <height> <pixelformat>")
+//=============================================================================
+{
+ unsigned int surfaceid = input->getUint("surfaceid");
+ unsigned int nativeHandle = input->getUint("nativehandle");
+ unsigned int width = input->getUint("width");
+ unsigned int height = input->getUint("height");
+ e_ilmPixelFormat pixelformat = (e_ilmPixelFormat)input->getUint("pixelformat");
+ ilm_surfaceCreate(nativeHandle, width, height, pixelformat, &surfaceid);
+}
+
+//=============================================================================
+COMMAND("destroy layer <layerid>")
+//=============================================================================
+{
+ unsigned int layerid = input->getUint("layerid");
+ ilm_layerRemove(layerid);
+}
+
+//=============================================================================
+COMMAND("destroy surface <surfaceid>")
+//=============================================================================
+{
+ unsigned int surfaceid = input->getUint("surfaceid");
+ ilm_surfaceRemove(surfaceid);
+}
+
+//=============================================================================
+COMMAND("get scene")
+//=============================================================================
+{
+ unsigned int screenCount = 0;
+ unsigned int* screenArray = NULL;
+
+ ilm_getScreenIDs(&screenCount, &screenArray);
+
+ for (unsigned int screenIndex = 0; screenIndex < screenCount; ++screenIndex)
+ {
+ unsigned int screenid = screenArray[screenIndex];
+ printScreenProperties(screenid);
+ cout << "\n";
+
+ int layerCount = 0;
+ unsigned int* layerArray = NULL;
+ ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
+ for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
+ {
+ unsigned int layerid = layerArray[layerIndex];
+ printLayerProperties(layerid, " ");
+ cout << "\n";
+
+ int surfaceCount = 0;
+ unsigned int* surfaceArray = NULL;
+ ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
+ for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
+ {
+ unsigned int surfaceid = surfaceArray[surfaceIndex];
+ printSurfaceProperties(surfaceid, " ");
+ cout << "\n";
+ }
+ }
+ }
+}
+
+//=============================================================================
+bool gBenchmark_running;
+
+void benchmarkSigHandler(int sig)
+{
+ gBenchmark_running = false;
+}
+
+COMMAND("get communicator performance")
+//=============================================================================
+{
+ int runs = 0;
+ int runtimeInSec = 5;
+ unsigned int hwLayerCnt = 0;
+ cout << "running performance test for " << runtimeInSec << " seconds... ";
+ flush(cout);
+
+ signal(SIGALRM, benchmarkSigHandler);
+
+ gBenchmark_running = true;
+
+ alarm(runtimeInSec);
+
+ while (gBenchmark_running)
+ {
+ ilm_getNumberOfHardwareLayers(0, &hwLayerCnt);
+ ++runs;
+ }
+
+ signal(SIGALRM, SIG_DFL);
+
+ cout << (runs/runtimeInSec) << " transactions/second\n";
+}
+
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either inputess or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+#include "ilm_client.h"
+#include "Expression.h"
+#include "ExpressionInterpreter.h"
+#include <iostream>
+using namespace std;
+
+//=============================================================================
+// common helper functions
+//=============================================================================
+
+void printArray(const char* text, unsigned int* array, int count)
+{
+ cout << count << " " << text << "(s):\n";
+ for (int i = 0; i < count; ++i)
+ {
+ cout << "- " << text << " "
+ << dec << array[i]
+ << hex << " (0x" << array[i] << ")"
+ << dec << "\n";
+ }
+}
+
+void printScreenProperties(unsigned int screenid, const char* prefix = "")
+{
+ cout << prefix << "screen " << screenid << " (0x" << hex << screenid << dec << ")\n";
+ cout << prefix << "---------------------------------------\n";
+
+ unsigned int resolutionX = 0;
+ unsigned int resolutionY = 0;
+ ilm_getScreenResolution(screenid, &resolutionX, &resolutionY);
+ cout << prefix << "- resolution: x=" << resolutionX << ", y=" << resolutionY << "\n";
+
+ unsigned int hwLayerCount = 0;
+ ilm_getNumberOfHardwareLayers(screenid, &hwLayerCount);
+ cout << prefix << "- hardware layer count: " << hwLayerCount << "\n";
+
+ cout << prefix << "- layer render order: ";
+ int layerCount = 0;
+ unsigned int* layerArray = NULL;
+ ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
+ for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
+ {
+ unsigned int layerid = layerArray[layerIndex];
+ cout << layerid << "(0x" << hex << layerid << dec << "), ";
+ }
+ cout << "\n";
+}
+
+void printLayerProperties(unsigned int layerid, const char* prefix = "")
+{
+ cout << prefix << "layer " << layerid << " (0x" << hex << layerid << dec << ")\n";
+ cout << prefix << "---------------------------------------\n";
+
+ ilmLayerProperties p;
+ ilm_getPropertiesOfLayer(layerid, &p);
+
+ cout << prefix << "- original size: x=" << p.origSourceWidth << ", y=" << p.origSourceHeight << "\n";
+ cout << prefix << "- destination region: x=" << p.destX << ", y=" << p.destY<< ", w=" << p.destWidth<< ", h=" << p.destHeight << "\n";
+ cout << prefix << "- source region: x=" << p.sourceX << ", y=" << p.sourceY<< ", w=" << p.sourceWidth<< ", h=" << p.sourceHeight << "\n";
+
+ cout << prefix << "- orientation: " << p.orientation << " (";
+ switch (p.orientation)
+ {
+ case 0/*Zero*/:
+ cout << "up is top)\n";
+ break;
+ case 1/*Ninety*/:
+ cout << "up is right)\n";
+ break;
+ case 2/*OneEighty*/:
+ cout << "up is bottom)\n";
+ break;
+ case 3/*TwoSeventy*/:
+ cout << "up is left)\n";
+ break;
+ default:
+ cout << "unknown)\n";
+ break;
+ }
+
+ cout << prefix << "- opacity: " << p.opacity << "\n";
+ cout << prefix << "- visibility: " << p.visibility << "\n";
+
+ cout << prefix << "- type: " << p.type << " (";
+ switch (p.type)
+ {
+ case 1/*Hardware*/:
+ cout << "hardware)\n";
+ break;
+ case 2/*Software_2D*/:
+ cout << "software 2d)\n";
+ break;
+ case 3/*Software_2_5D*/:
+ cout << "software 2.5d)\n";
+ break;
+ default:
+ cout << "unknown)\n";
+ break;
+ }
+
+ cout << prefix << "- surface render order: ";
+ int surfaceCount = 0;
+ unsigned int* surfaceArray = NULL;
+ ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
+ for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
+ {
+ cout << surfaceArray[surfaceIndex] << "(0x" << hex << surfaceArray[surfaceIndex] << dec << "), ";
+ }
+ cout << "\n";
+
+ cout << prefix << "- on screen: ";
+ unsigned int screenCount = 0;
+ unsigned int* screenArray = NULL;
+ ilm_getScreenIDs(&screenCount, &screenArray);
+ for (unsigned int screenIndex = 0; screenIndex < screenCount; ++screenIndex)
+ {
+ unsigned int screenid = screenArray[screenIndex];
+ int layerCount = 0;
+ unsigned int* layerArray = NULL;
+ ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
+ for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
+ {
+ unsigned int id = layerArray[layerIndex];
+ if (id == layerid)
+ {
+ cout << screenid << "(0x" << hex << screenid << dec << ") ";
+ }
+ }
+ }
+ cout << "\n";
+
+ // TODO: print layer groups, this layer is part of
+}
+
+void printSurfaceProperties(unsigned int surfaceid, const char* prefix = "")
+{
+ cout << prefix << "surface " << surfaceid << " (0x" << hex << surfaceid << dec << ")\n";
+ cout << prefix << "---------------------------------------\n";
+
+ ilmSurfaceProperties p;
+ ilm_getPropertiesOfSurface(surfaceid, &p);
+
+ cout << prefix << "- original size: x=" << p.origSourceWidth << ", y=" << p.origSourceHeight << "\n";
+ cout << prefix << "- destination region: x=" << p.destX << ", y=" << p.destY<< ", w=" << p.destWidth<< ", h=" << p.destHeight << "\n";
+ cout << prefix << "- source region: x=" << p.sourceX << ", y=" << p.sourceY<< ", w=" << p.sourceWidth<< ", h=" << p.sourceHeight << "\n";
+
+ cout << prefix << "- orientation: " << p.orientation << " (";
+ switch (p.orientation)
+ {
+ case 0/*Zero*/:
+ cout << "up is top)\n";
+ break;
+ case 1/*Ninety*/:
+ cout << "up is right)\n";
+ break;
+ case 2/*OneEighty*/:
+ cout << "up is bottom)\n";
+ break;
+ case 3/*TwoSeventy*/:
+ cout << "up is left)\n";
+ break;
+ default:
+ cout << "unknown)\n";
+ break;
+ }
+
+ cout << prefix << "- opacity: " << p.opacity << "\n";
+ cout << prefix << "- visibility: " << p.visibility << "\n";
+
+ cout << prefix << "- pixel format: " << p.pixelformat << " (";
+ switch (p.pixelformat)
+ {
+ case 0/*PIXELFORMAT_R8*/:
+ cout << "R-8)\n";
+ break;
+ case 1/*PIXELFORMAT_RGB888*/:
+ cout << "RGB-888)\n";
+ break;
+ case 2/*PIXELFORMAT_RGBA8888*/:
+ cout << "RGBA-8888)\n";
+ break;
+ case 3/*PIXELFORMAT_RGB565*/:
+ cout << "RGB-565)\n";
+ break;
+ case 4/*PIXELFORMAT_RGBA5551*/:
+ cout << "RGBA-5551)\n";
+ break;
+ case 5/*PIXELFORMAT_RGBA6661*/:
+ cout << "RGBA-6661)\n";
+ break;
+ case 6/*PIXELFORMAT_RGBA4444*/:
+ cout << "RGBA-4444)\n";
+ break;
+ default:
+ cout << "unknown)\n";
+ break;
+ }
+
+ cout << prefix << "- native surface: " << p.nativeSurface << "\n";
+ cout << prefix << "- counters: frame=" << p.frameCounter
+ << ", draw=" << p.drawCounter
+ << ", update=" << p.updateCounter << "\n";
+
+ cout << prefix << "- on layer: ";
+ int layerCount = 0;
+ unsigned int* layerArray = NULL;
+ ilm_getLayerIDs(&layerCount, &layerArray);
+ for (unsigned int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
+ {
+ unsigned int layerid = layerArray[layerIndex];
+ int surfaceCount = 0;
+ unsigned int* surfaceArray = NULL;
+ ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
+ for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
+ {
+ unsigned int id = surfaceArray[surfaceIndex];
+ if (id == surfaceid)
+ {
+ cout << layerid << "(0x" << hex << layerid << dec << ") ";
+ }
+ }
+ }
+ cout << "\n";
+
+ // TODO: print surface groups, this surface is part of
+}
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2012 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 "ExpressionInterpreter.h"
+#include "ilm_client.h"
+#include <iostream>
+using namespace std;
+
+int main(int argc, char* argv[])
+{
+ ExpressionInterpreter interpreter;
+
+ // create full string of arguments
+ string userCommand;
+
+ if(argc == 1)
+ {
+ userCommand = "help";
+ }
+ else
+ {
+ for (int i = 1; i < argc; ++i)
+ {
+ userCommand += argv[i];
+ userCommand += ' ';
+ }
+ userCommand = userCommand.substr(0, userCommand.size() - 1);
+ }
+
+ if (ILM_SUCCESS != ilm_init() && userCommand != "help")
+ {
+ cerr << "Could not connect to LayerManagerService.\n";
+ return 0;
+ }
+
+ // start interpreter
+ if (CommandSuccess != interpreter.interpretCommand(userCommand))
+ {
+ cerr << "Interpreter error: " << interpreter.getLastError() << endl;
+ }
+
+ ilm_destroy();
+
+ return 0;
+}