* limitations under the License.
*
****************************************************************************/
-#ifndef _APPLICATION_REFERENCE_LIST_H_
-#define _APPLICATION_REFERENCE_LIST_H_
+#ifndef _APPLICATIONREFERENCELIST_H_
+#define _APPLICATIONREFERENCELIST_H_
#include <list>
typedef std::list<t_ilm_client_handle>::iterator ApplicationReferenceListIterator;
typedef std::list<t_ilm_client_handle>::const_iterator ApplicationReferenceListConstIterator;
-#endif // _APPLICATION_REFERENCE_LIST_H_
+#endif // _APPLICATIONREFERENCELIST_H_
* limitations under the License.
*
****************************************************************************/
-#ifndef _APPLICATION_REFERENCE_MAP_H_
-#define _APPLICATION_REFERENCE_MAP_H_
+#ifndef _APPLICATIONREFERENCEMAP_H_
+#define _APPLICATIONREFERENCEMAP_H_
#include <map>
#include "IApplicationReference.h"
typedef std::map<t_ilm_client_handle, IApplicationReference*>::iterator ApplicationReferenceMapIterator;
typedef std::map<t_ilm_client_handle, IApplicationReference*>::const_iterator ApplicationReferenceMapConstIterator;
-#endif /* _APPLICATION_REFERENCE_MAP_H_ */
+#endif /* _APPLICATIONREFERENCEMAP_H_ */
std::string getPluginPath();
void logAllSettings();
-
+
private:
void processCommandLine(int argc, char** argv);
void processBuildFlags();
/***************************************************************************
- *
+ *
* Copyright 2012 BMW Car IT GmbH
*
*
--- /dev/null
+/***************************************************************************
+ *
+ * Copyright 2013 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 _FLOATRECTANGLE_H_
+#define _FLOATRECTANGLE_H_
+
+#include <ostream>
+#include "FloatRectangle.h"
+
+class FloatRectangle
+{
+public:
+ FloatRectangle()
+ : x(0.0f)
+ , y(0.0f)
+ , width(0.0f)
+ , height(0.0f)
+ {
+ }
+
+ FloatRectangle(float x, float y, float width, float height)
+ : x(x)
+ , y(y)
+ , width(width)
+ , height(height)
+ {
+ }
+
+ FloatRectangle(const Rectangle& rhs)
+ : x(rhs.x)
+ , y(rhs.y)
+ , width(rhs.width)
+ , height(rhs.height)
+ {
+ }
+
+ float x;
+ float y;
+ float width;
+ float height;
+};
+
+#endif /* _FLOATRECTANGLE_H_ */
bool DestToSourceCoordinates(int *x, int *y, bool check) const;
int OriginalSourceWidth;
- int OriginalSourceHeight;
-
+ int OriginalSourceHeight;
+
private:
OrientationType m_orientation; // Rotation of the graphical content
Rectangle m_sourceViewport;
, OriginalSourceWidth(0)
, OriginalSourceHeight(0)
, m_orientation(Zero)
-, m_sourceViewport(0,0,0,0)
-, m_destinationViewport(0,0,0,0)
+, m_sourceViewport(0, 0, 0, 0)
+, m_destinationViewport(0, 0, 0, 0)
{
}
, OriginalSourceWidth(0)
, OriginalSourceHeight(0)
, m_orientation(Zero)
-, m_sourceViewport(0,0,0,0)
-, m_destinationViewport(0,0,0,0)
+, m_sourceViewport(0, 0, 0, 0)
+, m_destinationViewport(0, 0, 0, 0)
{
}
inline Vector2 GraphicalSurface::getPosition()
{
- return Vector2(m_destinationViewport.x,m_destinationViewport.y);
+ return Vector2(m_destinationViewport.x, m_destinationViewport.y);
}
inline bool GraphicalSurface::setDimension(const unsigned int& width, const unsigned int& height)
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
*
****************************************************************************/
-#ifndef _IAPPLICATION_REFERENCE_H_
-#define _IAPPLICATION_REFERENCE_H_
+#ifndef _IAPPLICATIONREFERENCE_H_
+#define _IAPPLICATIONREFERENCE_H_
#include <locale>
#include <string.h>
#include <stdlib.h>
/**
- * Abstract Base Class for all Application References
+ * Abstract Base Class for all Application References
*/
class IApplicationReference
{
public:
/**
* Constructor: Contructs a Object with the provided Application id and SerialId
- *
+ *
*/
IApplicationReference(char* processName, unsigned int processId);
~IApplicationReference();
- const char* getProcessName();
- unsigned int getProcessId();
+ const char* getProcessName();
+ unsigned int getProcessId();
protected:
char* m_processName;
return m_processName;
}
-#endif /* _IAPPLICATION_REFERENCE_H_ */
+#endif /* _IAPPLICATIONREFERENCE_H_ */
*
****************************************************************************/
-#ifndef _COMMANDEXECUTOR_H_
-#define _COMMANDEXECUTOR_H_
+#ifndef _ICOMMANDEXECUTOR_H_
+#define _ICOMMANDEXECUTOR_H_
#include "RendererList.h"
#include "CommunicatorList.h"
virtual HealthCondition getHealth() = 0;
};
-#endif /* _COMMANDEXECUTOR_H_ */
+#endif /* _ICOMMANDEXECUTOR_H_ */
*
****************************************************************************/
-#ifndef __IHEALTH_H__
-#define __IHEALTH_H__
+#ifndef __IHEALTHMONITOR_H__
+#define __IHEALTHMONITOR_H__
#include "ilm_types.h"
{
}
-#endif // __IHEALTH_H__
+#endif // __IHEALTHMONITOR_H__
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
virtual bool isLayerInCurrentRenderOrder(const uint id) = 0;
bool debugMode;
-
};
#endif /* _ISCENE_H_ */
*
****************************************************************************/
-#ifndef _ISCENE_PROVIDER_H_
-#define _ISCENE_PROVIDER_H_
+#ifndef _ISCENEPROVIDER_H_
+#define _ISCENEPROVIDER_H_
class ICommandExecutor;
* 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() = 0;
+ virtual bool delegateScene() = 0;
protected:
ICommandExecutor* m_executor;
{
}
-#endif /* _ISCENE_PROVIDER_H_ */
+#endif /* _ISCENEPROVIDER_H_ */
class InputManager
{
- public:
- /** Ctor / Dtor
- */
- InputManager(IScene* s);
- ~InputManager();
-
-
- /** Methods to report input events
- * They all return the surface to transfer the event to, or NULL if the event should not be dispatched
- */
- Surface * reportKeyboardEvent(InputEventState state, long keyId);
- Surface * reportTouchEvent(PointVect& pv);
- Surface * reportPointerEvent(Point& p);
-
-
- /** Methods to control the focus
- */
- bool setKeyboardFocusOn(unsigned int surfId);
- bool updateInputEventAcceptanceOn(unsigned int surfId, InputDevice devices, bool accept);
-
- /** Few getters
- */
- unsigned int getKeyboardFocusSurfaceId();
-
- private:
- Surface * electSurfaceForPointerEvent(int& x, int& y);
- void transformGlobalToLocalCoordinates(Surface* surf, int& x, int& y);
-
-
- /*
- * Private Getters / Setters
- * Needed because access to their associated member requires exclusive area
- */
-
- /** \brief Set the keyboard focus on a particular surface */
- void _setKbdFocus(Surface * s);
- /** \brief Get the surface which has keyboard focus */
- Surface * _getKbdFocus();
- /** \brief Set the pointer focus on a particular surface */
- void _setPointerFocus(Surface * s);
- /** \brief Get the surface which has pointer focus */
- Surface * _getPointerFocus();
- /** \brief Set the touch focus on a particular surface */
- void _setTouchFocus(Surface * s);
- /** \brief Get the surface which has touch focus */
- Surface * _getTouchFocus();
-
-
- private:
- IScene * m_pScene; /*!< Pointer to the scene */
- std::map<long, Surface*> m_KeyMap; /*!< Map that associate keypressed event to the surface it has been forward to. See @ref<InputManager-KeypressedMap>. */
- pthread_mutex_t m_mutex; /*!< Mutex to avoid concurrent access to shared variables */
-
- /* Access to the below members must be protected by mutex to avoid concurrent accesses */
- Surface * m_KbdFocus; /*!< Pointer to the surface which has the focus for keyboard event.
- Should only be accessed via its getter / setter */
- Surface * m_PointerFocus; /*!< Pointer to the surface which has the focus for pointer event.
- Should only be accessed via its getter / setter */
- Surface * m_TouchFocus; /*!< Pointer to the surface which has the focus for touch event.
- Should only be accessed via its getter / setter */
-
+public:
+ /** Ctor / Dtor
+ */
+ InputManager(IScene* s);
+ ~InputManager();
+
+ /** Methods to report input events
+ * They all return the surface to transfer the event to, or NULL if the event should not be dispatched
+ */
+ Surface * reportKeyboardEvent(InputEventState state, long keyId);
+ Surface * reportTouchEvent(PointVect& pv);
+ Surface * reportPointerEvent(Point& p);
+
+ /** Methods to control the focus
+ */
+ bool setKeyboardFocusOn(unsigned int surfId);
+ bool updateInputEventAcceptanceOn(unsigned int surfId, InputDevice devices, bool accept);
+
+ /** Few getters
+ */
+ unsigned int getKeyboardFocusSurfaceId();
+
+private:
+ Surface * electSurfaceForPointerEvent(int& x, int& y);
+ void transformGlobalToLocalCoordinates(Surface* surf, int& x, int& y);
+
+ /*
+ * Private Getters / Setters
+ * Needed because access to their associated member requires exclusive area
+ */
+
+ /** \brief Set the keyboard focus on a particular surface */
+ void _setKbdFocus(Surface * s);
+ /** \brief Get the surface which has keyboard focus */
+ Surface * _getKbdFocus();
+ /** \brief Set the pointer focus on a particular surface */
+ void _setPointerFocus(Surface * s);
+ /** \brief Get the surface which has pointer focus */
+ Surface * _getPointerFocus();
+ /** \brief Set the touch focus on a particular surface */
+ void _setTouchFocus(Surface * s);
+ /** \brief Get the surface which has touch focus */
+ Surface * _getTouchFocus();
+
+
+private:
+ IScene * m_pScene; /*!< Pointer to the scene */
+ std::map<long, Surface*> m_KeyMap; /*!< Map that associate keypressed event to the surface it has been forward to.
+ See @ref<InputManager-KeypressedMap>. */
+ pthread_mutex_t m_mutex; /*!< Mutex to avoid concurrent access to shared variables */
+
+ /* Access to the below members must be protected by mutex to avoid concurrent accesses */
+ Surface * m_KbdFocus; /*!< Pointer to the surface which has the focus for keyboard event.
+ Should only be accessed via its getter / setter */
+ Surface * m_PointerFocus; /*!< Pointer to the surface which has the focus for pointer event.
+ Should only be accessed via its getter / setter */
+ Surface * m_TouchFocus; /*!< Pointer to the surface which has the focus for touch event.
+ Should only be accessed via its getter / setter */
};
* \anchor<LM_INPUT_REQ_06>
* <li>
* LM_INPUT_REQ_06:
- * A surface can request to not receive particular input events. In this case, the surface should not be considered for focus election & the events
- * must be dispatched to an other surface, if relevant.
+ * A surface can request to not receive particular input events. In this case, the surface should not be considered
+ * for focus election & the events must be dispatched to an other surface, if relevant.
* </li>
*
* </ul>
* 3- The command "surfaceSetKeyboardFocus" is called on S2, so the surface S2 is now the keyboard elected one
* 4- Key X is released.
* We should then forward the KeyRelased event to S1 since we have reported the pressed event to it.
- * So we need a map that associate keyPressed -> Surface. When the same key is released, we must forward that event to the original surface, and not to the elected one.
+ * So we need a map that associate keyPressed -> Surface. When the same key is released, we must forward that event
+ * to the original surface, and not to the elected one.
*
*
*/
/*
* A graphical Layerobject which contains Surfaces.
*/
-class Layer: public GraphicalSurface
+class Layer : public GraphicalSurface
{
friend class Scene;
SurfaceListConstIterator iter = m_surfaces.begin();
SurfaceListConstIterator iterEnd = m_surfaces.end();
- if(iter == iterEnd)
+ if (iter == iterEnd)
return false;
for (; iter != iterEnd; ++iter)
inline void Layer::applySurfaceTransform()
{
- SurfaceListConstIterator iter = m_surfaces.begin();
- SurfaceListConstIterator iterEnd = m_surfaces.end();
- if(iter != iterEnd)
- {
- for (; iter != iterEnd; ++iter)
- {
- (*iter)->calculateTargetDestination(getSourceRegion(),getDestinationRegion());
- }
- }
+ SurfaceListConstIterator iter = m_surfaces.begin();
+ SurfaceListConstIterator iterEnd = m_surfaces.end();
+ if (iter != iterEnd)
+ {
+ for (; iter != iterEnd; ++iter)
+ {
+ (*iter)->calculateTargetDestination(getSourceRegion(), getDestinationRegion());
+ }
+ }
}
#endif /* _LAYER_H_ */
typedef std::list<IPlugin*> PluginList;
-class Layermanager: public ICommandExecutor
+class Layermanager : public ICommandExecutor
{
public:
Layermanager(Configuration& config);
*
****************************************************************************/
-#ifndef _GRAPHICALOBJECTTYPE_H_
-#define _GRAPHICALOBJECTTYPE_H_
+#ifndef _OBJECTTYPE_H_
+#define _OBJECTTYPE_H_
#include "ilm_types.h"
TypeMax
};
-#endif /* _GRAPHICALOBJECTTYPE_H_ */
+#endif /* _OBJECTTYPE_H_ */
*
****************************************************************************/
-#ifndef _OPTIMIZATION_H
-#define _OPTIMIZATION_H
+#ifndef _OPTIMIZATIONTYPE_H
+#define _OPTIMIZATIONTYPE_H
#include "ilm_types.h"
const int OPT_MODE_COUNT = 4;
-#endif /* _OPTIMIZATION_H */
+#endif /* _OPTIMIZATIONTYPE_H */
*
****************************************************************************/
-#ifndef _ORIENTATION_H
-#define _ORIENTATION_H
+#ifndef _ORIENTATIONTYPE_H
+#define _ORIENTATIONTYPE_H
#include "ilm_types.h"
TwoSeventy = ILM_TWOHUNDREDSEVENTY
};
-#endif /* _ORIENTATION_H */
+#endif /* _ORIENTATIONTYPE_H */
PIXELFORMAT_UNKNOWN = ILM_PIXEL_FORMAT_UNKNOWN
};
-#define PixelFormatHasAlpha(pf) ((pf == PIXELFORMAT_RGBA8888) || (pf == PIXELFORMAT_RGBA5551) || (pf == PIXELFORMAT_RGBA6661) || (pf == PIXELFORMAT_RGBA4444))
+#define PixelFormatHasAlpha(pf) \
+ ((pf == PIXELFORMAT_RGBA8888) || (pf == PIXELFORMAT_RGBA5551) || (pf == PIXELFORMAT_RGBA6661) || (pf == PIXELFORMAT_RGBA4444))
#endif /* _PIXELFORMAT_H_ */
// Reference to platform independant surface type for access to size etc
Surface* s;
-
};
#endif /* _PLATFORMSURFACE_H_ */
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
/***************************************************************************
- *
+ *
* Copyright 2012 BMW Car IT GmbH
*
*
/***************************************************************************
- *
+ *
* Copyright 2012 BMW Car IT GmbH
*
*
public:
PluginManager(ICommandExecutor& executor, Configuration& config);
~PluginManager();
-
+
void getRendererList(RendererList& list);
void getHealthMonitorList(HealthMonitorList& list);
void getSceneProviderList(SceneProviderList& list);
void getCommunicatorList(CommunicatorList& list);
-
+
static bool registerStaticPluginCreateFunction(StaticPluginCreateFunc func);
-
+
private:
void createStaticallyLinkedPlugins();
void getAllFilesInPluginPath(std::string path);
void createDynamicallyLinkedPlugins();
IPlugin* createDynamicallyLinkedPlugin(std::string path);
-
+
private:
ICommandExecutor& mExecutor;
Configuration& mConfiguration;
static StaticPluginCreateFuncList mStaticPluginCreateFuncList;
};
-#endif // __PLUGINMANAGER_H__
\ No newline at end of file
+#endif // __PLUGINMANAGER_H__
}
};
-class FloatRectangle
-{
-public:
- FloatRectangle()
- : x(0.0f)
- , y(0.0f)
- , width(0.0f)
- , height(0.0f)
- {
- }
-
- FloatRectangle(float x, float y, float width, float height)
- : x(x)
- , y(y)
- , width(width)
- , height(height)
- {
- }
-
- FloatRectangle(const Rectangle& rhs)
- : x(rhs.x)
- , y(rhs.y)
- , width(rhs.width)
- , height(rhs.height)
- {
- }
-
- float x;
- float y;
- float width;
- float height;
-};
-
#endif /* _RECTANGLE_H_ */
/*
* Represents a list of Layers which contain the Surfaces.
*/
-class Scene: public IScene
+class Scene : public IScene
{
// TODO: these should use public interface instead
friend class Layermanager;
* Represents a shader instance.
*
* It stores a set of uniform parameters and refers to an OpenGL program object.
- * Some uniform variables are pre-defined, like surface position and size,
+ * Some uniform variables are pre-defined, like surface position and size,
* opacity, etc... Additionally, there may be user-defined uniforms.
*/
class Shader
*
****************************************************************************/
-#ifndef __SIGNALHADLER_H__
-#define __SIGNALHADLER_H__
+#ifndef __SIGNALHANDLER_H__
+#define __SIGNALHANDLER_H__
#include "ilm_types.h"
void waitForShutdownSignal();
};
-#endif // __SIGNALHADLER_H__
+#endif // __SIGNALHANDLER_H__
/**
* Represents a graphical surface generated by an application. Always contained in layers.
*/
-class Surface: public GraphicalSurface
+class Surface : public GraphicalSurface
{
-
public:
PixelFormat getPixelFormat() const
{
{
return m_hasNativeContent;
}
-
- void removeNativeContent()
+
+ void removeNativeContent()
{
m_hasNativeContent = false;
}
return hasNativeContent() ? m_nativeHandle : -1;
}
+ void calculateTargetDestination(const Rectangle &layerSource, const Rectangle &layerDestination)
+ {
+ if (ViewportTransform::isFullyCropped(getDestinationRegion(), layerSource))
+ {
+ m_isCropped = true;
+ return; // skip rendering of this surface, because it is cropped by layer source region
+ }
+ else
+ {
+ m_isCropped = false;
+ }
+
+ const FloatRectangle layerSourceRegion = layerSource;
+ const FloatRectangle layerDestinationRegion = layerDestination;
+
+ FloatRectangle targetSource = getSourceRegion();
+ FloatRectangle targetDestination = getDestinationRegion();
+
+ ViewportTransform::applyLayerSource(layerSourceRegion, targetSource, targetDestination);
+ ViewportTransform::applyLayerDestination(layerDestinationRegion, layerSourceRegion, targetDestination);
+ m_targetDestination = targetDestination;
+ m_targetSource = targetSource;
+ }
+
+ bool isCropped()
+ {
+ return m_isCropped;
+ }
+
+ const FloatRectangle& getTargetSourceRegion() const
+ {
+ return m_targetSource;
+ }
+
+ const FloatRectangle& getTargetDestinationRegion() const
+ {
+ return m_targetDestination;
+ }
- void calculateTargetDestination (const Rectangle &layerSource,const Rectangle &layerDestination)
- {
- if (ViewportTransform::isFullyCropped(getDestinationRegion(), layerSource ) )
- {
- m_isCropped =true;
- return; // skip rendering of this surface, because it is cropped by layer source region
- } else {
- m_isCropped =false;
- }
-
- const FloatRectangle layerSourceRegion = layerSource;
- const FloatRectangle layerDestinationRegion = layerDestination;
-
- FloatRectangle targetSource = getSourceRegion();
- FloatRectangle targetDestination = getDestinationRegion();
-
- ViewportTransform::applyLayerSource(layerSourceRegion, targetSource, targetDestination);
- ViewportTransform::applyLayerDestination(layerDestinationRegion, layerSourceRegion, targetDestination );
- m_targetDestination = targetDestination;
- m_targetSource = targetSource;
- }
- bool isCropped()
- {
- return m_isCropped;
- }
-
- const FloatRectangle& getTargetSourceRegion() const
- {
- return m_targetSource;
- }
-
- const FloatRectangle& getTargetDestinationRegion() const
- {
- return m_targetDestination;
- }
-
/**
* Indicate from which input devices the Surface can accept events.
*
}
}
-
/**
* Indicate if the surface accepts input events from the specified list of devices.
*
return ret;
}
-
+
/**
* Get the set of devices from which the surface can accept input events
*
{
return m_acceptInputFrom;
}
-
+
/**
* Platform specific Object containing surface information specific to a used platform.
* This typically contains a native window handle/surface handle or information only used
, m_hasNativeContent(false)
, m_acceptInputFrom(INPUT_DEVICE_ALL)
, m_isCropped(false)
- , m_targetDestination(0.0,0.0,0.0,0.0)
- , m_targetSource(0.0,0.0,0.0,0.0)
+ , m_targetDestination(0.0, 0.0, 0.0, 0.0)
+ , m_targetSource(0.0, 0.0, 0.0, 0.0)
{
pthread_mutex_init(&m_inputAcceptMutex, NULL);
}
, m_hasNativeContent(false)
, m_acceptInputFrom(INPUT_DEVICE_ALL)
, m_isCropped(false)
- , m_targetDestination(0.0,0.0,0.0,0.0)
- , m_targetSource(0.0,0.0,0.0,0.0)
+ , m_targetDestination(0.0, 0.0, 0.0, 0.0)
+ , m_targetSource(0.0, 0.0, 0.0, 0.0)
{
pthread_mutex_init(&m_inputAcceptMutex, NULL);
}
{
pthread_mutex_destroy(&m_inputAcceptMutex);
}
-
+
private:
long m_nativeHandle;
*
****************************************************************************/
-#ifndef _VIEWPORT_TRANSFORM_H_
-#define _VIEWPORT_TRANSFORM_H_
+#ifndef _VIEWPORTTRANSFORM_H_
+#define _VIEWPORTTRANSFORM_H_
+
+#include "FloatRectangle.h"
class ViewportTransform
{
static void applyLayerSource(const FloatRectangle& layerSource, FloatRectangle& surfaceSource, FloatRectangle& surfaceDestination);
/*
- * Apply Destination View of Layer to the given surface destination region, ie scale and movement relative to scaling and position of layer
+ * Apply Destination View of Layer to the given surface destination region, ie scale and movement relative
+ * to scaling and position of layer
*/
- static void applyLayerDestination(const FloatRectangle& layerDestination, const FloatRectangle& layerSource, FloatRectangle& regionToScale);
+ static void applyLayerDestination(const FloatRectangle& layerDestination,
+ const FloatRectangle& layerSource,
+ FloatRectangle& regionToScale);
/*
* Calculate Texture Coordinates as relation of the given rectangle to original values.
* Example: x position of 10 with an original width of 40 will yield a texture coordinate of 10/40=0.25f.
* This function expects textureCoordinates to be an allocated float array of size 4, in which the texture coordinates will be returned.
*/
- static void transformRectangleToTextureCoordinates(const FloatRectangle& rectangle, const float originalWidth, const float originalHeight, float* textureCoordinates);
+ static void transformRectangleToTextureCoordinates(const FloatRectangle& rectangle,
+ const float originalWidth,
+ const float originalHeight,
+ float* textureCoordinates);
};
inline bool ViewportTransform::isFullyCropped(const Rectangle& surfaceDestination, const Rectangle& layerSource)
{
// is surface completely to the right of layer source region?
- if (surfaceDestination.x >= layerSource.x + layerSource.width )
+ if (surfaceDestination.x >= layerSource.x + layerSource.width)
return true;
// is surface completely beneath layer source region?
- if (surfaceDestination.y >= layerSource.y + layerSource.height )
+ if (surfaceDestination.y >= layerSource.y + layerSource.height)
return true;
// is surface completely to the left of layer source region?
if (surfaceDestination.x + surfaceDestination.width <= layerSource.x)
return false;
}
-inline void ViewportTransform::applyLayerSource(const FloatRectangle& layerSource, FloatRectangle& surfaceSource, FloatRectangle& surfaceDestination)
+inline void ViewportTransform::applyLayerSource(const FloatRectangle& layerSource,
+ FloatRectangle& surfaceSource,
+ FloatRectangle& surfaceDestination)
{
float cropamount = 0;
float surfaceInverseScaleX = surfaceSource.width / surfaceDestination.width;
}
}
-inline void ViewportTransform::applyLayerDestination(const FloatRectangle& layerDestination, const FloatRectangle& layerSource, FloatRectangle& regionToScale)
+inline void ViewportTransform::applyLayerDestination(const FloatRectangle& layerDestination,
+ const FloatRectangle& layerSource,
+ FloatRectangle& regionToScale)
{
float scaleX = layerDestination.width / layerSource.width;
float scaleY = layerDestination.height / layerSource.height;
regionToScale.y += layerDestination.y;
}
-inline void ViewportTransform::transformRectangleToTextureCoordinates(const FloatRectangle& rectangle, const float originalWidth, const float originalHeight, float* textureCoordinates)
+inline void ViewportTransform::transformRectangleToTextureCoordinates(const FloatRectangle& rectangle,
+ const float originalWidth,
+ const float originalHeight,
+ float* textureCoordinates)
{
// move texture coordinate proportional to the cropped pixels
float percentageCroppedFromLeftSide = rectangle.x / originalWidth;
textureCoordinates[3] = 1.0f - percentageCroppedFromBottomSide;
}
-#endif /* _VIEWPORT_TRANSFORM_H_ */
+#endif /* _VIEWPORTTRANSFORM_H_ */
LOG_INFO("LayerManagerService", "Display " << mDisplayName << " size: " << mDisplayWidth << "x" << mDisplayHeight);
LOG_INFO("LayerManagerService", "Plugin path: " << mPluginPath);
LOG_DEBUG("LayerManagerService", "Log level: console " << mLogLevelConsole << ", file " << mLogLevelFile << ", trace " << mLogLevelTrace);
-
+
for (int i = 0; i < mBuildFlagCount; ++i)
{
const BuildFlag& flag = mpBuildFlags[i];
switch (flag.type)
{
- case DEBUG_FLAG:
- LOG_DEBUG("LayerManagerService", flag.description);
- break;
- case INFO_FLAG:
- LOG_INFO("LayerManagerService", flag.description);
- break;
+ case DEBUG_FLAG:
+ LOG_DEBUG("LayerManagerService", flag.description);
+ break;
+ case INFO_FLAG:
+ LOG_INFO("LayerManagerService", flag.description);
+ break;
}
}
}
int option = getopt(argc, argv, "w::h::d::?::c::f::v::l::");
switch (option)
{
- case 'd':
- mDisplayName = optarg;
- break;
-
- case 'w':
- mDisplayWidth = atoi(optarg);
- break;
-
- case 'h':
- mDisplayHeight = atoi(optarg);
- break;
-
- case 'c':
- if (atoi(optarg) < LOG_MAX_LEVEL)
- {
- mLogLevelConsole = (LOG_MODES)atoi(optarg);
- }
- break;
-
- case 'f':
- if (atoi(optarg) < LOG_MAX_LEVEL)
- {
- mLogLevelFile = (LOG_MODES)atoi(optarg);
- }
- break;
-
- case 'l':
- if (atoi(optarg) < LOG_MAX_LEVEL)
- {
- mLogLevelTrace = (LOG_MODES)atoi(optarg);
- }
- break;
-
- case 'v':
- LOG_INFO("LayerManagerService", "Version: " << ILM_VERSION);
- exit(-1);
- break;
-
- case '?':
- default:
- LOG_INFO("LayerManagerService", "Version: " << ILM_VERSION);
- puts(USAGE_DESCRIPTION);
- exit(-1);
+ case 'd':
+ mDisplayName = optarg;
+ break;
+
+ case 'w':
+ mDisplayWidth = atoi(optarg);
+ break;
+
+ case 'h':
+ mDisplayHeight = atoi(optarg);
+ break;
+
+ case 'c':
+ if (atoi(optarg) < LOG_MAX_LEVEL)
+ {
+ mLogLevelConsole = (LOG_MODES)atoi(optarg);
+ }
+ break;
+
+ case 'f':
+ if (atoi(optarg) < LOG_MAX_LEVEL)
+ {
+ mLogLevelFile = (LOG_MODES)atoi(optarg);
+ }
+ break;
+
+ case 'l':
+ if (atoi(optarg) < LOG_MAX_LEVEL)
+ {
+ mLogLevelTrace = (LOG_MODES)atoi(optarg);
+ }
+ break;
+
+ case 'v':
+ LOG_INFO("LayerManagerService", "Version: " << ILM_VERSION);
+ exit(-1);
+ break;
+
+ case '?':
+ default:
+ LOG_INFO("LayerManagerService", "Version: " << ILM_VERSION);
+ puts(USAGE_DESCRIPTION);
+ exit(-1);
}
}
#include "GraphicalObject.h"
-unsigned int GraphicalObject::nextGraphicId[TypeMax]={1,1};
+unsigned int GraphicalObject::nextGraphicId[TypeMax]={1, 1};
const unsigned int GraphicalObject::INVALID_ID=0xFFFFFFFF;
bool GraphicalSurface::isInside(unsigned int x_DestCoordinateSyst, unsigned int y_DestCoordinateSyst) const
{
- bool ret;
-
- switch (m_orientation)
- {
- case Zero:
- ret = (
- ((x_DestCoordinateSyst >= m_destinationViewport.x) && (x_DestCoordinateSyst < m_destinationViewport.x + m_destinationViewport.width))
- &&
- ((y_DestCoordinateSyst >= m_destinationViewport.y) && (y_DestCoordinateSyst < m_destinationViewport.y + m_destinationViewport.height))
- );
- break;
-
- case Ninety:
- case OneEighty:
- case TwoSeventy:
- /* Not yet supported */
- ret = false;
- break;
-
- default:
- ret = false;
- break;
- }
-
- return ret;
+ bool ret;
+
+ switch (m_orientation)
+ {
+ case Zero:
+ ret = ((x_DestCoordinateSyst >= m_destinationViewport.x)
+ && (x_DestCoordinateSyst < m_destinationViewport.x + m_destinationViewport.width)
+ && (y_DestCoordinateSyst >= m_destinationViewport.y)
+ && (y_DestCoordinateSyst < m_destinationViewport.y + m_destinationViewport.height));
+ break;
+
+ case Ninety:
+ case OneEighty:
+ case TwoSeventy:
+ /* Not yet supported */
+ ret = false;
+ break;
+
+ default:
+ ret = false;
+ break;
+ }
+
+ return ret;
}
*/
bool GraphicalSurface::DestToSourceCoordinates(int *x, int *y, bool check) const
{
- bool ret;
- int TVxD, TVyD; /* Translation vector x,y in destination system */
- int TVxS, TVyS; /* Translation vector x,y in source system */
- float SFx, SFy; /* Scaling factor x,y */
-
- if (!check || isInside(*x, *y))
- {
- /* The translation vector in the Destination system */
- TVxD = m_destinationViewport.x;
- TVyD = m_destinationViewport.y;
-
- /* The translation vector in the Source system */
- TVxS = m_sourceViewport.x;
- TVyS = m_sourceViewport.y;
-
- /* Compute the scaling factors */
- SFx = (float) m_sourceViewport.width / (float) m_destinationViewport.width;
- SFy = (float) m_sourceViewport.height / (float) m_destinationViewport.height;
-
- /* Compute the rotation */
- // To be done ...
-
- /* Apply the transformations */
- *x = ((*x - TVxD) * SFx) + TVxS;
- *y = ((*y - TVyD) * SFy) + TVyS;
-
- ret = true;
- }
- else
- {
- ret = false;
- }
-
- return ret;
+ bool ret;
+ int TVxD; /* Translation vector x in destination system */
+ int TVyD; /* Translation vector y in destination system */
+ int TVxS; /* Translation vector x in source system */
+ int TVyS; /* Translation vector y in source system */
+ float SFx; /* Scaling factor x */
+ float SFy; /* Scaling factor y */
+
+ if (!check || isInside(*x, *y))
+ {
+ /* The translation vector in the Destination system */
+ TVxD = m_destinationViewport.x;
+ TVyD = m_destinationViewport.y;
+
+ /* The translation vector in the Source system */
+ TVxS = m_sourceViewport.x;
+ TVyS = m_sourceViewport.y;
+
+ /* Compute the scaling factors */
+ SFx = (float) m_sourceViewport.width / (float) m_destinationViewport.width;
+ SFy = (float) m_sourceViewport.height / (float) m_destinationViewport.height;
+
+ /* Compute the rotation */
+ // To be done ...
+
+ /* Apply the transformations */
+ *x = ((*x - TVxD) * SFx) + TVxS;
+ *y = ((*y - TVyD) * SFy) + TVyS;
+
+ ret = true;
+ }
+ else
+ {
+ ret = false;
+ }
+
+ return ret;
}
*
****************************************************************************/
-
#include <cassert>
#include "Log.h"
}
}
-
return ret;
}
switch (state)
{
- case INPUT_STATE_PRESSED:
- elected = _getKbdFocus();
- m_KeyMap[keyId] = elected;
- break;
-
- case INPUT_STATE_RELEASED:
- elected = m_KeyMap[keyId];
- break;
-
- default:
- elected = NULL;
- LOG_WARNING("InputManager", "Invalid input state reported for reportKeyboardEvent() : " << state);
- break;
+ case INPUT_STATE_PRESSED:
+ elected = _getKbdFocus();
+ m_KeyMap[keyId] = elected;
+ break;
+
+ case INPUT_STATE_RELEASED:
+ elected = m_KeyMap[keyId];
+ break;
+
+ default:
+ elected = NULL;
+ LOG_WARNING("InputManager", "Invalid input state reported for reportKeyboardEvent() : " << state);
+ break;
}
return elected;
switch (p.state)
{
- case INPUT_STATE_PRESSED:
- elected = electSurfaceForPointerEvent(p.x, p.y);
- _setPointerFocus(elected);
- /* Pointer pressed also assigns the focus for touch events */
- _setTouchFocus(elected);
- break;
-
- case INPUT_STATE_OTHER:
- case INPUT_STATE_MOTION:
- case INPUT_STATE_RELEASED:
- elected = _getPointerFocus();
- if (elected != NULL)
- {
- transformGlobalToLocalCoordinates(elected, p.x, p.y);
- }
- break;
+ case INPUT_STATE_PRESSED:
+ elected = electSurfaceForPointerEvent(p.x, p.y);
+ _setPointerFocus(elected);
+ /* Pointer pressed also assigns the focus for touch events */
+ _setTouchFocus(elected);
+ break;
+
+ case INPUT_STATE_OTHER:
+ case INPUT_STATE_MOTION:
+ case INPUT_STATE_RELEASED:
+ elected = _getPointerFocus();
+ if (elected != NULL)
+ {
+ transformGlobalToLocalCoordinates(elected, p.x, p.y);
+ }
+ break;
- default:
- elected = NULL;
- LOG_WARNING("InputManager", "Invalid input state reported for reportPointerEvent() : " << p.state);
+ default:
+ elected = NULL;
+ LOG_WARNING("InputManager", "Invalid input state reported for reportPointerEvent() : " << p.state);
}
return elected;
LayerList &ll = m_pScene->getCurrentRenderOrder(0);
LayerListConstReverseIterator currentLayer;
SurfaceListConstReverseIterator currentSurf;
- int x_SurfCoordinate, y_SurfCoordinate;
+ int x_SurfCoordinate;
+ int y_SurfCoordinate;
surf = NULL;
/* Need to browse for all layers. 1st layer of m_currentRenderOrder is rendered
* on bottom, last one is rendrered on top. So we have to reverse iterate */
LayerListConstReverseIterator layerEnd(ll.rend());
- for (currentLayer = ll.rbegin();
- currentLayer != layerEnd && surf == NULL;
- currentLayer++)
+ for (currentLayer = ll.rbegin(); currentLayer != layerEnd && surf == NULL; currentLayer++)
{
- if ( ((*currentLayer)->visibility) && ((*currentLayer)->getOpacity() != 0) )
+ if ((*currentLayer)->visibility
+ && ((*currentLayer)->getOpacity() != 0)
+ && (*currentLayer)->isInside(x, y))
{
- if ((*currentLayer)->isInside(x, y))
+ x_SurfCoordinate = x;
+ y_SurfCoordinate = y;
+ (*currentLayer)->DestToSourceCoordinates(&x_SurfCoordinate, &y_SurfCoordinate, false);
+ /* Need to browse for all surfaces */
+ SurfaceListConstReverseIterator surfEnd((*currentLayer)->getAllSurfaces().rend());
+ for (currentSurf = (*currentLayer)->getAllSurfaces().rbegin();
+ currentSurf != surfEnd && surf == NULL;
+ currentSurf++)
{
- x_SurfCoordinate = x;
- y_SurfCoordinate = y;
- (*currentLayer)->DestToSourceCoordinates(&x_SurfCoordinate, &y_SurfCoordinate, false);
- /* Need to browse for all surfaces */
- SurfaceListConstReverseIterator surfEnd((*currentLayer)->getAllSurfaces().rend());
- for (currentSurf = (*currentLayer)->getAllSurfaces().rbegin();
- currentSurf != surfEnd && surf == NULL;
- currentSurf++)
+ if ((*currentSurf)->hasNativeContent()
+ && (*currentSurf)->visibility
+ && ((*currentSurf)->getOpacity() != 0)
+ && (*currentSurf)->isInside(x_SurfCoordinate, y_SurfCoordinate)
+ && (*currentSurf)->isInputEventAcceptedFrom(INPUT_DEVICE_POINTER))
{
- if ( ((*currentSurf)->hasNativeContent()) && ((*currentSurf)->visibility) && ((*currentSurf)->getOpacity() != 0) )
- {
- if ((*currentSurf)->isInside(x_SurfCoordinate, y_SurfCoordinate))
- {
- if ((*currentSurf)->isInputEventAcceptedFrom(INPUT_DEVICE_POINTER))
- {
- surf = *currentSurf;
- (*currentSurf)->DestToSourceCoordinates(&x_SurfCoordinate, &y_SurfCoordinate, false);
- x = x_SurfCoordinate;
- y = y_SurfCoordinate;
- }
- }
- }
+ surf = *currentSurf;
+ (*currentSurf)->DestToSourceCoordinates(&x_SurfCoordinate, &y_SurfCoordinate, false);
+ x = x_SurfCoordinate;
+ y = y_SurfCoordinate;
}
}
}
layer = m_pScene->getLayer(surf->getContainingLayerId());
if (layer != NULL)
{
- layer->DestToSourceCoordinates(&x,&y, false);
- surf->DestToSourceCoordinates(&x,&y, false);
+ layer->DestToSourceCoordinates(&x, &y, false);
+ surf->DestToSourceCoordinates(&x, &y, false);
}
}
// via the renderer for a redraw because of a rendering property change
void Layermanager::signalRendererRedraw()
{
- IRenderer* renderer = *m_pRendererList->begin();
- if (NULL!=renderer)
- renderer->signalWindowSystemRedraw();
+ IRenderer* renderer = *m_pRendererList->begin();
+ if (renderer)
+ {
+ renderer->signalWindowSystemRedraw();
+ }
}
void Layermanager::addApplicationReference(t_ilm_client_handle client, IApplicationReference* reference)
if (status == ExecutionFailedRedraw || status == ExecutionSuccessRedraw)
{
- // either a command that has changed the output was executed, or
- // commit command was executed which contained commands that requested redraw was executed.
- signalRendererRedraw();
+ // either a command that has changed the output was executed, or
+ // commit command was executed which contained commands that requested redraw was executed.
+ signalRendererRedraw();
}
unsigned int commandPid = commandToBeExecuted->getSenderPid();
LOG_INFO("LayerManagerService", "executed " << commandToBeExecuted->getString()
- << " from " << getSenderName(commandPid) << "(" << commandPid << ")"
- << ((status == ExecutionSuccess || status == ExecutionSuccessRedraw) ? "+" : "-"));
+ << " from " << getSenderName(commandPid) << "(" << commandPid << ")"
+ << ((status == ExecutionSuccess || status == ExecutionSuccessRedraw) ? "+" : "-"));
return (status == ExecutionSuccess || status == ExecutionSuccessRedraw);
}
}
if (renderer == NULL || allStarted == false)
{
- break;
+ break;
}
}
if (!allStarted)
{
- LOG_ERROR("LayerManagerService","Could not start Compositing Controllers");
+ LOG_ERROR("LayerManagerService", "Could not start Compositing Controllers");
}
return allStarted;
}
}
if (!allStarted)
{
- LOG_WARNING("LayerManagerService","Could not start delegate Scenes, initial Scene is lost");
+ LOG_WARNING("LayerManagerService", "Could not start delegate Scenes, initial Scene is lost");
}
return allStarted;
}
bool Layermanager::startAllCommunicators()
{
bool allStarted = true;
-
+
CommunicatorListIterator communicatorIter = m_pCommunicatorList->begin();
CommunicatorListIterator communicatorIterEnd = m_pCommunicatorList->end();
-
+
for (; communicatorIter != communicatorIterEnd; ++communicatorIter)
{
ICommunicator *communicator = *communicatorIter;
}
if (!allStarted)
{
- LOG_ERROR("LayerManagerService","Could not start Communication Controllers");
+ LOG_ERROR("LayerManagerService", "Could not start Communication Controllers");
}
return allStarted;
}
bool Layermanager::startAllHealthMonitors()
{
bool allStarted = true;
-
+
HealthMonitorListIterator iter = m_pHealthMonitorList->begin();
HealthMonitorListIterator iterEnd = m_pHealthMonitorList->end();
-
+
for (; iter != iterEnd; ++iter)
{
IHealthMonitor* healthMonitor = *iter;
}
if (!allStarted)
{
- LOG_ERROR("LayerManagerService","Could not start Health Monitors");
+ LOG_ERROR("LayerManagerService", "Could not start Health Monitors");
}
return allStarted;
}
const int width = mConfiguration.getDisplayWidth();
const int height = mConfiguration.getDisplayHeight();
const char* displayName = mConfiguration.getDisplayName().c_str();
-
+
// 1. start renderers, no prerequisites
// 2. execute scene provider plugins
// 3. start communication (after scene is ready to use)
result = startAllRenderers(width, height, displayName)
- && delegateScene()
- && startAllCommunicators()
- && startAllHealthMonitors();
+ && delegateScene()
+ && startAllCommunicators()
+ && startAllHealthMonitors();
return result;
}
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
{
mHealth = health;
}
-
/***************************************************************************
- *
+ *
* Copyright 2012 BMW Car IT GmbH
*
*
#include <dlfcn.h>
#include <stdlib.h>
-
StaticPluginCreateFuncList PluginManager::mStaticPluginCreateFuncList;
//===========================================================================
, mConfiguration(config)
{
LOG_DEBUG("PluginManager", "loading plugins from " << mConfiguration.getPluginPath());
-
+
// create static plugins
createStaticallyLinkedPlugins();
-
+
#ifndef WITH_STATIC_LIBRARIES
// create dynamic plugins
getAllFilesInPluginPath(mConfiguration.getPluginPath());
createDynamicallyLinkedPlugins();
#endif
-
+
LOG_INFO("PluginManager", "created " << mPluginList.size() << " plugins");
}
{
PluginList::iterator iter = mPluginList.begin();
PluginList::iterator iterEnd = mPluginList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = *iter;
{
PluginList::const_iterator iter = mPluginList.begin();
PluginList::const_iterator iterEnd = mPluginList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = *iter;
{
PluginList::const_iterator iter = mPluginList.begin();
PluginList::const_iterator iterEnd = mPluginList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = *iter;
{
PluginList::const_iterator iter = mPluginList.begin();
PluginList::const_iterator iterEnd = mPluginList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = *iter;
{
PluginList::const_iterator iter = mPluginList.begin();
PluginList::const_iterator iterEnd = mPluginList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = *iter;
{
StaticPluginCreateFuncList::iterator iter = mStaticPluginCreateFuncList.begin();
StaticPluginCreateFuncList::iterator iterEnd = mStaticPluginCreateFuncList.end();
-
+
for (; iter != iterEnd; ++iter)
{
StaticPluginCreateFunc func = *iter;
{
DIR *directory = opendir(path.c_str());
struct dirent *itemInDirectory = 0;
-
+
while (directory && (itemInDirectory = readdir(directory)))
{
unsigned char entryType = itemInDirectory->d_type;
std::string entryName = itemInDirectory->d_name;
std::string fullPath = path + "/" + entryName;
-
+
if (entryName.at(0) == '.')
{
continue;
}
-
+
switch (entryType)
{
- case DT_REG:
- case DT_LNK:
- case DT_UNKNOWN:
- mFileList.push_back(fullPath);
- LOG_DEBUG("PluginManager", "considering File " << fullPath);
- break;
-
- case DT_DIR:
- getAllFilesInPluginPath(fullPath);
- break;
-
- default:
- LOG_DEBUG("PluginManager", "ignored file " << fullPath);
- break;
+ case DT_REG:
+ case DT_LNK:
+ case DT_UNKNOWN:
+ mFileList.push_back(fullPath);
+ LOG_DEBUG("PluginManager", "considering File " << fullPath);
+ break;
+
+ case DT_DIR:
+ getAllFilesInPluginPath(fullPath);
+ break;
+
+ default:
+ LOG_DEBUG("PluginManager", "ignored file " << fullPath);
+ break;
}
}
-
+
closedir(directory);
}
{
FileList::const_iterator iter = mFileList.begin();
FileList::const_iterator iterEnd = mFileList.end();
-
+
for (; iter != iterEnd; ++iter)
{
IPlugin* plugin = createDynamicallyLinkedPlugin(*iter);
IPlugin* PluginManager::createDynamicallyLinkedPlugin(std::string path)
{
IPlugin* returnValue = NULL;
-
+
// open library
void *libraryHandle;
dlerror(); // Clear any existing error
LOG_DEBUG("PluginManager", "not a shared library: " << dlopen_error);
return NULL;
}
-
+
// load entry point
union
{
void* data;
IPlugin* (*createFunc)(ICommandExecutor&, Configuration&);
} convertUnion;
-
+
int cutBegin = path.find_last_of('/') + 4; // remove '*/lib' from name
int cutEnd = path.find_first_of('.', cutBegin); // remove '.extension' from name
-
+
std::string createFunctionName = "create";
createFunctionName += path.substr(cutBegin, cutEnd - cutBegin);
-
+
convertUnion.data = dlsym(libraryHandle, createFunctionName.c_str());
-
+
// create plugin instance from entry point
const char* dlsym_error = dlerror();
if (convertUnion.data && !dlsym_error)
dlclose(libraryHandle);
returnValue = NULL;
}
-
+
return returnValue;
-}
\ No newline at end of file
+}
}
else
{
- LOG_DEBUG("Scene","createLayer: Layer with id " << layerId << " already exists ");
+ LOG_DEBUG("Scene", "createLayer: Layer with id " << layerId << " already exists ");
newLayer = m_layerMap[layerId];
}
}
else
{
newSurface = m_surfaceMap[surfaceId];
- LOG_DEBUG("Scene","Surface with id [ " << surfaceId << " ] " << " already exists " );
+ LOG_DEBUG("Scene", "Surface with id [ " << surfaceId << " ] " << " already exists ");
}
}
return newSurface;
return (*iter);
}
}
- LOG_WARNING("Scene","screen not found : id [ " << screenId << " ]");
+ LOG_WARNING("Scene", "screen not found : id [ " << screenId << " ]");
return NULL;
}
}
else
{
- LOG_WARNING("Scene","layer not found : id [ " << layerId << " ]");
+ LOG_WARNING("Scene", "layer not found : id [ " << layerId << " ]");
}
return layer;
}
}
else
{
- LOG_WARNING("Scene","surface not found : id [ " << surfaceId << " ]");
+ LOG_WARNING("Scene", "surface not found : id [ " << surfaceId << " ]");
}
return surface;
}
#include <Shader.h>
-unsigned int Shader::m_nextUniqueShaderId=1;
+unsigned int Shader::m_nextUniqueShaderId = 1;
Shader* Shader::createShader(const string& vertFileName, const string& fragFileName)
{
UniformMapConstIterator iterEnd = m_uniformMap.end();
for (; iter != iterEnd; ++iter)
- {
+ {
ShaderUniform* uniform = (*iter).second;
uniform->load(m_program);
}
{
uniform1iv(m_texUnitLoc, texCount, uniforms.texUnit);
}
- if (m_chromaKeyLoc>= 0)
+ if (m_chromaKeyLoc >= 0)
{
uniform3fv(m_chromaKeyLoc, 1, uniforms.chromaKey);
}
using namespace std;
const int ShaderUniform::m_vectorSizesOfDataTypes[] =
-{ 0, // Undefined
- 1, // Vector1f
- 2, // Vector2f
- 3, // Vector3f
- 4, // Vector4f
- 4, // Matrix2f
- 9, // Matrix3f
- 16 // Matrix4f
- };
+{
+ 0, // Undefined
+ 1, // Vector1f
+ 2, // Vector2f
+ 3, // Vector3f
+ 4, // Vector4f
+ 4, // Matrix2f
+ 9, // Matrix3f
+ 16 // Matrix4f
+};
ShaderUniform* ShaderUniform::createFromStringDescription(
const string& description)
}
else
{
- LOG_ERROR("Shader Uniform","Can not parse Type " << token);
+ LOG_ERROR("Shader Uniform", "Can not parse Type " << token);
return NULL;
}
if (iss.fail())
{
// failed to parse element count
- LOG_ERROR("Shader Uniform","Fail to parse element count.");
+ LOG_ERROR("Shader Uniform", "Fail to parse element count.");
return NULL;
}
{
if ((iss >> transpose).fail())
{
- LOG_ERROR("Shader Uniform","Fail to parse value ");
+ LOG_ERROR("Shader Uniform", "Fail to parse value ");
return NULL;
}
}
if (iss.fail())
{
// failed to parse value
- LOG_ERROR("Shader Uniform","Fail to parse value " << value);
+ LOG_ERROR("Shader Uniform", "Fail to parse value " << value);
return NULL;
}
floatData.push_back(value);
if (floatData.size() != numValuesExpected)
{
- LOG_ERROR("Shader Uniform","Invalid number of values");
+ LOG_ERROR("Shader Uniform", "Invalid number of values");
return NULL;
}
void ShaderUniform::load(ShaderProgram& program)
{
- LOG_DEBUG("ShaderUniform","Load Uniform " << getName() << " location " << m_location);
- if ( m_location == 0 )
+ LOG_DEBUG("ShaderUniform", "Load Uniform " << getName() << " location " << m_location);
+ if (m_location == 0)
{
m_location = program.getUniformLocation(getName().c_str());
}
- LOG_DEBUG("ShaderUniform","Load Uniform " << getName() << " location " << m_location);
+ LOG_DEBUG("ShaderUniform", "Load Uniform " << getName() << " location " << m_location);
if (m_location == -1)
{
// TODO: error? or silently fail?
- LOG_WARNING("ShaderUniform","Load Uniform failed, location not defined" );
+ LOG_WARNING("ShaderUniform", "Load Uniform failed, location not defined");
return;
}
switch (m_type)
{
case Vector1f:
- LOG_DEBUG("ShaderUniform","Load Uniform1fv : " << values[0] );
+ LOG_DEBUG("ShaderUniform", "Load Uniform1fv : " << values[0]);
program.uniform1fv(m_location, m_count, values);
break;
case Vector2f:
- LOG_DEBUG("ShaderUniform","Load Uniform2fv : " << values[0] << "," << values[1] );
+ LOG_DEBUG("ShaderUniform", "Load Uniform2fv : " << values[0] << ", " << values[1]);
program.uniform2fv(m_location, m_count, values);
break;
case Vector3f:
- LOG_DEBUG("ShaderUniform","Load Uniform3fv : " << values[0] << "," << values[1] << "," << values[2] );
+ LOG_DEBUG("ShaderUniform", "Load Uniform3fv : " << values[0] << ", " << values[1] << ", " << values[2]);
program.uniform3fv(m_location, m_count, values);
break;
case Vector4f:
- LOG_DEBUG("ShaderUniform","Load Uniform4fv : " << values[0] << "," << values[1] << "," << values[2] << "," << values[3] );
+ LOG_DEBUG("ShaderUniform", "Load Uniform4fv : " << values[0] << ", " << values[1] << ", " << values[2] << ", " << values[3]);
program.uniform4fv(m_location, m_count, values);
break;
#include <pthread.h> // mutex
#ifdef HAVE_EXECINFO_H
- #include <execinfo.h>
+#include <execinfo.h>
#endif
#ifdef HAVE_BACKTRACE
const int maxStackSize = 64;
void* stack[maxStackSize];
-
+
size_t count = backtrace(stack, maxStackSize);
char **lines = backtrace_symbols(stack, count);
-
+
LOG_INFO("LayerManagerService", "--------------------------------------------------");
for (unsigned int i = 0; i < count; ++i)
{
{
switch (sig)
{
- case SIGTERM:
- LOG_INFO("LayerManagerService", "Signal SIGTERM received. Shutting down.");
- pthread_mutex_unlock(&gShutdownReceived);
- break;
-
- case SIGINT:
- LOG_INFO("LayerManagerService", "Signal SIGINT received. Shutting down.");
- pthread_mutex_unlock(&gShutdownReceived);
- break;
-
- case SIGBUS:
- LOG_ERROR("LayerManagerService", "Signal SIGBUS received. Shutting down.");
- printStackTrace();
- pthread_mutex_unlock(&gShutdownReceived);
- break;
-
- case SIGSEGV:
- LOG_ERROR("LayerManagerService", "Signal SIGSEGV received. Shutting down.");
- printStackTrace();
- pthread_mutex_unlock(&gShutdownReceived);
- break;
-
- case SIGABRT:
- LOG_ERROR("LayerManagerService", "Signal SIGABRT received. Shutting down.");
- printStackTrace();
- pthread_mutex_unlock(&gShutdownReceived);
- break;
-
- default:
- LOG_INFO("LayerManagerService", "Signal " << sig << " received.");
- break;
+ case SIGTERM:
+ LOG_INFO("LayerManagerService", "Signal SIGTERM received. Shutting down.");
+ pthread_mutex_unlock(&gShutdownReceived);
+ break;
+
+ case SIGINT:
+ LOG_INFO("LayerManagerService", "Signal SIGINT received. Shutting down.");
+ pthread_mutex_unlock(&gShutdownReceived);
+ break;
+
+ case SIGBUS:
+ LOG_ERROR("LayerManagerService", "Signal SIGBUS received. Shutting down.");
+ printStackTrace();
+ pthread_mutex_unlock(&gShutdownReceived);
+ break;
+
+ case SIGSEGV:
+ LOG_ERROR("LayerManagerService", "Signal SIGSEGV received. Shutting down.");
+ printStackTrace();
+ pthread_mutex_unlock(&gShutdownReceived);
+ break;
+
+ case SIGABRT:
+ LOG_ERROR("LayerManagerService", "Signal SIGABRT received. Shutting down.");
+ printStackTrace();
+ pthread_mutex_unlock(&gShutdownReceived);
+ break;
+
+ default:
+ LOG_INFO("LayerManagerService", "Signal " << sig << " received.");
+ break;
}
}
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_surfaceCreate(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface *pSurfaceId);
+ilmErrorTypes ilm_surfaceCreate(t_ilm_nativehandle nativehandle,
+ t_ilm_int width,
+ t_ilm_int height,
+ ilmPixelFormat pixelFormat,
+ t_ilm_surface *pSurfaceId);
/**
* \brief Get the horizontal and vertical dimension of the surface.
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_surfaceSetNativeContent(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface surfaceId);
+ilmErrorTypes ilm_surfaceSetNativeContent(t_ilm_nativehandle nativehandle,
+ t_ilm_int width,
+ t_ilm_int height,
+ ilmPixelFormat pixelFormat,
+ t_ilm_surface surfaceId);
/**
* \brief Set the area of a surface which should be used for the rendering.
* By default, a surface accept input events from all kind of devices (keyboards, pointer, ...)
* By calling this function, you can adjust surface preferences. Note that this function only
* adjust the acceptance for the specified devices. Non specified are keept untouched.
- *
+ *
* Typicall use case for this function is when dealing with pointer or touch events.
* Those are normally dispatched to the first visible surface below the coordinate.
* If you want a different behavior (i.e. forward events to an other surface below the coordinate,
{
ILM_PIXELFORMAT_R_8 = 0, /*!< Pixelformat value, to describe a 8 bit luminance surface */
ILM_PIXELFORMAT_RGB_888 = 1, /*!< Pixelformat value, to describe a 24 bit rgb surface */
- ILM_PIXELFORMAT_RGBA_8888 =2, /*!< Pixelformat value, to describe a 24 bit rgb surface with 8 bit alpha */
+ ILM_PIXELFORMAT_RGBA_8888 = 2, /*!< Pixelformat value, to describe a 24 bit rgb surface with 8 bit alpha */
ILM_PIXELFORMAT_RGB_565 = 3, /*!< Pixelformat value, to describe a 16 bit rgb surface */
ILM_PIXELFORMAT_RGBA_5551 = 4, /*!< Pixelformat value, to describe a 16 bit rgb surface, with binary mask */
ILM_PIXELFORMAT_RGBA_6661 = 5, /*!< Pixelformat value, to describe a 18 bit rgb surface, with binars mask */
ILM_LAYERTYPE_UNKNOWN = 0, /*!< LayerType not known */
ILM_LAYERTYPE_HARDWARE = 1, /*!< LayerType value, to describe a hardware layer */
ILM_LAYERTYPE_SOFTWARE2D = 2, /*!< LayerType value, to describe a redirected offscreen buffer layer */
- ILM_LAYERTYPE_SOFTWARE2_5D = 3 /*!< LayerType value, to describe a redirected offscreen buffer layer, which can be rotated in the 3d space */
+ ILM_LAYERTYPE_SOFTWARE2_5D = 3 /*!< LayerType value, to describe a redirected offscreen buffer layer,
+ which can be rotated in the 3d space */
} ilmLayerType;
/**
*/
typedef enum
{
- ILM_NOTIFICATION_VISIBILITY = ILM_BIT(1),
- ILM_NOTIFICATION_OPACITY = ILM_BIT(2),
- ILM_NOTIFICATION_ORIENTATION = ILM_BIT(3),
- ILM_NOTIFICATION_SOURCE_RECT = ILM_BIT(4),
- ILM_NOTIFICATION_DEST_RECT = ILM_BIT(5),
- ILM_NOTIFICATION_ALL = 0xffff
+ ILM_NOTIFICATION_VISIBILITY = ILM_BIT(1),
+ ILM_NOTIFICATION_OPACITY = ILM_BIT(2),
+ ILM_NOTIFICATION_ORIENTATION = ILM_BIT(3),
+ ILM_NOTIFICATION_SOURCE_RECT = ILM_BIT(4),
+ ILM_NOTIFICATION_DEST_RECT = ILM_BIT(5),
+ ILM_NOTIFICATION_ALL = 0xffff
} t_ilm_notification_mask;
/**
* Typedef for notification callback on property changes of a layer
*/
typedef void(*layerNotificationFunc)(t_ilm_layer layer,
- struct ilmLayerProperties*,
- t_ilm_notification_mask mask);
+ struct ilmLayerProperties*,
+ t_ilm_notification_mask mask);
/**
* Typedef for notification callback on property changes of a surface
*/
typedef void(*surfaceNotificationFunc)(t_ilm_surface surface,
- struct ilmSurfaceProperties*,
- t_ilm_notification_mask mask);
+ struct ilmSurfaceProperties*,
+ t_ilm_notification_mask mask);
/**
* enum for identifying different health states
*/
typedef enum PluginApi
{
- Renderer_Api = 0x00010000,
+ Renderer_Api = 0x00010000,
Renderer_Api_v1,
- SceneProvider_Api = 0x00020000,
+ SceneProvider_Api = 0x00020000,
SceneProvider_Api_v1,
- Communicator_Api = 0x00040000,
+ Communicator_Api = 0x00040000,
Communicator_Api_v1,
- HealthMonitor_Api = 0x00080000,
+ HealthMonitor_Api = 0x00080000,
HealthMonitor_Api_v1
} ilmPluginApi;
+/***************************************************************************
+ *
+ * Copyright 2013 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 "ilm_tools.h"
#include "ilm_types.h"
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_getLayerIDs(t_ilm_int* pLength,t_ilm_layer** ppArray);
+ilmErrorTypes ilm_getLayerIDs(t_ilm_int* pLength, t_ilm_layer** ppArray);
/**
* \brief Get all LayerIds of the given screen
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_getLayerIDsOnScreen(t_ilm_uint screenID, t_ilm_int* pLength,t_ilm_layer** ppArray);
+ilmErrorTypes ilm_getLayerIDsOnScreen(t_ilm_uint screenID, t_ilm_int* pLength, t_ilm_layer** ppArray);
/**
* \brief Get all SurfaceIDs which are currently registered and managed by the services
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_getSurfaceIDs(t_ilm_int* pLength,t_ilm_surface** ppArray);
+ilmErrorTypes ilm_getSurfaceIDs(t_ilm_int* pLength, t_ilm_surface** ppArray);
/**
* \brief Get all SurfaceIds which are currently registered to a given layer and are managed by the services
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_getSurfaceIDsOnLayer(t_ilm_layer layer,t_ilm_int* pLength,t_ilm_surface** ppArray);
+ilmErrorTypes ilm_getSurfaceIDsOnLayer(t_ilm_layer layer, t_ilm_int* pLength, t_ilm_surface** ppArray);
/**
* \brief Create a layer which should be managed by the service
* \ingroup ilmControl
* \param[out] pLayerId pointer where the id should be/is stored. It is possible
* to set a id from outside, 0 will create a new id.
- *\param[in] width horizontal dimension of the layer
- *
+ * \param[in] width horizontal dimension of the layer
+ *
* \param[in] height vertical dimension of the layer
- *
-*
+ *
+ *
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
* \return ILM_SUCCESS if the method call was successful
* \return ILM_FAILED if the client can not call the method on the service.
*/
-ilmErrorTypes ilm_layerGetVisibility(t_ilm_layer layerId,t_ilm_bool *pVisibility);
+ilmErrorTypes ilm_layerGetVisibility(t_ilm_layer layerId, t_ilm_bool *pVisibility);
/**
* \brief Set the opacity of a layer.
* To receive keyboard events, 2 conditions must be fulfilled:
* 1- The surface must accept events from keyboard. See ilm_UpdateInputEventAcceptanceOn
* 2- The keyboard focus must be set on that surface
- *
+ *
* \ingroup ilmControl
* \param[in] surfaceId Identifier of the surface to set the keyboard focus on.
* \return ILM_SUCCESS if the method call was successful
/**
* \brief Get the indentifier of the surface which hold the keyboard focus
- *
+ *
* \ingroup ilmControl
* \param[out] pSurfaceId Pointer on the a surface identifier
* \return ILM_SUCCESS if the method call was successful
: ICommand(ExecuteSynchronous, sender)
{}
- /**
+ /**
* \brief default destructor
*/
virtual ~CommitCommand() {}
#include "ICommand.h"
-class ExitCommand: public ICommand
+class ExitCommand : public ICommand
{
public:
: ICommand(ExecuteSynchronous, sender)
{}
- /**
+ /**
* \brief default destructor
*/
virtual ~ExitCommand() {}
* \param[in] returnMode location to store mode of optimization on execution
* \ingroup Commands
*/
- GetOptimizationModeCommand(pid_t sender,OptimizationType id, OptimizationModeType* returnMode)
+ GetOptimizationModeCommand(pid_t sender, OptimizationType id, OptimizationModeType* returnMode)
: ICommand(ExecuteSynchronous, sender)
, m_id(id)
, m_pReturnMode(returnMode)
#include "ICommand.h"
#include <string>
-class LayerDumpCommand: public ICommand
+class LayerDumpCommand : public ICommand
{
public:
/*!
#include "ICommand.h"
-class LayerGetDimensionCommand: public ICommand
+class LayerGetDimensionCommand : public ICommand
{
public:
/*!
#include "ICommand.h"
#include "OrientationType.h"
-class LayerGetOrientationCommand: public ICommand
+class LayerGetOrientationCommand : public ICommand
{
public:
/*!
const unsigned int m_height;
// for unit testing
- template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type> friend class LayerSetDestinationRectangleCommandEqMatcherP5;
+ template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type>
+ friend class LayerSetDestinationRectangleCommandEqMatcherP5;
};
, m_y(y)
{}
-
/**
* \brief default destructor
*/
const unsigned int m_height;
// for unit testing
- template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type> friend class LayerSetSourceRectangleCommandEqMatcherP5;
+ template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type>
+ friend class LayerSetSourceRectangleCommandEqMatcherP5;
};
#include "ICommand.h"
#include <string>
-class ScreenDumpCommand: public ICommand
+class ScreenDumpCommand : public ICommand
{
public:
/*!
#include "ICommand.h"
-class ScreenSetRenderOrderCommand: public ICommand
+class ScreenSetRenderOrderCommand : public ICommand
{
public:
/*!
#include "ICommand.h"
#include <string>
-class SurfaceDumpCommand: public ICommand
+class SurfaceDumpCommand : public ICommand
{
public:
/*!
#include "ICommand.h"
-class SurfaceGetDimensionCommand: public ICommand
+class SurfaceGetDimensionCommand : public ICommand
{
public:
/*!
private:
unsigned int* m_pSurfId;
-
// for unit testing
friend class GetKeyboardFocusSurfaceIdCommandEqMatcher;
};
#include "ICommand.h"
#include "OrientationType.h"
-class SurfaceGetOrientationCommand: public ICommand
+class SurfaceGetOrientationCommand : public ICommand
{
public:
/*!
uint m_surfaceId;
// for unit testing
- //template <typename nativeHandle_type, typename pixelformat_type, typename OriginalWidth_type, typename OriginalHeight_type> friend class SurfaceSetRenderBufferCommandEqMatcherP4;
+ //template <typename nativeHandle_type, typename pixelformat_type, typename OriginalWidth_type, typename OriginalHeight_type>
+ //friend class SurfaceSetRenderBufferCommandEqMatcherP4;
};
const unsigned int m_height;
// for unit testing
- template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type> friend class SurfaceSetDestinationRectangleCommandEqMatcherP5;
+ template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type>
+ friend class SurfaceSetDestinationRectangleCommandEqMatcherP5;
};
* \param[in] height height of surface
* \ingroup Commands
*/
- SurfaceSetDimensionCommand(pid_t sender, int id, unsigned int width,unsigned int height)
+ SurfaceSetDimensionCommand(pid_t sender, int id, unsigned int width, unsigned int height)
: ICommand(ExecuteAsynchronous, sender)
, m_id(id)
, m_width(width)
class SurfaceSetKeyboardFocusCommand : public ICommand
{
- public:
- /*!
- * \action This command sets the keyboard focus on a particular surface
- * \frequency Called whenever a surface needs to receive keyboard events
- * \param[in] sender process id of application that sent this command
- * \param[in] surfId id of surface
- * \ingroup Commands
- */
- SurfaceSetKeyboardFocusCommand(pid_t sender, unsigned int surfId)
- : ICommand(ExecuteSynchronous, sender)
- , m_surfId(surfId)
- {}
+public:
+ /*!
+ * \action This command sets the keyboard focus on a particular surface
+ * \frequency Called whenever a surface needs to receive keyboard events
+ * \param[in] sender process id of application that sent this command
+ * \param[in] surfId id of surface
+ * \ingroup Commands
+ */
+ SurfaceSetKeyboardFocusCommand(pid_t sender, unsigned int surfId)
+ : ICommand(ExecuteSynchronous, sender)
+ , m_surfId(surfId)
+ {}
- /**
- * \brief default destructor
- */
- virtual ~SurfaceSetKeyboardFocusCommand() {}
+ /**
+ * \brief default destructor
+ */
+ virtual ~SurfaceSetKeyboardFocusCommand() {}
- /**
- * \brief Execute this command.
- * \param[in] executor Pointer to instance executing the LayerManagement Commands
- * \return ExecutionSuccess: execution successful
- * \return ExecutionFailed: execution failed
- */
- virtual ExecutionResult execute(ICommandExecutor* executor);
+ /**
+ * \brief Execute this command.
+ * \param[in] executor Pointer to instance executing the LayerManagement Commands
+ * \return ExecutionSuccess: execution successful
+ * \return ExecutionFailed: execution failed
+ */
+ virtual ExecutionResult execute(ICommandExecutor* executor);
- /**
- * \brief Get description string for this command.
- * \return String object with description of this command object
- */
- virtual const std::string getString();
-
- private:
- const unsigned int m_surfId;
+ /**
+ * \brief Get description string for this command.
+ * \return String object with description of this command object
+ */
+ virtual const std::string getString();
+private:
+ const unsigned int m_surfId;
// for unit testing
template <typename surfaceid_type> friend class SetKeyboardFocusOnCommandEqMatcherP;
* \param[in] OriginalHeight original height for native content
* \ingroup Commands
*/
- SurfaceSetNativeContentCommand(pid_t sender, unsigned int surfaceId, unsigned int handle, PixelFormat pixelformat, uint OriginalWidth, uint OriginalHeight)
+ SurfaceSetNativeContentCommand(pid_t sender,
+ unsigned int surfaceId,
+ unsigned int handle,
+ PixelFormat pixelformat,
+ uint OriginalWidth,
+ uint OriginalHeight)
: ICommand(ExecuteSynchronous, sender)
, m_surfaceId(surfaceId)
, m_nativeHandle(handle)
uint m_originalHeight;
// for unit testing
- //template <typename nativeHandle_type, typename pixelformat_type, typename OriginalWidth_type, typename OriginalHeight_type> friend class SurfaceSetRenderBufferCommandEqMatcherP4;
+ //template <typename nativeHandle_type, typename pixelformat_type, typename OriginalWidth_type,
+ // typename OriginalHeight_type> friend class SurfaceSetRenderBufferCommandEqMatcherP4;
};
const unsigned int m_height;
// for unit testing
- template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type> friend class SurfaceSetSourceRectangleCommandEqMatcherP5;
+ template <typename id_type, typename x_type, typename y_type, typename width_type, typename height_type>
+ friend class SurfaceSetSourceRectangleCommandEqMatcherP5;
};
class SurfaceUpdateInputEventAcceptance : public ICommand
{
- public:
- /*!
- * \action This command update the list of input devices the surface
- * can accept events from. Call this method if you do not want a surface
- * to receive particular type of event (touch, keyboard, ...)
- *
- * \frequency Preferably at init. This could lead to weird results
- * if you update the acceptance at runtime, while the surface has already
- * a focus (touch, keyboard, ...)
- *
- * \param[in] sender process id of application that sent this command
- * \param[in] surfId id of surface
- * \param[in] devices Bitmask of ilmInputDevice. To set the acceptance status of one or more input device.
- * Note that this method will only the acceptance status for the specified InputDeviced in the
- * "devices" parameter. Not specified input device status will remain unchanged.
- * \param[in] accept if TRUE, input events from all specified devices will be accepted
- *
- * \ingroup Commands
- */
- SurfaceUpdateInputEventAcceptance(pid_t sender, unsigned int surfId, InputDevice devices, bool accept)
- : ICommand(ExecuteSynchronous, sender)
- , m_surfId(surfId)
- , m_devices(devices)
- , m_accept(accept)
- {}
+public:
+ /*!
+ * \action This command update the list of input devices the surface
+ * can accept events from. Call this method if you do not want a surface
+ * to receive particular type of event (touch, keyboard, ...)
+ *
+ * \frequency Preferably at init. This could lead to weird results
+ * if you update the acceptance at runtime, while the surface has already
+ * a focus (touch, keyboard, ...)
+ *
+ * \param[in] sender process id of application that sent this command
+ * \param[in] surfId id of surface
+ * \param[in] devices Bitmask of ilmInputDevice. To set the acceptance status of one or more input device.
+ * Note that this method will only the acceptance status for the specified InputDeviced in the
+ * "devices" parameter. Not specified input device status will remain unchanged.
+ * \param[in] accept if TRUE, input events from all specified devices will be accepted
+ *
+ * \ingroup Commands
+ */
+ SurfaceUpdateInputEventAcceptance(pid_t sender, unsigned int surfId, InputDevice devices, bool accept)
+ : ICommand(ExecuteSynchronous, sender)
+ , m_surfId(surfId)
+ , m_devices(devices)
+ , m_accept(accept)
+ {}
- /**
- * \brief default destructor
- */
- virtual ~SurfaceUpdateInputEventAcceptance() {}
+ /**
+ * \brief default destructor
+ */
+ virtual ~SurfaceUpdateInputEventAcceptance() {}
- /**
- * \brief Execute this command.
- * \param[in] executor Pointer to instance executing the LayerManagement Commands
- * \return ExecutionSuccess: execution successful
- * \return ExecutionFailed: execution failed
- */
- virtual ExecutionResult execute(ICommandExecutor* executor);
+ /**
+ * \brief Execute this command.
+ * \param[in] executor Pointer to instance executing the LayerManagement Commands
+ * \return ExecutionSuccess: execution successful
+ * \return ExecutionFailed: execution failed
+ */
+ virtual ExecutionResult execute(ICommandExecutor* executor);
- /**
- * \brief Get description string for this command.
- * \return String object with description of this command object
- */
- virtual const std::string getString();
-
- private:
- const unsigned int m_surfId;
- const InputDevice m_devices;
- const bool m_accept;
+ /**
+ * \brief Get description string for this command.
+ * \return String object with description of this command object
+ */
+ virtual const std::string getString();
+private:
+ const unsigned int m_surfId;
+ const InputDevice m_devices;
+ const bool m_accept;
// for unit testing
- template <typename surfaceid_type, typename devices_type, typename acceptance_type> friend class UpdateInputEventAcceptanceOnCommandEqMatcherP3;
+ template <typename surfaceid_type, typename devices_type, typename acceptance_type>
+ friend class UpdateInputEventAcceptanceOnCommandEqMatcherP3;
};
#endif /* ! _SURFACEUPDATEINPUTEVENTACCEPTANCE_H_ */
{
if (layer->addSurface(surface))
{
- LOG_DEBUG("LayerAddSurfaceCommand","Adding surface(" << m_surfaceid << ")" << surface->getID() << " to layer(" << m_layerid << ") " << layer->getID());
+ LOG_DEBUG("LayerAddSurfaceCommand", "Adding surface(" << m_surfaceid << ")" << surface->getID() << " to layer(" << m_layerid << ") " << layer->getID());
LOG_DEBUG("LayerAddSurfaceCommand", "Layer now has #surfaces:" << layer->getAllSurfaces().size());
result = surface->hasNativeContent() ? ExecutionSuccessRedraw : ExecutionSuccess;
}
else
{
unsigned int layer_id = surface->getContainingLayerId();
- LOG_WARNING("LayerAddSurfaceCommand","surface : id [ " << m_surfaceid << " ] already belongs to layer : id [ " << layer_id << " ]");
+ LOG_WARNING("LayerAddSurfaceCommand", "surface : id [ " << m_surfaceid << " ] already belongs to layer : id [ " << layer_id << " ]");
result = (m_layerid == layer_id) ? ExecutionSuccess : ExecutionFailed;
}
- surface->calculateTargetDestination(layer->getSourceRegion(),layer->getDestinationRegion());
+ surface->calculateTargetDestination(layer->getSourceRegion(), layer->getDestinationRegion());
}
return result;
Scene& scene = *(executor->getScene());
ExecutionResult result = ExecutionFailed;
- Layer *layer = scene.createLayer(*m_idReturn, getSenderPid());
- if (layer)
- {
- *m_idReturn = layer->getID();
+ Layer *layer = scene.createLayer(*m_idReturn, getSenderPid());
+ if (layer)
+ {
+ *m_idReturn = layer->getID();
- layer->setDestinationRegion(Rectangle(0, 0, m_originalWidth, m_originalHeight));
- layer->setSourceRegion(Rectangle(0, 0, m_originalWidth, m_originalHeight));
- layer->OriginalSourceWidth = m_originalWidth;
- layer->OriginalSourceHeight = m_originalHeight;
+ layer->setDestinationRegion(Rectangle(0, 0, m_originalWidth, m_originalHeight));
+ layer->setSourceRegion(Rectangle(0, 0, m_originalWidth, m_originalHeight));
+ layer->OriginalSourceWidth = m_originalWidth;
+ layer->OriginalSourceHeight = m_originalHeight;
- LOG_DEBUG("LayerCreateCommand", "created layer with id: " << layer->getID() << "width: " << m_originalWidth << " height: " << m_originalHeight);
- result = ExecutionSuccess;
+ LOG_DEBUG("LayerCreateCommand", "created layer with id: " << layer->getID() << "width: " << m_originalWidth << " height: " << m_originalHeight);
+ result = ExecutionSuccess;
}
return result;
}
ExecutionResult LayerDumpCommand::execute(ICommandExecutor* executor)
{
- ExecutionResult result = ExecutionFailed;
+ ExecutionResult result = ExecutionFailed;
Scene& scene = *(executor->getScene());
RendererList& m_rendererList = *(executor->getRendererList());
bool status = false;
- LOG_INFO("LayerDumpCommand","making screenshot, output file: " << m_filename);
+ LOG_INFO("LayerDumpCommand", "making screenshot, output file: " << m_filename);
- if (scene.getLayer(m_id))
- {
- status = scene.isLayerInCurrentRenderOrder(m_id);
- if (!status)
- {
- LOG_WARNING("LayerDumpCommand","Requested layer: " << m_id << " does not belong to the current render order");
- }
- }
+ if (scene.getLayer(m_id))
+ {
+ status = scene.isLayerInCurrentRenderOrder(m_id);
+ if (!status)
+ {
+ LOG_WARNING("LayerDumpCommand", "Requested layer: " << m_id << " does not belong to the current render order");
+ }
+ }
if (status)
{
{
if (layer)
{
- LOG_DEBUG("LayerSetChromaKeyCommand","new chromakey disable for id: " << m_layerid);
+ LOG_DEBUG("LayerSetChromaKeyCommand", "new chromakey disable for id: " << m_layerid);
result = layer->setChromaKeyEnabled(false) ? ExecutionSuccessRedraw : ExecutionSuccess;
}
}
{
if (layer)
{
- LOG_DEBUG("LayerSetChromaKeyCommand","new chromakey ("
+ LOG_DEBUG("LayerSetChromaKeyCommand", "new chromakey ("
<< m_array[0] << ", " << m_array[1] << ", " << m_array[2] << ") for id: " << m_layerid);
bool ansSetEnabled = layer->setChromaKeyEnabled(true);
bool ansSetValues = layer->setChromaKey((unsigned char)m_array[0], (unsigned char)m_array[1], (unsigned char)m_array[2]);
if (layer)
{
- LOG_DEBUG("LayerSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
+ LOG_DEBUG("LayerSetOpacityCommand", "new opacity " << m_opacity << " for id: " << m_id);
if (layer->setOpacity(m_opacity))
{
result = ExecutionSuccessRedraw;
unsigned int layer_id = surface->getContainingLayerId();
if (layer->addSurface(surface))
{
- LOG_DEBUG("LayerSetRenderOrderCommand","Adding surface " << surface->getID() << " to renderorder of layer " << m_layerid);
+ LOG_DEBUG("LayerSetRenderOrderCommand", "Adding surface " << surface->getID() << " to renderorder of layer " << m_layerid);
result = ExecutionSuccessRedraw;
}
else
{
- LOG_WARNING("LayerSetRenderOrderCommand","surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
+ LOG_WARNING("LayerSetRenderOrderCommand", "surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
}
}
}
ExecutionResult ScreenDumpCommand::execute(ICommandExecutor* executor)
{
- ExecutionResult result = ExecutionFailed;
+ ExecutionResult result = ExecutionFailed;
RendererList& m_rendererList = *(executor->getRendererList());
bool status = false;
- LOG_INFO("ScreenDumpCommand","making screenshot, output file: " << m_filename);
+ LOG_INFO("ScreenDumpCommand", "making screenshot, output file: " << m_filename);
status = (m_id == 0);
{
// insert shader to shader map
int id = shader->getId();
- LOG_DEBUG("CreateShaderCommand","Shader with shader id : " << id << " successfully created");
+ LOG_DEBUG("CreateShaderCommand", "Shader with shader id : " << id << " successfully created");
ShaderMap &shaderMap = scene.m_shaderMap;
shaderMap[id] = shader;
*m_returnID = id;
const std::vector<std::string> uniformDesc = m_uniforms;
std::vector<std::string>::const_iterator uiterator;
- for (uiterator=uniformDesc.begin(); uiterator != uniformDesc.end(); ++uiterator)
+ for (uiterator = uniformDesc.begin(); uiterator != uniformDesc.end(); ++uiterator)
{
// parse description string and create uniform object
ShaderUniform* uniform = ShaderUniform::createFromStringDescription(*uiterator);
else
{
// shader not found
- LOG_ERROR("ShaderSetUniformsCommand", "shader ID "<<m_shaderid<<" not found");
+ LOG_ERROR("ShaderSetUniformsCommand", "shader ID " << m_shaderid << " not found");
result = ExecutionFailed;
}
ExecutionResult SurfaceDumpCommand::execute(ICommandExecutor* executor)
{
- ExecutionResult result = ExecutionFailed;
+ ExecutionResult result = ExecutionFailed;
Scene& scene = *(executor->getScene());
RendererList& m_rendererList = *(executor->getRendererList());
bool status = false;
unsigned int layer_id = 0;
- LOG_INFO("SurfaceDumpCommand","making screenshot, output file: " << m_filename);
+ LOG_INFO("SurfaceDumpCommand", "making screenshot, output file: " << m_filename);
- if (scene.getSurface(m_id))
- {
- layer_id = scene.getSurface(m_id)->getContainingLayerId();
- status = scene.isLayerInCurrentRenderOrder(layer_id);
- if (!status)
- {
- LOG_WARNING("SurfaceDumpCommand","Requested surface: " << m_id << " does not belong to a layer which is part of the current render order");
- }
- }
+ if (scene.getSurface(m_id))
+ {
+ layer_id = scene.getSurface(m_id)->getContainingLayerId();
+ status = scene.isLayerInCurrentRenderOrder(layer_id);
+ if (!status)
+ {
+ LOG_WARNING("SurfaceDumpCommand", "Requested surface: " << m_id << " does not belong to a layer which is part of the current render order");
+ }
+ }
if (status)
{
result = ExecutionSuccess;
}
- return result;
+ return result;
}
const std::string SurfaceGetOrientationCommand::getString()
ExecutionResult result = ExecutionFailed;
- Surface* surface = scene.getSurface(m_id);
- if (surface)
- {
- *m_pFormatreturn = surface->getPixelFormat();
- result = ExecutionSuccess;
- }
+ Surface* surface = scene.getSurface(m_id);
+ if (surface)
+ {
+ *m_pFormatreturn = surface->getPixelFormat();
+ result = ExecutionSuccess;
+ }
return result;
}
if (surface)
{
- if(surface->hasNativeContent())
+ if (surface->hasNativeContent())
{
surface->removeNativeContent();
result = ExecutionSuccessRedraw;
{
if (surface)
{
- LOG_DEBUG("SurfaceSetChromaKeyCommand","new chromakey disable for id: " << m_surfaceid);
+ LOG_DEBUG("SurfaceSetChromaKeyCommand", "new chromakey disable for id: " << m_surfaceid);
result = surface->setChromaKeyEnabled(false) ? ExecutionSuccessRedraw : ExecutionSuccess;
}
}
{
if (surface)
{
- LOG_DEBUG("SurfaceSetChromaKeyCommand","new chromakey (" << m_array[0] << ", " << m_array[1] << ", " << m_array[2] << ") for id: " << m_surfaceid);
+ LOG_DEBUG("SurfaceSetChromaKeyCommand", "new chromakey (" << m_array[0] << ", " << m_array[1] << ", " << m_array[2] << ") for id: " << m_surfaceid);
bool ansSetEnabled = surface->setChromaKeyEnabled(true);
bool ansSetValues = surface->setChromaKey((unsigned char)m_array[0], (unsigned char)m_array[1], (unsigned char)m_array[2]);
if ((true == ansSetEnabled) | (true == ansSetValues))
{
result = ExecutionSuccess;
}
- if ( layerid != Surface::INVALID_ID )
+ if (layerid != Surface::INVALID_ID)
{
- surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),scene.getLayer(layerid)->getDestinationRegion());
+ surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),
+ scene.getLayer(layerid)->getDestinationRegion());
}
}
Surface* surface = scene.getSurface(m_id);
if (surface)
{
- unsigned int layerid = surface->getContainingLayerId();
- if(surface->setDimension(m_width, m_height))
+ unsigned int layerid = surface->getContainingLayerId();
+ if (surface->setDimension(m_width, m_height))
{
executor->addClientNotification(surface, ILM_NOTIFICATION_DEST_RECT);
result = ExecutionSuccessRedraw;
result = ExecutionSuccess;
}
- if ( layerid != Surface::INVALID_ID )
- {
- surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),scene.getLayer(layerid)->getDestinationRegion());
- }
+ if (layerid != Surface::INVALID_ID)
+ {
+ surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),
+ scene.getLayer(layerid)->getDestinationRegion());
+ }
}
return result;
{
result = (*it)->getInputManager()->setKeyboardFocusOn(m_surfId) ? ExecutionSuccess : ExecutionFailed;
}
-
+
return result;
}
const std::string SurfaceSetKeyboardFocusCommand::getString()
{
std::stringstream description;
-
+
description << "SurfaceSetKeyboardFocusCommand("
<< "m_surfId=" << m_surfId << "(0x" << std::hex << m_surfId << ")" << std::dec
<< ")";
if (surface)
{
- if(!surface->hasNativeContent())
+ if (!surface->hasNativeContent())
{
surface->setNativeContent(m_nativeHandle);
surface->setPixelFormat(m_pixelformat);
result = ExecutionSuccessRedraw;
}
- else if( (unsigned int) surface->getNativeContent() == m_nativeHandle)
+ else if ((unsigned int) surface->getNativeContent() == m_nativeHandle)
{
result = ExecutionSuccess;
}
if (surface)
{
- LOG_DEBUG("SurfaceSetOpacityCommand","new opacity " << m_opacity << " for id: " << m_id);
+ LOG_DEBUG("SurfaceSetOpacityCommand", "new opacity " << m_opacity << " for id: " << m_id);
if (surface->setOpacity(m_opacity))
{
executor->addClientNotification(surface, ILM_NOTIFICATION_OPACITY);
}
if (layerid != Surface::INVALID_ID)
{
- surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),scene.getLayer(layerid)->getDestinationRegion());
+ surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),
+ scene.getLayer(layerid)->getDestinationRegion());
}
}
return result;
{
result = ExecutionSuccess;
}
- if ( layerid != Surface::INVALID_ID )
+ if (layerid != Surface::INVALID_ID)
{
- surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),scene.getLayer(layerid)->getDestinationRegion());
+ surface->calculateTargetDestination(scene.getLayer(layerid)->getSourceRegion(),
+ scene.getLayer(layerid)->getDestinationRegion());
}
}
callback mFuncPtr;
string mVarValue;
string mMatchText;
-
};
#endif // __EXPRESSION_H__
* limitations under the License.
*
****************************************************************************/
-#ifndef __COMMANDINTERPRETER_H__
-#define __COMMANDINTERPRETER_H__
+#ifndef __EXPRESSIONINTERPRETER_H__
+#define __EXPRESSIONINTERPRETER_H__
#include "Expression.h"
#include <string>
string mErrorText;
};
-#endif // __COMMANDINTERPRETER_H__
+#endif // __EXPRESSIONINTERPRETER_H__
/*
* Vector of four integers <x y z w>
*/
-class tuple4
+struct tuple4
{
public:
- int x, y, z, w;
+ int x;
+ int y;
+ int z;
+ int w;
+
tuple4(int _x, int _y, int _z, int _w) :
x(_x), y(_y), z(_z), w(_w)
{
-
}
tuple4() :
x(0), y(0), z(0), w(0)
{
-
}
tuple4(const tuple4& other)
w = other.w;
return *this;
}
-
};
*
****************************************************************************/
-#ifndef __SCENE_STORE_H__
-#define __SCENE_STORE_H__
+#ifndef __SCENESTORE_H__
+#define __SCENESTORE_H__
//=========================================================================
template<typename T> string getPrimitiveType(T* var)
{
(void) var;//suppress warning: unsued variable
- T var2=0;
+ T var2 = 0;
return getPrimitiveType(var2) + "*";
}
#endif
-class WrapperHelper
+struct WrapperHelper
{
public:
const string mType;
WrapperHelper(string t) :
mType(t)
{
-
}
virtual ~WrapperHelper()
{
-
}
virtual void fromString(string s)
};
template<typename T>
-class ComplexWrapper: public WrapperHelper
+struct ComplexWrapper : public WrapperHelper
{
public:
list<T> components;
ComplexWrapper(string t) :
WrapperHelper(t)
{
-
}
virtual void toStringMapTree(StringMapTree* parent)
{
- for(typename list<T>::iterator it = components.begin(); it != components.end(); ++it)
+ for (typename list<T>::iterator it = components.begin(); it != components.end(); ++it)
{
StringMapTree* node = new StringMapTree;
(*it)->toStringMapTree(node);
};
template<typename T>
-class BasicWrapper: public WrapperHelper
+struct BasicWrapper : public WrapperHelper
{
public:
T value;
BasicWrapper(string t) :
WrapperHelper(t)
{
-
}
virtual void fromString(string s)
{
stringstream ss;
ss.str(s);
- ss >> std::skipws>> value;
+ ss >> std::skipws >> value;
}
virtual string asString()
{
return getPrimitiveType(value);
}
-
};
template<>
BasicWrapper(string t) :
WrapperHelper(t)
{
-
}
virtual void fromString(string s)
BasicWrapper(char* t) :
WrapperHelper(t)
{
-
}
virtual void fromString(string s)
};
template<typename T>
-class DummyWrapper: public WrapperHelper
+struct DummyWrapper : public WrapperHelper
{
public:
T value;
DummyWrapper(string t) :
WrapperHelper(t)
{
-
}
-
virtual WrapperHelper* tryClone(string type, StringMapTree* tree)
{
if (type == mType)
value.toGrammarMapTree(tree);
}
-
virtual void addToComplexWrapper(WrapperHelper* wrapper)
{
ComplexWrapper<T*>* complexWrapper = static_cast<ComplexWrapper<T*>* >(wrapper);
}
};
-map<int,string> _globalTypeIndexdToType;
+map<int, string> _globalTypeIndexdToType;
#define OBJECT(class_name) \
class class_name;\
}\
}\
void fromStringMapTree(StringMapTree* node)\
- {\
+ {\
mClassName = node->mNodeLabel;\
- for(map<string,pair<string,string> >::iterator it = node->mNodeValues.begin(); it != node->mNodeValues.end();++it)\
- {\
- properties[it->first]->fromString(it->second.second);\
- }\
- for(list<StringMapTree*>::iterator it = node->mChildren.begin(); it != node->mChildren.end(); ++it )\
- {\
- string type = (*it)->mNodeLabel;\
- WrapperHelper* wrapper = dummyComponentClones[type]->tryClone(type, (*it));\
- WrapperHelper* complexWrapper = components[type];\
- wrapper->addToComplexWrapper(complexWrapper);\
- }\
- }\
+ for(map<string,pair<string,string> >::iterator it = node->mNodeValues.begin(); it != node->mNodeValues.end();++it)\
+ {\
+ properties[it->first]->fromString(it->second.second);\
+ }\
+ for(list<StringMapTree*>::iterator it = node->mChildren.begin(); it != node->mChildren.end(); ++it )\
+ {\
+ string type = (*it)->mNodeLabel;\
+ WrapperHelper* wrapper = dummyComponentClones[type]->tryClone(type, (*it));\
+ WrapperHelper* complexWrapper = components[type];\
+ wrapper->addToComplexWrapper(complexWrapper);\
+ }\
+ }\
};
CONTAINS(IlmDisplay)
OBJECTEND
-#endif
+#endif /* __SCENESTORE_H__ */
****************************************************************************/
-#ifndef __STRING_MAP_TREE_H__
-#define __STRING_MAP_TREE_H__
+#ifndef __STRINGMAPTREE_H__
+#define __STRINGMAPTREE_H__
#include <map>
#include <list>
{
public:
string mNodeLabel;
- map<string,pair<string,string> > mNodeValues;//key: property name, value= pair(type, property value)
+ map<string, pair<string, string> > mNodeValues;//key: property name, value= pair(type, property value)
list<StringMapTree*> mChildren;// pair(type, child component node)
- string toString(string prefix="")
+ string toString(string prefix = "")
{
string result;
- result += prefix + mNodeLabel+ ":{\n";
- for(map<string,pair<string,string> >::iterator it = mNodeValues.begin(); it != mNodeValues.end() ; ++it)
+ result += prefix + mNodeLabel + ":{\n";
+ for(map<string, pair<string, string> >::iterator it = mNodeValues.begin(); it != mNodeValues.end(); ++it)
{
- result += prefix + "\t[" + it->first + ":"+ it->second.first + "]=[" + it->second.second + "]\n";
+ result += prefix + "\t[" + it->first + ":" + it->second.first + "]=[" + it->second.second + "]\n";
}
for(list<StringMapTree*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
{
}
};
-
-
-#endif
+#endif /* __STRINGMAPTREE_H__ */
{
//remove brackets if needed
string noBrackets = mName;
- noBrackets = noBrackets[0] == '['? noBrackets.substr(1, noBrackets.size()-1) : noBrackets;
- noBrackets = noBrackets[noBrackets.size()-1] == ']'? noBrackets.substr(0, noBrackets.size()-1) : noBrackets;
+ noBrackets = noBrackets[0] == '[' ? noBrackets.substr(1, noBrackets.size() - 1) : noBrackets;
+ noBrackets = noBrackets[noBrackets.size() - 1] == ']' ? noBrackets.substr(0, noBrackets.size() - 1) : noBrackets;
- noBrackets = noBrackets[0] == '<'? noBrackets.substr(1, noBrackets.size()-1) : noBrackets;
- noBrackets = noBrackets[noBrackets.size()-1] == '>'? noBrackets.substr(0, noBrackets.size()-1) : noBrackets;
+ noBrackets = noBrackets[0] == '<' ? noBrackets.substr(1, noBrackets.size() - 1) : noBrackets;
+ noBrackets = noBrackets[noBrackets.size() - 1] == '>' ? noBrackets.substr(0, noBrackets.size() - 1) : noBrackets;
//remove default value (if needed)
string exprName = noBrackets.substr(0, noBrackets.find("="));
*count = 0;
string stringVal;
- while (getline( ss, stringVal, ',' ))
+ while (getline(ss, stringVal, ','))
{
sscanf(stringVal.c_str(), "%u", &buffer[*count]);
{
ExpressionList closure;
- if(bypass)
+ if (bypass)
{
//if expression is end of the optional expression
bool bypassChildren = mName[mName.length() - 1] != ']';
string exprName = expr->mName;
//remove brakcets
- exprName = exprName[0] == '['? exprName.substr(1, exprName.size()-1) : exprName;
- exprName = exprName[exprName.size()-1] == ']'? exprName.substr(0, exprName.size()-1) : exprName;
+ exprName = exprName[0] == '[' ? exprName.substr(1, exprName.size() - 1) : exprName;
+ exprName = exprName[exprName.size() - 1] == ']' ? exprName.substr(0, exprName.size() - 1) : exprName;
- exprName = exprName[0] == '<'? exprName.substr(1, exprName.size()-1) : exprName;
- exprName = exprName[exprName.size()-1] == '>'? exprName.substr(0, exprName.size()-1) : exprName;
+ exprName = exprName[0] == '<' ? exprName.substr(1, exprName.size()-1) : exprName;
+ exprName = exprName[exprName.size() - 1] == '>' ? exprName.substr(0, exprName.size() - 1) : exprName;
//remove default value (if needed)
exprName = exprName.substr(0, exprName.find("="));
{
//remove brackets if needed
string exprName = expr->mName;
- exprName = exprName[0] == '['? exprName.substr(1, exprName.size()-1) : exprName;
- exprName = exprName[exprName.size()-1] == ']'? exprName.substr(0, exprName.size()-1) : exprName;
+ exprName = exprName[0] == '[' ? exprName.substr(1, exprName.size() - 1) : exprName;
+ exprName = exprName[exprName.size() - 1] == ']' ? exprName.substr(0, exprName.size() - 1) : exprName;
//check all alternatives (in case there are alternatives)
while (exprName.length() > 0)
ExpressionList::const_iterator iter = currentState.begin();
ExpressionList::const_iterator end = currentState.end();
- for (;iter != end; ++iter)
+ for (; iter != end; ++iter)
{
Expression* expr = *iter;
ExpressionList exprNextList = expr->getNextExpressionClosure(text);
nextState.clear();
ExpressionList::const_iterator iter = currentState.begin();
ExpressionList::const_iterator end = currentState.end();
- for (;iter != end; ++iter)
+ for (; iter != end; ++iter)
{
Expression* expr = *iter;
if (expr->isExecutable())
ExpressionList::const_iterator iter = children.begin();
ExpressionList::const_iterator end = children.end();
- for (;iter != end; ++iter)
+ for (; iter != end; ++iter)
{
if ((*iter)->getName()[0] == '[')
{
namespace
{
-
void analyzePrintHelper(string tag, string flag, string description)
{
cout << left << setw(25) << tag << " | " << setw(7) << flag << " | " << description << endl;
t_ilm_layer targetSurfaceLayer = scene.surfaceLayer[targetSurfaceId];
ilmSurfaceProperties& targetSurfaceProperties = scene.surfaceProperties[targetSurfaceId];
ilmLayerProperties& targetLayerProperties = scene.layerProperties[targetSurfaceLayer];
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
//check visibility
void analyzeSurfaceDimensions(t_ilm_surface targetSurfaceId, t_scene_data& scene)
{
ilmSurfaceProperties& targetSurfaceProperties = scene.surfaceProperties[targetSurfaceId];
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
t_ilm_uint minDimension = 32;
ilmLayerProperties& targetLayerProperties = scene.layerProperties[targetSurfaceLayer];
t_ilm_uint minDimension = 32;
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tag = "Layer dest width";
if (targetLayerProperties.destWidth <= minDimension)
void analyzeDimensions(t_ilm_surface targetSurfaceId, t_scene_data& scene)
{
-
analyzeSurfaceDimensions(targetSurfaceId, scene);
analyzeLayerDimensions(targetSurfaceId, scene);
}
t_ilm_layer targetSurfaceLayer = scene.surfaceLayer[targetSurfaceId];
tuple4 targetSurfaceCoordinates = getSurfaceScreenCoordinates(&scene, targetSurfaceId);
ilmLayerProperties& targetLayerProperties = scene.layerProperties[targetSurfaceLayer];
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tuple4 layerCoordinates(targetLayerProperties.destX,
map<t_ilm_layer, ilmLayerProperties>& layerProperties,
vector<t_ilm_surface>& allSurfaces, tuple4 targetSurfaceCoordinates)
{
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
vector<t_ilm_surface> occludingSurfaces;
//coordinates of the surface on screen
t_ilm_int horizontalScale = layerProperties[surfaceLayer].destWidth / layerProperties[surfaceLayer].sourceWidth;
t_ilm_int surfaceX1 = layerProperties[surfaceLayer].destX + horizontalScale
- * (surfaceProperties[surfaceId].destX- layerProperties[surfaceLayer].sourceX);
+ * (surfaceProperties[surfaceId].destX - layerProperties[surfaceLayer].sourceX);
t_ilm_int surfaceX2 = surfaceX1 + horizontalScale * surfaceProperties[surfaceId].destWidth;
t_ilm_int verticalScale = layerProperties[surfaceLayer].destHeight / layerProperties[surfaceLayer].sourceHeight;
analyzePrintHelper(tag, flag, description);
occluded = ILM_TRUE;
-
}
//if the surface is partially occluded
else if (intersect(targetSurfaceCoordinates, surfaceCoordinates))
void analyzeOcclusion(t_ilm_surface targetSurfaceId, t_scene_data& scene)
{
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(&scene);
vector<t_ilm_surface>::iterator it = find(renderedSurfaces.begin(), renderedSurfaces.end(), targetSurfaceId);
- tuple4 targetSurfaceCoordinates = getSurfaceScreenCoordinates( &scene, targetSurfaceId);
+ tuple4 targetSurfaceCoordinates = getSurfaceScreenCoordinates(&scene, targetSurfaceId);
t_ilm_bool occluded = ILM_FALSE;
tag = "Occlusion";
{
t_ilm_bool exists = ILM_FALSE;
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tag = "Surface existance";
}
//output
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tag = "Surface on layer";
t_ilm_bool analyzeSharedNative(t_ilm_surface targetSurfaceId, t_scene_data& scene)
{
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tag = "Shared native";
ilmSurfaceProperties& targetSurfaceProperties = scene.surfaceProperties[targetSurfaceId];
t_ilm_bool problem = targetSurfaceProperties.updateCounter == 0;
- string tag, flag;
+ string tag;
+ string flag;
char description[300] = "";
tag = "Update Counter";
return !problem;
}
-
} //end of anonymous namespace
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed in writing, software
+ * 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 inputess or implied.
+ * 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.
*
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << x << "," << y << ", "<< w << ", " << h <<") for layer with ID " << id << "\n";
+ cout << "Failed to set source rectangle (" << x << "," << y << ", " << w << ", " << h << ") for layer with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << x << ", " << y << ", "<< w << ", " << h <<") for surface with ID " << id << "\n";
+ cout << "Failed to set source rectangle (" << x << ", " << y << ", " << w << ", " << h << ") for surface with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << x << ", " << y << ", "<< w << ", " << h <<") for layer with ID " << id << "\n";
+ cout << "Failed to set destination rectangle (" << x << ", " << y << ", " << w << ", " << h << ") for layer with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << x << ", " << y << ", "<< w << ", " << h <<") for surface with ID " << id << "\n";
+ cout << "Failed to set destination rectangle (" << x << ", " << y << ", " << w << ", " << h << ") for surface with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity "<< opacity << " for layer with ID " << id << "\n";
+ cout << "Failed to set opacity " << opacity << " for layer with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity "<< opacity << " for surface with ID " << id << "\n";
+ cout << "Failed to set opacity " << opacity << " for surface with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set visibility "<< visibility << " for layer with ID " << id << "\n";
+ cout << "Failed to set visibility " << visibility << " for layer with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set visibility "<< visibility << " for surface with ID " << id << "\n";
+ cout << "Failed to set visibility " << visibility << " for surface with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set orientation "<< orientation << " for layer with ID " << id << "\n";
+ cout << "Failed to set orientation " << orientation << " for layer with ID " << id << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set orientation "<< orientation << " for surface with ID " << id << "\n";
+ cout << "Failed to set orientation " << orientation << " for surface with ID " << id << "\n";
return;
}
ilm_commitChanges();
}
-
}
//=============================================================================
1.0 * targetLayerProperties.destWidth / targetLayerProperties.sourceWidth : 0;
t_ilm_float targetX1 = targetLayerProperties.destX + horizontalScale
- * (targetSurfaceProperties.destX- targetLayerProperties.sourceX);
+ * (targetSurfaceProperties.destX - targetLayerProperties.sourceX);
t_ilm_float targetX2 = targetX1 + horizontalScale * targetSurfaceProperties.destWidth;
t_ilm_float verticalScale = targetLayerProperties.sourceHeight ?
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to get layers on screen with ID "<< screenId <<"\n";
+ cout << "Failed to get layers on screen with ID " << screenId << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to get properties of layer with ID "<< layerId <<"\n";
+ cout << "Failed to get properties of layer with ID " << layerId << "\n";
return;
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to get surfaces on layer with ID "<< layerId <<"\n";
+ cout << "Failed to get surfaces on layer with ID " << layerId << "\n";
return;
}
{
t_ilm_layer layer = it->first;
vector<t_ilm_surface>& surfaces = it->second;
- if(surfaces.data() == NULL)
+ if (surfaces.data() == NULL)
{
surfaces.reserve(1);
}
t_ilm_uint count;
t_ilm_display* screenArray;
ilm_getScreenIDs(&count, &screenArray);
- for(t_ilm_uint i = 0 ; i < count ; ++i)
+ for (t_ilm_uint i = 0; i < count; ++i)
{
pScene->screens.push_back(screenArray[i]);
//prepare values needed for dummy (animation) scene
t_ilm_layer extraLayer = -1;
//if the scene is already uni layer just reuse same layer
- if(pScene->layers.size() == 1)
+ if (pScene->layers.size() == 1)
{
extraLayer = pScene->layers[0];
}
//sleep time
long sleepMillis = durationMillis / frameCount;
struct timespec sleepTime;
- sleepTime.tv_nsec = (sleepMillis% 1000) * 1000000;
+ sleepTime.tv_nsec = (sleepMillis % 1000) * 1000000;
sleepTime.tv_sec = sleepMillis / 1000;
struct timespec remTime;
//start and end coordinates of surfaces
map<t_ilm_surface, tuple4> start;
map<t_ilm_surface, tuple4> end;
- for(vector<t_ilm_surface>::iterator it = dummyScene.surfaces.begin();
+ for (vector<t_ilm_surface>::iterator it = dummyScene.surfaces.begin();
it != dummyScene.surfaces.end(); ++it)
{
t_ilm_surface surface = *it;
float t = 1.0 * i / frameCount;
//interpolate properties of each surface
- for(vector<t_ilm_surface>::iterator it = dummyScene.surfaces.begin();
+ for (vector<t_ilm_surface>::iterator it = dummyScene.surfaces.begin();
it != dummyScene.surfaces.end(); ++it)
{
t_ilm_surface surface = *it;
tuple4 coords = interpolateCoordinatesHelper(start[surface], end[surface], t);
- ilmErrorTypes callResult = ilm_surfaceSetDestinationRectangle(surface, coords.x, coords.y, coords.z - coords.x, coords.w - coords.y);
+ ilmErrorTypes callResult = ilm_surfaceSetDestinationRectangle(surface, coords.x, coords.y,
+ coords.z - coords.x, coords.w - coords.y);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coords.x << "," << coords.y << ", "<< coords.z - coords.x << ", " << coords.w - coords.y
+ cout << "Failed to set destination rectangle (" << coords.x << "," << coords.y << ", "
+ << coords.z - coords.x << ", " << coords.w - coords.y
<<") for surface with ID " << surface << "\n";
return;
}
float opacity = t * pFinalScene->surfaceProperties[surface].opacity
- + (1-t) * pInitialScene->surfaceProperties[surface].opacity;
+ + (1 - t) * pInitialScene->surfaceProperties[surface].opacity;
ilm_surfaceSetOpacity(surface, opacity);
}
{
(void) s;
- cout<<"LayerManagerControl :Interrupt signal...\n";
+ cout << "LayerManagerControl :Interrupt signal...\n";
if (global_pOriginalScene != NULL)
{
setScene(global_pOriginalScene, true);
ilmInputDevice devices = (ilmInputDevice)0;
str = new char [kbdPointerTouch.size()+1];
- strcpy (str, kbdPointerTouch.c_str());
+ strcpy(str, kbdPointerTouch.c_str());
tok = strtok(str, ":");
while (tok != NULL)
{
if (ILM_NOTIFICATION_SOURCE_RECT & mask)
{
cout << "\tsource rect = x:" << properties->sourceX
- << ", y:" << properties->sourceY
- << ", width:" << properties->sourceWidth
- << ", height:" << properties->sourceHeight
- << "\n";
+ << ", y:" << properties->sourceY
+ << ", width:" << properties->sourceWidth
+ << ", height:" << properties->sourceHeight
+ << "\n";
}
if (ILM_NOTIFICATION_DEST_RECT & mask)
{
cout << "\tdest rect = x:" << properties->destX
- << ", y:" << properties->destY
- << ", width:" << properties->destWidth
- << ", height:" << properties->destHeight
- << "\n";
+ << ", y:" << properties->destY
+ << ", width:" << properties->destWidth
+ << ", height:" << properties->destHeight
+ << "\n";
}
}
return;
}
- for (int i = 0; i < 2; ++i)
+ for (int i = 0; i < 2; ++i)
{
usleep(100 * 1000);
cout << "Set layer 1000 visbility to FALSE\n";
if (ILM_NOTIFICATION_SOURCE_RECT & mask)
{
cout << "\tsource rect = x:" << properties->sourceX
- << ", y:" << properties->sourceY
- << ", width:" << properties->sourceWidth
- << ", height:" << properties->sourceHeight
- << "\n";
+ << ", y:" << properties->sourceY
+ << ", width:" << properties->sourceWidth
+ << ", height:" << properties->sourceHeight
+ << "\n";
}
if (ILM_NOTIFICATION_DEST_RECT & mask)
{
cout << "\tdest rect = x:" << properties->destX
- << ", y:" << properties->destY
- << ", width:" << properties->destWidth
- << ", height:" << properties->destHeight
- << "\n";
+ << ", y:" << properties->destY
+ << ", width:" << properties->destWidth
+ << ", height:" << properties->destHeight
+ << "\n";
}
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set optimization with ID "<< id <<" mode " << mode << "\n";
+ cout << "Failed to set optimization with ID " << id << " mode " << mode << "\n";
return;
}
ilmErrorTypes callResult = ilm_GetOptimizationMode(optimizationId, &optimizationMode);
if (callResult == ILM_SUCCESS)
{
- switch ( optimizationId )
+ switch (optimizationId)
{
case ILM_OPT_MULTITEXTURE :
cout << "Optimization " << (int)optimizationId << " (Multitexture Optimization)" << endl;
break;
default:
- cout <<"Mode " << "unknown" << endl ;
+ cout << "Mode " << "unknown" << endl;
break;
}
}
else
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to get mode for optimization with ID "<< optimizationId << "\n";
+ cout << "Failed to get mode for optimization with ID " << optimizationId << "\n";
return;
}
namespace
{
-
-typedef void (*t_pDemoAnimatorFunc)(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo);
+typedef void(*t_pDemoAnimatorFunc)(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo);
void demoAnimatorDownwards(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
surfaceSpeed[surface] *= rand() % 2 ? -1 : 1;
}
-
//get surface positions and set initial positions
map<t_ilm_surface, tuple4> surfaceCoordinates;
long sleepTimeMillis = 25;
//start animation !
- while(! *pStopDemo)
+ while (! *pStopDemo)
{
for (vector<t_ilm_surface>::iterator it = renderedSurfaces.begin();
it != renderedSurfaces.end(); ++it)
//set source region to only the visible part of the surface
int ySource = static_cast<int>(-coordinates.y / surfaceScale[surface]);
- ilmErrorTypes callResult = ilm_surfaceSetSourceRectangle(surface, 0, ySource, properties.sourceWidth, properties.sourceHeight - ySource);
+ ilmErrorTypes callResult = ilm_surfaceSetSourceRectangle(surface, 0, ySource, properties.sourceWidth,
+ properties.sourceHeight - ySource);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", "<< properties.sourceWidth << ", " << properties.sourceHeight - ySource
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", " << properties.sourceWidth
+ << ", " << properties.sourceHeight - ySource
+ << ") for surface with ID " << surface << "\n";
}
//set the destination region AT THE TOP of the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", "<< max(0, coordinates.z - coordinates.x) << ", "
- << max(0, coordinates.w) <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", " << max(0, coordinates.z - coordinates.x) << ", "
+ << max(0, coordinates.w) << ") for surface with ID " << surface << "\n";
}
}
else
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", "<< properties.sourceWidth << ", " << properties.sourceHeight
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", " << properties.sourceWidth << ", " << properties.sourceHeight
+ << ") for surface with ID " << surface << "\n";
}
//set destination region to the region on the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", "<< max(0, coordinates.z - coordinates.x) << ", "
- << max(0, coordinates.w - coordinates.y) <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", " << max(0, coordinates.z - coordinates.x) << ", "
+ << max(0, coordinates.w - coordinates.y) << ") for surface with ID " << surface << "\n";
}
}
long sleepTimeMillis = 25;
//start animation !
- while(! *pStopDemo)
+ while (! *pStopDemo)
{
//set transparency to be inversly proportional to scale
for (vector<t_ilm_surface>::iterator it = renderedSurfaces.begin();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity " << opacity <<" for surface with ID " << surface << "\n";
+ cout << "Failed to set opacity " << opacity << " for surface with ID " << surface << "\n";
}
}
coordinates.y += surfaceSpeed[surface];
coordinates.w += surfaceSpeed[surface];
-
//if the upper part is not visible remove it from the source and destination regions
if (coordinates.y <= 0)
{
//set source region to only the visible part of the surface
int ySource = static_cast<int>(-coordinates.y / surfaceScale[surface]);
- ilmErrorTypes callResult = ilm_surfaceSetSourceRectangle(surface, 0, ySource, properties.sourceWidth, properties.sourceHeight - ySource);
+ ilmErrorTypes callResult = ilm_surfaceSetSourceRectangle(surface, 0, ySource, properties.sourceWidth,
+ properties.sourceHeight - ySource);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", "<< properties.sourceWidth << ", " << properties.sourceHeight - ySource
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", " << properties.sourceWidth
+ << ", " << properties.sourceHeight - ySource
+ << ") for surface with ID " << surface << "\n";
}
//set the destination region AT THE TOP of the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", "<< max(0, coordinates.z - coordinates.x) << ", " << max(0, coordinates.w)
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", " << max(0, coordinates.z - coordinates.x) << ", " << max(0, coordinates.w)
+ << ") for surface with ID " << surface << "\n";
}
}
else
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", "<< properties.sourceWidth << ", " << properties.sourceHeight
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", " << properties.sourceWidth << ", " << properties.sourceHeight
+ << ") for surface with ID " << surface << "\n";
}
//set destination region to the region on the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", "<< max(0, coordinates.z - coordinates.x) << ", "
- << max(0, coordinates.w - coordinates.y) <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", " << max(0, coordinates.z - coordinates.x) << ", "
+ << max(0, coordinates.w - coordinates.y) << ") for surface with ID " << surface << "\n";
}
}
long sleepTimeMillis = 25;
//start animation !
- while(! *pStopDemo)
+ while (! *pStopDemo)
{
for (vector<t_ilm_surface>::iterator it = renderedSurfaces.begin();
it != renderedSurfaces.end(); ++it)
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity " << opacity <<" for surface with ID " << surface << "\n";
+ cout << "Failed to set opacity " << opacity << " for surface with ID " << surface << "\n";
}
//move
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", "<< properties.sourceWidth << ", " << properties.sourceHeight - ySource
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << ySource << ", " << properties.sourceWidth << ", " << properties.sourceHeight - ySource
+ << ") for surface with ID " << surface << "\n";
}
//set the destination region AT THE TOP of the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", "<< max(0, coordinates.z - coordinates.x) << ", " << max(0, coordinates.w)
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << 0 << ", " << max(0, coordinates.z - coordinates.x) << ", " << max(0, coordinates.w)
+ << ") for surface with ID " << surface << "\n";
}
}
else
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", "<< properties.sourceWidth << ", " << properties.sourceHeight
- <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set source rectangle (" << 0 << "," << 0 << ", " << properties.sourceWidth << ", " << properties.sourceHeight
+ << ") for surface with ID " << surface << "\n";
}
//set destination region to the region on the layer used for displaying the surface
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", "<< max(0, coordinates.z - coordinates.x) << ", "
- << max(0, coordinates.w - coordinates.y) <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << coordinates.x << "," << coordinates.y << ", " << max(0, coordinates.z - coordinates.x) << ", "
+ << max(0, coordinates.w - coordinates.y) << ") for surface with ID " << surface << "\n";
}
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
-
}
//sleeping time
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
callResult = ilm_layerSetRenderOrder(layer, renderedSurfaces.data() + currentSurfaceIndex, 1);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
float opacity = 1 / pow(t, 0.4);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity " << opacity <<" for surface with ID " << surface << "\n";
+ cout << "Failed to set opacity " << opacity << " for surface with ID " << surface << "\n";
}
}
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
scaleFactors[surface] = 1;
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", "<< surfaceProperties.destWidth << ", "
- << surfaceProperties.destHeight <<") for surface with ID " << surface << "\n";
+ cout << "Failed to set destination rectangle (" << surfaceProperties.destX << "," << surfaceProperties.destY << ", " << surfaceProperties.destWidth << ", "
+ << surfaceProperties.destHeight << ") for surface with ID " << surface << "\n";
}
float opacity = 1 / pow(scaleFactors[surface], 0.4f);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set opacity " << opacity <<" for surface with ID " << surface << "\n";
+ cout << "Failed to set opacity " << opacity << " for surface with ID " << surface << "\n";
}
}
}
void* demoThreadCallback(void* param)
{
//call function on parameters
- map<string,void*>* paramMap = (map<string,void*>*) param;
+ map<string, void*>* paramMap = (map<string, void*>*) param;
int* pAnimatorIndex = (int*) paramMap->at("pAnimatorIndex");
t_pDemoAnimatorFunc animator = animators[*pAnimatorIndex];
return NULL;
}
-
} //end of anonymous namespace
void demo(t_ilm_uint mode)
pthread_create(&demoThread, NULL, demoThreadCallback, (void*) ¶mMap);
//set initial scene (reset)
- cout<<"Press ENTER to stop demo...";
+ cout << "Press ENTER to stop demo...";
cin.get();
- cout<<"Resetting scene...";
+ cout << "Resetting scene...";
cout.flush();
stopDemo = true; //this variable has to be checked in the animator function !!
captureSceneData(&finalScene);
transformScene(&finalScene, &initialScene, 1000, 50);
setScene(&initialScene, true);
- cout<<"done"<<endl;
+ cout << "done" << endl;
}
else
{
// create full string of arguments
string userCommand;
- if(argc == 1)
+ if (argc == 1)
{
userCommand = "help";
}
//make dummy scene
t_scene_data scatteredScene = cloneToUniLayerScene(&initialScene);
-
//get render order of surfaces in initial scene
vector<t_ilm_surface> renderOrder = getSceneRenderOrder(&initialScene);
//get surfaces' coordinates of surfaces in initial scene
int maxWidth = static_cast<int>(initialScene.screenWidth * scale);
int maxHeight = static_cast<int>(initialScene.screenHeight * scale);
-
//scale surface coordinates
int counter = 0;
for (vector<t_ilm_surface>::iterator it = renderOrder.begin();
{
map<string, void*> * pParamMap = static_cast<map<string, void*>* >(param);
t_ilm_surface* surface = static_cast<t_ilm_surface*>((*pParamMap)["pHighlighedSurface"]);
- bool* stop= static_cast<bool*>((*pParamMap)["pStop"]);
- while(! *stop)
+ bool* stop = static_cast<bool*>((*pParamMap)["pStop"]);
+ while (! *stop)
{
- if(*surface != 0xFFFFFFFF)
+ if (*surface != 0xFFFFFFFF)
{
t_ilm_surface currentSurface = *surface;
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set visibility "<< false << " for surface with ID " << currentSurface << "\n";
+ cout << "Failed to set visibility " << false << " for surface with ID " << currentSurface << "\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set visibility "<< true << " for surface with ID " << currentSurface << "\n";
+ cout << "Failed to set visibility " << true << " for surface with ID " << currentSurface << "\n";
}
ilm_commitChanges();
//make keys map
map<string, t_ilm_surface> keySurfaceMap;
- for(int i = 0 ; i < n ; ++i)
+ for (int i = 0; i < n; ++i)
{
int row = i / cols;
int col = i % cols;
pthread_create(& highlightThread, NULL, scatterThreadCallback, &threadParamMap);
char userInput[3];
- while(true)
+ while (true)
{
//print Grid
- for(int i = 0 ; i < n ; ++i)
+ for (int i = 0; i < n; ++i)
{
int row = i / cols;
int col = i % cols;
key[0] = 'A' + row;
key[1] = '0' + col;
key[2] = '\0';
- if(col == 0)
+ if (col == 0)
{
- cout<<endl;
- cout<<string(5 * cols + 1, '-')<<endl;
- cout <<"| ";
+ cout << endl;
+ cout << string(5 * cols + 1, '-') << endl;
+ cout << "| ";
}
- cout<<key<<" | ";
+ cout << key << " | ";
}
- cout<<endl<<string(5 * cols + 1, '-')<<endl;
+ cout << endl << string(5 * cols + 1, '-') << endl;
//take input from user
- cout<<"Choose a surface [Or press ENTER to exit...]:"<<endl;
+ cout << "Choose a surface [Or press ENTER to exit...]:" << endl;
userInput[0] = cin.get();
userInput[1] = cin.get();
//if the user presses Enter by mistake: reset input
- if(userInput[1] == '\n')
+ if (userInput[1] == '\n')
{
continue;
}
userInput[2] = cin.get();
//if the user DOES NOT press Enter by mistake: reset input
- if(userInput[2] != '\n')
+ if (userInput[2] != '\n')
{
continue;
}
userInput[2] = '\0';
- if(keySurfaceMap.find(userInput) != keySurfaceMap.end())
+ if (keySurfaceMap.find(userInput) != keySurfaceMap.end())
{
//this change is reflected in the highligh thread
hightlightThreadSurface = keySurfaceMap[userInput];
stringstream tempStream;
char fillChar = '-';
int width = 20;
- tempStream <<"\n--------------------------------\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Surface"<< ":" << hightlightThreadSurface << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Destination Region"<< ":" << "[x:"<< surfaceProperties.destX<< ", y:" << surfaceProperties.destY<< ", w:"<< surfaceProperties.destWidth<< ", h:"<< surfaceProperties.destHeight<< "]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Source Region"<< ":" << "[x:"<< surfaceProperties.sourceX<< ", y:" << surfaceProperties.sourceY<< ", w:"<< surfaceProperties.sourceWidth<< ", h:"<< surfaceProperties.sourceHeight<< "]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Original Dimensions"<< ":" << "[w:"<< surfaceProperties.origSourceWidth<< ", h:" << surfaceProperties.origSourceHeight<< "]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Opacity"<< ":" << surfaceProperties.opacity << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Visibility"<< ":" << surfaceProperties.visibility << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Input Devices"<< ":" << surfaceProperties.inputDevicesAcceptance << " [" << inputDeviceAcceptance<<"]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Native Surface"<< ":" << surfaceProperties.nativeSurface << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Orientation"<< ":" << surfaceProperties.orientation << " ["<< orientations[surfaceProperties.orientation]<< "]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Pixel Format"<< ":" << surfaceProperties.pixelformat << " ["<< pixelFormats[surfaceProperties.pixelformat]<< "]\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Update Counter"<< ":" << surfaceProperties.updateCounter << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Draw Counter"<< ":" << surfaceProperties.drawCounter << "\n";
- tempStream <<std::setw(width)<<std::left<<std::setfill(fillChar)<<"Frame Counter"<< ":" << surfaceProperties.frameCounter << "\n";
-
- cout<<tempStream.str();
+ tempStream << "\n--------------------------------\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Surface" << ":" << hightlightThreadSurface << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Destination Region" << ":" << "[x:" << surfaceProperties.destX << ", y:" << surfaceProperties.destY << ", w:" << surfaceProperties.destWidth << ", h:" << surfaceProperties.destHeight << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Source Region" << ":" << "[x:" << surfaceProperties.sourceX << ", y:" << surfaceProperties.sourceY << ", w:" << surfaceProperties.sourceWidth << ", h:" << surfaceProperties.sourceHeight << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Original Dimensions" << ":" << "[w:" << surfaceProperties.origSourceWidth << ", h:" << surfaceProperties.origSourceHeight << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Opacity" << ":" << surfaceProperties.opacity << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Visibility" << ":" << surfaceProperties.visibility << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Input Devices" << ":" << surfaceProperties.inputDevicesAcceptance << " [" << inputDeviceAcceptance << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Native Surface" << ":" << surfaceProperties.nativeSurface << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Orientation" << ":" << surfaceProperties.orientation << " [" << orientations[surfaceProperties.orientation] << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Pixel Format" << ":" << surfaceProperties.pixelformat << " [" << pixelFormats[surfaceProperties.pixelformat] << "]\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Update Counter" << ":" << surfaceProperties.updateCounter << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Draw Counter" << ":" << surfaceProperties.drawCounter << "\n";
+ tempStream << std::setw(width) << std::left << std::setfill(fillChar) << "Frame Counter" << ":" << surfaceProperties.frameCounter << "\n";
+
+ cout << tempStream.str();
}
else
{
- cout<<"Unrecognized input!"<<endl;
+ cout << "Unrecognized input!" << endl;
}
}
}
//transform from initial to scattered scene
transformScene(&initialScene, &scatteredScene, 1000, 50);
-
//wait for user input
scatterHandleUserInput(&initialScene, &scatteredScene);
t_ilm_surface surface = *it;
//if surface does not belong to a layer or layer does not belong to a surface
- if( ! surfaceRenderedOnScreen(initialScene, surface ))
+ if (! surfaceRenderedOnScreen(initialScene, surface))
{
modifiedScene.surfaces.push_back(surface);
modifiedScene.surfaceProperties[surface] = initialScene.surfaceProperties[surface];
modifiedScene.surfaceProperties[surface].visibility = true;
}
-
//just scatter !!
setScene(&modifiedScene);
scatter();
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed in writing, software
+ * 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 inputess or implied.
+ * 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.
*
namespace {
-
void captureSceneDataHelper(t_ilm_surface surfaceId, t_scene_data* pSceneData, IlmSurface* pSurface)
{
ilmSurfaceProperties& props = pSceneData->surfaceProperties[surfaceId];
cout << "Failed to get available surface IDs\n";
}
-
if (find(surfaceArray, surfaceArray + surfaceCount, surfaceId)
== surfaceArray + surfaceCount)
{
ilmPixelFormat pixelFormat;
pixelFormat = toPixelFormat(props.pixelformat);
- ilmErrorTypes callResult = ilm_surfaceCreate(props.nativeSurface, props.origSourceWidth, props.origSourceHeight, pixelFormat, &surfaceId);
+ ilmErrorTypes callResult = ilm_surfaceCreate(props.nativeSurface, props.origSourceWidth,
+ props.origSourceHeight, pixelFormat, &surfaceId);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to create layer width dimensions (" << props.origSourceWidth <<" ,"<< props.origSourceHeight << ")\n";
+ cout << "Failed to create layer width dimensions (" << props.origSourceWidth << " ," << props.origSourceHeight << ")\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set render order for layer with ID "<< layerId << ")\n";
+ cout << "Failed to set render order for layer with ID " << layerId << ")\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set render order for display with ID "<< displayId << ")\n";
+ cout << "Failed to set render order for display with ID " << displayId << ")\n";
}
ilm_commitChanges();
ilmPixelFormat pixelFormat;
pixelFormat = toPixelFormat(props.pixelformat);
- ilmErrorTypes callResult = ilm_surfaceSetNativeContent(props.nativeSurface, props.origSourceWidth, props.origSourceHeight, pixelFormat, surfaceId);
+ ilmErrorTypes callResult = ilm_surfaceSetNativeContent(props.nativeSurface, props.origSourceWidth,
+ props.origSourceHeight, pixelFormat, surfaceId);
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set native content for surface with ID "<< surfaceId << ")\n";
+ cout << "Failed to set native content for surface with ID " << surfaceId << ")\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to set destination rectangle for layer with ID "<< layerId << ")\n";
+ cout << "Failed to set destination rectangle for layer with ID " << layerId << ")\n";
}
ilm_commitChanges();
if (ILM_SUCCESS != callResult)
{
cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
- cout << "Failed to remove surface "<< it->first << " from layer " << it->second << ")\n";
+ cout << "Failed to remove surface " << it->first << " from layer " << it->second << ")\n";
}
}
restoreSceneHelper(*it);
}
}
-
} //end of anonymous namespace
fstream stream(filename.c_str(), ios::out);
- cout<<buffer.str()<<endl;
+ cout << buffer.str() << endl;
stream << buffer.str();
stream.flush();
stream.close();
*
****************************************************************************/
-#ifndef WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
-#define WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
+#ifndef WAYLANDSERVERINFOCLIENTPROTOCOL_H
+#define WAYLANDSERVERINFOCLIENTPROTOCOL_H
#ifdef __cplusplus
extern "C" {
}
#endif
-#endif
+#endif /* WAYLANDSERVERINFOCLIENTPROTOCOL_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _WL_CONTEXT_H_
-#define _WL_CONTEXT_H_
+#ifndef _WLCONTEXT_H_
+#define _WLCONTEXT_H_
#include <wayland-client.h>
#include <wayland-client-protocol.h>
inline void WLContext::SetWLTouch(struct wl_touch* wlTouch)
{ m_wlTouch = wlTouch; }
-#endif
+#endif /* _WLCONTEXT_H_ */
* limitations under the License.
*
****************************************************************************/
-#ifndef _WL_EGL_SURFACE_H_
-#define _WL_EGL_SURFACE_H_
+#ifndef _WLEGLSURFACE_H_
+#define _WLEGLSURFACE_H_
#include <EGL/egl.h>
#include <wayland-egl.h>
inline EGLSurface WLEGLSurface::GetEGLSurface() const { return m_eglSurface; }
inline EGLContext WLEGLSurface::GetEGLContext() const { return m_eglContext; }
-#endif
+#endif /* _WLEGLSURFACE_H_ */
* limitations under the License.
*
****************************************************************************/
-#ifndef _WL_EYES_H_
-#define _WL_EYES_H_
+#ifndef _WLEYES_H_
+#define _WLEYES_H_
#include "transform.h"
WLEyes();
};
-#endif
+#endif /* _WLEYES_H_ */
* limitations under the License.
*
****************************************************************************/
-#ifndef _WL_EYES_RENDERER_H_
-#define _WL_EYES_RENDERER_H_
+#ifndef _WLEYESRENDERER_H_
+#define _WLEYESRENDERER_H_
#include <wayland-client.h>
#include "WLEGLSurface.h"
extern const struct wl_keyboard_listener KeyboardListener;
extern const struct wl_touch_listener TouchListener;
-#endif
+#endif /* _WLEYESRENDERER_H_ */
* limitations under the License.
*
****************************************************************************/
-#ifndef _WL_SURFACE_H_
-#define _WL_SURFACE_H_
+#ifndef _WLSURFACE_H_
+#define _WLSURFACE_H_
#include "ilm_client.h"
#include "WLContext.h"
inline struct wl_display* WLSurface::GetWLDisplay() const
{ return m_wlContext->GetWLDisplay(); }
-#endif
+#endif /* _WLSURFACE_H_ */
*
****************************************************************************/
-#ifndef WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
-#define WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
+#ifndef WAYLANDSERVERINFOCLIENTPROTOCOL_H
+#define WAYLANDSERVERINFOCLIENTPROTOCOL_H
#ifdef __cplusplus
extern "C" {
}
#endif
-#endif
+#endif /* WAYLANDSERVERINFOCLIENTPROTOCOL_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Argument_h
-#define _Argument_h
+#ifndef _ARGUMENT_H
+#define _ARGUMENT_H
#include <string>
using std::string;
unsigned int value;
};
-#endif
+#endif /* _ARGUMENT_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Camera_h
-#define _Camera_h
+#ifndef _CAMERA_H
+#define _CAMERA_H
#include "IUpdateable.h"
#include "IlmMatrix.h"
IlmMatrix m_identityMatrix;
};
-#endif
+#endif /* _CAMERA_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Car_h
-#define _Car_h
+#ifndef _CAR_H
+#define _CAR_H
#include "IRenderable.h"
#include "vec.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _CAR_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Ground_h
-#define _Ground_h
+#ifndef _GROUND_H
+#define _GROUND_H
#include "IRenderable.h"
#include "vec.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _GROUND_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _MockNaviHouse_h
-#define _MockNaviHouse_h
+#ifndef _HOUSE_H
+#define _HOUSE_H
#include "IRenderable.h"
#include "IUpdateable.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _HOUSE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _IRenderable_h
-#define _IRenderable_h
+#ifndef _IRENDERABLE_H
+#define _IRENDERABLE_H
class IRenderable
{
virtual void render() = 0;
};
-#endif
+#endif /* _IRENDERABLE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _IUpdateable_h
-#define _IUpdateable_h
+#ifndef _IUPDATEABLE_H
+#define _IUPDATEABLE_H
class IUpdateable
{
virtual void update(int currentTimeInMs, int lastFrameTime) = 0;
};
-#endif
+#endif /* _IUPDATEABLE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _MockNavi_h
-#define _MockNavi_h
+#ifndef _MOCKNAVI_H
+#define _MOCKNAVI_H
#include "OpenGLES2App.h"
#include "IRenderable.h"
list<IUpdateable*> m_updateList;
};
-#endif
+#endif /* _MOCKNAVI_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _OpenGLES2App_h
-#define _OpenGLES2App_h
+#ifndef _OPENGLES2APP_H
+#define _OPENGLES2APP_H
#include "wayland-client.h"
#include "wayland-egl.h"
WLContextStruct m_wlContextStruct;
};
-#endif
+#endif /* _OPENGLES2APP_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Street_h
-#define _Street_h
+#ifndef _STREET_H
+#define _STREET_H
#include "IRenderable.h"
#include "IUpdateable.h"
ShaderBase* m_shader;
};
-#endif
+#endif /* _STREET_H */
*
****************************************************************************/
-#ifndef WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
-#define WAYLAND_SERVERINFO_CLIENT_PROTOCOL_H
+#ifndef WAYLANDSERVERINFOCLIENTPROTOCOL_H
+#define WAYLANDSERVERINFOCLIENTPROTOCOL_H
#ifdef __cplusplus
extern "C" {
}
#endif
-#endif
+#endif /* WAYLANDSERVERINFOCLIENTPROTOCOL_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _vec_h
-#define _vec_h
+#ifndef _VEC_H
+#define _VEC_H
#include <GLES2/gl2.h>
typedef vec4<GLint> vec4i;
typedef vec4<GLushort> vec4u;
-#endif
+#endif /* _VEC_H */
XSetWindowAttributes windowAttributes;
unsigned int windowMask;
int colorDepth;
- int widthCorrected, heightCorrected;
+ int widthCorrected;
+ int heightCorrected;
g_x11ContextStruct.x11Window = 0;
g_x11ContextStruct.x11Display = NULL;
g_eglContextStruct.eglSurface = NULL;
g_eglContextStruct.eglContext = NULL;
- g_eglContextStruct.eglDisplay = eglGetDisplay((EGLNativeDisplayType) g_x11ContextStruct.x11Display); // TODO: remove all C style casts in C++ code; use C++ casts
+ g_eglContextStruct.eglDisplay = eglGetDisplay(
+ (EGLNativeDisplayType) g_x11ContextStruct.x11Display); // TODO: remove all C style casts in C++ code; use C++ casts
EGLint eglstatus = eglGetError();
if (!g_eglContextStruct.eglDisplay)
{
printf("Error: eglGetDisplay() failed.\n");
}
- EGLint iMajorVersion, iMinorVersion;
+ EGLint iMajorVersion;
+ EGLint iMinorVersion;
if (!eglInitialize(g_eglContextStruct.eglDisplay, &iMajorVersion,
&iMinorVersion))
{
t_ilm_surface surfaceid = (t_ilm_surface)SURFACE_EXAMPLE_EGLX11_APPLICATION;
printf("create a surface %lu\n", (t_ilm_nativehandle) g_x11ContextStruct.x11Window);
- ilm_surfaceCreate( (t_ilm_nativehandle) g_x11ContextStruct.x11Window, width, height,
+ ilm_surfaceCreate((t_ilm_nativehandle) g_x11ContextStruct.x11Window, width, height,
ILM_PIXELFORMAT_RGBA_8888, &surfaceid);
printf("set surface dest region\n");
GLfloat triangleVertexData[] =
{
- -0.4f, -0.4f, 0.0f, -0.2f, -0.4f, 0.0f, -0.3f, -0.2f, 0.0f,
- -0.2f, -0.4f, 0.0f, -0.0f, -0.4f, 0.0f, -0.1f, -0.2f, 0.0f,
- -0.0f, -0.4f, 0.0f, 0.2f, -0.4f, 0.0f, 0.1f, -0.2f, 0.0f,
- 0.2f, -0.4f, 0.0f, 0.4f, -0.4f, 0.0f, 0.3f, -0.2f, 0.0f,
- -0.3f, -0.2f, 0.0f, -0.1f, -0.2f, 0.0f, -0.2f, -0.0f, 0.0f,
- 0.1f, -0.2f, 0.0f, 0.3f, -0.2f, 0.0f, 0.2f, -0.0f, 0.0f,
- -0.2f, -0.0f, 0.0f, -0.0f, -0.0f, 0.0f, -0.1f, 0.2f, 0.0f,
- 0.0f, -0.0f, 0.0f, 0.2f, -0.0f, 0.0f, 0.1f, 0.2f, 0.0f,
- -0.1f, 0.2f, 0.0f, 0.1f, 0.2f, 0.0f, 0.0f, 0.4f, 0.0f
+ -0.4f, -0.4f, 0.0f, -0.2f, -0.4f, 0.0f, -0.3f, -0.2f, 0.0f,
+ -0.2f, -0.4f, 0.0f, -0.0f, -0.4f, 0.0f, -0.1f, -0.2f, 0.0f,
+ -0.0f, -0.4f, 0.0f, 0.2f, -0.4f, 0.0f, 0.1f, -0.2f, 0.0f,
+ 0.2f, -0.4f, 0.0f, 0.4f, -0.4f, 0.0f, 0.3f, -0.2f, 0.0f,
+ -0.3f, -0.2f, 0.0f, -0.1f, -0.2f, 0.0f, -0.2f, -0.0f, 0.0f,
+ 0.1f, -0.2f, 0.0f, 0.3f, -0.2f, 0.0f, 0.2f, -0.0f, 0.0f,
+ -0.2f, -0.0f, 0.0f, -0.0f, -0.0f, 0.0f, -0.1f, 0.2f, 0.0f,
+ 0.0f, -0.0f, 0.0f, 0.2f, -0.0f, 0.0f, 0.1f, 0.2f, 0.0f,
+ -0.1f, 0.2f, 0.0f, 0.1f, 0.2f, 0.0f, 0.0f, 0.4f, 0.0f
};
t_ilm_bool initGlApplication()
if (!result)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(shader.fragmentShaderId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
if (!result)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(shader.vertexShaderId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
if (!result)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(shader.shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
-
}
void detachVertexBuffer()
swapBuffers();
startTime = currentTime;
}
-
}
void destroyGlApplication()
* limitations under the License.
*
****************************************************************************/
-#ifndef _Argument_h
-#define _Argument_h
+#ifndef _ARGUMENT_H
+#define _ARGUMENT_H
#include <string>
using std::string;
unsigned int value;
};
-#endif
+#endif /* _ARGUMENT_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Camera_h
-#define _Camera_h
+#ifndef _CAMERA_H
+#define _CAMERA_H
#include "IUpdateable.h"
#include "IlmMatrix.h"
IlmMatrix m_identityMatrix;
};
-#endif
+#endif /* _CAMERA_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Car_h
-#define _Car_h
+#ifndef _CAR_H
+#define _CAR_H
#include "IRenderable.h"
#include "vec.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _CAR_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Ground_h
-#define _Ground_h
+#ifndef _GROUND_H
+#define _GROUND_H
#include "IRenderable.h"
#include "vec.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _GROUND_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _MockNaviHouse_h
-#define _MockNaviHouse_h
+#ifndef _HOUSE_H
+#define _HOUSE_H
#include "IRenderable.h"
#include "IUpdateable.h"
ShaderBase* m_pShader;
};
-#endif
+#endif /* _HOUSE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _IRenderable_h
-#define _IRenderable_h
+#ifndef _IRENDERABLE_H
+#define _IRENDERABLE_H
class IRenderable
{
virtual void render() = 0;
};
-#endif
+#endif /* _IRENDERABLE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _IUpdateable_h
-#define _IUpdateable_h
+#ifndef _IUPDATEABLE_H
+#define _IUPDATEABLE_H
class IUpdateable
{
virtual void update(int currentTimeInMs, int lastFrameTime) = 0;
};
-#endif
+#endif /* _IUPDATEABLE_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _MockNavi_h
-#define _MockNavi_h
+#ifndef _MOCKNAVI_H
+#define _MOCKNAVI_H
#include "OpenGLES2App.h"
#include "IRenderable.h"
list<IUpdateable*> m_updateList;
};
-#endif
+#endif /* _MOCKNAVI_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _OpenGLES2App_h
-#define _OpenGLES2App_h
+#ifndef _OPENGLES2APP_H
+#define _OPENGLES2APP_H
#include <GLES2/gl2.h>
};
-#endif
+#endif /* _OPENGLES2APP_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _Street_h
-#define _Street_h
+#ifndef _STREET_H
+#define _STREET_H
#include "IRenderable.h"
#include "IUpdateable.h"
ShaderBase* m_shader;
};
-#endif
+#endif /* _STREET_H */
* limitations under the License.
*
****************************************************************************/
-#ifndef _vec_h
-#define _vec_h
+#ifndef _VEC_H
+#define _VEC_H
#include <GLES2/gl2.h>
typedef vec4<GLint> vec4i;
typedef vec4<GLuint> vec4u;
-#endif
+#endif /* _VEC_H */
BoolArgument::BoolArgument(string name, bool default_value, int argc, const char * const argv[])
: value(default_value)
{
- for (int arg = 1; arg < argc; ++arg) {
+ for (int arg = 1; arg < argc; ++arg)
+ {
const char* lpArgNow = argv[arg];
-
- if ((lpArgNow[0] == '-') && (name == &lpArgNow[1])) {
+
+ if ((lpArgNow[0] == '-') && (name == &lpArgNow[1]))
+ {
value = !value;
}
}
, m_index(0, 1, 2)
, m_pShader(shader)
{
- m_vertex[0].x = 0.0;
- m_vertex[0].y = 0.0;
- m_vertex[0].z = 0.0;
-
- m_vertex[1].x = 0.5 * m_size.x;
- m_vertex[1].y = 0.0;
- m_vertex[1].z = -m_size.z;
-
- m_vertex[2].x = m_size.x;
- m_vertex[2].y = 0.0;
- m_vertex[2].z = 0.0;
+ m_vertex[0].x = 0.0;
+ m_vertex[0].y = 0.0;
+ m_vertex[0].z = 0.0;
+
+ m_vertex[1].x = 0.5 * m_size.x;
+ m_vertex[1].y = 0.0;
+ m_vertex[1].z = -m_size.z;
+
+ m_vertex[2].x = m_size.x;
+ m_vertex[2].y = 0.0;
+ m_vertex[2].z = 0.0;
}
void Car::render()
, m_color(color)
, m_pShader(pShader)
{
- m_index[0] = vec3u(0, 1, 2);
- m_index[1] = vec3u(2, 3, 0);
-
+ m_index[0] = vec3u(0, 1, 2);
+ m_index[1] = vec3u(2, 3, 0);
+
// y z
// 3-------------2 | /
// / / |/
// / / ------x
// 0-------------1
-
- m_vertex[0].x = m_position.x;
- m_vertex[0].y = m_position.y;
- m_vertex[0].z = m_position.z;
-
- m_vertex[1].x = m_position.x + m_size.x;
- m_vertex[1].y = m_position.y;
- m_vertex[1].z = m_position.z;
-
- m_vertex[2].x = m_position.x + m_size.x;
- m_vertex[2].y = m_position.y;
- m_vertex[2].z = m_position.z + m_size.z;
-
- m_vertex[3].x = m_position.x;
- m_vertex[3].y = m_position.y;
- m_vertex[3].z = m_position.z + m_size.z;
+
+ m_vertex[0].x = m_position.x;
+ m_vertex[0].y = m_position.y;
+ m_vertex[0].z = m_position.z;
+
+ m_vertex[1].x = m_position.x + m_size.x;
+ m_vertex[1].y = m_position.y;
+ m_vertex[1].z = m_position.z;
+
+ m_vertex[2].x = m_position.x + m_size.x;
+ m_vertex[2].y = m_position.y;
+ m_vertex[2].z = m_position.z + m_size.z;
+
+ m_vertex[3].x = m_position.x;
+ m_vertex[3].y = m_position.y;
+ m_vertex[3].z = m_position.z + m_size.z;
}
void Ground::render()
, m_color(houseColor)
, m_pShader(pShader)
{
- /*
+ /*
// 5-------------6
// /| /|
// / | / |
// 0-------------3
*/
- float height = 0.1 + 1.5 * random() / INT_MAX;
+ float height = 0.1 + 1.5 * random() / INT_MAX;
m_index[0] = vec3u(7, 4, 0); // bottom
m_index[1] = vec3u(0, 3, 7); // bottom
m_index[10] = vec3u(0, 1, 2); // front
m_index[11] = vec3u(2, 3, 0); // front
+ m_vertex[0].x = 0.0f;
+ m_vertex[0].y = 0.0f;
+ m_vertex[0].z = 1.0f;
- m_vertex[0].x = 0.0f; m_vertex[0].y = 0.0f; m_vertex[0].z = 1.0f;
- m_vertex[1].x = 1.0f; m_vertex[1].y = 0.0f; m_vertex[1].z = 1.0f;
- m_vertex[2].x = 1.0f; m_vertex[2].y = height; m_vertex[2].z = 1.0f;
- m_vertex[3].x = 0.0f; m_vertex[3].y = height; m_vertex[3].z = 1.0f;
- m_vertex[4].x = 0.0f; m_vertex[4].y = 0.0f; m_vertex[4].z = 0.0f;
- m_vertex[5].x = 1.0f; m_vertex[5].y = 0.0f; m_vertex[5].z = 0.0f;
- m_vertex[6].x = 1.0f; m_vertex[6].y = height; m_vertex[6].z = 0.0f;
- m_vertex[7].x = 0.0f; m_vertex[7].y = height; m_vertex[7].z = 0.0f;
+ m_vertex[1].x = 1.0f;
+ m_vertex[1].y = 0.0f;
+ m_vertex[1].z = 1.0f;
+
+ m_vertex[2].x = 1.0f;
+ m_vertex[2].y = height;
+ m_vertex[2].z = 1.0f;
+
+ m_vertex[3].x = 0.0f;
+ m_vertex[3].y = height;
+ m_vertex[3].z = 1.0f;
+
+ m_vertex[4].x = 0.0f;
+ m_vertex[4].y = 0.0f;
+ m_vertex[4].z = 0.0f;
+
+ m_vertex[5].x = 1.0f;
+ m_vertex[5].y = 0.0f;
+ m_vertex[5].z = 0.0f;
+
+ m_vertex[6].x = 1.0f;
+ m_vertex[6].y = height;
+ m_vertex[6].z = 0.0f;
+
+ m_vertex[7].x = 0.0f;
+ m_vertex[7].y = height;
+ m_vertex[7].z = 0.0f;
}
House::~House()
void House::update(int currentTimeInMs, int lastFrameTime)
{
- (void)currentTimeInMs; //prevent warning
+ (void)currentTimeInMs; //prevent warning
- m_position.z += 0.0005f * (GLfloat)lastFrameTime;
+ m_position.z += 0.0005f * (GLfloat)lastFrameTime;
- if (m_position.z > 3.0)
- {
- m_position.z -= 15.0 * 2.0 * 1.0;
- }
+ if (m_position.z > 3.0)
+ {
+ m_position.z -= 15.0 * 2.0 * 1.0;
+ }
}
void MockNavi::update(int currentTimeInMs, int lastFrameTime)
{
- m_camera.update(currentTimeInMs, lastFrameTime);
+ m_camera.update(currentTimeInMs, lastFrameTime);
- list<IUpdateable*>::const_iterator iter = m_updateList.begin();
+ list<IUpdateable*>::const_iterator iter = m_updateList.begin();
list<IUpdateable*>::const_iterator iterEnd = m_updateList.end();
-
+
for (; iter != iterEnd; ++iter)
{
(*iter)->update(currentTimeInMs, lastFrameTime);
{
list<IRenderable*>::const_iterator iter = m_renderList.begin();
list<IRenderable*>::const_iterator iterEnd = m_renderList.end();
-
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
for (; iter != iterEnd; ++iter)
void MockNavi::generateCity()
{
- IlmMatrix* projection = m_camera.getViewProjectionMatrix();
+ IlmMatrix* projection = m_camera.getViewProjectionMatrix();
ShaderLighting* pShader = new ShaderLighting(projection);
// generate base plate
- vec4f groundColor(0.8, 0.8, 0.6, 1.0);
+ vec4f groundColor(0.8, 0.8, 0.6, 1.0);
vec3f position = vec3f(0.0, -0.001, 0.0);
vec3f size = vec3f(CITY_GRID_SIZE * 3, 0.0, -CITY_GRID_SIZE * 2.0 * m_houseCount);
Ground* ground = new Ground(position, size, groundColor, pShader);
m_renderList.push_back(car);
// generate houses
- vec4f houseColor(0.6, 0.6, 0.8, 1.0);
+ vec4f houseColor(0.6, 0.6, 0.8, 1.0);
for (int x = 0; x < 2; ++x)
{
for (int z = 0; z < m_houseCount; ++z)
XSetWindowAttributes windowAttributes;
unsigned int windowMask;
int colorDepth;
- int widthCorrected, heightCorrected;
+ int widthCorrected;
+ int heightCorrected;
m_x11ContextStruct.x11Window = 0;
m_x11ContextStruct.x11Display = NULL;
m_eglContextStruct.eglSurface = NULL;
m_eglContextStruct.eglContext = NULL;
- m_eglContextStruct.eglDisplay = eglGetDisplay((EGLNativeDisplayType) m_x11ContextStruct.x11Display); // TODO: remove all C style casts in C++ code; use C++ casts
+ m_eglContextStruct.eglDisplay = eglGetDisplay(
+ (EGLNativeDisplayType) m_x11ContextStruct.x11Display); // TODO: remove all C style casts in C++ code; use C++ casts
EGLint eglstatus = eglGetError();
if (!m_eglContextStruct.eglDisplay)
{
cout << "Error: eglGetDisplay() failed.\n";
}
- EGLint iMajorVersion, iMinorVersion;
+ EGLint iMajorVersion;
+ EGLint iMinorVersion;
if (!eglInitialize(m_eglContextStruct.eglDisplay, &iMajorVersion,
&iMinorVersion))
{
float opacity = config->opacity;
cout << "creating surface " << surfaceid << "\n";
- ilm_surfaceCreate( (t_ilm_nativehandle) m_x11ContextStruct.x11Window, width, height,
+ ilm_surfaceCreate((t_ilm_nativehandle) m_x11ContextStruct.x11Window, width, height,
ILM_PIXELFORMAT_RGBA_8888, &surfaceid);
cout << "set surface " << surfaceid << " dest region " << posX << ", " << posY << ", " << width << ", " << height << "\n";
, m_fragmentCode(fragmentCode)
, m_projectionMatrix(projectionMatrix)
{
- m_vertexCode = "uniform mediump mat4 u_projectionMatrix;\n";
- m_vertexCode += vertexCode;
- initShader();
+ m_vertexCode = "uniform mediump mat4 u_projectionMatrix;\n";
+ m_vertexCode += vertexCode;
+ initShader();
}
ShaderBase::~ShaderBase()
{
- destroyShader();
+ destroyShader();
}
bool ShaderBase::initShader()
if (glResult == GL_FALSE)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
if (glResult == GL_FALSE)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
if (glResult == GL_FALSE)
{
- t_ilm_int infoLength, numberChars;
+ t_ilm_int infoLength;
+ t_ilm_int numberChars;
glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
// Allocate Log Space
void ShaderBase::use(vec3f* position, vec4f* color)
{
- (void)position; // prevent warning
- (void)color; // prevent warning
+ (void)position; // prevent warning
+ (void)color; // prevent warning
- glUseProgram(shaderProgramId);
- glUniformMatrix4fv(m_uniformProjectionMatrix, 1, GL_FALSE, m_projectionMatrix->f);
+ glUseProgram(shaderProgramId);
+ glUniformMatrix4fv(m_uniformProjectionMatrix, 1, GL_FALSE, m_projectionMatrix->f);
}
#include "IlmMatrix.h"
const char* vertexShaderCode =
- "attribute mediump vec4 a_vertex; \
- uniform mediump mat4 u_modelMatrix; \
- varying mediump vec4 v_normal; \
- void main(void) \
- { \
- gl_Position = u_projectionMatrix * u_modelMatrix * a_vertex; \
- v_normal = normalize(a_vertex); \
- }";
+ "attribute mediump vec4 a_vertex; \
+ uniform mediump mat4 u_modelMatrix; \
+ varying mediump vec4 v_normal; \
+ void main(void) \
+ { \
+ gl_Position = u_projectionMatrix * u_modelMatrix * a_vertex; \
+ v_normal = normalize(a_vertex); \
+ }";
const char* fragmentShaderCode =
- "uniform mediump vec4 u_color; \
- varying mediump vec4 v_normal; \
- mediump vec4 lightPosition; \
- void main (void) \
- { \
- lightPosition = normalize(vec4(-3.0, -5.0, 10.0, 1.0)); \
- gl_FragColor = max(dot(v_normal, lightPosition), 0.0) * 0.5 * u_color + 0.8 * u_color; \
- gl_FragColor.a = 1.0; \
- }";
+ "uniform mediump vec4 u_color; \
+ varying mediump vec4 v_normal; \
+ mediump vec4 lightPosition; \
+ void main (void) \
+ { \
+ lightPosition = normalize(vec4(-3.0, -5.0, 10.0, 1.0)); \
+ gl_FragColor = max(dot(v_normal, lightPosition), 0.0) * 0.5 * u_color + 0.8 * u_color; \
+ gl_FragColor.a = 1.0; \
+ }";
ShaderLighting::ShaderLighting(IlmMatrix* projectionMatrix)
: ShaderBase(vertexShaderCode, fragmentShaderCode, projectionMatrix)
void ShaderLighting::use(vec3f* position, vec4f* color)
{
- ShaderBase::use(position, color);
+ ShaderBase::use(position, color);
IlmMatrix translation;
- IlmMatrixTranslation(translation, position->x, position->y, position->z);
+ IlmMatrixTranslation(translation, position->x, position->y, position->z);
- glUseProgram(shaderProgramId);
- glUniformMatrix4fv(m_uniformModelMatrix, 1, GL_FALSE, translation.f);
+ glUseProgram(shaderProgramId);
+ glUniformMatrix4fv(m_uniformModelMatrix, 1, GL_FALSE, translation.f);
glUniform4fv(m_uniformColor, 1, &color->r);
-
}
, m_color(color)
, m_shader(shader)
{
- m_index[0] = vec3u(0, 3, 2);
- m_index[1] = vec3u(2, 1, 0);
-
+ m_index[0] = vec3u(0, 3, 2);
+ m_index[1] = vec3u(2, 1, 0);
+
// y z
// 3-------------2 | /
// / / |/
// / / ------x
// 0-------------1
-
- m_vertex[0].x = m_position.x;
- m_vertex[0].y = m_position.y;
- m_vertex[0].z = m_position.z;
- m_vertex[1].x = m_position.x + m_size.x;
- m_vertex[1].y = m_position.y;
- m_vertex[1].z = m_position.z;
-
- m_vertex[2].x = m_position.x + m_size.x;
- m_vertex[2].y = m_position.y;
- m_vertex[2].z = m_position.z + m_size.z;
-
- m_vertex[3].x = m_position.x;
- m_vertex[3].y = m_position.y;
- m_vertex[3].z = m_position.z + m_size.z;
+ m_vertex[0].x = m_position.x;
+ m_vertex[0].y = m_position.y;
+ m_vertex[0].z = m_position.z;
+
+ m_vertex[1].x = m_position.x + m_size.x;
+ m_vertex[1].y = m_position.y;
+ m_vertex[1].z = m_position.z;
+
+ m_vertex[2].x = m_position.x + m_size.x;
+ m_vertex[2].y = m_position.y;
+ m_vertex[2].z = m_position.z + m_size.z;
+
+ m_vertex[3].x = m_position.x;
+ m_vertex[3].y = m_position.y;
+ m_vertex[3].z = m_position.z + m_size.z;
}
void Street::render()
void Street::update(int currentTimeInMs, int lastFrameTime)
{
- (void)currentTimeInMs; //prevent warning
- m_position.z += 0.0005 * lastFrameTime;
+ (void)currentTimeInMs; //prevent warning
+ m_position.z += 0.0005 * lastFrameTime;
- if (m_position.z > 3.0)
- {
- m_position.z -= 2 * 2.0;
- }
+ if (m_position.z > 3.0)
+ {
+ m_position.z -= 2 * 2.0;
+ }
}
#define DEFAULT_NOSKY false
#define DEFAULT_HELP false
-int main (int argc, const char * argv[])
+int main(int argc, const char * argv[])
{
FloatArgument fps("fps", DEFAULT_FPS, argc, argv);
FloatArgument animSpeed("anim", DEFAULT_ANIM, argc, argv);
FloatArgument opacity("opacity", DEFAULT_OPACITY, argc, argv);
BoolArgument nosky("nosky", DEFAULT_NOSKY, argc, argv);
BoolArgument help("help", DEFAULT_HELP, argc, argv);
-
+
if (help.get())
{
cout << "\nUsage: " << argv[0] << " [options]\n"
for(index = 0; index < 3; ++index)
{
printf("Creating Layer... ");
- error = ilm_layerCreateWithDimension(&layer[index],LayerWidth,LayerHeight);
+ error = ilm_layerCreateWithDimension(&layer[index], LayerWidth, LayerHeight);
if(ILM_SUCCESS == error)
{
printf("success\n");
printf("Setting Layer source rectangle(0, 0, %d, %d)... \n", LayerWidth, LayerHeight);
error = ilm_layerSetSourceRectangle(layer[index], 0, 0, LayerWidth, LayerHeight);
printf("Setting Layer visibility(%d)... \n", 1);
- error = ilm_layerSetVisibility(layer[index],1);
+ error = ilm_layerSetVisibility(layer[index], 1);
if(ILM_SUCCESS == error)
{
printf("success\n");
t_ilm_uint LayerWidth = LAYERWIDTH;
t_ilm_uint LayerHeight = LAYERHEIGHT;
- if (ILM_SUCCESS != init())
+ if(ILM_SUCCESS != init())
{
return -1;
}
ilm_getScreenResolution(0, &LayerWidth, &LayerHeight);
- if (argc == 2 && atoi(argv[1]) == 1)
+ if(argc == 2 && atoi(argv[1]) == 1)
{
doSceneLayeout(LayerWidth, LayerHeight);
changeLayerOpacity();
}
- else if (argc == 2 && atoi(argv[1]) == 2)
+ else if(argc == 2 && atoi(argv[1]) == 2)
{
RemoveSceneLayout();
}
*
****************************************************************************/
-#ifndef _LAYERSCENE_PROVIDER_H_
-#define _LAYERSCENE_PROVIDER_H_
+#ifndef _LAYERSCENEPROVIDER_H_
+#define _LAYERSCENEPROVIDER_H_
#include "ISceneProvider.h"
};
-#endif /* _LAYERSCENE_PROVIDER_H_ */
+#endif /* _LAYERSCENEPROVIDER_H_ */
* limitations under the License.
*
****************************************************************************/
-#ifndef SERVERINFO_CLIENT_PROTOCOL_H
-#define SERVERINFO_CLIENT_PROTOCOL_H
+#ifndef SERVERINFO-CLIENT-PROTOCOL_H
+#define SERVERINFO-CLIENT-PROTOCOL_H
#ifdef __cplusplus
extern "C" {
}
#endif
-#endif /* SERVERINFO_CLIENT_PROTOCOL_H */
+#endif /* SERVERINFO-CLIENT-PROTOCOL_H */
const char *name;
CallBackMethod function;
};
-typedef std::map<std::string,MethodTable> CallBackTable;
+typedef std::map<std::string, MethodTable> CallBackTable;
//=============================================================================
// interface
//=============================================================================
-class GenericCommunicator: public ICommunicator, protected ThreadBase, public PluginBase
+class GenericCommunicator : public ICommunicator, protected ThreadBase, public PluginBase
{
public:
GenericCommunicator(ICommandExecutor& executor, Configuration& config);
// from ThreadBase
virtual t_ilm_bool threadMainLoop();
-
+
// from PluginBase
virtual t_ilm_const_string pluginGetName() const;
virtual HealthCondition pluginGetHealth();
{
MethodTable manager_methods[] =
{
- { "ServiceConnect", &GenericCommunicator::ServiceConnect },
- { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
- { "Debug", &GenericCommunicator::Debug },
- { "ScreenShot", &GenericCommunicator::ScreenShot },
- { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
- { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
- { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
- { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
- { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
- { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
- { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
- { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
- { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
- { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
- { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
- { "CreateSurface", &GenericCommunicator::CreateSurface },
- { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
- { "InitializeSurface", &GenericCommunicator::InitializeSurface },
- { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
- { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
- { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
- { "RemoveSurface", &GenericCommunicator::RemoveSurface },
- { "CreateLayer", &GenericCommunicator::CreateLayer },
- { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
- { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
- { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
- { "RemoveLayer", &GenericCommunicator::RemoveLayer },
- { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
- { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
- { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
- { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
- { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
- { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
- { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
- { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
- { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
- { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
- { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
- { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
- { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
- { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
- { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
- { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
- { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
- { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
- { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
- { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
- { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
- { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
- { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
- { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
- { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
- { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
- { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
- { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
+ { "ServiceConnect", &GenericCommunicator::ServiceConnect },
+ { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
+ { "Debug", &GenericCommunicator::Debug },
+ { "ScreenShot", &GenericCommunicator::ScreenShot },
+ { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
+ { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
+ { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
+ { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
+ { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
+ { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
+ { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
+ { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
+ { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
+ { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
+ { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
+ { "CreateSurface", &GenericCommunicator::CreateSurface },
+ { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
+ { "InitializeSurface", &GenericCommunicator::InitializeSurface },
+ { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
+ { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
+ { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
+ { "RemoveSurface", &GenericCommunicator::RemoveSurface },
+ { "CreateLayer", &GenericCommunicator::CreateLayer },
+ { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
+ { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
+ { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
+ { "RemoveLayer", &GenericCommunicator::RemoveLayer },
+ { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
+ { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
+ { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
+ { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
+ { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
+ { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
+ { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
+ { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
+ { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
+ { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
+ { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
+ { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
+ { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
+ { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
+ { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
+ { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
+ { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
+ { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
+ { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
+ { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
+ { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
+ { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
+ { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
+ { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
+ { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
+ { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
+ { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
+ { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
{ "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
- { "GetLayerType", &GenericCommunicator::GetLayerType },
- { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
- { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
- { "Exit", &GenericCommunicator::Exit },
- { "CommitChanges", &GenericCommunicator::CommitChanges },
- { "CreateShader", &GenericCommunicator::CreateShader },
- { "DestroyShader", &GenericCommunicator::DestroyShader },
- { "SetShader", &GenericCommunicator::SetShader },
- { "SetUniforms", &GenericCommunicator::SetUniforms },
- { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
- { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
- { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
- { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
- { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
- { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
- { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
- { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
- { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
- { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
- { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode },
- { "GetPropertiesOfScreen", &GenericCommunicator::GetPropertiesOfScreen }
+ { "GetLayerType", &GenericCommunicator::GetLayerType },
+ { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
+ { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
+ { "Exit", &GenericCommunicator::Exit },
+ { "CommitChanges", &GenericCommunicator::CommitChanges },
+ { "CreateShader", &GenericCommunicator::CreateShader },
+ { "DestroyShader", &GenericCommunicator::DestroyShader },
+ { "SetShader", &GenericCommunicator::SetShader },
+ { "SetUniforms", &GenericCommunicator::SetUniforms },
+ { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
+ { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
+ { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
+ { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
+ { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
+ { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
+ { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
+ { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
+ { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
+ { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
+ { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode },
+ { "GetPropertiesOfScreen", &GenericCommunicator::GetPropertiesOfScreen }
};
int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
void GenericCommunicator::stop()
{
- LOG_INFO("GenericCommunicator","stopping");
+ LOG_INFO("GenericCommunicator", "stopping");
threadStop();
-
+
if (m_running)
{
m_ipcModule.destroy();
t_ilm_const_string name = m_ipcModule.getMessageName(message);
t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
- switch(messageType)
+ switch (messageType)
{
case IpcMessageTypeCommand:
if (m_callBackTable.end() != m_callBackTable.find(name))
{
LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
- << m_executor->getSenderName(senderHandle)
- << "(" << m_executor->getSenderPid(senderHandle) << ")");
+ << m_executor->getSenderName(senderHandle)
+ << "(" << m_executor->getSenderPid(senderHandle) << ")");
CallBackMethod method = m_callBackTable[name].function;
(this->*method)(message);
}
else
{
LOG_WARNING("GenericCommunicator", "Received unknown command " << name
- << " from " << m_executor->getSenderName(senderHandle)
- << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
+ << " from " << m_executor->getSenderName(senderHandle)
+ << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
}
processNotificationQueue();
break;
case IpcMessageTypeConnect:
LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
- << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
+ << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
break;
case IpcMessageTypeDisconnect:
LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
- << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
+ << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
{
const LayerMap& layers = m_executor->getScene()->getAllLayers();
- LayerMapConstIterator layerIter = layers.begin();
+ LayerMapConstIterator layerIter = layers.begin();
LayerMapConstIterator layerIterEnd = layers.end();
for (; layerIter != layerIterEnd; ++layerIter)
{
}
const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
- SurfaceMapConstIterator surfaceIter = surfaces.begin();
+ SurfaceMapConstIterator surfaceIter = surfaces.begin();
SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
{
case IpcMessageTypeError:
LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
- << m_executor->getSenderName(senderHandle)
- << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
+ << m_executor->getSenderName(senderHandle)
+ << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
break;
case IpcMessageTypeShutdown:
default:
LOG_DEBUG("GenericCommunicator", "Received unknown data from "
- << m_executor->getSenderName(senderHandle)
- << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
+ << m_executor->getSenderName(senderHandle)
+ << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
break;
}
m_ipcModule.destroyMessage(message);
m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
LOG_DEBUG("GenericCommunicator", "ServiceConnect called from "
- << m_executor->getSenderName(clientHandle)
- << "(" << m_executor->getSenderPid(clientHandle) << ")");
+ << m_executor->getSenderName(clientHandle)
+ << "(" << m_executor->getSenderPid(clientHandle) << ")");
response = m_ipcModule.createResponse(message);
m_ipcModule.sendToClients(response, &clientHandle, 1);
t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called from "
- << m_executor->getSenderName(clientHandle)
- << "(" << m_executor->getSenderPid(clientHandle) << ")");
+ << m_executor->getSenderName(clientHandle)
+ << "(" << m_executor->getSenderPid(clientHandle) << ")");
m_executor->removeApplicationReference(clientHandle);
pf = (PixelFormat) pixelformat;
-
// First of all create the surface
t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
switch (object->type)
{
case TypeLayer:
- {
- Layer* layer = static_cast<Layer*>(object);
- if (layer)
{
- ApplicationReferenceList& arl = layer->getNotificationClients();
-
- if (arl.size())
+ Layer* layer = static_cast<Layer*>(object);
+ if (layer)
{
- t_ilm_message notification;
- Rectangle dest = layer->getDestinationRegion();
- Rectangle src = layer->getSourceRegion();
- OrientationType orientation = layer->getOrientation();
-
- unsigned char chromaKeyRed = 0;
- unsigned char chromaKeyGreen = 0;
- unsigned char chromaKeyBlue = 0;
- layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
-
- std::stringstream notificationName;
- notificationName << "NotificationForLayer" << layer->getID();
-
- notification = m_ipcModule.createNotification(notificationName.str().c_str());
- m_ipcModule.appendUint(notification, layer->getID());
- m_ipcModule.appendUint(notification, mask);
-
- m_ipcModule.appendDouble(notification, layer->getOpacity());
- m_ipcModule.appendUint(notification, src.x);
- m_ipcModule.appendUint(notification, src.y);
- m_ipcModule.appendUint(notification, src.width);
- m_ipcModule.appendUint(notification, src.height);
- m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
- m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
- m_ipcModule.appendUint(notification, dest.x);
- m_ipcModule.appendUint(notification, dest.y);
- m_ipcModule.appendUint(notification, dest.width);
- m_ipcModule.appendUint(notification, dest.height);
- m_ipcModule.appendUint(notification, orientation);
- m_ipcModule.appendBool(notification, layer->getVisibility());
- m_ipcModule.appendUint(notification, layer->getLayerType());
- m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
- m_ipcModule.appendUint(notification, chromaKeyRed);
- m_ipcModule.appendUint(notification, chromaKeyGreen);
- m_ipcModule.appendUint(notification, chromaKeyBlue);
- m_ipcModule.appendInt(notification, layer->getCreatorPid());
-
- int clientCount = arl.size();
- t_ilm_client_handle clientArray[256];
-
- ApplicationReferenceList::iterator iter = arl.begin();
- ApplicationReferenceList::iterator end = arl.end();
-
- for (int clientNumber = 0;
- iter != end, clientNumber < 256;
- ++iter, ++clientNumber)
- {
- t_ilm_client_handle client = *iter;
- clientArray[clientNumber] = client;
- }
+ ApplicationReferenceList& arl = layer->getNotificationClients();
- LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
-
- if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
+ if (arl.size())
{
- LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
+ t_ilm_message notification;
+ Rectangle dest = layer->getDestinationRegion();
+ Rectangle src = layer->getSourceRegion();
+ OrientationType orientation = layer->getOrientation();
+
+ unsigned char chromaKeyRed = 0;
+ unsigned char chromaKeyGreen = 0;
+ unsigned char chromaKeyBlue = 0;
+ layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+
+ std::stringstream notificationName;
+ notificationName << "NotificationForLayer" << layer->getID();
+
+ notification = m_ipcModule.createNotification(notificationName.str().c_str());
+ m_ipcModule.appendUint(notification, layer->getID());
+ m_ipcModule.appendUint(notification, mask);
+
+ m_ipcModule.appendDouble(notification, layer->getOpacity());
+ m_ipcModule.appendUint(notification, src.x);
+ m_ipcModule.appendUint(notification, src.y);
+ m_ipcModule.appendUint(notification, src.width);
+ m_ipcModule.appendUint(notification, src.height);
+ m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
+ m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
+ m_ipcModule.appendUint(notification, dest.x);
+ m_ipcModule.appendUint(notification, dest.y);
+ m_ipcModule.appendUint(notification, dest.width);
+ m_ipcModule.appendUint(notification, dest.height);
+ m_ipcModule.appendUint(notification, orientation);
+ m_ipcModule.appendBool(notification, layer->getVisibility());
+ m_ipcModule.appendUint(notification, layer->getLayerType());
+ m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
+ m_ipcModule.appendUint(notification, chromaKeyRed);
+ m_ipcModule.appendUint(notification, chromaKeyGreen);
+ m_ipcModule.appendUint(notification, chromaKeyBlue);
+ m_ipcModule.appendInt(notification, layer->getCreatorPid());
+
+ int clientCount = arl.size();
+ t_ilm_client_handle clientArray[256];
+
+ ApplicationReferenceList::iterator iter = arl.begin();
+ ApplicationReferenceList::iterator end = arl.end();
+
+ for (int clientNumber = 0;
+ iter != end, clientNumber < 256;
+ ++iter, ++clientNumber)
+ {
+ t_ilm_client_handle client = *iter;
+ clientArray[clientNumber] = client;
+ }
+
+ LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
+
+ if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
+ {
+ LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
+ }
+
+ m_ipcModule.destroyMessage(notification);
}
-
- m_ipcModule.destroyMessage(notification);
}
}
- }
- break;
+ break;
case TypeSurface:
- {
- Surface* surface = static_cast<Surface*>(object);
- if (surface)
{
- ApplicationReferenceList& arl = surface->getNotificationClients();
-
- if (arl.size())
+ Surface* surface = static_cast<Surface*>(object);
+ if (surface)
{
- t_ilm_message notification;
- std::stringstream notificationName;
- notificationName << "NotificationForSurface" << surface->getID();
-
- unsigned char chromaKeyRed = 0;
- unsigned char chromaKeyGreen = 0;
- unsigned char chromaKeyBlue = 0;
- surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
-
- notification = m_ipcModule.createNotification(notificationName.str().c_str());
- m_ipcModule.appendUint(notification, surface->getID());
- m_ipcModule.appendUint(notification, mask);
-
- m_ipcModule.appendDouble(notification, surface->getOpacity());
- m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
- m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
- m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
- m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
- m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
- m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
- m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
- m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
- m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
- m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
- m_ipcModule.appendUint(notification, surface->getOrientation());
- m_ipcModule.appendBool(notification, surface->getVisibility());
- m_ipcModule.appendUint(notification, surface->frameCounter);
- m_ipcModule.appendUint(notification, surface->drawCounter);
- m_ipcModule.appendUint(notification, surface->updateCounter);
- m_ipcModule.appendUint(notification, surface->getPixelFormat());
- m_ipcModule.appendUint(notification, surface->getNativeContent());
- m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
- m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
- m_ipcModule.appendUint(notification, chromaKeyRed);
- m_ipcModule.appendUint(notification, chromaKeyGreen);
- m_ipcModule.appendUint(notification, chromaKeyBlue);
- m_ipcModule.appendInt(notification, surface->getCreatorPid());
-
- int clientCount = arl.size();
- t_ilm_client_handle clients[256];
-
- ApplicationReferenceList::iterator iter = arl.begin();
- ApplicationReferenceList::iterator end = arl.end();
-
- for (int clientNumber = 0;
- iter != end, clientNumber < 256;
- ++iter, ++clientNumber)
- {
- clients[clientNumber] = *iter;
- }
+ ApplicationReferenceList& arl = surface->getNotificationClients();
- LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
-
- if (!m_ipcModule.sendToClients(notification, clients, clientCount))
+ if (arl.size())
{
- LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
+ t_ilm_message notification;
+ std::stringstream notificationName;
+ notificationName << "NotificationForSurface" << surface->getID();
+
+ unsigned char chromaKeyRed = 0;
+ unsigned char chromaKeyGreen = 0;
+ unsigned char chromaKeyBlue = 0;
+ surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+
+ notification = m_ipcModule.createNotification(notificationName.str().c_str());
+ m_ipcModule.appendUint(notification, surface->getID());
+ m_ipcModule.appendUint(notification, mask);
+
+ m_ipcModule.appendDouble(notification, surface->getOpacity());
+ m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
+ m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
+ m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
+ m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
+ m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
+ m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
+ m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
+ m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
+ m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
+ m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
+ m_ipcModule.appendUint(notification, surface->getOrientation());
+ m_ipcModule.appendBool(notification, surface->getVisibility());
+ m_ipcModule.appendUint(notification, surface->frameCounter);
+ m_ipcModule.appendUint(notification, surface->drawCounter);
+ m_ipcModule.appendUint(notification, surface->updateCounter);
+ m_ipcModule.appendUint(notification, surface->getPixelFormat());
+ m_ipcModule.appendUint(notification, surface->getNativeContent());
+ m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
+ m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
+ m_ipcModule.appendUint(notification, chromaKeyRed);
+ m_ipcModule.appendUint(notification, chromaKeyGreen);
+ m_ipcModule.appendUint(notification, chromaKeyBlue);
+ m_ipcModule.appendInt(notification, surface->getCreatorPid());
+
+ int clientCount = arl.size();
+ t_ilm_client_handle clients[256];
+
+ ApplicationReferenceList::iterator iter = arl.begin();
+ ApplicationReferenceList::iterator end = arl.end();
+
+ for (int clientNumber = 0;
+ iter != end, clientNumber < 256;
+ ++iter, ++clientNumber)
+ {
+ clients[clientNumber] = *iter;
+ }
+
+ LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
+
+ if (!m_ipcModule.sendToClients(notification, clients, clientCount))
+ {
+ LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
+ }
+
+ m_ipcModule.destroyMessage(notification);
}
-
- m_ipcModule.destroyMessage(notification);
}
}
- }
- break;
+ break;
default:
LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
break;
t_ilm_message response;
OptimizationType optimizationId;
OptimizationModeType optimizationMode;
- unsigned int o;
+ unsigned int optMode;
t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
- m_ipcModule.getUint(message,&o);
- optimizationId = (OptimizationType) o;
- m_ipcModule.getUint(message,&o);
- optimizationMode = (OptimizationModeType) o;
+ m_ipcModule.getUint(message, &optMode);
+ optimizationId = (OptimizationType)optMode;
+ m_ipcModule.getUint(message, &optMode);
+ optimizationMode = (OptimizationModeType)optMode;
t_ilm_bool status = m_executor->execute(new SetOptimizationModeCommand(clientPid, optimizationId, optimizationMode));
if (status)
{
- response = m_ipcModule.createResponse(message);
+ response = m_ipcModule.createResponse(message);
}
else
{
response = m_ipcModule.createErrorResponse(message);
m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
}
- m_ipcModule.sendToClients(response,&clientHandle,1);
+ m_ipcModule.sendToClients(response, &clientHandle, 1);
m_ipcModule.destroyMessage(response);
}
OptimizationModeType optimizationMode;
unsigned int o;
- m_ipcModule.getUint(message,&o);
+ m_ipcModule.getUint(message, &o);
optimizationId = (OptimizationType)o;
t_ilm_bool status = m_executor->execute(new GetOptimizationModeCommand(clientPid, optimizationId, &optimizationMode));
if (status)
{
-
response = m_ipcModule.createResponse(message);
- m_ipcModule.appendUint(response,(unsigned int)optimizationMode);
+ m_ipcModule.appendUint(response, (unsigned int)optimizationMode);
}
else
{
response = m_ipcModule.createErrorResponse(message);
m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
}
- m_ipcModule.sendToClients(response,&clientHandle,1);
+ m_ipcModule.sendToClients(response, &clientHandle, 1);
m_ipcModule.destroyMessage(response);
-
}
void GenericCommunicator::GetPropertiesOfScreen(t_ilm_message message)
response = m_ipcModule.createResponse(message);
m_ipcModule.appendUintArray(response, layerIdVector.data(), layerIdVector.size());
- m_ipcModule.appendUint(response,numberOfHardwareLayers);
+ m_ipcModule.appendUint(response, numberOfHardwareLayers);
m_ipcModule.appendUint(response, resolution[0]);
m_ipcModule.appendUint(response, resolution[1]);
}
*
****************************************************************************/
-#ifndef MockCommandExecutor_H_
-#define MockCommandExecutor_H_
+#ifndef MOCK_COMMANDEXECUTOR_H_
+#define MOCK_COMMANDEXECUTOR_H_
#include "GraphicalSurface.h"
#include "ICommand.h"
MOCK_METHOD1(getEnqueuedCommands, CommandList&(unsigned int clientPid));
};
-#endif /* MockCommandExecutor_H_ */
+#endif /* MOCK_COMMANDEXECUTOR_H_ */
*
****************************************************************************/
-#ifndef MockCommunicator_H_
-#define MockCommunicator_H_
+#ifndef MOCK_COMMUNICATOR_H_
+#define MOCK_COMMUNICATOR_H_
#include "AbstractCommunicator.h"
#include <list>
};
-#endif /* MockCommunicator_H_ */
+#endif /* MOCK_COMMUNICATOR_H_ */
*
****************************************************************************/
-#ifndef MockLayerList_H_
-#define MockLayerList_H_
+#ifndef MOCK_LAYERLIST_H_
+#define MOCK_LAYERLIST_H_
#include "Scene.h"
#include <list>
MOCK_METHOD0(unlockScene, void());
};
-#endif /* MockLayerList_H_ */
+#endif /* MOCK_LAYERLIST_H_ */
*
****************************************************************************/
-#ifndef MockRenderer_H_
-#define MockRenderer_H_
+#ifndef MOCK_RENDERER_H_
+#define MOCK_RENDERER_H_
#include "AbstractRenderer.h"
#include <list>
};
-#endif /* MockRenderer_H_ */
+#endif /* MOCK_RENDERER_H_ */
*
****************************************************************************/
-#ifndef __HEALTHSYSTEMD_H__
-#define __HEALTHSYSTEMD_H__
+#ifndef __SYSTEMDHEALTHMONITOR_H__
+#define __SYSTEMDHEALTHMONITOR_H__
#include "IHealthMonitor.h"
#include "ThreadBase.h"
// from ThreadBase
virtual t_ilm_bool threadMainLoop();
-
+
private:
int mIntervalInMs;
};
-#endif // __HEALTHSYSTEMD_H__
\ No newline at end of file
+#endif // __SYSTEMDHEALTHMONITOR_H__
return ILM_TRUE;
}
-DECLARE_LAYERMANAGEMENT_PLUGIN(SystemdHealthMonitor)
\ No newline at end of file
+DECLARE_LAYERMANAGEMENT_PLUGIN(SystemdHealthMonitor)
*
****************************************************************************/
-#ifndef _DBUSINTROSPECTION_H_
-#define _DBUSINTROSPECTION_H_
+#ifndef _INTROSPECTION_H_
+#define _INTROSPECTION_H_
#include "common.h"
void generateIntrospectionString(char* msgBuffer);
-#endif /* _DBUSINTROSPECTION_H_ */
+#endif /* _INTROSPECTION_H_ */
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
{
- char *name, *old, *new;
+ char* name;
+ char* old;
+ char* new;
if (!dbus_message_get_args(message, NULL,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_STRING, &old,
gpIncomingMessage->pMessage = dbus_message_copy(message);
dbus_message_set_sender(gpIncomingMessage->pMessage, old);
}
-
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
int ret;
const char* rule = "type='signal',"
- "sender='"DBUS_INTERFACE_DBUS"',"
- "interface='"DBUS_INTERFACE_DBUS"',"
- "member='NameOwnerChanged'";
+ "sender='"DBUS_INTERFACE_DBUS"',"
+ "interface='"DBUS_INTERFACE_DBUS"',"
+ "member='NameOwnerChanged'";
memset(&gDbus, 0, sizeof(gDbus));
dbus_error_init(&gDbus.error);
useSessionBus = getenv("LM_USE_SESSION_BUS");
- if (useSessionBus && strcmp(useSessionBus, "enable") == 0 )
+ if (useSessionBus && strcmp(useSessionBus, "enable") == 0)
{
gDbus.type = DBUS_BUS_SESSION;
printf("DbusIpcmodule: using session bus\n");
exit(1);
}
- if(!dbus_connection_set_watch_functions(gDbus.connection,
+ if (!dbus_connection_set_watch_functions(gDbus.connection,
addWatch,
removeWatch,
toggleWatch,
dbus_error_init(&gDbus.error);
useSessionBus = getenv("LM_USE_SESSION_BUS");
- if (useSessionBus && strcmp(useSessionBus, "enable") == 0 )
+ if (useSessionBus && strcmp(useSessionBus, "enable") == 0)
{
gDbus.type = DBUS_BUS_SESSION;
printf("DbusIpcmodule: using session bus\n");
exit(1);
}
- if(!dbus_connection_set_watch_functions(gDbus.connection,
+ if (!dbus_connection_set_watch_functions(gDbus.connection,
addWatch,
removeWatch,
toggleWatch,
t_ilm_bool errorset;
const char* rule = "type='signal',"
- "sender='"DBUS_INTERFACE_DBUS"',"
- "interface='"DBUS_INTERFACE_DBUS"',"
- "member='NameOwnerChanged'";
+ "sender='"DBUS_INTERFACE_DBUS"',"
+ "interface='"DBUS_INTERFACE_DBUS"',"
+ "member='NameOwnerChanged'";
dbus_error_init(&err);
*/
struct IntrospectionTable introspectionInterface[] =
{
- { "ServiceConnect", "u", "" },
- { "ServiceDisconnect", "u", "" },
- { "Debug", "b", "" },
- { "ScreenShot", "us", "" },
- { "ScreenShotOfLayer", "su", "" },
- { "ScreenShotOfSurface", "su", "" },
- { "GetScreenResolution", "u", "uu" },
- { "GetNumberOfHardwareLayers", "u", "u" },
- { "GetScreenIDs", "", "au" },
- { "ListAllLayerIDS", "", "au" },
- { "ListAllLayerIDsOnScreen", "u", "au" },
- { "ListAllSurfaceIDS", "", "au" },
- { "ListSurfaceofLayer", "u", "au" },
- { "GetPropertiesOfSurface", "u", "duuuuuuuuuuybu" },
- { "GetPropertiesOfLayer", "u", "duuuuuuuuuuyb" },
- { "CreateSurface", "uuuu", "u" },
- { "CreateSurfaceFromId", "uuuuu", "u" },
- { "InitializeSurface", "", "u" },
- { "InitializeSurfaceFromId", "u", "u" },
- { "SetSurfaceNativeContent", "uuuuu", "" },
- { "RemoveSurfaceNativeContent", "u", "" },
- { "RemoveSurface", "u", "" },
- { "CreateLayer", "", "u" },
- { "CreateLayerFromId", "u", "u" },
- { "CreateLayerWithDimension", "uu", "u" },
- { "CreateLayerFromIdWithDimension", "uuu", "u" },
- { "RemoveLayer", "u", "" },
- { "AddSurfaceToLayer", "uu", "" },
- { "RemoveSurfaceFromLayer", "uu", "" },
- { "SetSurfaceSourceRegion", "uuuuu", "" },
- { "SetLayerSourceRegion", "uuuuu", "" },
- { "SetSurfaceDestinationRegion", "uuuuu", "" },
- { "SetSurfacePosition", "uuu", "" },
- { "GetSurfacePosition", "u", "uu" },
- { "SetSurfaceDimension", "uuu", "" },
- { "SetLayerDestinationRegion", "uuuuu", "" },
- { "SetLayerPosition", "uuu", "" },
- { "GetLayerPosition", "u", "uu" },
- { "SetLayerDimension", "uuu", "" },
- { "GetLayerDimension", "u", "uu" },
- { "GetSurfaceDimension", "u", "uu" },
- { "SetSurfaceOpacity", "ud", "" },
- { "SetLayerOpacity", "ud", "" },
- { "GetSurfaceOpacity", "u", "d" },
- { "GetLayerOpacity", "u", "d" },
- { "SetSurfaceOrientation", "uu", "" },
- { "GetSurfaceOrientation", "uu", "" },
- { "SetLayerOrientation", "uu", "" },
- { "GetLayerOrientation", "uu", "" },
- { "GetSurfacePixelformat", "u", "u" },
- { "SetSurfaceVisibility", "ub", "" },
- { "SetLayerVisibility", "ub", "" },
- { "GetSurfaceVisibility", "u", "b" },
- { "GetLayerVisibility", "u", "b" },
- { "SetRenderOrderOfLayers", "auu", "" },
- { "SetSurfaceRenderOrderWithinLayer", "uau", "" },
- { "GetLayerType", "u", "u" },
- { "GetLayertypeCapabilities", "u", "u" },
- { "GetLayerCapabilities", "u", "u" },
- { "Exit", "", "" },
- { "CommitChanges", "", "" },
- { "CreateShader", "ss", "u" },
- { "DestroyShader", "u", "" },
- { "SetShader", "uu", "" },
- { "SetUniforms", "uas", "" },
- { "SetKeyboardFocusOn", "u", "" },
- { "GetKeyboardFocusSurfaceId", "", "u" },
- { "UpdateInputEventAcceptanceOn", "uub", "" },
- { "LayerAddNotification", "u", "" },
- { "LayerRemoveNotification", "u", "" },
- { "SurfaceAddNotification", "u", "" },
- { "SurfaceRemoveNotification", "u", "" },
- { "SetOptimizationMode", "uu", "" },
- { "GetOptimizationMode", "u", "u" }
+ { "ServiceConnect", "u", "" },
+ { "ServiceDisconnect", "u", "" },
+ { "Debug", "b", ""},
+ { "ScreenShot", "us", "" },
+ { "ScreenShotOfLayer", "su", "" },
+ { "ScreenShotOfSurface", "su", "" },
+ { "GetScreenResolution", "u", "uu" },
+ { "GetNumberOfHardwareLayers", "u", "u" },
+ { "GetScreenIDs", "", "au" },
+ { "ListAllLayerIDS", "", "au" },
+ { "ListAllLayerIDsOnScreen", "u", "au" },
+ { "ListAllSurfaceIDS", "", "au" },
+ { "ListSurfaceofLayer", "u", "au" },
+ { "GetPropertiesOfSurface", "u", "duuuuuuuuuuybu" },
+ { "GetPropertiesOfLayer", "u", "duuuuuuuuuuyb" },
+ { "CreateSurface", "uuuu", "u" },
+ { "CreateSurfaceFromId", "uuuuu", "u" },
+ { "InitializeSurface", "", "u" },
+ { "InitializeSurfaceFromId", "u", "u" },
+ { "SetSurfaceNativeContent", "uuuuu", "" },
+ { "RemoveSurfaceNativeContent", "u", "" },
+ { "RemoveSurface", "u", "" },
+ { "CreateLayer", "", "u" },
+ { "CreateLayerFromId", "u", "u" },
+ { "CreateLayerWithDimension", "uu", "u" },
+ { "CreateLayerFromIdWithDimension", "uuu", "u" },
+ { "RemoveLayer", "u", "" },
+ { "AddSurfaceToLayer", "uu", "" },
+ { "RemoveSurfaceFromLayer", "uu", "" },
+ { "SetSurfaceSourceRegion", "uuuuu", "" },
+ { "SetLayerSourceRegion", "uuuuu", "" },
+ { "SetSurfaceDestinationRegion", "uuuuu", "" },
+ { "SetSurfacePosition", "uuu", "" },
+ { "GetSurfacePosition", "u", "uu" },
+ { "SetSurfaceDimension", "uuu", "" },
+ { "SetLayerDestinationRegion", "uuuuu", "" },
+ { "SetLayerPosition", "uuu", "" },
+ { "GetLayerPosition", "u", "uu" },
+ { "SetLayerDimension", "uuu", "" },
+ { "GetLayerDimension", "u", "uu" },
+ { "GetSurfaceDimension", "u", "uu" },
+ { "SetSurfaceOpacity", "ud", "" },
+ { "SetLayerOpacity", "ud", "" },
+ { "GetSurfaceOpacity", "u", "d" },
+ { "GetLayerOpacity", "u", "d" },
+ { "SetSurfaceOrientation", "uu", "" },
+ { "GetSurfaceOrientation", "uu", "" },
+ { "SetLayerOrientation", "uu", "" },
+ { "GetLayerOrientation", "uu", "" },
+ { "GetSurfacePixelformat", "u", "u" },
+ { "SetSurfaceVisibility", "ub", "" },
+ { "SetLayerVisibility", "ub", "" },
+ { "GetSurfaceVisibility", "u", "b" },
+ { "GetLayerVisibility", "u", "b" },
+ { "SetRenderOrderOfLayers", "auu", "" },
+ { "SetSurfaceRenderOrderWithinLayer", "uau", "" },
+ { "GetLayerType", "u", "u" },
+ { "GetLayertypeCapabilities", "u", "u" },
+ { "GetLayerCapabilities", "u", "u" },
+ { "Exit", "", "" },
+ { "CommitChanges", "", "" },
+ { "CreateShader", "ss", "u" },
+ { "DestroyShader", "u", "" },
+ { "SetShader", "uu", "" },
+ { "SetUniforms", "uas", "" },
+ { "SetKeyboardFocusOn", "u", "" },
+ { "GetKeyboardFocusSurfaceId", "", "u" },
+ { "UpdateInputEventAcceptanceOn", "uub", "" },
+ { "LayerAddNotification", "u", "" },
+ { "LayerRemoveNotification", "u", "" },
+ { "SurfaceAddNotification", "u", "" },
+ { "SurfaceRemoveNotification", "u", "" },
+ { "SetOptimizationMode", "uu", "" },
+ { "GetOptimizationMode", "u", "u" }
};
int introspectionInterfaceCount = sizeof(introspectionInterface) / sizeof(struct IntrospectionTable);
msgBuffer += openMethod(msgBuffer, methodName);
- for(i = 0; i < parameterLength; ++i)
+ for (i = 0; i < parameterLength; ++i)
{
switch (parameter[i])
{
- case 'a':
- i++;
- msgBuffer += addArrayArgument(msgBuffer, "", "in", ¶meter[i]);
- break;
- default:
- msgBuffer += addArgument(msgBuffer, "", "in", ¶meter[i]);
- break;
+ case 'a':
+ i++;
+ msgBuffer += addArrayArgument(msgBuffer, "", "in", ¶meter[i]);
+ break;
+ default:
+ msgBuffer += addArgument(msgBuffer, "", "in", ¶meter[i]);
+ break;
}
}
- for(i = 0; i < returnValueLength; ++i)
+ for (i = 0; i < returnValueLength; ++i)
{
switch (returnValue[i])
{
- case 'a':
- i++;
- msgBuffer += addArrayArgument(msgBuffer, "", "out", &returnValue[i]);
- break;
- default:
- msgBuffer += addArgument(msgBuffer, "", "out", &returnValue[i]);
- break;
+ case 'a':
+ i++;
+ msgBuffer += addArrayArgument(msgBuffer, "", "out", &returnValue[i]);
+ break;
+ default:
+ msgBuffer += addArgument(msgBuffer, "", "out", &returnValue[i]);
+ break;
}
}
readFds = gDbus.incomingSockets;
writeFds = gDbus.outgoingSockets;
fdMax = (gDbus.incomingSocketsMax > gDbus.outgoingSocketsMax) ?
- gDbus.incomingSocketsMax : gDbus.outgoingSocketsMax;
+ gDbus.incomingSocketsMax : gDbus.outgoingSocketsMax;
fdsReady = 0;
char rule[1024];
t_ilm_uint id;
dbus_message_get_args(message->pMessage, NULL,
- DBUS_TYPE_UINT32, &id,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_UINT32, &id,
+ DBUS_TYPE_INVALID);
sprintf(rule,
"type='signal',sender='%s',interface='%s',member='%s%u'",
char rule[1024];
t_ilm_uint id;
dbus_message_get_args(message->pMessage, NULL,
- DBUS_TYPE_UINT32, &id,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_UINT32, &id,
+ DBUS_TYPE_INVALID);
sprintf(rule,
"type='signal',sender='%s',interface='%s',member='%s%d'",
*
****************************************************************************/
-#ifndef _TCPSOCKETCONFIGURATION_H_
-#define _TCPSOCKETCONFIGURATION_H_
+#ifndef _SOCKETCONFIGURATION_H_
+#define _SOCKETCONFIGURATION_H_
//=============================================================================
// tcp socket configuration
#define ENV_TCP_HOST "LM_TCP_HOST"
#define ENV_TCP_PORT "LM_TCP_PORT"
-#endif // _TCPSOCKETCONFIGURATION_H_
+#endif // _SOCKETCONFIGURATION_H_
{
msg->index -= sizeof(readType);
printf("command value type mismatch: expected '%s', got '%s'.\n",
- &protocolType, &readType);
+ &protocolType, &readType);
return ILM_FALSE;
}
msg->index -= sizeof(readType);
msg->index -= sizeof(size);
printf("command value size mismatch for type '%s': "
- "expected %d bytes, got %d bytes.\n",
- &protocolType, expectedSize, size);
+ "expected %d bytes, got %d bytes.\n",
+ &protocolType, expectedSize, size);
return ILM_FALSE;
}
{
msg->index -= sizeof(readType);
printf("command value type mismatch: expected '%c', got '%s'.\n",
- SOCKET_MESSAGE_TYPE_ARRAY, &readType);
+ SOCKET_MESSAGE_TYPE_ARRAY, &readType);
return ILM_FALSE;
}
}
if (0 != connect(gState.socket,
- (struct sockaddr *) &gState.serverAddrIn,
- sizeof(gState.serverAddrIn)))
+ (struct sockaddr *) &gState.serverAddrIn,
+ sizeof(gState.serverAddrIn)))
{
result = ILM_FALSE;
}
if (0 > bind(gState.socket,
(struct sockaddr *) &gState.serverAddrIn,
- sizeof(gState.serverAddrIn)))
+ sizeof(gState.serverAddrIn)))
{
printf("TcpIpcModule: bind()...failed\n");
result = ILM_FALSE;
}
if (0 != connect(gState.socket,
- (struct sockaddr *) &gState.serverAddrIn,
- sizeof(gState.serverAddrIn)))
+ (struct sockaddr *) &gState.serverAddrIn,
+ sizeof(gState.serverAddrIn)))
{
result = ILM_FALSE;
}
if (0 > bind(gState.socket,
(struct sockaddr *) &gState.serverAddrIn,
- sizeof(gState.serverAddrIn)))
+ sizeof(gState.serverAddrIn)))
{
printf("TcpIpcModule: bind()...failed\n");
result = ILM_FALSE;
// receive data from socket
receiveFromSocket(msg, socketNumber);
- if(msg->paket.size > 0)
+ if (msg->paket.size > 0)
{
// new message from client
getString(msg, msg->name);
continue;
}
- if(msg->paket.size == 0)
+ if (msg->paket.size == 0)
{
// client disconnected
msg->paket.type = IpcMessageTypeDisconnect;
do
{
retVal += send(socketNumber,
- &msg->paket + sentBytes,
- sendSize - sentBytes,
- 0);
+ &msg->paket + sentBytes,
+ sendSize - sentBytes,
+ 0);
sentBytes += retVal;
} while (retVal > 0 && sentBytes < sendSize);
do
{
retVal = recv(msg->sender,
- &messageBuffer[receivedBytes],
- msg->paket.size - receivedBytes,
- 0);
+ &messageBuffer[receivedBytes],
+ msg->paket.size - receivedBytes,
+ 0);
receivedBytes += retVal;
} while ((retVal > 0) && (receivedBytes < msg->paket.size));
#include "IRenderer.h"
#include "WindowSystems/BaseWindowSystem.h"
-class BaseRenderer: public IRenderer, public PluginBase
+class BaseRenderer : public IRenderer, public PluginBase
{
public:
BaseRenderer(ICommandExecutor& executor, Configuration& config);
virtual void doScreenShot(std::string fileToSave) = 0;
virtual uint getLayerTypeCapabilities(LayerType layerType);
- virtual InputManager* getInputManager() const {return m_pInputManager;}
- virtual Shader* createShader(const string* vertexName, const string* fragmentName);
+ virtual InputManager* getInputManager() const
+ {
+ return m_pInputManager;
+ }
+
+ virtual Shader* createShader(const string* vertexName, const string* fragmentName);
virtual bool setOptimizationMode(unsigned int id, unsigned int mode)
{
(void)id;
static bool debugMode;
};
-inline Shader* BaseRenderer::createShader(const string* vertexName, const string* fragmentName)
+inline Shader* BaseRenderer::createShader(const string* vertexName, const string* fragmentName)
{
- (void)vertexName; // TODO: removed, prevents warning
- (void)fragmentName; // TODO: removed, prevents warning
+ (void)vertexName; // TODO: removed, prevents warning
+ (void)fragmentName; // TODO: removed, prevents warning
return NULL;
}
inline void BaseRenderer::setdebug(bool onoff)
// Loads a file containing shader code
static char* RenderUtilLoadShaderFile(const char *szFilename)
{
- if(!szFilename)
+ if (!szFilename)
{
- return(NULL);
+ return (NULL);
}
FILE* pFile = fopen(szFilename, "rb");
- if(!pFile)
+ if (!pFile)
{
- LOG_ERROR("RenderUtilLoadShaderFile","Unable to open ShaderFile " << szFilename);
- return(NULL);
+ LOG_ERROR("RenderUtilLoadShaderFile", "Unable to open ShaderFile " << szFilename);
+ return (NULL);
}
fseek(pFile, 0, SEEK_END);
if (size < 0)
{
- LOG_ERROR("RenderUtilLoadShaderFile","Unable get size of ShaderFile " << szFilename);
+ LOG_ERROR("RenderUtilLoadShaderFile", "Unable get size of ShaderFile " << szFilename);
fclose(pFile);
- return(NULL);
+ return (NULL);
}
fseek(pFile, 0, SEEK_SET);
- char *pBuffer = new char[size+1];
- if(!pBuffer)
+ char *pBuffer = new char[size + 1];
+ if (!pBuffer)
{
- LOG_ERROR("RenderUtilLoadShaderFile","Unable to allocate Memory for ShaderFile " << szFilename);
+ LOG_ERROR("RenderUtilLoadShaderFile", "Unable to allocate Memory for ShaderFile " << szFilename);
fclose(pFile);
- return(NULL);
+ return (NULL);
}
- if(1 != fread(pBuffer, size, 1, pFile))
+ if (1 != fread(pBuffer, size, 1, pFile))
{
- LOG_ERROR("RenderUtilLoadShaderFile","Unable to allocate Memory for ShaderFile " << szFilename);
+ LOG_ERROR("RenderUtilLoadShaderFile", "Unable to allocate Memory for ShaderFile " << szFilename);
fclose(pFile);
delete [] pBuffer;
- return(NULL);
+ return (NULL);
}
pBuffer[size] = 0;
fclose(pFile);
- LOG_DEBUG("RenderUtilShaderDebug","loaded file with bytes: " << size);
- return(pBuffer);
+ LOG_DEBUG("RenderUtilShaderDebug", "loaded file with bytes: " << size);
+ return (pBuffer);
}
}
if (str != NULL && *str != '\0')
{
- strncpy(errorMessage, "--- ",1024); // TODO: sizeof(errorMessage)
+ strncpy(errorMessage, "--- ", 1024); // TODO: sizeof(errorMessage)
strncat(errorMessage, op, 1000); // TODO: why 1000? dangerous
strncat(errorMessage, " log ---", 8);
- LOG_ERROR("RenderUtilShaderDebug",errorMessage);
- LOG_ERROR("RenderUtilShaderDebug",str);
+ LOG_ERROR("RenderUtilShaderDebug", errorMessage);
+ LOG_ERROR("RenderUtilShaderDebug", str);
}
if (str)
glGetShaderSource(obj, len, NULL, str);
if (str != NULL && *str != '\0')
{
- strncpy(errorMessage, "--- ",1024);// TODO: sizeof(errorMessage)
- strncat(errorMessage,op, 1000); // TODO: why 1000? dangerous
+ strncpy(errorMessage, "--- ", 1024);// TODO: sizeof(errorMessage)
+ strncat(errorMessage, op, 1000); // TODO: why 1000? dangerous
strncat(errorMessage, " log ---", 8);
- LOG_ERROR("RenderUtilShaderDebug",errorMessage);
- LOG_ERROR("RenderUtilShaderDebug",str);
+ LOG_ERROR("RenderUtilShaderDebug", errorMessage);
+ LOG_ERROR("RenderUtilShaderDebug", str);
}
delete[] str;
}
if (!success)
{
- strncpy(errorMessage, "--- ",1024);// TODO: sizeof(errorMessage)
- strncat(errorMessage,op, 1000); // TODO: why 1000? dangerous
- strncat(errorMessage, " failed ---", 7);
- LOG_ERROR("RenderUtilShaderDebug",errorMessage);
+ strncpy(errorMessage, "--- ", 1024);// TODO: sizeof(errorMessage)
+ strncat(errorMessage, op, 1000); // TODO: why 1000? dangerous
+ strncat(errorMessage, " failed ---", 7);
+ LOG_ERROR("RenderUtilShaderDebug", errorMessage);
}
}
GLuint binaryFormat,
GLboolean debugging)
{
- LOG_DEBUG("RenderUtil","Loading shaders binaries. Size " << vertBinSize << " : " << fragBinSize );
+ LOG_DEBUG("RenderUtil", "Loading shaders binaries. Size " << vertBinSize << " : " << fragBinSize);
// Binary shaders not supportable for non-ES OpenGL
GLuint prog;
GLuint vertShader;
// Link the shader program
glLinkProgram(prog);
- if (debugging)
+ if (debugging)
{
RenderUtilShaderDebug(prog, GL_LINK_STATUS, "Program Link");
}
// Takes shader source files, compiles them, and builds a shader program
static GLuint RenderUtilLoadShaderSources(const char* vertFile, const char* fragFile, GLboolean debugging)
{
- LOG_DEBUG("RenderUtilShaderDebug","loading shaders sources");
- LOG_DEBUG("RenderUtilShaderDebug","loading vertex shader: " << vertFile);
- LOG_DEBUG("RenderUtilShaderDebug","loading fragment shader: " << fragFile);
+ LOG_DEBUG("RenderUtilShaderDebug", "loading shaders sources");
+ LOG_DEBUG("RenderUtilShaderDebug", "loading vertex shader: " << vertFile);
+ LOG_DEBUG("RenderUtilShaderDebug", "loading fragment shader: " << fragFile);
GLuint prog = 0;
char* vertSource;
GLint linked;
// Load the shader files
- vertSource =RenderUtilLoadShaderFile(vertFile);
- fragSource = RenderUtilLoadShaderFile(fragFile);
- LOG_DEBUG("RenderUtilShaderDebug","loaded shaders source files");
+ vertSource = RenderUtilLoadShaderFile(vertFile);
+ fragSource = RenderUtilLoadShaderFile(fragFile);
+ LOG_DEBUG("RenderUtilShaderDebug", "loaded shaders source files");
if (!vertSource || !fragSource) goto done;
vertSourceLen = (GLint)strlen(vertSource);
fragSourceLen = (GLint)strlen(fragSource);
// Create the program
prog = glCreateProgram();
- if (prog==0)
+ if (prog == 0)
{
- LOG_DEBUG("RenderUtilShaderDebug","glError occured : " << glGetError());
- LOG_DEBUG("RenderUtilShaderDebug","could not create prog, prog is 0");
+ LOG_DEBUG("RenderUtilShaderDebug", "glError occured : " << glGetError());
+ LOG_DEBUG("RenderUtilShaderDebug", "could not create prog, prog is 0");
}
// Create the GL shader objects
glGetProgramiv(prog, GL_LINK_STATUS, &linked);
if (!linked)
{
- LOG_DEBUG("RenderUtilShaderDebug","could not link shader");
+ LOG_DEBUG("RenderUtilShaderDebug", "could not link shader");
}
}
else
{
- LOG_DEBUG("RenderUtilShaderDebug","could not compile fragment shader");
+ LOG_DEBUG("RenderUtilShaderDebug", "could not compile fragment shader");
}
}
else
{
- LOG_DEBUG("RenderUtilShaderDebug","could not compile vertex shader");
+ LOG_DEBUG("RenderUtilShaderDebug", "could not compile vertex shader");
}
if (!compiled || !linked)
prog = 0;
}
- done:
+done:
delete[] fragSource;
delete[] vertSource;
uint BaseRenderer::getLayerTypeCapabilities(LayerType layerType)
{
uint result = 0;
- switch(layerType)
+ switch (layerType)
{
- case Software_2D:
- result = LayerPosition | LayerScalable | LayerOrientable | LayerComposedByAlpha;
- break;
+ case Software_2D:
+ result = LayerPosition | LayerScalable | LayerOrientable | LayerComposedByAlpha;
+ break;
- case Software_2_5D:
- result = LayerPosition | LayerScalable | LayerOrientable | LayerComposedByAlpha;
- break;
+ case Software_2_5D:
+ result = LayerPosition | LayerScalable | LayerOrientable | LayerComposedByAlpha;
+ break;
- default :
- break;
+ default :
+ break;
}
return result;
}
struct gbm_device;
-struct DrmMode {
- uint32_t flags;
- int32_t width;
- int32_t height;
- uint32_t refresh;
- drmModeModeInfo modeInfo;
- wl_list link;
+struct DrmMode
+{
+ uint32_t flags;
+ int32_t width;
+ int32_t height;
+ uint32_t refresh;
+ drmModeModeInfo modeInfo;
+ wl_list link;
};
struct DrmOutput;
-struct DrmFb {
- struct gbm_bo *bo;
- struct DrmOutput *output;
- uint32_t fbId;
+struct DrmFb
+{
+ struct gbm_bo *bo;
+ struct DrmOutput *output;
+ uint32_t fbId;
};
-struct DrmOutput {
- struct wl_list link;
- struct DrmMode* currentMode;
- struct wl_list modeList;
- uint32_t crtcID;
- uint32_t connectorID;
- drmModeCrtcPtr orgCrtc;
- int pageFlipPending;
- int fdDev;
- struct gbm_surface *surface;
- struct DrmFb *current, *next;
- EGLSurface eglSurface;
- uint32_t screenID;
- BaseWindowSystem *windowSystem;
+struct DrmOutput
+{
+ struct wl_list link;
+ struct DrmMode* currentMode;
+ struct wl_list modeList;
+ uint32_t crtcID;
+ uint32_t connectorID;
+ drmModeCrtcPtr orgCrtc;
+ int pageFlipPending;
+ int fdDev;
+ struct gbm_surface *surface;
+ struct DrmFb *current, *next;
+ EGLSurface eglSurface;
+ uint32_t screenID;
+ BaseWindowSystem *windowSystem;
};
-class DrmGLESGraphicSystem: public GLESGraphicsystem
+class DrmGLESGraphicSystem : public GLESGraphicsystem
{
// functions
public:
DrmGLESGraphicSystem(int windowWidth, int windowHeight,
- PfnShaderProgramCreator shaderProgram);
+ PfnShaderProgramCreator shaderProgram);
virtual ~DrmGLESGraphicSystem();
virtual bool init(EGLNativeDisplayType display, EGLNativeWindowType window);
// proterties
private:
- struct wl_list m_outputList;
+ struct wl_list m_outputList;
- gbm_device* m_gbm;
- int m_fdDev;
- uint32_t* m_crtcs;
- int m_crtcsNum;
- uint32_t m_crtcAllocator;
- uint32_t m_connectorAllocator;
- DrmOutput* m_currentOutput;
+ gbm_device* m_gbm;
+ int m_fdDev;
+ uint32_t* m_crtcs;
+ int m_crtcsNum;
+ uint32_t m_crtcAllocator;
+ uint32_t m_connectorAllocator;
+ DrmOutput* m_currentOutput;
- PFNEGLBINDWAYLANDDISPLAYWL m_pfEglBindWaylandDisplayWL;
- PFNEGLUNBINDWAYLANDDISPLAYWL m_pfEglUnbindWaylandDisplayWL;
+ PFNEGLBINDWAYLANDDISPLAYWL m_pfEglBindWaylandDisplayWL;
+ PFNEGLUNBINDWAYLANDDISPLAYWL m_pfEglUnbindWaylandDisplayWL;
// private functions
private:
bool initializeSystem();
- bool createOutputs();
- int createOutputForConnector(drmModeRes* resources, drmModeConnector* connector, int x, int y);
- int drmOutputAddMode(struct DrmOutput* output, drmModeModeInfo* info);
- int drmOutputPrepareRender(struct DrmOutput* output);
+ bool createOutputs();
+ int createOutputForConnector(drmModeRes* resources, drmModeConnector* connector, int x, int y);
+ int drmOutputAddMode(struct DrmOutput* output, drmModeModeInfo* info);
+ int drmOutputPrepareRender(struct DrmOutput* output);
};
#endif /* _DRMGLESGRAPHICSYSTEM_H_ */
SurfaceList m_surfaces;
};
-class GLESGraphicsystem: public BaseGraphicSystem<EGLNativeDisplayType, EGLNativeWindowType>
+class GLESGraphicsystem : public BaseGraphicSystem<EGLNativeDisplayType, EGLNativeWindowType>
{
public:
virtual bool needsBlending(SurfaceList surfaces);
virtual unsigned shaderKey(int numSurfaces,
- int needsBlend,
- int hasTransparency1, int hasAlphaChannel1, int hasChromakey1,
- int hasTransparency2, int hasAlphaChannel2, int hasChromakey2,
- int hasTransparency3, int hasAlphaChannel3, int hasChromakey3,
- int hasTransparency4, int hasAlphaChannel4, int hasChromakey4);
+ int needsBlend,
+ int hasTransparency1, int hasAlphaChannel1, int hasChromakey1,
+ int hasTransparency2, int hasAlphaChannel2, int hasChromakey2,
+ int hasTransparency3, int hasAlphaChannel3, int hasChromakey3,
+ int hasTransparency4, int hasAlphaChannel4, int hasChromakey4);
virtual void debugShaderKey(unsigned key);
protected:
class GLXGraphicsystem : public BaseGraphicSystem<Display*, Window>
{
public:
- GLXGraphicsystem( int windowWidth, int windowHeight);
+ GLXGraphicsystem(int windowWidth, int windowHeight);
virtual ~GLXGraphicsystem();
static XVisualInfo* GetMatchingVisual(Display *dpy);
virtual bool init(Display* x11Display, Window x11Window);
virtual void swapBuffers();
virtual void saveScreenShotOfFramebuffer(std::string fileToSave);
GLXFBConfig* GetMatchingPixmapConfig(Display *curDisplay);
- bool CheckConfigValue(Display *curDisplay,GLXFBConfig currentConfig, int attribute, int expectedValue);
- bool CheckConfigMask(Display *curDisplay,GLXFBConfig currentConfig, int attribute, int expectedValue);
+ bool CheckConfigValue(Display *curDisplay, GLXFBConfig currentConfig, int attribute, int expectedValue);
+ bool CheckConfigMask(Display *curDisplay, GLXFBConfig currentConfig, int attribute, int expectedValue);
virtual void renderSurface(Surface* currentSurface);
virtual void activateGraphicContext();
virtual void releaseGraphicContext();
class BeaglePlatformSurface : public PlatformSurface
{
public:
- BeaglePlatformSurface (Surface* surface)
+ BeaglePlatformSurface(Surface* surface)
: PlatformSurface(surface)
, eglImage(0)
{
/***************************************************************************
*
- * Copyright 2010, 2011 BMW Car IT GmbH
+ * Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
#include "EGL/eglext.h"
#include "WaylandPlatformSurface.h"
-class EglWaylandPlatformSurface: public WaylandPlatformSurface
+class EglWaylandPlatformSurface : public WaylandPlatformSurface
{
public:
EglWaylandPlatformSurface(Surface* surface)
#include "EGL/eglext.h"
#include "XPlatformSurface.h"
-class EglXPlatformSurface: public XPlatformSurface
+class EglXPlatformSurface : public XPlatformSurface
{
public:
EglXPlatformSurface(Surface* surface)
#include "Surface.h"
#include "GL/glx.h"
-class GLXPlatformSurface: public XPlatformSurface
+class GLXPlatformSurface : public XPlatformSurface
{
public:
GLXPlatformSurface(Surface* surface)
/***************************************************************************
*
- * Copyright 2010, 2011 BMW Car IT GmbH
+ * Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
#include "PlatformSurface.h"
#include "Surface.h"
-class WaylandPlatformSurface: public PlatformSurface
+class WaylandPlatformSurface : public PlatformSurface
{
public:
unsigned short connectionId;
~WaylandPlatformSurface()
{
}
-
+
bool enableRendering()
{
m_isReadyForRendering = true;
- return true;
+ return true;
}
bool disableRendering()
{
m_isReadyForRendering = false;
- return true;
+ return true;
}
bool isReadyForRendering()
return m_isReadyForRendering;
}
uint texture;
- bool m_isReadyForRendering;
+ bool m_isReadyForRendering;
};
#endif /* _WAYLANDPLATFORMSURFACE_H_ */
#include "Surface.h"
#include "X11/X.h"
-class XPlatformSurface: public PlatformSurface
+class XPlatformSurface : public PlatformSurface
{
public:
XPlatformSurface(Surface* surface)
~XPlatformSurface()
{
}
-
+
bool enableRendering()
{
m_isReadyForRendering = true;
bool isMapped;
Pixmap pixmap;
uint texture;
- bool m_isReadyForRendering;
+ bool m_isReadyForRendering;
};
#endif /* _XPLATFORMSURFACE_H_ */
#include <cmem.h>
#include "PlatformSurfaces/BeaglePlatformSurface.h"
-class BeagleEglImage: public ITextureBinder
+class BeagleEglImage : public ITextureBinder
{
public:
BeagleEglImage(EGLDisplay eglDisplay)
void unbindSurfaceTexture(Surface*s)
{
-
}
PlatformSurface* createPlatformSurface(Surface* s)
EGL_NO_CONTEXT, //eglContext,
EGL_NATIVE_PIXMAP_KHR, //EGL_GL_TEXTURE_2D_KHR,
pNativePixmap, //(void*)textureId0,//
- NULL //miplevel 0 is fine, thank you
- );
+ NULL); //miplevel 0 is fine, thank you
if (nativeSurface->eglImage == 0)
{
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-class WaylandGLESTexture: public ITextureBinder
+class WaylandGLESTexture : public ITextureBinder
{
public:
virtual PlatformSurface* createPlatformSurface(Surface* surface);
#include "PlatformSurfaces/XPlatformSurface.h"
#include <X11/extensions/Xcomposite.h>
-class X11Copy: public ITextureBinder
+class X11Copy : public ITextureBinder
{
public:
X11Copy(Display* display);
#include <X11/extensions/Xcomposite.h>
#include <EGL/egl.h>
-class X11CopyGLES: public X11Copy
+class X11CopyGLES : public X11Copy
{
public:
X11CopyGLES(EGLDisplay eglDisplay, Display* display) : X11Copy(display)
{
-
// pseudo require EGL to have been initialised
// we dont really need the handle
// remove compiler Warning
(void)eglDisplay; // TODO
};
- void swapPixmap(unsigned char* src,unsigned char* dest,unsigned int width,unsigned int height,bool swaprgb,bool includeAlpha);
+ void swapPixmap(unsigned char* src, unsigned char* dest, unsigned int width, unsigned int height, bool swaprgb, bool includeAlpha);
bool bindSurfaceTexture(Surface* surface);
void createClientBuffer(Surface* surface);
void destroyClientBuffer(Surface* surface);
-
};
#endif /* _X11COPYGLES_H_ */
#include "PlatformSurfaces/XPlatformSurface.h"
#include <X11/extensions/Xcomposite.h>
-class X11CopyGLX: public X11Copy
+class X11CopyGLX : public X11Copy
{
public:
X11CopyGLX(Display* display)
bool bindSurfaceTexture(Surface* surface);
void createClientBuffer(Surface* surface);
void destroyClientBuffer(Surface* surface);
-
};
#endif /* _X11COPYGLX_H_ */
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-class X11EglImage: public ITextureBinder
+class X11EglImage : public ITextureBinder
{
public:
virtual PlatformSurface* createPlatformSurface(Surface* surface);
#include "TextureBinders/ITextureBinder.h"
#include "PlatformSurfaces/GLXPlatformSurface.h"
-class X11TextureFromPixmap: public ITextureBinder
+class X11TextureFromPixmap : public ITextureBinder
{
public:
X11TextureFromPixmap(Display* display, GLXFBConfig pixmapConfig);
class BaseWindowSystem
{
public:
- BaseWindowSystem(Scene* pScene, InputManager* pInputManager )
+ BaseWindowSystem(Scene* pScene, InputManager* pInputManager)
: m_pInputManager(pInputManager)
, m_pScene(pScene)
*
****************************************************************************/
-#ifndef _WAYLANDWINDOWSYSTEM_H_
-#define _WAYLANDWINDOWSYSTEM_H_
+#ifndef _WAYLANDBASEWINDOWSYSTEM_H_
+#define _WAYLANDBASEWINDOWSYSTEM_H_
#include "WindowSystems/BaseWindowSystem.h"
#include "GraphicSystems/BaseGraphicSystem.h"
#include "Surface.h"
UNKOWN_STATE
} WaylandWindowSystemStates;
-typedef struct _wlevent {
- int x, y;
+typedef struct _wlevent
+{
+ int x;
+ int y;
int32_t button;
enum wl_pointer_button_state buttonState;
long keyCode;
int touchId;
int touchType;
} WLEvent;
-
} // extern "C"
struct native_surface;
-class WaylandBaseWindowSystem: public BaseWindowSystem
+class WaylandBaseWindowSystem : public BaseWindowSystem
{
public:
WaylandBaseWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager);
struct native_surface* getNativeSurfaceFromSurface(Surface* surface);
virtual void checkForNewSurfaceNativeContent();
void calculateFps();
- void calculateSurfaceFps(Surface *currentSurface, float time) ;
+ void calculateSurfaceFps(Surface *currentSurface, float time);
void printDebug();
void* eventLoop();
static void bindCompositor(struct wl_client* client, void* data, uint32_t version, uint32_t id);
static int signalEventOnTerm(int signal_number, void *data);
- static void destroyListenerSurfaceBuffer(struct wl_listener* listener,void *data);
- static void destroyListenerSurfacePendingBuffer(struct wl_listener* listener,void *data);
+ static void destroyListenerSurfaceBuffer(struct wl_listener* listener, void *data);
+ static void destroyListenerSurfacePendingBuffer(struct wl_listener* listener, void *data);
static void idleEventRepaint(void *data);
bool createWaylandClient();
void releaseWaylandClient();
static void destroySurfaceCallback(struct wl_resource* resource);
static void destroyFrameCallback(struct wl_resource *resource);
static void* eventLoopCallback(void* ptr);
- static void registryHandleGlobalClient(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
+ static void registryHandleGlobalClient(void* data,
+ struct wl_registry* registry,
+ uint32_t name,
+ const char* interface,
+ uint32_t version);
static void surfaceListenerFrame(void* data, struct wl_callback* callback, uint32_t time);
static int finishFrameHandler(void *data);
// wl_surface interface
- static void surfaceIFDestroy(struct wl_client *client, struct wl_resource *resource);
- static void surfaceIFAttach(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t x, int32_t y);
- static void surfaceIFDamage(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height);
- static void surfaceIFFrame(struct wl_client *client, struct wl_resource *resource, uint32_t callback);
- static void surfaceIFCommit(struct wl_client *client, struct wl_resource *resource);
-
+ static void surfaceIFDestroy(struct wl_client *client,
+ struct wl_resource *resource);
+ static void surfaceIFAttach(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *buffer_resource,
+ int32_t x,
+ int32_t y);
+ static void surfaceIFDamage(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height);
+ static void surfaceIFFrame(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t callback);
+ static void surfaceIFCommit(struct wl_client *client,
+ struct wl_resource *resource);
+
// wl_compositor interface
static void compositorIFCreateSurface(struct wl_client *client, struct wl_resource* resource, uint32_t id);
void manageWLInputEvent(const InputDevice type, const InputEventState state, const WLEvent *wlEvent);
};
-inline void WaylandBaseWindowSystem::setSystemState (WaylandWindowSystemStates state)
+inline void WaylandBaseWindowSystem::setSystemState(WaylandWindowSystemStates state)
{
m_systemState = state;
}
-inline WaylandWindowSystemStates WaylandBaseWindowSystem::getSystemState ()
+inline WaylandWindowSystemStates WaylandBaseWindowSystem::getSystemState()
{
return m_systemState;
}
return false;
}
-inline int WaylandBaseWindowSystem::getWindowWidth() const { return m_width; }
-inline int WaylandBaseWindowSystem::getWindowHeight() const { return m_height; }
+inline int WaylandBaseWindowSystem::getWindowWidth() const
+{
+ return m_width;
+}
+
+inline int WaylandBaseWindowSystem::getWindowHeight() const
+{
+ return m_height;
+}
extern "C" {
- struct native_surface {
- struct wl_surface surface;
- WaylandBaseWindowSystem* windowSystem;
- struct wl_buffer* buffer;
- int connectionId;
+struct native_surface
+{
+ struct wl_surface surface;
+ WaylandBaseWindowSystem* windowSystem;
+ struct wl_buffer* buffer;
+ int connectionId;
- uint32_t visual; // TODO confirm:it's necessary or not
- struct wl_listener buffer_destroy_listener;
- struct wl_list link;
+ uint32_t visual; // TODO confirm:it's necessary or not
+ struct wl_listener buffer_destroy_listener;
+ struct wl_list link;
- /* All the pending state, that wl_surface.commit will apply. */
- struct {
- /* wl_surface.attach */
- int remove_contents;
- struct wl_buffer *buffer;
- struct wl_listener buffer_destroy_listener;
- int32_t sx;
- int32_t sy;
+ /* All the pending state, that wl_surface.commit will apply. */
+ struct
+ {
+ /* wl_surface.attach */
+ int remove_contents;
+ struct wl_buffer *buffer;
+ struct wl_listener buffer_destroy_listener;
+ int32_t sx;
+ int32_t sy;
- /* wl_surface.damage */
- Rectangle damage;
- bool damaged;
+ /* wl_surface.damage */
+ Rectangle damage;
+ bool damaged;
- /* wl_surface.frame */
- struct wl_list frame_callback_list;
- } pending;
- };
+ /* wl_surface.frame */
+ struct wl_list frame_callback_list;
+ } pending;
+};
- struct native_frame_callback {
- struct wl_resource resource;
- struct wl_list link;
- };
+struct native_frame_callback
+{
+ struct wl_resource resource;
+ struct wl_list link;
+};
- struct native_process;
- typedef void (*cleanupFuncForNativeProcess)(struct native_process* process, int status);
+struct native_process;
+typedef void (*cleanupFuncForNativeProcess)(struct native_process* process, int status);
- struct native_process {
- pid_t pid;
- cleanupFuncForNativeProcess cleanup;
- struct wl_list link;
- };
+struct native_process
+{
+ pid_t pid;
+ cleanupFuncForNativeProcess cleanup;
+ struct wl_list link;
+};
}
-#endif /* _WAYLANDWINDOWSYSTEM_H_ */
+#endif /* _WAYLANDBASEWINDOWSYSTEM_H_ */
struct gbm_device;
-class WaylandDrmWindowSystem: public WaylandBaseWindowSystem
+class WaylandDrmWindowSystem : public WaylandBaseWindowSystem
{
public:
WaylandDrmWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager);
//////////////////////////////////////////////////////////////////////////////
#define MAX_SLOTS 16
-enum evdev_event_type {
+enum evdev_event_type
+{
EVDEV_ABSOLUTE_MOTION = (1 << 0),
EVDEV_ABSOLUTE_MT_DOWN = (1 << 1),
EVDEV_ABSOLUTE_MT_MOTION = (1 << 2),
EVDEV_RELATIVE_MOTION = (1 << 4)
};
-enum evdev_device_capability {
+enum evdev_device_capability
+{
EVDEV_KEYBOARD = (1 << 0),
EVDEV_BUTTON = (1 << 1),
EVDEV_MOTION_ABS = (1 << 2),
EVDEV_TOUCH = (1 << 4)
};
-enum key_state_update {
+enum key_state_update
+{
STATE_UPDATE_AUTOMATIC,
STATE_UPDATE_NONE
};
class WaylandEvdevInputEvent;
struct evdev_dispatch;
-struct evdev_input_device {
+struct evdev_input_device
+{
WaylandEvdevInputEvent *master;
struct wl_list link;
struct wl_event_source *source;
struct evdev_dispatch *dispatch;
char *devnode;
int fd;
- struct {
- int min_x, max_x, min_y, max_y;
- int32_t x, y;
+ struct
+ {
+ int min_x;
+ int max_x;
+ int min_y;
+ int max_y;
+
+ int32_t x;
+ int32_t y;
} abs;
- struct {
+ struct
+ {
int slot;
int32_t x[MAX_SLOTS];
int32_t y[MAX_SLOTS];
} mt;
struct mtdev* mtdev;
- struct {
- wl_fixed_t dx, dy;
+ struct
+ {
+ wl_fixed_t dx;
+ wl_fixed_t dy;
} rel;
unsigned int pending_events;
int isMt;
};
-struct evdev_dispatch_interface {
+struct evdev_dispatch_interface
+{
// Process an evdev input event
void (*process)(struct evdev_dispatch *dispatch,
struct evdev_input_device *device,
void (*destroy)(struct evdev_dispatch *dispatch);
};
-struct evdev_dispatch {
+struct evdev_dispatch
+{
struct evdev_dispatch_interface *interface;
};
#define DEFAULT_MAX_ACCEL_FACTOR 1.0
#define DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR 700.0
-enum touchpad_model {
+enum touchpad_model
+{
TOUCHPAD_MODEL_UNKNOWN = 0,
TOUCHPAD_MODEL_SYNAPTICS,
TOUCHPAD_MODEL_ALPS,
#define TOUCHPAD_EVENT_ABSOLUTE_Y (1 << 2)
#define TOUCHPAD_EVENT_REPORT (1 << 3)
-struct touchpad_model_spec {
+struct touchpad_model_spec
+{
short vendor;
short product;
enum touchpad_model model;
};
-enum touchpad_state {
+enum touchpad_state
+{
TOUCHPAD_STATE_NONE = 0,
TOUCHPAD_STATE_TOUCH,
TOUCHPAD_STATE_PRESS
#define TOUCHPAD_HISTORY_LENGTH 4
-struct touchpad_motion {
+struct touchpad_motion
+{
int32_t x;
int32_t y;
};
-enum touchpad_fingers_state {
+enum touchpad_fingers_state
+{
TOUCHPAD_FINGERS_ONE = (1 << 0),
TOUCHPAD_FINGERS_TWO = (1 << 1),
TOUCHPAD_FINGERS_THREE = (1 << 2)
};
-struct touchpad_dispatch {
+struct touchpad_dispatch
+{
struct evdev_dispatch base;
struct evdev_input_device *device;
int reset;
- struct {
+ struct
+ {
int32_t x;
int32_t y;
} hw_abs;
int has_pressure;
- struct {
+ struct
+ {
int32_t touch_low;
int32_t touch_high;
int32_t press;
} pressure;
- struct {
+ struct
+ {
int32_t margin_x;
int32_t margin_y;
int32_t center_x;
struct wl_list motion_filters;
};
-struct motion_params {
- double dx, dy;
+struct motion_params
+{
+ double dx;
+ double dy;
};
struct motion_filter;
-struct motion_filter_interface {
+struct motion_filter_interface
+{
void (*filter)(struct motion_filter *filter,
- struct motion_params *motion,
- void *data, uint32_t time);
+ struct motion_params *motion,
+ void *data, uint32_t time);
void (*destroy)(struct motion_filter *filter);
};
-struct motion_filter {
+struct motion_filter
+{
struct motion_filter_interface *interface;
struct wl_list link;
};
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
- void *data,
- double velocity,
- uint32_t time);
+ void *data,
+ double velocity,
+ uint32_t time);
-struct pointer_tracker {
+struct pointer_tracker
+{
double dx;
double dy;
uint32_t time;
int dir;
};
-struct pointer_accelerator {
+struct pointer_accelerator
+{
struct motion_filter base;
accel_profile_func_t profile;
int cur_tracker;
};
-enum directions {
- N = 1 << 0,
+enum directions
+{
+ N = 1 << 0,
NE = 1 << 1,
- E = 1 << 2,
+ E = 1 << 2,
SE = 1 << 3,
- S = 1 << 4,
+ S = 1 << 4,
SW = 1 << 5,
- W = 1 << 6,
+ W = 1 << 6,
NW = 1 << 7,
UNDEFINED_DIRECTION = 0xff
};
private:
static int handleInputEvent(int fd, uint32_t mask, void *data);
static void processEvents(struct evdev_input_device *device,
- struct input_event *ev, int count);
+ struct input_event *ev, int count);
// Default event handler
static void evdevProcessRelative(struct evdev_input_device *device,
- uint32_t time, struct input_event *e);
+ uint32_t time, struct input_event *e);
static void evdevProcessAbsolute(struct evdev_input_device *device,
- struct input_event *e);
+ struct input_event *e);
static void evdevProcessKey(struct evdev_input_device *device,
uint32_t time, struct input_event *e);
struct evdev_input_device *device,
struct input_event *e);
static void touchpadProcessKey(struct touchpad_dispatch *touchpad,
- struct evdev_input_device *device,
- struct input_event *e,
- uint32_t time);
+ struct evdev_input_device *device,
+ struct input_event *e,
+ uint32_t time);
static void touchpadUpdateState(struct touchpad_dispatch *touchpad,
uint32_t time);
// Notifier
static void notifyButton(struct evdev_input_device *device, uint32_t time,
- int32_t button, enum wl_pointer_button_state state);
+ int32_t button, enum wl_pointer_button_state state);
static void notifyMotion(struct evdev_input_device *device, uint32_t time,
- wl_fixed_t fx, wl_fixed_t fy);
+ wl_fixed_t fx, wl_fixed_t fy);
static void notifyKey(struct evdev_input_device *device, uint32_t time,
- uint32_t key, enum wl_keyboard_key_state state,
- bool bUpdateAutomatic);
+ uint32_t key, enum wl_keyboard_key_state state,
+ bool bUpdateAutomatic);
static void notifyTouch(struct evdev_input_device *device);
bool addDevices();
void createInputDevice(struct wl_display *display, const char *path);
int configureDevice(struct evdev_input_device *device);
void dispatchProcess(struct evdev_input_device *device,
- struct input_event *ev,
- uint32_t time);
+ struct input_event *ev,
+ uint32_t time);
void notifyKeyboardFocus();
void notifyKeyboardFocusIn(struct wl_array *keys, enum key_state_update updateState);
void updateModifierState(struct wl_seat *wlSeat, uint32_t serial, uint32_t key,
- enum wl_keyboard_key_state state);
+ enum wl_keyboard_key_state state);
void notifyModifiers(struct wl_seat *wlSeat, uint32_t serial);
struct evdev_dispatch* createTouchpad(struct evdev_input_device *device);
void configureTouchpad(struct touchpad_dispatch *touchpad,
- struct evdev_input_device *device);
-
+ struct evdev_input_device *device);
};
#endif /* _WAYLANDEVDEVINPUTEVENT_H_ */
#define _WAYLANDFBDEVWINDOWSYSTEM_H_
#include "WindowSystems/WaylandBaseWindowSystem.h"
-class WaylandFbdevWindowSystem: public WaylandBaseWindowSystem
+class WaylandFbdevWindowSystem : public WaylandBaseWindowSystem
{
public:
WaylandFbdevWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager);
struct wl_resource* m_wlTouchFocusResource;
struct wl_listener m_wlTouchFocusResourceListener;
- struct {
+ struct
+ {
struct wl_pointer wlPointer;
struct wl_keyboard wlKeyboard;
struct wl_touch wlTouch;
const struct wl_touch *touchDevice() const;
void sendMousePressEvent(const Point& globalPos, const Point& localPos,
- uint32_t button, uint32_t time);
+ uint32_t button, uint32_t time);
void sendMouseReleaseEvent(const Point& globalPos, const Point& localPos,
- uint32_t button, uint32_t time);
+ uint32_t button, uint32_t time);
void sendMouseMotionEvent(struct wl_surface *surface,
- const Point& globalPos, const Point& localPos, uint32_t time);
+ const Point& globalPos, const Point& localPos, uint32_t time);
void sendKeyPressEvent(struct wl_surface *surface, uint32_t time, uint32_t code);
void sendKeyReleaseEvent(struct wl_surface *surface, uint32_t time, uint32_t code);
void setKeyboardFocus(struct wl_surface *surface);
void sendTouchPointEvent(struct wl_surface *surface, uint32_t time,
- int touchId, int touchState, const Point& touchPos);
+ int touchId, int touchState, const Point& touchPos);
void sendTouchFrameEvent();
void sendTouchCancelEvent();
void cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev);
void setMouseFocus(struct wl_surface *surface,
- const Point& globalPos,
- const Point& localPos);
+ const Point& globalPos,
+ const Point& localPos);
void sendMouseMotionEvent(const Point& globalPos,
- const Point& localPos,
- uint32_t time);
+ const Point& localPos,
+ uint32_t time);
void setTouchFocus(struct wl_surface *surface);
static void destroyDeviceResource(struct wl_resource *resource);
static void getPointer(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id);
+ struct wl_resource *resource,
+ uint32_t id);
static void getKeyboard(struct wl_client *client,
struct wl_resource *resource,
uint32_t id);
static void getTouch(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id);
+ struct wl_resource *resource,
+ uint32_t id);
};
-inline struct wl_display* WaylandInputDevice::display() { return m_wlDisplay; }
-inline struct wl_seat* WaylandInputDevice::seat() { return &m_wlSeat; }
-inline bool WaylandInputDevice::hasPointer() const { return m_hasPointer; }
-inline bool WaylandInputDevice::hasKeyboard() const { return m_hasKeyboard; }
-inline bool WaylandInputDevice::hasTouch() const { return m_hasTouch; }
+inline struct wl_display* WaylandInputDevice::display()
+{
+ return m_wlDisplay;
+}
+
+inline struct wl_seat* WaylandInputDevice::seat()
+{
+ return &m_wlSeat;
+}
+
+inline bool WaylandInputDevice::hasPointer() const
+{
+ return m_hasPointer;
+}
+
+inline bool WaylandInputDevice::hasKeyboard() const
+{
+ return m_hasKeyboard;
+}
+
+inline bool WaylandInputDevice::hasTouch() const
+{
+ return m_hasTouch;
+}
inline struct wl_pointer* WaylandInputDevice::pointerDevice()
- { return &m_deviceInterfaces.wlPointer; }
+{
+ return &m_deviceInterfaces.wlPointer;
+}
+
inline struct wl_keyboard* WaylandInputDevice::keyboardDevice()
- { return &m_deviceInterfaces.wlKeyboard; }
+{
+ return &m_deviceInterfaces.wlKeyboard;
+}
+
inline struct wl_touch* WaylandInputDevice::touchDevice()
- { return &m_deviceInterfaces.wlTouch; }
+{
+ return &m_deviceInterfaces.wlTouch;
+}
inline const struct wl_pointer* WaylandInputDevice::pointerDevice() const
- { return &m_deviceInterfaces.wlPointer; }
+{
+ return &m_deviceInterfaces.wlPointer;
+}
+
inline const struct wl_keyboard* WaylandInputDevice::keyboardDevice() const
- { return &m_deviceInterfaces.wlKeyboard; }
+{
+ return &m_deviceInterfaces.wlKeyboard;
+}
+
inline const struct wl_touch* WaylandInputDevice::touchDevice() const
- { return &m_deviceInterfaces.wlTouch; }
+{
+ return &m_deviceInterfaces.wlTouch;
+}
#endif /* _WAYLANDINPUTDEVICE_H_ */
#include "config.h"
#include "WindowSystems/WaylandInputDevice.h"
-enum keyboard_modifier {
+enum keyboard_modifier
+{
MODIFIER_CTRL = (1 << 0),
MODIFIER_ALT = (1 << 1),
MODIFIER_SUPER = (1 << 2),
MODIFIER_SHIFT = (1 << 3)
};
-enum keyboard_led {
+enum keyboard_led
+{
LED_NUM_LOCK = (1 << 0),
LED_CAPS_LOCK = (1 << 1),
LED_SCROLL_LOCK = (1 << 2)
struct wl_event_source *m_wlEventSource;
int m_fd;
- struct weston_xkb_info {
+ struct weston_xkb_info
+ {
struct xkb_keymap *keymap;
int keymap_fd;
size_t keymap_size;
xkb_led_index_t scroll_led;
} m_xkbInfo;
- struct weston_xkb_state {
+ struct weston_xkb_state
+ {
struct xkb_state *state;
enum keyboard_led leds;
} m_xkbState;
void buildGlobalKeymap();
};
-inline WaylandInputDevice& WaylandInputEvent::inputDevice() const { return *m_inputDevice; }
-inline WaylandBaseWindowSystem& WaylandInputEvent::windowSystem() const { return *m_windowSystem; }
+inline WaylandInputDevice& WaylandInputEvent::inputDevice() const
+{
+ return *m_inputDevice;
+}
+inline WaylandBaseWindowSystem& WaylandInputEvent::windowSystem() const
+{
+ return *m_windowSystem;
+}
#endif /* _WAYLANDINPUTEVENT_H_ */
/***************************************************************************
*
- * Copyright 2010, 2011 BMW Car IT GmbH
+ * Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
****************************************************************************/
-#ifndef WAYLAND_SERVERINFO_SERVER_PROTOCOL_H
-#define WAYLAND_SERVERINFO_SERVER_PROTOCOL_H
+#ifndef WAYLANDSERVERINFOSERVERPROTOCOL_H
+#define WAYLANDSERVERINFOSERVERPROTOCOL_H
#ifdef __cplusplus
extern "C" {
extern const struct wl_interface serverinfo_interface;
-struct serverinfo_interface {
- void (*get_connection_id)(struct wl_client *client,
- struct wl_resource *resource);
+struct serverinfo_interface
+{
+ void (*get_connection_id)(struct wl_client *client,
+ struct wl_resource *resource);
};
-#define SERVERINFO_CONNECTION_ID 0
+#define SERVERINFO_CONNECTION_ID 0
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* WAYLANDSERVERINFOSERVERPROTOCOL_H */
#include <wayland-server.h>
#include <xcb/xcb.h>
#ifdef HAVE_XCB_XKB // XCB-XKB Extension: not required
- #define explicit tmpexplicit
- #include <xcb/xkb.h>
- #undef explicit
+# define explicit tmpexplicit
+# include <xcb/xkb.h>
+# undef explicit
#endif
#include <xkbcommon/xkbcommon.h>
#include <X11/Xlib.h>
//////////////////////////////////////////////////////////////////////////////
extern "C"
{
- struct atom_ {
- xcb_atom_t xkbNames;
- xcb_atom_t string;
- };
+struct atom_
+{
+ xcb_atom_t xkbNames;
+ xcb_atom_t string;
+};
}
//////////////////////////////////////////////////////////////////////////////
uint8_t xkbEventBase();
};
-inline bool WaylandX11InputEvent::hasXkb() { return m_hasXkb; }
-inline xcb_connection_t* WaylandX11InputEvent::connection() { return m_xcbConn; }
-inline uint8_t WaylandX11InputEvent::xkbEventBase() { return m_xkbEventBase; }
+inline bool WaylandX11InputEvent::hasXkb()
+{
+ return m_hasXkb;
+}
+
+inline xcb_connection_t* WaylandX11InputEvent::connection()
+{
+ return m_xcbConn;
+}
+
+inline uint8_t WaylandX11InputEvent::xkbEventBase()
+{
+ return m_xkbEventBase;
+}
#endif /* _WAYLANDX11INPUTEVENT_H_ */
#include <EGL/egl.h>
#include <EGL/eglext.h>
-class WaylandX11WindowSystem: public WaylandBaseWindowSystem
+class WaylandX11WindowSystem : public WaylandBaseWindowSystem
{
public:
WaylandX11WindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager);
Colormap m_x11Colormap;
};
-inline Display* WaylandX11WindowSystem::x11Display() const { return m_x11Display; }
+inline Display* WaylandX11WindowSystem::x11Display() const
+{
+ return m_x11Display;
+}
#endif /* _WAYLANDX11WINDOWSYSTEM_H_ */
UNKOWN_STATE
} X11WindowSystemStates;
-class X11WindowSystem: public BaseWindowSystem
+class X11WindowSystem : public BaseWindowSystem
{
public:
- X11WindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager, GetVisualInfoFunction func = X11WindowSystem::getDefaultVisual);
+ X11WindowSystem(const char* displayname,
+ int width,
+ int height,
+ Scene* pScene,
+ InputManager* pInputManager,
+ GetVisualInfoFunction func = X11WindowSystem::getDefaultVisual);
virtual ~X11WindowSystem();
bool init(BaseGraphicSystem<Display*, Window>* sys);
bool start();
static XVisualInfo * getDefaultVisual(Display *dpy);
void signalRedrawEvent();
void wakeUpRendererThread();
- void setSystemState (X11WindowSystemStates state);
- X11WindowSystemStates getSystemState ();
+ void setSystemState(X11WindowSystemStates state);
+ X11WindowSystemStates getSystemState();
Display* getNativeDisplayHandle();
Window getCompositorNativeWindowHandle();
virtual void allocatePlatformSurface(Surface *surface);
int resolutionWidth;
int resolutionHeight;
static int composite_opcode;
- int composite_event, composite_error;
- int composite_major, composite_minor;
+ int composite_event;
+ int composite_error;
+ int composite_major;
+ int composite_minor;
static int damage_opcode;
- int damage_event, damage_error;
- int damage_major, damage_minor;
+ int damage_event;
+ int damage_error;
+ int damage_major;
+ int damage_minor;
static const char CompositorWindowTitle[];
- bool m_running;
+ bool m_running;
/* bool m_initialized; */
bool m_success;
X11WindowSystemStates m_systemState;
// Window background;
Window CompositorWindow;
XVisualInfo* windowVis;
- float m_fpsinterval;
+ float m_fpsinterval;
pthread_mutex_t run_lock;
pthread_mutex_t init_lock;
pthread_cond_t init_condition;
virtual void RedrawAllLayers(bool clear, bool swap);
virtual void renderHWLayer(Layer* layer);
virtual void calculateFps();
- virtual void calculateSurfaceFps(Surface *currentSurface, float time) ;
+ virtual void calculateSurfaceFps(Surface *currentSurface, float time);
private:
void cleanup();
void Screenshot();
void ManageXInputEvent(InputDevice type, InputEventState state, XEvent *pevent);
static bool m_xerror;
-
friend void * X11eventLoopCallback(void *);
};
-inline void X11WindowSystem::setSystemState (X11WindowSystemStates state)
+inline void X11WindowSystem::setSystemState(X11WindowSystemStates state)
{
m_systemState = state;
}
-inline X11WindowSystemStates X11WindowSystem::getSystemState ()
+inline X11WindowSystemStates X11WindowSystem::getSystemState()
{
return m_systemState;
}
#include <libudev.h>
static drmModeModeInfo builtin_800x480_for_Crossville = {
- 31746,
- 800, 859, 999, 999, 0,
- 480, 507, 538, 524, 0,
- 0,
- DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC,
- 0,
- "800x480"
+ 31746,
+ 800, 859, 999, 999, 0,
+ 480, 507, 538, 524, 0,
+ 0,
+ DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC,
+ 0,
+ "800x480"
};
static void
pageFlipHandler(int /*fd*/, unsigned int /*frame*/, unsigned int /*sec*/,
- unsigned int /*usec*/, void *data)
+ unsigned int /*usec*/, void *data)
{
- struct DrmOutput *output = static_cast<struct DrmOutput*>(data);
+ struct DrmOutput *output = static_cast<struct DrmOutput*>(data);
- output->pageFlipPending = 0;
+ output->pageFlipPending = 0;
- if (output->current)
- {
- gbm_surface_release_buffer(output->surface, output->current->bo);
- }
+ if (output->current)
+ {
+ gbm_surface_release_buffer(output->surface, output->current->bo);
+ }
- output->current = output->next;
- output->next = NULL;
+ output->current = output->next;
+ output->next = NULL;
- if (output->windowSystem)
- {
- output->windowSystem->finishFrame();
- }
+ if (output->windowSystem)
+ {
+ output->windowSystem->finishFrame();
+ }
}
static int
onDrmInput(int fd, uint32_t /*mask*/, void * /*data*/)
{
- drmEventContext evctx;
- memset(&evctx, 0, sizeof evctx);
+ drmEventContext evctx;
+ memset(&evctx, 0, sizeof evctx);
- evctx.version = DRM_EVENT_CONTEXT_VERSION;
- evctx.page_flip_handler = pageFlipHandler;
- evctx.vblank_handler = NULL;
+ evctx.version = DRM_EVENT_CONTEXT_VERSION;
+ evctx.page_flip_handler = pageFlipHandler;
+ evctx.vblank_handler = NULL;
- drmHandleEvent(fd, &evctx);
+ drmHandleEvent(fd, &evctx);
- return 1;
+ return 1;
}
static void
drmFbDestroyCallback(struct gbm_bo *bo, void *data)
{
- struct DrmFb *fb = (struct DrmFb*)data;
- struct gbm_device *gbm = gbm_bo_get_device(bo);
+ struct DrmFb *fb = (struct DrmFb*)data;
+ struct gbm_device *gbm = gbm_bo_get_device(bo);
- if (fb->fbId)
- drmModeRmFB(gbm_device_get_fd(gbm), fb->fbId);
+ if (fb->fbId)
+ drmModeRmFB(gbm_device_get_fd(gbm), fb->fbId);
- free(data);
+ free(data);
}
struct DrmFb*
drmFbGetFromBo(struct gbm_bo *bo, int fdDev, struct DrmOutput *output)
{
- struct DrmFb *fb = (struct DrmFb*)gbm_bo_get_user_data(bo);
- uint32_t width, height, stride, handle;
- int ret;
-
- if (fb)
- return fb;
-
- fb = (struct DrmFb*)malloc(sizeof *fb);
- fb->bo = bo;
- fb->output = output;
-
- width = gbm_bo_get_width(bo);
- height = gbm_bo_get_height(bo);
- stride = gbm_bo_get_stride(bo);
- handle = gbm_bo_get_handle(bo).u32;
-
- ret = drmModeAddFB(fdDev, width, height, 24, 32, stride, handle, &fb->fbId);
- if (ret)
- {
- return NULL;
- }
+ struct DrmFb *fb = (struct DrmFb*)gbm_bo_get_user_data(bo);
+ uint32_t width;
+ uint32_t height;
+ uint32_t stride;
+ uint32_t handle;
+ int ret;
+
+ if (fb)
+ return fb;
+
+ fb = (struct DrmFb*)malloc(sizeof *fb);
+ fb->bo = bo;
+ fb->output = output;
+
+ width = gbm_bo_get_width(bo);
+ height = gbm_bo_get_height(bo);
+ stride = gbm_bo_get_stride(bo);
+ handle = gbm_bo_get_handle(bo).u32;
+
+ ret = drmModeAddFB(fdDev, width, height, 24, 32, stride, handle, &fb->fbId);
+ if (ret)
+ {
+ return NULL;
+ }
- gbm_bo_set_user_data(bo, fb, drmFbDestroyCallback);
+ gbm_bo_set_user_data(bo, fb, drmFbDestroyCallback);
- return fb;
+ return fb;
}
DrmGLESGraphicSystem::DrmGLESGraphicSystem(int windowWidth, int windowHeight,
{
LOG_DEBUG("DrmGLESGraphicSystem", "creating DrmGLESGraphicSystem");
- m_pfEglBindWaylandDisplayWL = (PFNEGLBINDWAYLANDDISPLAYWL)eglGetProcAddress("eglBindWaylandDisplayWL");
- m_pfEglUnbindWaylandDisplayWL = (PFNEGLUNBINDWAYLANDDISPLAYWL)eglGetProcAddress("eglUnbindWaylandDisplayWL");
+ m_pfEglBindWaylandDisplayWL = (PFNEGLBINDWAYLANDDISPLAYWL)eglGetProcAddress("eglBindWaylandDisplayWL");
+ m_pfEglUnbindWaylandDisplayWL = (PFNEGLUNBINDWAYLANDDISPLAYWL)eglGetProcAddress("eglUnbindWaylandDisplayWL");
- if (!m_pfEglBindWaylandDisplayWL ||
- !m_pfEglUnbindWaylandDisplayWL)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "Query EGL extensions failed.");
- }
+ if (!m_pfEglBindWaylandDisplayWL ||
+ !m_pfEglUnbindWaylandDisplayWL)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "Query EGL extensions failed.");
+ }
}
DrmGLESGraphicSystem::~DrmGLESGraphicSystem()
{
- WaylandBaseWindowSystem* windowSystem = dynamic_cast<WaylandBaseWindowSystem*>(m_baseWindowSystem);
- struct wl_display* wlDisplay = windowSystem->getNativeDisplayHandle();
-
- if (NULL != m_eglContext)
- {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- m_eglContext = NULL;
- }
-
- struct DrmOutput* output = NULL;
- wl_list_for_each(output, &m_outputList, link) {
- if (NULL != output->eglSurface)
- {
- eglDestroySurface(m_eglDisplay, output->eglSurface);
- output->eglSurface = NULL;
- }
-
- if (NULL != output->surface)
- {
- gbm_surface_destroy(output->surface);
- output->surface = NULL;
- }
- free(output);
- }
-
- if (wlDisplay)
- m_pfEglUnbindWaylandDisplayWL(m_eglDisplay, wlDisplay);
+ WaylandBaseWindowSystem* windowSystem = dynamic_cast<WaylandBaseWindowSystem*>(m_baseWindowSystem);
+ struct wl_display* wlDisplay = windowSystem->getNativeDisplayHandle();
+
+ if (NULL != m_eglContext)
+ {
+ eglDestroyContext(m_eglDisplay, m_eglContext);
+ m_eglContext = NULL;
+ }
+
+ struct DrmOutput* output = NULL;
+ wl_list_for_each(output, &m_outputList, link)
+ {
+ if (NULL != output->eglSurface)
+ {
+ eglDestroySurface(m_eglDisplay, output->eglSurface);
+ output->eglSurface = NULL;
+ }
+
+ if (NULL != output->surface)
+ {
+ gbm_surface_destroy(output->surface);
+ output->surface = NULL;
+ }
+ free(output);
+ }
+
+ if (wlDisplay)
+ m_pfEglUnbindWaylandDisplayWL(m_eglDisplay, wlDisplay);
}
bool DrmGLESGraphicSystem::init(EGLNativeDisplayType display, EGLNativeWindowType NativeWindow)
{
- bool ret = true;
- LOG_DEBUG("DrmGLESGraphicSystem", "init..display:" << display <<
- ", NativeWindow:" << NativeWindow);
-
- m_nativeDisplay = display;
- m_nativeWindow = NativeWindow;
-
- wl_list_init(&m_outputList);
-
- m_gbm = (gbm_device*)display;
- if (m_gbm == NULL)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "gbm device is NULL.");
- return false;
- }
-
- m_fdDev = gbm_device_get_fd(m_gbm);
- if (m_fdDev < 0)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to get device fd.");
- return false;
- }
-
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_gbm);
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to get EGL display.");
- return false;
- }
-
- EGLint major, minor;
- if (!eglInitialize(m_eglDisplay, &major, &minor))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to initialising EGL.");
- return false;
- }
-
- static const EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RED_SIZE, 1,
- EGL_GREEN_SIZE, 1,
- EGL_BLUE_SIZE, 1,
- EGL_ALPHA_SIZE, 0,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_NONE
- };
- EGLint n = 0;
- if (!eglChooseConfig(m_eglDisplay, configAttribs, &m_eglConfig, 1, &n) || n != 1)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to choose config.");
- return false;
- }
-
- if (!initializeSystem())
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to initialize system.");
- return false;
- }
-
- if (!GLESGraphicsystem::initOpenGLES(m_windowWidth, m_windowHeight))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to initialize gles.");
- return false;
- }
+ bool ret = true;
+ LOG_DEBUG("DrmGLESGraphicSystem", "init..display:" << display <<
+ ", NativeWindow:" << NativeWindow);
+
+ m_nativeDisplay = display;
+ m_nativeWindow = NativeWindow;
+
+ wl_list_init(&m_outputList);
+
+ m_gbm = (gbm_device*)display;
+ if (m_gbm == NULL)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "gbm device is NULL.");
+ return false;
+ }
+
+ m_fdDev = gbm_device_get_fd(m_gbm);
+ if (m_fdDev < 0)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to get device fd.");
+ return false;
+ }
+
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_gbm);
+ if (m_eglDisplay == EGL_NO_DISPLAY)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to get EGL display.");
+ return false;
+ }
+
+ EGLint major;
+ EGLint minor;
+ if (!eglInitialize(m_eglDisplay, &major, &minor))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to initialising EGL.");
+ return false;
+ }
+
+ static const EGLint configAttribs[] = {
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RED_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_BLUE_SIZE, 1,
+ EGL_ALPHA_SIZE, 0,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE
+ };
+ EGLint n = 0;
+ if (!eglChooseConfig(m_eglDisplay, configAttribs, &m_eglConfig, 1, &n) || n != 1)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to choose config.");
+ return false;
+ }
+
+ if (!initializeSystem())
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to initialize system.");
+ return false;
+ }
+
+ if (!GLESGraphicsystem::initOpenGLES(m_windowWidth, m_windowHeight))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to initialize gles.");
+ return false;
+ }
return ret;
}
{
LOG_DEBUG("DrmGLESGraphicSystem", "initializeSystem IN");
- WaylandBaseWindowSystem* windowSystem = dynamic_cast<WaylandBaseWindowSystem*>(m_baseWindowSystem);
- struct wl_display* wlDisplay = windowSystem->getNativeDisplayHandle();
+ WaylandBaseWindowSystem* windowSystem = dynamic_cast<WaylandBaseWindowSystem*>(m_baseWindowSystem);
+ struct wl_display* wlDisplay = windowSystem->getNativeDisplayHandle();
- // bind display
- m_pfEglBindWaylandDisplayWL(m_eglDisplay, wlDisplay);
+ // bind display
+ m_pfEglBindWaylandDisplayWL(m_eglDisplay, wlDisplay);
- if (!createOutputs())
- return false;
+ if (!createOutputs())
+ return false;
- if (!eglBindAPI(EGL_OPENGL_ES_API))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to bind api EGL_OPENGL_ES_API.");
- return false;
- }
+ if (!eglBindAPI(EGL_OPENGL_ES_API))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to bind api EGL_OPENGL_ES_API.");
+ return false;
+ }
- EGLint contextAttrs[] = {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
+ EGLint contextAttrs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttrs);
- if (!m_eglContext)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to create EGL context.");
- return false;
- }
+ m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttrs);
+ if (!m_eglContext)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to create EGL context.");
+ return false;
+ }
- struct DrmOutput *output = wl_container_of(m_outputList.prev, output, link);
+ struct DrmOutput *output = wl_container_of(m_outputList.prev, output, link);
- if (!eglMakeCurrent(m_eglDisplay, output->eglSurface, output->eglSurface, m_eglContext))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to make context current.");
- return false;
- }
+ if (!eglMakeCurrent(m_eglDisplay, output->eglSurface, output->eglSurface, m_eglContext))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to make context current.");
+ return false;
+ }
- struct wl_event_loop *loop = wl_display_get_event_loop(wlDisplay);
- wl_event_loop_add_fd(loop, m_fdDev, WL_EVENT_READABLE, onDrmInput, NULL);
+ struct wl_event_loop *loop = wl_display_get_event_loop(wlDisplay);
+ wl_event_loop_add_fd(loop, m_fdDev, WL_EVENT_READABLE, onDrmInput, NULL);
LOG_DEBUG("DrmGLESGraphicSystem", "initializeSystem OUT");
- return true;
+ return true;
}
bool DrmGLESGraphicSystem::createOutputs()
{
LOG_DEBUG("DrmGLESGraphicSystem", "createOutputs IN");
- drmModeConnector* connector;
- drmModeRes* resources;
- int x = 0, y = 0;
-
- resources = drmModeGetResources(m_fdDev);
- if (!resources)
- {
- LOG_DEBUG("DrmGLESGraphicSystem", "drmModeGetResources failed.");
- return false;
- }
-
- m_crtcs = (uint32_t*)calloc(resources->count_crtcs, sizeof(uint32_t));
- if (!m_crtcs)
- {
- drmModeFreeResources(resources);
- return false;
- }
- m_crtcsNum = resources->count_crtcs;
-
- memcpy(m_crtcs, resources->crtcs, sizeof(uint32_t) * m_crtcsNum);
-
- for (int ii = 0; ii < resources->count_connectors; ++ii)
- {
- connector = drmModeGetConnector(m_fdDev, resources->connectors[ii]);
- if (connector == NULL)
- continue;
-
- if (connector->connection == DRM_MODE_CONNECTED)
- {
- if (createOutputForConnector(resources, connector, x, y) < 0)
- {
- drmModeFreeConnector(connector);
- continue;
- }
-
- //x += container_of(m_outputList.prev, struct DrmOutput, link)->currentMode->width;
- }
-
- drmModeFreeConnector(connector);
- }
-
- if (wl_list_empty(&m_outputList))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "DrmOutput list is empty.");
- drmModeFreeResources(resources);
- return false;
- }
-
- drmModeFreeResources(resources);
+ drmModeConnector* connector;
+ drmModeRes* resources;
+ int x = 0, y = 0;
+
+ resources = drmModeGetResources(m_fdDev);
+ if (!resources)
+ {
+ LOG_DEBUG("DrmGLESGraphicSystem", "drmModeGetResources failed.");
+ return false;
+ }
+
+ m_crtcs = (uint32_t*)calloc(resources->count_crtcs, sizeof(uint32_t));
+ if (!m_crtcs)
+ {
+ drmModeFreeResources(resources);
+ return false;
+ }
+ m_crtcsNum = resources->count_crtcs;
+
+ memcpy(m_crtcs, resources->crtcs, sizeof(uint32_t) * m_crtcsNum);
+
+ for (int ii = 0; ii < resources->count_connectors; ++ii)
+ {
+ connector = drmModeGetConnector(m_fdDev, resources->connectors[ii]);
+ if (connector == NULL)
+ continue;
+
+ if (connector->connection == DRM_MODE_CONNECTED)
+ {
+ if (createOutputForConnector(resources, connector, x, y) < 0)
+ {
+ drmModeFreeConnector(connector);
+ continue;
+ }
+
+ //x += container_of(m_outputList.prev, struct DrmOutput, link)->currentMode->width;
+ }
+
+ drmModeFreeConnector(connector);
+ }
+
+ if (wl_list_empty(&m_outputList))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "DrmOutput list is empty.");
+ drmModeFreeResources(resources);
+ return false;
+ }
+
+ drmModeFreeResources(resources);
LOG_DEBUG("DrmGLESGraphicSystem", "createOutputs OUT");
- return true;
+ return true;
}
int DrmGLESGraphicSystem::createOutputForConnector(drmModeRes* resources,
- drmModeConnector* connector,
- int, int)
+ drmModeConnector* connector,
+ int, int)
{
- LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector IN");
- int ii;
- drmModeEncoder* encoder;
- struct DrmMode* drmMode = NULL;
-
- encoder = drmModeGetEncoder(m_fdDev, connector->encoders[0]);
- if (encoder == NULL){
- LOG_ERROR("DrmGLESGraphicSystem", "No encoder for connector.");
- return -1;
- }
-
- for (ii = 0; ii < resources->count_crtcs; ++ii)
- {
- if (encoder->possible_crtcs & (1 << ii) &&
- !(m_crtcAllocator & (1 << resources->crtcs[ii])))
- {
- break;
- }
- }
- if (ii == resources->count_crtcs)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "No usable crtc for encoder.");
- return -1;
- }
-
- DrmOutput* output = (DrmOutput*)malloc(sizeof *output);
- if (output == NULL)
- {
- drmModeFreeEncoder(encoder);
- return -1;
- }
- memset(output, 0x00, sizeof *output);
-
- output->windowSystem = m_baseWindowSystem;
- output->fdDev = m_fdDev;
- output->crtcID = resources->crtcs[ii];
- output->connectorID = connector->connector_id;
-
- m_crtcAllocator |= (1 << output->crtcID);
- m_connectorAllocator |= (1 << output->connectorID);
-
- wl_list_init(&output->modeList);
-
- output->orgCrtc = drmModeGetCrtc(m_fdDev, output->crtcID);
- drmModeFreeEncoder(encoder);
-
- for (ii = 0; ii < connector->count_modes; ++ii)
- {
- if (drmOutputAddMode(output, &connector->modes[ii]))
- goto err_free;
- }
-
- if (connector->count_modes == 0)
- {
- if (drmOutputAddMode(output, &builtin_800x480_for_Crossville))
- goto err_free;
- }
-
- drmMode = wl_container_of(output->modeList.next, drmMode, link);
- output->currentMode = drmMode;
- drmMode->flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
-
- output->surface = gbm_surface_create(m_gbm,
- output->currentMode->width,
- output->currentMode->height,
- GBM_BO_FORMAT_XRGB8888,
- GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
- if (!output->surface) {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to create gbm surface.");
- goto err_gbm_surface;
- }
-
- output->eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig,
- (EGLNativeWindowType)output->surface, NULL);
- if (output->eglSurface == EGL_NO_SURFACE) {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to create egl surface.");
- goto err_egl_surface;
- }
-
- output->screenID = (uint)wl_list_length(&m_outputList);
- m_currentOutput = output;
-
- wl_list_insert(m_outputList.prev, &output->link);
-
- LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector OUT (NORMAL)");
- return 0;
+ LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector IN");
+ int ii;
+ drmModeEncoder* encoder;
+ struct DrmMode* drmMode = NULL;
+
+ encoder = drmModeGetEncoder(m_fdDev, connector->encoders[0]);
+ if (encoder == NULL)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "No encoder for connector.");
+ return -1;
+ }
+
+ for (ii = 0; ii < resources->count_crtcs; ++ii)
+ {
+ if (encoder->possible_crtcs & (1 << ii) &&
+ !(m_crtcAllocator & (1 << resources->crtcs[ii])))
+ {
+ break;
+ }
+ }
+ if (ii == resources->count_crtcs)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "No usable crtc for encoder.");
+ return -1;
+ }
+
+ DrmOutput* output = (DrmOutput*)malloc(sizeof *output);
+ if (output == NULL)
+ {
+ drmModeFreeEncoder(encoder);
+ return -1;
+ }
+ memset(output, 0x00, sizeof *output);
+
+ output->windowSystem = m_baseWindowSystem;
+ output->fdDev = m_fdDev;
+ output->crtcID = resources->crtcs[ii];
+ output->connectorID = connector->connector_id;
+
+ m_crtcAllocator |= (1 << output->crtcID);
+ m_connectorAllocator |= (1 << output->connectorID);
+
+ wl_list_init(&output->modeList);
+
+ output->orgCrtc = drmModeGetCrtc(m_fdDev, output->crtcID);
+ drmModeFreeEncoder(encoder);
+
+ for (ii = 0; ii < connector->count_modes; ++ii)
+ {
+ if (drmOutputAddMode(output, &connector->modes[ii]))
+ goto err_free;
+ }
+
+ if (connector->count_modes == 0)
+ {
+ if (drmOutputAddMode(output, &builtin_800x480_for_Crossville))
+ goto err_free;
+ }
+
+ drmMode = wl_container_of(output->modeList.next, drmMode, link);
+ output->currentMode = drmMode;
+ drmMode->flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
+
+ output->surface = gbm_surface_create(m_gbm,
+ output->currentMode->width,
+ output->currentMode->height,
+ GBM_BO_FORMAT_XRGB8888,
+ GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+ if (!output->surface)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to create gbm surface.");
+ goto err_gbm_surface;
+ }
+
+ output->eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig,
+ (EGLNativeWindowType)output->surface, NULL);
+ if (output->eglSurface == EGL_NO_SURFACE)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to create egl surface.");
+ goto err_egl_surface;
+ }
+
+ output->screenID = (uint)wl_list_length(&m_outputList);
+ m_currentOutput = output;
+
+ wl_list_insert(m_outputList.prev, &output->link);
+
+ LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector OUT (NORMAL)");
+ return 0;
err_egl_surface:
- if (output->eglSurface)
- eglDestroySurface(m_eglDisplay, output->eglSurface);
+ if (output->eglSurface)
+ eglDestroySurface(m_eglDisplay, output->eglSurface);
err_gbm_surface:
- if (output->surface)
- gbm_surface_destroy(output->surface);
+ if (output->surface)
+ gbm_surface_destroy(output->surface);
err_free:
- drmModeFreeCrtc(output->orgCrtc);
- m_crtcAllocator &= ~(1 << output->crtcID);
- m_connectorAllocator &= ~(1 << output->connectorID);
+ drmModeFreeCrtc(output->orgCrtc);
+ m_crtcAllocator &= ~(1 << output->crtcID);
+ m_connectorAllocator &= ~(1 << output->connectorID);
- free(output);
- LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector OUT (ERROR)");
- return -1;
+ free(output);
+ LOG_DEBUG("DrmGLESGraphicSystem", "createOutputForConnector OUT (ERROR)");
+ return -1;
}
int DrmGLESGraphicSystem::drmOutputAddMode(struct DrmOutput* output, drmModeModeInfo* info)
{
- struct DrmMode* mode;
+ struct DrmMode* mode;
- mode = (struct DrmMode*)malloc(sizeof *mode);
- if (mode == NULL)
- return -1;
+ mode = (struct DrmMode*)malloc(sizeof *mode);
+ if (mode == NULL)
+ return -1;
- mode->flags = 0;
- mode->width = info->hdisplay;
- mode->height = info->vdisplay;
- mode->refresh = info->vrefresh;
- mode->modeInfo = *info;
- wl_list_insert(output->modeList.prev, &mode->link);
+ mode->flags = 0;
+ mode->width = info->hdisplay;
+ mode->height = info->vdisplay;
+ mode->refresh = info->vrefresh;
+ mode->modeInfo = *info;
+ wl_list_insert(output->modeList.prev, &mode->link);
- return 0;
+ return 0;
}
int DrmGLESGraphicSystem::drmOutputPrepareRender(struct DrmOutput* output)
{
- if (!eglMakeCurrent(m_eglDisplay, output->eglSurface, output->eglSurface, m_eglContext))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to make current.");
- return -1;
- }
- return 0;
+ if (!eglMakeCurrent(m_eglDisplay, output->eglSurface, output->eglSurface, m_eglContext))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to make current.");
+ return -1;
+ }
+ return 0;
}
void DrmGLESGraphicSystem::swapBuffers()
{
LOG_DEBUG("DrmGLESGraphicSystem", "swapBuffers IN");
- struct DrmOutput* output = NULL;
-
- wl_list_for_each(output, &m_outputList, link)
- {
- if (output != m_currentOutput)
- {
- continue;
- }
-
- if (!output->next)
- {
- eglSwapBuffers(m_eglDisplay, output->eglSurface);
- struct gbm_bo *bo = gbm_surface_lock_front_buffer(output->surface);
- if (!bo)
- break;
-
- output->next = drmFbGetFromBo(bo, m_fdDev, output);
- if (!output->next)
- {
- gbm_surface_release_buffer(output->surface, bo);
- break;
- }
- }
-
- if (!output->current)
- {
- if (drmModeSetCrtc(m_fdDev, output->crtcID,
- output->next->fbId, 0, 0,
- &output->connectorID, 1,
- &output->currentMode->modeInfo))
- {
- LOG_ERROR("DrmGLESGraphicSystem", "failed to set mode in swapBuffers.");
- break;
- }
- }
-
- if (drmModePageFlip(m_fdDev, output->crtcID, output->next->fbId,
- DRM_MODE_PAGE_FLIP_EVENT, output) < 0)
- {
- LOG_ERROR("DrmGLESGraphicSystem", "queueing pageflip failed");
- break;
- }
-
- output->pageFlipPending = 1;
- break;
- }
+ struct DrmOutput* output = NULL;
+
+ wl_list_for_each(output, &m_outputList, link)
+ {
+ if (output != m_currentOutput)
+ {
+ continue;
+ }
+
+ if (!output->next)
+ {
+ eglSwapBuffers(m_eglDisplay, output->eglSurface);
+ struct gbm_bo *bo = gbm_surface_lock_front_buffer(output->surface);
+ if (!bo)
+ break;
+
+ output->next = drmFbGetFromBo(bo, m_fdDev, output);
+ if (!output->next)
+ {
+ gbm_surface_release_buffer(output->surface, bo);
+ break;
+ }
+ }
+
+ if (!output->current)
+ {
+ if (drmModeSetCrtc(m_fdDev, output->crtcID,
+ output->next->fbId, 0, 0,
+ &output->connectorID, 1,
+ &output->currentMode->modeInfo))
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "failed to set mode in swapBuffers.");
+ break;
+ }
+ }
+
+ if (drmModePageFlip(m_fdDev, output->crtcID, output->next->fbId,
+ DRM_MODE_PAGE_FLIP_EVENT, output) < 0)
+ {
+ LOG_ERROR("DrmGLESGraphicSystem", "queueing pageflip failed");
+ break;
+ }
+
+ output->pageFlipPending = 1;
+ break;
+ }
LOG_DEBUG("DrmGLESGraphicSystem", "swapBuffers OUT");
}
#include <algorithm>
static const float vertices[8 * 12] =
-{ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-
-0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
+{
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
+ 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
-1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
+ 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
-0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0
};
GLESGraphicsystem::GLESGraphicsystem(int windowWidth, int windowHeight, PfnShaderProgramCreator shaderProgram)
, m_texId(0)
{
LOG_DEBUG("GLESGraphicsystem", "creating GLESGraphicsystem");
- for (int i=0; i < OPT_COUNT; i++)
+ for (int i = 0; i < OPT_COUNT; i++)
{
m_optimizations[i] = OPT_MODE_HEURISTIC;
}
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
}
-void GLESGraphicsystem::releaseGraphicContext()
+void GLESGraphicsystem::releaseGraphicContext()
{
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
m_nativeDisplay = display;
m_nativeWindow = NativeWindow;
LOG_INFO("GLESGraphicsystem", "Initialisation");
- EGLint iMajorVersion, iMinorVersion;
+ EGLint iMajorVersion;
+ EGLint iMinorVersion;
LOG_DEBUG("GLESGraphicsystem", "Getting EGL Display with native display " << m_nativeDisplay);
m_eglDisplay = eglGetDisplay(m_nativeDisplay);
- if (m_eglDisplay == EGL_NO_DISPLAY){
+ if (m_eglDisplay == EGL_NO_DISPLAY)
+ {
LOG_ERROR("GLESGraphicsystem", "failed to Get EGL Display");
return false;
}
eglBindAPI(EGL_OPENGL_ES_API);
EGLint pi32ConfigAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_RED_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_NONE
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_NONE
};
LOG_DEBUG("GLESGraphicsystem", "EGLChooseConfig");
if (!m_eglSurface)
{
EGLenum status = eglGetError();
- LOG_ERROR("GLESGraphicsystem", "Window Surface creation failed with EGL Error Code: "<< status);
+ LOG_ERROR("GLESGraphicsystem", "Window Surface creation failed with EGL Error Code: " << status);
return false;
}
LOG_DEBUG("GLESGraphicsystem", "Window Surface creation successfull");
EGLint contextAttrs[] = {
- EGL_CONTEXT_CLIENT_VERSION,
- 2,
- EGL_NONE
+ EGL_CONTEXT_CLIENT_VERSION,
+ 2,
+ EGL_NONE
};
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, NULL, contextAttrs);
if (!m_eglContext)
{
- LOG_ERROR("GLESGraphicsystem","EGL couldn't create context\n");
+ LOG_ERROR("GLESGraphicsystem", "EGL couldn't create context\n");
return false;
}
LOG_DEBUG("GLESGraphicsystem", "EGL make current ...");
#define SHADERKEY_TRANSPARENCY_MASK(x) (0x1 << (SHADERKEY_TRANSPARENCY_SHIFT(x)))
unsigned int GLESGraphicsystem::shaderKey(int numSurfaces,
- int needsBlend,
- int hasTransparency0, int hasAlphaChannel0, int hasChromakey0,
- int hasTransparency1, int hasAlphaChannel1, int hasChromakey1,
- int hasTransparency2, int hasAlphaChannel2, int hasChromakey2,
- int hasTransparency3, int hasAlphaChannel3, int hasChromakey3)
+ int needsBlend,
+ int hasTransparency0, int hasAlphaChannel0, int hasChromakey0,
+ int hasTransparency1, int hasAlphaChannel1, int hasChromakey1,
+ int hasTransparency2, int hasAlphaChannel2, int hasChromakey2,
+ int hasTransparency3, int hasAlphaChannel3, int hasChromakey3)
{
return (((numSurfaces << SHADERKEY_NUM_SURF_SHIFT) & SHADERKEY_NUM_SURF_MASK) |
((needsBlend << SHADERKEY_BLEND_SHIFT) & SHADERKEY_BLEND_MASK) |
int needsBlend = ((key & SHADERKEY_BLEND_MASK) >> SHADERKEY_BLEND_SHIFT);
LOG_DEBUG("GLESGraphicsystem", "Key: " << std::hex << key
- << " numSurfaces:" << numSurfaces
- << " needsBlend:" << needsBlend);
+ << " numSurfaces:" << numSurfaces
+ << " needsBlend:" << needsBlend);
for (int i = 0; i < SHADERKEY_MAX_SURFACES; i++)
{
int hasAlphaChannel = ((key & SHADERKEY_ALPHA_CHANNEL_MASK(i)) >> SHADERKEY_ALPHA_CHANNEL_SHIFT(i));
int hasTransparency = ((key & SHADERKEY_TRANSPARENCY_MASK(i)) >> SHADERKEY_TRANSPARENCY_SHIFT(i));
LOG_DEBUG("GLESGraphicsystem", " Surface" << i << ":"
- << " hasTransparency:" << hasTransparency
- << " hasAlphaChannel:" << hasAlphaChannel
- << " hasChromakey:" << hasChromakey);
+ << " hasTransparency:" << hasTransparency
+ << " hasAlphaChannel:" << hasAlphaChannel
+ << " hasChromakey:" << hasChromakey);
}
}
if (layer->visibility && layer->opacity > 0.0)
{
SurfaceList surfaces = layer->getAllSurfaces();
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->renderPropertyChanged)
{
clearBackground();
}
- if ( layer->visibility && layer->opacity > 0.0 )
+ if (layer->visibility && layer->opacity > 0.0)
{
bool bChromaKeyEnabled = m_currentLayer->getChromaKeyEnabled();
if (bChromaKeyEnabled && !setupTextureForChromaKey())
}
SurfaceList surfaces = m_currentLayer->getAllSurfaces();
- for(std::list<Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (std::list<Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->hasNativeContent() && (*currentS)->visibility && (*currentS)->opacity>0.0f)
{
{
if ((int)id >= OPT_COUNT)
{
- return false;
+ return false;
}
if ((int)mode >= OPT_MODE_COUNT)
{
if ((int)id >= OPT_COUNT)
{
- return false;
+ return false;
}
*mode = m_optimizations[id];
{
// No layer rotation support currently for multitexture rendering
// No multitexture rendering if one layer has chromaKeyEnabled
- if ((*layer)->getOrientation() != 0 || (*layer)->getChromaKeyEnabled() )
+ if ((*layer)->getOrientation() != 0 || (*layer)->getChromaKeyEnabled())
{
return false;
}
}
// TODO, other custom shaders okay too.
- if ( (shader && shader != m_defaultShader) || (*surface)->getChromaKeyEnabled())
+ if ((shader && shader != m_defaultShader) || (*surface)->getChromaKeyEnabled())
{
return false;
}
static int count = 0;
count++;
- switch(m_optimizations[OPT_MULTITEXTURE])
+ switch (m_optimizations[OPT_MULTITEXTURE])
{
case OPT_MODE_FORCE_OFF:
return false;
// not always wise.
bool GLESGraphicsystem::useSkipClear(LayerList layers)
{
- float surfaceArea, displayArea, threshold;
+ float surfaceArea;
+ float displayArea;
+ float threshold;
SurfaceList surfaces;
static int count = 0;
count++;
- switch(m_optimizations[OPT_SKIP_CLEAR])
+ switch (m_optimizations[OPT_SKIP_CLEAR])
{
case OPT_MODE_FORCE_OFF:
return false;
displayArea = m_displayWidth * m_displayHeight;
surfaceArea = 0;
threshold = .75; // 75% (Needs to be refined by experimentation)
- for(LayerListConstIterator layer = layers.begin(); layer != layers.end(); layer++)
+ for (LayerListConstIterator layer = layers.begin(); layer != layers.end(); layer++)
{
surfaces = (*layer)->getAllSurfaces();
if (surfaces.size() == 0) continue;
if (!(*layer)->visibility || (*layer)->getOpacity() <= 0.0f) continue;
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->visibility == true && (*currentS)->getOpacity() > 0.0f)
{
static void incrementDrawCounters(LayerList layers)
{
- for(LayerListConstIterator layer = layers.begin(); layer != layers.end(); layer++)
+ for (LayerListConstIterator layer = layers.begin(); layer != layers.end(); layer++)
{
SurfaceList surfaces = (*layer)->getAllSurfaces();
if (surfaces.size() == 0) continue;
if (!(*layer)->visibility || (*layer)->getOpacity() <= 0.0f) continue;
- for(SurfaceListConstIterator surface = surfaces.begin(); surface != surfaces.end(); surface++)
+ for (SurfaceListConstIterator surface = surfaces.begin(); surface != surfaces.end(); surface++)
{
if ((*surface)->visibility == true && (*surface)->getOpacity() > 0.0f)
{
{
renderRegion(*region, false); //don't blend
}
- } else {
+ }
+ else
+ {
renderSWLayer(*layer, clear);
countersIncremented = true;
}
hastransparency[i] = ((*surface)->getOpacity() * layer->getOpacity()) < 1.0f;
hasalphachannel[i] = PixelFormatHasAlpha((*surface)->getPixelFormat());
- haschromakey[i] = (*surface)->getChromaKeyEnabled() ? 1:0 ;
+ haschromakey[i] = (*surface)->getChromaKeyEnabled() ? 1 : 0;
}
unsigned int key = shaderKey(numSurfaces,
LOG_WARNING("GLESGraphicsystem", "No optimal shader found for key=" << std::hex << key);
LOG_WARNING("GLESGraphicsystem", "Falling back to default shader");
- switch (numSurfaces) {
+ switch (numSurfaces)
+ {
case 0:
return m_defaultShaderClear;
case 1:
if (haschromakey[0])
{
return m_defaultShaderAddUniformChromaKey;
- } else {
+ }
+ else
+ {
return needsBlend ? m_defaultShader : m_defaultShaderNoBlend;
}
case 2:
shader = layerShader;
}
-
FloatRectangle targetSurfaceSource = surface->getTargetSourceRegion();
FloatRectangle targetSurfaceDestination = surface->getTargetDestinationRegion();
float textureCoordinates[4];
- ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource, surface->OriginalSourceWidth, surface->OriginalSourceHeight, textureCoordinates);
+ ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ textureCoordinates);
applyLayerMatrix(layerMatrix);
// update all common uniforms, scale values to display size
// offsets are generated w.r.t lower left corner (following GL conventions)
uniforms.x = targetSurfaceDestination.x / m_displayWidth;
- uniforms.y = 1.0f - (targetSurfaceDestination.y + targetSurfaceDestination.height) / m_displayHeight;;
+ uniforms.y = 1.0f - (targetSurfaceDestination.y + targetSurfaceDestination.height) / m_displayHeight;
uniforms.width = targetSurfaceDestination.width / m_displayWidth;
uniforms.height = targetSurfaceDestination.height / m_displayHeight;
uniforms.opacity[0] = (surface)->getOpacity() * m_currentLayer->getOpacity();
//We only know about specific Shaders, only do this if we start with the defaultShader
if (shader == m_defaultShader && uniforms.opacity[0] == 1.0f)
{
- if(!PixelFormatHasAlpha((surface)->getPixelFormat()))
+ if (!PixelFormatHasAlpha((surface)->getPixelFormat()))
{
//disable alpha blend completely
- glDisable (GL_BLEND);
+ glDisable(GL_BLEND);
}
else
{
//make sure alpha blend is enabled
- glEnable (GL_BLEND);
+ glEnable(GL_BLEND);
}
}
else
{
//make sure alpha blend is enabled
- glEnable (GL_BLEND);
+ glEnable(GL_BLEND);
}
{
SurfaceList sl;
sl.push_back(surface);
bool needblend = shader != m_defaultShader ||
- PixelFormatHasAlpha((surface)->getPixelFormat()) ||
- uniforms.opacity[0] < 1.0f;
+ PixelFormatHasAlpha((surface)->getPixelFormat()) ||
+ uniforms.opacity[0] < 1.0f;
shader = pickOptimizedShader(sl, needblend);
}
m_binder->unbindSurfaceTexture(surface);
glErrorCode = glGetError();
- if ( GL_NO_ERROR != glErrorCode )
+ if (GL_NO_ERROR != glErrorCode)
{
- LOG_ERROR("GLESGraphicsystem", "GL Error occured :" << glErrorCode );
+ LOG_ERROR("GLESGraphicsystem", "GL Error occured :" << glErrorCode);
};
}
// update all common uniforms, scale values to display size
// offsets are generated w.r.t lower left corner (following GL conventions)
uniforms.x = targetDestination.x / m_displayWidth;
- uniforms.y = 1.0f - (targetDestination.y + targetDestination.height) / m_displayHeight;;
+ uniforms.y = 1.0f - (targetDestination.y + targetDestination.height) / m_displayHeight;
uniforms.width = targetDestination.width / m_displayWidth;
uniforms.height = targetDestination.height / m_displayHeight;
uniforms.matrix = &identityMatrix.f[0];
// Set GL blend state (ignored for binary shaders)
if (blend)
{
- glEnable (GL_BLEND);
+ glEnable(GL_BLEND);
}
else
{
- glDisable (GL_BLEND);
+ glDisable(GL_BLEND);
}
shader->use();
}
glErrorCode = glGetError();
- if ( GL_NO_ERROR != glErrorCode )
+ if (GL_NO_ERROR != glErrorCode)
{
- LOG_ERROR("GLESGraphicsystem", "GL Error occured :" << glErrorCode );
+ LOG_ERROR("GLESGraphicsystem", "GL Error occured :" << glErrorCode);
return false;
};
// Render all surfaces in this region, performing as many rendering
// passes as necessary, each with up to MAX_MULTI_SURFACE surfaces.
SurfaceList surfaceBatch;
- for(SurfaceListConstIterator currentS = region->m_surfaces.begin(); currentS != region->m_surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = region->m_surfaces.begin(); currentS != region->m_surfaces.end(); currentS++)
{
surfaceBatch.push_back(*currentS);
}
}
-struct OrderedSurface {
+struct OrderedSurface
+{
Surface *surface;
int depth;
- OrderedSurface(Surface *s, int d):surface(s),depth(d) {}
- bool operator<(OrderedSurface rhs) const { return depth < rhs.depth; }
- bool operator==(OrderedSurface rhs) const { return surface == rhs.surface; }
+ OrderedSurface(Surface *s, int d):surface(s), depth(d) {}
+ bool operator<(OrderedSurface rhs) const
+ {
+ return depth < rhs.depth;
+ }
+ bool operator==(OrderedSurface rhs) const
+ {
+ return surface == rhs.surface;
+ }
};
-struct RegionLimit {
+struct RegionLimit
+{
float value; // Location on either X or Y axis
bool entry; // 1=in, 0=out
OrderedSurface orderedSurface;
- RegionLimit(float v, bool e, OrderedSurface s):value(v),entry(e),orderedSurface(s) {}
- bool operator<(RegionLimit rhs) const { return value < rhs.value; }
+ RegionLimit(float v, bool e, OrderedSurface s):value(v), entry(e), orderedSurface(s) {}
+ bool operator<(RegionLimit rhs) const
+ {
+ return value < rhs.value;
+ }
};
// Creates a list of non-overlapping screen-space regions, each with a list of
std::list<MultiSurfaceRegion*> regions;
std::vector<RegionLimit> xlimits;
std::vector<RegionLimit> ylimits;
-
+
// If clear is needed enable a dummy surface so that additional zero-surface
// regions will be created around the edges to fill screen (when necessary)
if (clear)
{
- xlimits.push_back(RegionLimit(0, true, OrderedSurface(NULL, 0)));
- xlimits.push_back(RegionLimit(m_displayWidth, false, OrderedSurface(NULL, 0)));
- ylimits.push_back(RegionLimit(0, true, OrderedSurface(NULL, 0)));
+ xlimits.push_back(RegionLimit(0, true, OrderedSurface(NULL, 0)));
+ xlimits.push_back(RegionLimit(m_displayWidth, false, OrderedSurface(NULL, 0)));
+ ylimits.push_back(RegionLimit(0, true, OrderedSurface(NULL, 0)));
ylimits.push_back(RegionLimit(m_displayHeight, false, OrderedSurface(NULL, 0)));
}
// also stored in the edge information.
LayerListConstIterator layer;
int depth = 0;
- for(layer = layers.begin(); layer != layers.end(); layer++)
+ for (layer = layers.begin(); layer != layers.end(); layer++)
{
if ((*layer)->visibility == false || (*layer)->getOpacity() <= 0.0f)
{
SurfaceList surfaces = (*layer)->getAllSurfaces();
SurfaceListConstIterator surface;
- for(surface = surfaces.begin(); surface != surfaces.end(); surface++)
+ for (surface = surfaces.begin(); surface != surfaces.end(); surface++)
{
if (!(*surface)->hasNativeContent())
{
FloatRectangle rect = (*surface)->getTargetDestinationRegion();
- xlimits.push_back(RegionLimit(rect.x, true, OrderedSurface((*surface), depth)));
- xlimits.push_back(RegionLimit(rect.x + rect.width, false, OrderedSurface((*surface), depth)));
- ylimits.push_back(RegionLimit(rect.y, true, OrderedSurface((*surface), depth)));
+ xlimits.push_back(RegionLimit(rect.x, true, OrderedSurface((*surface), depth)));
+ xlimits.push_back(RegionLimit(rect.x + rect.width, false, OrderedSurface((*surface), depth)));
+ ylimits.push_back(RegionLimit(rect.y, true, OrderedSurface((*surface), depth)));
ylimits.push_back(RegionLimit(rect.y + rect.height, false, OrderedSurface((*surface), depth)));
}
}
m_defaultShader = Shader::createShader("default", "default");
m_defaultShaderNoBlend = Shader::createShader("default", "default_no_blend");
m_defaultShaderNoUniformAlpha = Shader::createShader("default", "default_no_uniform_alpha");
- m_defaultShaderAddUniformChromaKey= Shader::createShader("default", "default_add_uniform_chromakey");
+ m_defaultShaderAddUniformChromaKey = Shader::createShader("default", "default_add_uniform_chromakey");
m_defaultShaderNoUniformAlphaNoBlend = Shader::createShader("default", "default_no_blend_no_uniform_alpha");
m_defaultShader2surf = Shader::createShader("default_2surf", "default_2surf");
m_defaultShader2surfNoBlend = Shader::createShader("default_2surf", "default_2surf_no_blend");
// C: Texture n has chromakey
// 0 1 2 3
// ----- ----- ----- -----
- // # B T A C T A C T A C T A C
- m_shaders[shaderKey(0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShaderClear;
- m_shaders[shaderKey(1,1, 1,1,0, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShader;
- m_shaders[shaderKey(1,1, 1,1,1, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShaderAddUniformChromaKey;
- m_shaders[shaderKey(1,0, 1,1,0, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShaderNoBlend;
- m_shaders[shaderKey(1,1, 0,1,0, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShaderNoUniformAlpha;
- m_shaders[shaderKey(1,0, 0,1,0, 0,0,0, 0,0,0, 0,0,0)] = m_defaultShaderNoUniformAlphaNoBlend;
-
- m_shaders[shaderKey(2,1, 1,1,0, 1,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surf;
- m_shaders[shaderKey(2,0, 1,1,0, 1,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoBlend;
- m_shaders[shaderKey(2,1, 0,1,0, 0,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlpha;
- m_shaders[shaderKey(2,0, 0,1,0, 0,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlphaNoBlend;
- m_shaders[shaderKey(2,1, 0,1,0, 1,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlpha0;
- m_shaders[shaderKey(2,0, 0,1,0, 1,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlpha0NoBlend;
- m_shaders[shaderKey(2,1, 1,1,0, 0,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlpha1;
- m_shaders[shaderKey(2,0, 1,1,0, 0,1,0, 0,0,0, 0,0,0)] = m_defaultShader2surfNoUniformAlpha1NoBlend;
+ // # B T A C T A C T A C T A C
+ m_shaders[shaderKey(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShaderClear;
+ m_shaders[shaderKey(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader;
+ m_shaders[shaderKey(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShaderAddUniformChromaKey;
+ m_shaders[shaderKey(1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShaderNoBlend;
+ m_shaders[shaderKey(1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShaderNoUniformAlpha;
+ m_shaders[shaderKey(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShaderNoUniformAlphaNoBlend;
+
+ m_shaders[shaderKey(2, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surf;
+ m_shaders[shaderKey(2, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoBlend;
+ m_shaders[shaderKey(2, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlpha;
+ m_shaders[shaderKey(2, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlphaNoBlend;
+ m_shaders[shaderKey(2, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlpha0;
+ m_shaders[shaderKey(2, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlpha0NoBlend;
+ m_shaders[shaderKey(2, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlpha1;
+ m_shaders[shaderKey(2, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)] = m_defaultShader2surfNoUniformAlpha1NoBlend;
return result;
}
{
// clear error if any
int error = glGetError();
- LOG_DEBUG("GLESGraphicSystem","taking screenshot and saving it to:" << fileToSave);
+ LOG_DEBUG("GLESGraphicSystem", "taking screenshot and saving it to:" << fileToSave);
- LOG_DEBUG("GLESGraphicSystem","Screenshot: " << m_displayWidth << " * " << m_displayHeight);
- char *buffer = (char *) malloc( m_displayWidth * m_displayHeight * 4 * sizeof(char));
+ LOG_DEBUG("GLESGraphicSystem", "Screenshot: " << m_displayWidth << " * " << m_displayHeight);
+ char *buffer = (char *) malloc(m_displayWidth * m_displayHeight * 4 * sizeof(char));
glReadPixels(0, 0, m_displayWidth, m_displayHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
error = glGetError();
if (error != GL_NO_ERROR)
{
- LOG_DEBUG("GLESGraphicSystem","error reading pixels for screenshot: " << error);
+ LOG_DEBUG("GLESGraphicSystem", "error reading pixels for screenshot: " << error);
}
// convert to RGB for bitmap
int pixelcount = m_displayHeight * m_displayWidth;
}
const FloatRectangle layerDestRegion = m_currentLayer->getDestinationRegion();
- EGLint width = static_cast<EGLint>(layerDestRegion.width);
+ EGLint width = static_cast<EGLint>(layerDestRegion.width);
EGLint height = static_cast<EGLint>(layerDestRegion.height);
EGLint pb_attrs[] = {
- EGL_WIDTH, width,
+ EGL_WIDTH, width,
EGL_HEIGHT, height,
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
void GLESGraphicsystem::renderTempTexture()
{
- // TODO FIX IT , IS NOT ALREADY WORKING ANYMORE WITH MULTITEXTURE OPTIMIZATION, IF WE HAVE CHROMAKEY LAYER
- const FloatRectangle layerSourceRegion = m_currentLayer->getSourceRegion();
+ // TODO FIX IT , IS NOT ALREADY WORKING ANYMORE WITH MULTITEXTURE OPTIMIZATION, IF WE HAVE CHROMAKEY LAYER
+ const FloatRectangle layerSourceRegion = m_currentLayer->getSourceRegion();
const FloatRectangle layerDestinationRegion = m_currentLayer->getDestinationRegion();
float textureCoordinates[4];
uniforms.x = layerDestinationRegion.x / m_displayWidth;
uniforms.y = 1.0f - (layerDestinationRegion.y + layerDestinationRegion.height) / m_displayHeight;
- uniforms.width = layerDestinationRegion.width / m_displayWidth;
- uniforms.height = layerDestinationRegion.height / m_displayHeight;
+ uniforms.width = layerDestinationRegion.width / m_displayWidth;
+ uniforms.height = layerDestinationRegion.height / m_displayHeight;
uniforms.opacity[0] = m_currentLayer->getOpacity();
uniforms.texRange[0][0] = textureCoordinates[2] - textureCoordinates[0];
uniforms.texRange[0][1] = textureCoordinates[3] - textureCoordinates[1];
uniforms.texUnit[0] = 0;
uniforms.matrix = layerMatrix.f;
uniforms.chromaKeyEnabled = m_currentLayer->getChromaKeyEnabled();
- if (uniforms.chromaKeyEnabled == true) {
- unsigned char red = 0;
+ if (uniforms.chromaKeyEnabled == true)
+ {
+ unsigned char red = 0;
unsigned char green = 0;
- unsigned char blue = 0;
+ unsigned char blue = 0;
m_currentLayer->getChromaKey(red, green, blue);
uniforms.chromaKey[0] = (float)red / 255.0f;
uniforms.chromaKey[1] = (float)green / 255.0f;
uniforms.chromaKey[2] = (float)blue / 255.0f;
}
- glEnable (GL_BLEND);
+ glEnable(GL_BLEND);
Shader* shader = m_currentLayer->getShader();
- if (!shader) {
+ if (!shader)
+ {
shader = m_defaultShader;
}
//shader = pickOptimizedShader(shader, uniforms);
shader = m_defaultShaderAddUniformChromaKey;
shader->use();
- shader->loadCommonUniforms(uniforms,0);
+ shader->loadCommonUniforms(uniforms, 0);
shader->loadUniforms();
glBindTexture(GL_TEXTURE_2D, m_texId);
int orientation = m_currentLayer->getOrientation() % 4;
- GLint index = orientation * 12;
+ GLint index = orientation * 12;
glDrawArrays(GL_TRIANGLES, index, 6);
GLenum glErrorCode = glGetError();
- if ( GL_NO_ERROR != glErrorCode ) {
- LOG_ERROR("GLESGraphicsystem", "GL Error occured in renderTempTexture:" << glErrorCode );
+ if (GL_NO_ERROR != glErrorCode)
+ {
+ LOG_ERROR("GLESGraphicsystem", "GL Error occured in renderTempTexture:" << glErrorCode);
}
}
int screen = DefaultScreen(dpy);
XVisualInfo *visinfo;
int attribs[] = {
- GLX_RGBA,
- GLX_ALPHA_SIZE,8,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DEPTH_SIZE,8,
- GLX_BUFFER_SIZE,32,
- GLX_DOUBLEBUFFER,
- None
+ GLX_RGBA,
+ GLX_ALPHA_SIZE, 8,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DEPTH_SIZE, 8,
+ GLX_BUFFER_SIZE, 32,
+ GLX_DOUBLEBUFFER,
+ None
};
visinfo = glXChooseVisual(dpy, screen, attribs);
}
return visinfo;
}
-bool GLXGraphicsystem::CheckConfigMask(Display *curDisplay,GLXFBConfig currentConfig, int attribute, int expectedValue)
+bool GLXGraphicsystem::CheckConfigMask(Display *curDisplay, GLXFBConfig currentConfig, int attribute, int expectedValue)
{
bool result = true;
int returnedValue = 0;
- glXGetFBConfigAttrib(curDisplay,currentConfig,attribute,&returnedValue);
+ glXGetFBConfigAttrib(curDisplay, currentConfig, attribute, &returnedValue);
if (!(returnedValue & expectedValue))
{
result = false;
return result;
}
-bool GLXGraphicsystem::CheckConfigValue(Display *curDisplay,GLXFBConfig currentConfig, int attribute, int expectedValue)
+bool GLXGraphicsystem::CheckConfigValue(Display *curDisplay, GLXFBConfig currentConfig, int attribute, int expectedValue)
{
bool result = true;
int returnedValue = 0;
- glXGetFBConfigAttrib(curDisplay,currentConfig,attribute,&returnedValue);
+ glXGetFBConfigAttrib(curDisplay, currentConfig, attribute, &returnedValue);
if ((returnedValue != expectedValue))
{
result = false;
void GLXGraphicsystem::activateGraphicContext()
{
- glXMakeCurrent(m_x11display, m_window, m_context);
+ glXMakeCurrent(m_x11display, m_window, m_context);
}
-void GLXGraphicsystem::releaseGraphicContext()
+void GLXGraphicsystem::releaseGraphicContext()
{
glXMakeCurrent(m_x11display, None, NULL);
}
{
int neededMaskAttribute[] =
{
- GLX_DRAWABLE_TYPE,GLX_PIXMAP_BIT,
- GLX_DRAWABLE_TYPE,GLX_WINDOW_BIT,
- GLX_BIND_TO_TEXTURE_TARGETS_EXT,GLX_TEXTURE_2D_BIT_EXT,
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
None
};
int neededValueAttribute[] =
{
- GLX_BUFFER_SIZE,32,
- GLX_ALPHA_SIZE,8,
- GLX_BIND_TO_TEXTURE_RGBA_EXT,True,
+ GLX_BUFFER_SIZE, 32,
+ GLX_ALPHA_SIZE, 8,
+ GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
None
};
LOG_DEBUG("GLXGraphicsystem", "Choose pixmap GL configuration");
bool result = true;
/* check first all mask values */
j = 0;
- while ( neededMaskAttribute[j] != None && result == true )
+ while (neededMaskAttribute[j] != None && result == true)
{
- result = CheckConfigMask(curDisplay,config, neededMaskAttribute[j], neededMaskAttribute[j+1]);
- j += 2;
+ result = CheckConfigMask(curDisplay, config, neededMaskAttribute[j], neededMaskAttribute[j + 1]);
+ j += 2;
}
/* no matching found in needed mask attribute, skip config take next */
- if (result == false )
+ if (result == false)
{
continue;
}
/* reset attribute counter */
j = 0;
/* check all fixed values */
- while ( neededValueAttribute[j] != None && result == true )
+ while (neededValueAttribute[j] != None && result == true)
{
- result = CheckConfigValue(curDisplay,config, neededValueAttribute[j], neededValueAttribute[j+1]);
- j += 2;
+ result = CheckConfigValue(curDisplay, config, neededValueAttribute[j], neededValueAttribute[j + 1]);
+ j += 2;
}
/* no matching found in needed fixed value attribute, skip config take next */
- if (result == false )
+ if (result == false)
{
continue;
}
}
LOG_DEBUG("GLXGraphicsystem", "Make GLX Context current");
glXMakeCurrent(m_x11display, m_window, m_context);
- glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
const char *ext;
ext = glXQueryExtensionsString(m_x11display, 0);
- if (!strstr(ext, "GLX_EXT_texture_from_pixmap") )
+ if (!strstr(ext, "GLX_EXT_texture_from_pixmap"))
{
m_zerocopy = false;
}
if (layer->visibility && layer->opacity > 0.0)
{
SurfaceList surfaces = layer->getAllSurfaces();
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->renderPropertyChanged)
{
clearBackground();
}
- if ( layer->visibility && layer->opacity > 0.0 )
+ if (layer->visibility && layer->opacity > 0.0)
{
SurfaceList surfaces = layer->getAllSurfaces();
beginLayer(layer);
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->hasNativeContent() && (*currentS)->visibility && (*currentS)->opacity>0.0f)
{
{
// LOG_DEBUG("GLXGraphicsystem", "renderSurface " << currentSurface->getID() );
GLenum glErrorCode = GL_NO_ERROR;
-
+
if (currentSurface->isCropped())
return; // skip rendering of this surface, because it is cropped by layer source region
-
+
// check if surface is cropped completely, if so then skip rendering
FloatRectangle targetSurfaceSource = currentSurface->getTargetSourceRegion();
FloatRectangle targetSurfaceDestination = currentSurface->getTargetDestinationRegion();
float textureCoordinates[4];
- ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource, currentSurface->OriginalSourceWidth, currentSurface->OriginalSourceHeight, textureCoordinates);
+ ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource,
+ currentSurface->OriginalSourceWidth,
+ currentSurface->OriginalSourceHeight,
+ textureCoordinates);
glPushMatrix();
if (false == m_binder->bindSurfaceTexture(currentSurface))
return;
}
// glPushMatrix();
- glColor4f(1.0f,1.0f,1.0f,currentSurface->opacity*(m_currentLayer)->opacity);
+ glColor4f(1.0f, 1.0f, 1.0f, currentSurface->opacity*(m_currentLayer)->opacity);
glBegin(GL_QUADS);
// LOG_DEBUG("GLXGraphicsystem","window: " << m_windowWidth << " " << m_windowHeight );
//bottom left
- glTexCoord2d(textureCoordinates[0],textureCoordinates[3]);
- glVertex2d((float)targetSurfaceDestination.x/m_windowWidth*2-1, 1-(float)(targetSurfaceDestination.y+targetSurfaceDestination.height)/m_windowHeight*2);
+ glTexCoord2d(textureCoordinates[0], textureCoordinates[3]);
+ glVertex2d((float)targetSurfaceDestination.x / m_windowWidth * 2 - 1,
+ 1 - (float)(targetSurfaceDestination.y + targetSurfaceDestination.height) / m_windowHeight * 2);
// bottom right
- glTexCoord2f(textureCoordinates[2],textureCoordinates[3]);
- glVertex2d( (float)(targetSurfaceDestination.x+targetSurfaceDestination.width)/m_windowWidth*2-1, 1-(float)(targetSurfaceDestination.y+targetSurfaceDestination.height)/m_windowHeight*2);
+ glTexCoord2f(textureCoordinates[2], textureCoordinates[3]);
+ glVertex2d((float)(targetSurfaceDestination.x + targetSurfaceDestination.width) / m_windowWidth * 2 - 1,
+ 1 - (float)(targetSurfaceDestination.y + targetSurfaceDestination.height) / m_windowHeight * 2);
// top right
glTexCoord2f(textureCoordinates[2], textureCoordinates[1]);
- glVertex2d((float)(targetSurfaceDestination.x+targetSurfaceDestination.width)/m_windowWidth*2-1, 1-(float)targetSurfaceDestination.y/m_windowHeight*2);
+ glVertex2d((float)(targetSurfaceDestination.x + targetSurfaceDestination.width) / m_windowWidth * 2 - 1,
+ 1 - (float)targetSurfaceDestination.y / m_windowHeight * 2);
// top left
glTexCoord2f(textureCoordinates[0], textureCoordinates[1]);
- glVertex2d((float)targetSurfaceDestination.x/m_windowWidth*2-1 , 1-(float)targetSurfaceDestination.y/m_windowHeight*2);
+ glVertex2d((float)targetSurfaceDestination.x/m_windowWidth * 2 - 1, 1 - (float)targetSurfaceDestination.y / m_windowHeight * 2);
glEnd();
m_binder->unbindSurfaceTexture(currentSurface);
glPopMatrix();
glErrorCode = glGetError();
- if ( GL_NO_ERROR != glErrorCode )
+ if (GL_NO_ERROR != glErrorCode)
{
- LOG_ERROR("GLXGraphicsystem", "GL Error occured :" << glErrorCode );
+ LOG_ERROR("GLXGraphicsystem", "GL Error occured :" << glErrorCode);
}
currentSurface->frameCounter++;
currentSurface->drawCounter++;
void GLXGraphicsystem::saveScreenShotOfFramebuffer(std::string fileToSave)
{
- LOG_DEBUG("GLXGraphicsystem","taking screenshot and saving it to:" << fileToSave);
+ LOG_DEBUG("GLXGraphicsystem", "taking screenshot and saving it to:" << fileToSave);
GLint viewport[4];
- glGetIntegerv(GL_VIEWPORT,viewport); // x,y,width,height
+ glGetIntegerv(GL_VIEWPORT, viewport); // x,y,width,height
- int WINDOW_WIDTH= viewport[2];
- int WINDOW_HEIGHT= viewport[3];
- LOG_DEBUG("GLXGraphicsystem","Screenshot: " << WINDOW_WIDTH << " * " << WINDOW_HEIGHT);
+ int WINDOW_WIDTH = viewport[2];
+ int WINDOW_HEIGHT = viewport[3];
+ LOG_DEBUG("GLXGraphicsystem", "Screenshot: " << WINDOW_WIDTH << " * " << WINDOW_HEIGHT);
char *buffer = (char *)malloc(WINDOW_WIDTH * WINDOW_HEIGHT * 3 * sizeof(unsigned char));
- glReadPixels(0,0,WINDOW_WIDTH,WINDOW_HEIGHT,GL_BGR,GL_UNSIGNED_BYTE, buffer);
+ glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, buffer);
- writeBitmap(fileToSave,buffer,WINDOW_WIDTH,WINDOW_HEIGHT);
+ writeBitmap(fileToSave, buffer, WINDOW_WIDTH, WINDOW_HEIGHT);
free(buffer);
- LOG_DEBUG("GLXGraphicsystem","done taking screenshot");
+ LOG_DEBUG("GLXGraphicsystem", "done taking screenshot");
}
{
/* Wayland SHM buffer */
unsigned int* pBuf = (unsigned int*)wl_shm_buffer_get_data(buffer);
- if( (NULL != buffer) && (NULL != pBuf) )
+ if ((NULL != buffer) && (NULL != pBuf))
{
- LOG_DEBUG("WaylandGLESTexture", "SHM buffer address:"<<pBuf);
+ LOG_DEBUG("WaylandGLESTexture", "SHM buffer address:" << pBuf);
unsigned int* pTmp = (unsigned int*)pBuf;
unsigned int col = 0;
int cnt = 0;
- unsigned int* pCnvImg = (unsigned int*)malloc(sizeof(unsigned int) * surface->OriginalSourceWidth * surface->OriginalSourceHeight);
+ unsigned int* pCnvImg = (unsigned int*)malloc(sizeof(unsigned int)
+ * surface->OriginalSourceWidth * surface->OriginalSourceHeight);
unsigned int* pCnvImgTmp = pCnvImg;
for (cnt = 0; cnt < surface->OriginalSourceWidth * surface->OriginalSourceHeight; cnt++, pTmp++, pCnvImgTmp++)
{
}
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->OriginalSourceWidth, surface->OriginalSourceHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pCnvImg);
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ pCnvImg);
free(pCnvImg);
}
return true;
-
}
else
{
/* Wayland Not SHM buffer */
if (nativeSurface->eglImage)
{
- LOG_DEBUG("WaylandGLESTexture", "nativeSurface->eglImage:"<<nativeSurface->eglImage);
+ LOG_DEBUG("WaylandGLESTexture", "nativeSurface->eglImage:" << nativeSurface->eglImage);
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
return true;
}
LOG_DEBUG("WaylandGLESTexture", "creating client buffer with native display: " << m_wlDisplay << " for native handle: " << surface->getNativeContent());
EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
- if (NULL!=nativeSurface)
+ if (NULL != nativeSurface)
{
struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
if (wl_buffer_is_shm(buffer))
{
if (nativeSurface->texture)
- {
- glDeleteTextures(1,&nativeSurface->texture);
+ {
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->texture = 0;
}
- glGenTextures(1,&nativeSurface->texture);
+ glGenTextures(1, &nativeSurface->texture);
}
else
{
if (nativeSurface->eglImage)
{
m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
- glDeleteTextures(1,&nativeSurface->texture);
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->eglImage = 0;
nativeSurface->texture = 0;
}
eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
- EGL_NO_CONTEXT,
- EGL_WAYLAND_BUFFER_WL,
- (EGLClientBuffer)buffer,
- NULL);
+ EGL_NO_CONTEXT,
+ EGL_WAYLAND_BUFFER_WL,
+ (EGLClientBuffer)buffer,
+ NULL);
if (!eglImage)
{
LOG_DEBUG("WaylandGLESTexture", "could not allocate EGL Image for window");
else
{
nativeSurface->eglImage = eglImage;
- glGenTextures(1,&nativeSurface->texture);
+ glGenTextures(1, &nativeSurface->texture);
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
- }
+ }
}
}
}
{
if (nativeSurface && nativeSurface->texture)
{
- glDeleteTextures(1,&nativeSurface->texture);
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->texture = 0;
}
}
if (nativeSurface && nativeSurface->eglImage)
{
m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
- glDeleteTextures(1,&nativeSurface->texture);
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->eglImage = 0;
nativeSurface->texture = 0;
}
unsigned char* swapedData = NULL;
bool swaprgb = false;
bool includeAlpha = false;
- if (surface != NULL )
+ if (surface != NULL)
{
nativeSurface = (XPlatformSurface*)surface->platform;
}
- if( nativeSurface != NULL && surface->getNativeContent() != -1 && nativeSurface->isReadyForRendering())
+ if (nativeSurface != NULL && surface->getNativeContent() != -1 && nativeSurface->isReadyForRendering())
{
- pixmap = XCompositeNameWindowPixmap (dpy, surface->getNativeContent());
+ pixmap = XCompositeNameWindowPixmap(dpy, surface->getNativeContent());
if (!pixmap)
{
LOG_ERROR("X11CopyGLES", "didnt create pixmap!");
return false;
}
nativeSurface->pixmap = pixmap;
- XImage * xim = XGetImage(dpy, nativeSurface->pixmap, 0, 0, surface->OriginalSourceWidth, surface->OriginalSourceHeight, AllPlanes, ZPixmap);
- if ( xim != NULL )
+ XImage * xim = XGetImage(dpy,
+ nativeSurface->pixmap,
+ 0,
+ 0,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ AllPlanes,
+ ZPixmap);
+ if (xim != NULL)
{
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- if ( surface->getPixelFormat() == PIXELFORMAT_RGB888)
+ if (surface->getPixelFormat() == PIXELFORMAT_RGB888)
{
targetType = GL_RGB;
sourceType = GL_RGB;
swaprgb = true;
swapedData = new unsigned char[surface->OriginalSourceWidth*surface->OriginalSourceHeight*3];
}
- else if ( surface->getPixelFormat() == PIXELFORMAT_RGBA8888)
+ else if (surface->getPixelFormat() == PIXELFORMAT_RGBA8888)
{
if (xim->depth == 24)
{
}
else
{
- LOG_ERROR("X11CopyGLES","Pixelformat currently not supported : " << surface->getPixelFormat());
+ LOG_ERROR("X11CopyGLES", "Pixelformat currently not supported : " << surface->getPixelFormat());
XDestroyImage(xim);
return false;
}
- swapPixmap((unsigned char*)xim->data, swapedData, surface->OriginalSourceWidth, surface->OriginalSourceHeight,swaprgb,includeAlpha);
- glTexImage2D(GL_TEXTURE_2D, 0, sourceType, surface->OriginalSourceWidth, surface->OriginalSourceHeight, 0, targetType, GL_UNSIGNED_BYTE, swapedData);
+ swapPixmap((unsigned char*)xim->data,
+ swapedData,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ swaprgb,
+ includeAlpha);
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ sourceType,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ 0,
+ targetType,
+ GL_UNSIGNED_BYTE,
+ swapedData);
XDestroyImage(xim);
delete[] swapedData;
return true;
- } else {
+ }
+ else
+ {
LOG_ERROR("X11CopyGLES", "X image data empty");
return false;
}
}
return false;
}
-void X11CopyGLES::swapPixmap(unsigned char* src,unsigned char* dest, unsigned int width,unsigned int height,bool swaprgb,bool includeAlpha)
+void X11CopyGLES::swapPixmap(unsigned char* src,
+ unsigned char* dest,
+ unsigned int width,
+ unsigned int height,
+ bool swaprgb,
+ bool includeAlpha)
{
unsigned int count = 0;
if (swaprgb == false)
{
count = width*height;
- for (uint j=0;j<count; j++) {
- dest[j*4]=src[j*4+2];
- dest[j*4+1]=src[j*4+1];
- dest[j*4+2]=src[j*4];
- dest[j*4+3]=src[j*4+3];
+ for (uint j = 0; j < count; j++)
+ {
+ dest[j * 4] = src[j * 4 + 2];
+ dest[j *4 + 1] = src[j * 4 + 1];
+ dest[j *4 + 2] = src[j * 4];
+ dest[j *4 + 3] = src[j * 4 + 3];
if (includeAlpha)
{
- dest[j*4+3]=255;
+ dest[j * 4 + 3] = 255;
}
}
- } else {
+ }
+ else
+ {
count = width*height;
- for (uint j=0;j<count; j++)
+ for (uint j = 0; j < count; j++)
{
- dest[j*3]=src[j*3+2];
- dest[j*3+1]=src[j*3+1];
- dest[j*3+2]=src[j*3];
+ dest[j * 3] = src[j * 3 + 2];
+ dest[j * 3 + 1]=src[j * 3 + 1];
+ dest[j * 3 + 2]=src[j *3];
}
}
}
void X11CopyGLES::createClientBuffer(Surface* surface)
{
XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
- glGenTextures(1,&nativeSurface->texture);
+ glGenTextures(1, &nativeSurface->texture);
}
void X11CopyGLES::destroyClientBuffer(Surface* surface)
XPlatformSurface* nativeSurface = (XPlatformSurface*) surface->platform;
if (nativeSurface && nativeSurface->pixmap)
{
- glDeleteTextures(1,&nativeSurface->texture);
- XFreePixmap(dpy, nativeSurface->pixmap);
- nativeSurface->pixmap = None;
+ glDeleteTextures(1, &nativeSurface->texture);
+ XFreePixmap(dpy, nativeSurface->pixmap);
+ nativeSurface->pixmap = None;
}
}
Pixmap pixmap = 0;
GLenum targetType = GL_BGRA;
GLenum sourceType = GL_RGBA;
- if (surface != NULL )
+ if (surface != NULL)
{
nativeSurface = (XPlatformSurface*)surface->platform;
}
- if( nativeSurface != NULL && surface->getNativeContent() != -1 && nativeSurface->isReadyForRendering())
+ if (nativeSurface != NULL && surface->getNativeContent() != -1 && nativeSurface->isReadyForRendering())
{
- pixmap = XCompositeNameWindowPixmap (dpy, surface->getNativeContent());
+ pixmap = XCompositeNameWindowPixmap(dpy, surface->getNativeContent());
if (!pixmap)
{
LOG_ERROR("X11CopyGLX", "didnt create pixmap!");
}
nativeSurface->pixmap = pixmap;
- XImage * xim = XGetImage(dpy, nativeSurface->pixmap, 0, 0, surface->OriginalSourceWidth, surface->OriginalSourceHeight, AllPlanes, ZPixmap);
+ XImage * xim = XGetImage(dpy,
+ nativeSurface->pixmap,
+ 0, 0,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ AllPlanes,
+ ZPixmap);
if (xim)
{
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- if ( surface->getPixelFormat() == PIXELFORMAT_RGB888 )
+ if (surface->getPixelFormat() == PIXELFORMAT_RGB888)
{
targetType = GL_BGR;
sourceType = GL_RGB;
- }
- else if ( surface->getPixelFormat() == PIXELFORMAT_RGBA8888 )
+ }
+ else if (surface->getPixelFormat() == PIXELFORMAT_RGBA8888)
{
targetType = GL_BGRA;
sourceType = GL_RGBA;
{
/* Set alpha value */
int count = surface->OriginalSourceWidth*surface->OriginalSourceHeight;
- for (int j=0;j<count; j++)
+ for (int j = 0; j < count; j++)
{
- xim->data[j*4+3] = (char)255;
+ xim->data[j * 4 + 3] = (char)255;
}
}
- } else {
- LOG_ERROR("X11CopyGLX","Pixelformat currently not supported : " << surface->getPixelFormat());
+ }
+ else
+ {
+ LOG_ERROR("X11CopyGLX", "Pixelformat currently not supported : " << surface->getPixelFormat());
XDestroyImage(xim);
return false;
}
- glTexImage2D(GL_TEXTURE_2D, 0, sourceType, surface->OriginalSourceWidth, surface->OriginalSourceHeight, 0, targetType, GL_UNSIGNED_BYTE, xim->data);
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ sourceType,
+ surface->OriginalSourceWidth,
+ surface->OriginalSourceHeight,
+ 0,
+ targetType,
+ GL_UNSIGNED_BYTE,
+ xim->data);
XDestroyImage(xim);
return true;
}
void X11CopyGLX::createClientBuffer(Surface* surface)
{
XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
- glGenTextures(1,&nativeSurface->texture);
+ glGenTextures(1, &nativeSurface->texture);
}
void X11CopyGLX::destroyClientBuffer(Surface* surface)
XPlatformSurface* nativeSurface = (XPlatformSurface*) surface->platform;
if (nativeSurface && nativeSurface->pixmap)
{
- glDeleteTextures(1,&nativeSurface->texture);
- XFreePixmap(dpy, nativeSurface->pixmap);
+ glDeleteTextures(1, &nativeSurface->texture);
+ XFreePixmap(dpy, nativeSurface->pixmap);
}
}
{
LOG_DEBUG("X11EglImage", "creating client buffer with native display: " << m_x11display << " for native handle: " << surface->getNativeContent());
EglXPlatformSurface* nativeSurface = (EglXPlatformSurface*)surface->platform;
- if (NULL!=nativeSurface)
+ if (NULL != nativeSurface)
{
Pixmap windowPixmap = 0;
- windowPixmap= XCompositeNameWindowPixmap (m_x11display, surface->getNativeContent());
- if (windowPixmap==0)
+ windowPixmap = XCompositeNameWindowPixmap(m_x11display, surface->getNativeContent());
+ if (windowPixmap == 0)
{
LOG_ERROR("X11EglImage", "didnt create pixmap!");
}
if (nativeSurface->eglImage)
{
m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
- glDeleteTextures(1,&nativeSurface->texture);
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->eglImage = 0;
nativeSurface->texture = 0;
}
eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)windowPixmap,
- NULL);
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)windowPixmap,
+ NULL);
if (!eglImage)
{
LOG_DEBUG("X11EglImage", "could not allocate EGL Image for window");
else
{
nativeSurface->eglImage = eglImage;
- glGenTextures(1,&nativeSurface->texture);
+ glGenTextures(1, &nativeSurface->texture);
glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
if (nativeSurface && nativeSurface->eglImage)
{
m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
- glDeleteTextures(1,&nativeSurface->texture);
+ glDeleteTextures(1, &nativeSurface->texture);
nativeSurface->eglImage = 0;
nativeSurface->texture = 0;
}
#include "Log.h"
const int X11TextureFromPixmap::pixmapAttribs[] = {
- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, None
+ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+ GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, None
};
X11TextureFromPixmap::X11TextureFromPixmap(Display* display, GLXFBConfig pixmapConfig)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return true;
}
- return false;
+ return false;
}
bool X11TextureFromPixmap::unbindSurfaceTexture(Surface* surface)
return false;
}
-void X11TextureFromPixmap::createClientBuffer(Surface* surface){
+void X11TextureFromPixmap::createClientBuffer(Surface* surface)
+{
LOG_DEBUG("X11TextureFromPixmap", "creating clientBuffer for window: " << surface->getNativeContent());
GLXPlatformSurface* platformSurface = (GLXPlatformSurface*)surface->platform;
- if (NULL!=platformSurface)
+ if (NULL != platformSurface)
{
Pixmap pixmap = 0;
LOG_DEBUG("X11TextureFromPixmap", "get X Pixmap");
- pixmap= XCompositeNameWindowPixmap (dpy, surface->getNativeContent());
- if (pixmap==0)
+ pixmap = XCompositeNameWindowPixmap(dpy, surface->getNativeContent());
+ if (pixmap == 0)
{
LOG_ERROR("X11TextureFromPixmap", "didnt create pixmap!");
}
GLXPixmap glxPixmap = 0;
LOG_DEBUG("X11TextureFromPixmap", "creating glx pixmap from xpixmap");
glxPixmap = glXCreatePixmap(dpy, pixmapConfig, pixmap, pixmapAttribs);
- if (glxPixmap ==0)
+ if (glxPixmap == 0)
{
LOG_DEBUG("X11TextureFromPixmap", "could not allocate glxpixmap for window");
}
LOG_ERROR("X11TextureFromPixmap", "destroying clientBuffer");
GLXPlatformSurface* platformSurface = (GLXPlatformSurface*)surface->platform;
LOG_DEBUG("X11TextureFromPixmap", "removing GLX Pixmap");
- if (NULL!=platformSurface)
+ if (NULL != platformSurface)
{
//glXReleaseTexImageEXT_func(dpy, x11surf->glxPixmap, GLX_FRONT_LEFT_EXT);
glXDestroyPixmap(dpy, platformSurface->glxPixmap);
XSync(dpy, 0);
LOG_DEBUG("X11TextureFromPixmap", "removing X Pixmap");
- if (NULL!=platformSurface)
+ if (NULL != platformSurface)
{
XFreePixmap(dpy, platformSurface->pixmap);
platformSurface->pixmap = 0;
#include "InputManager.h"
extern "C" {
- struct serverinfo {
- struct wl_resource base;
- WaylandBaseWindowSystem* windowSystem;
- };
-
- struct serverinfoClient {
- struct wl_client *client;
- uint connectionId;
- struct wl_list link;
- };
-
- void WaylandBaseWindowSystem::serverinfoIFCreateConnection(struct wl_client *client, struct wl_resource *resource)
- {
- struct serverinfo* deliver = (struct serverinfo*)resource->data;
+struct serverinfo
+{
+ struct wl_resource base;
+ WaylandBaseWindowSystem* windowSystem;
+};
- // creates new connection id and store it in memory
- struct serverinfoClient* clientPair = (struct serverinfoClient*)malloc( sizeof *clientPair );
+struct serverinfoClient
+{
+ struct wl_client *client;
+ uint connectionId;
+ struct wl_list link;
+};
- clientPair->client = client;
- clientPair->connectionId = deliver->windowSystem->m_manageConnectionId;
- deliver->windowSystem->m_manageConnectionId++;
+void WaylandBaseWindowSystem::serverinfoIFCreateConnection(struct wl_client *client, struct wl_resource *resource)
+{
+ struct serverinfo* deliver = (struct serverinfo*)resource->data;
- wl_list_init(&clientPair->link);
- wl_list_insert(&deliver->windowSystem->m_connectionList, &clientPair->link);
+ // creates new connection id and store it in memory
+ struct serverinfoClient* clientPair = (struct serverinfoClient*)malloc(sizeof *clientPair);
- // send native client handle to this client.
- // by protocol default, this information is not needed.
- wl_resource_post_event(resource, SERVERINFO_CONNECTION_ID, clientPair->connectionId);
- LOG_DEBUG("WaylandBaseWindowSystem", "serverinfoIFCreateConnection() create connection id" << clientPair->connectionId << " for client " << clientPair->client);
- }
+ clientPair->client = client;
+ clientPair->connectionId = deliver->windowSystem->m_manageConnectionId;
+ deliver->windowSystem->m_manageConnectionId++;
- struct serverinfo_interface g_serverinfoImplementation = {
- WaylandBaseWindowSystem::serverinfoIFCreateConnection,
- };
+ wl_list_init(&clientPair->link);
+ wl_list_insert(&deliver->windowSystem->m_connectionList, &clientPair->link);
- void WaylandBaseWindowSystem::bindServerinfo(struct wl_client *client, void *data, uint32_t version, uint32_t id)
- {
- LOG_DEBUG("WaylandBaseWindowSystem", "bindServerinfo client:" << client << ", data:" << data << ", version:" << version << ", id:" << id);
- wl_client_add_object(client, &serverinfo_interface, &g_serverinfoImplementation, id, data);
- }
+ // send native client handle to this client.
+ // by protocol default, this information is not needed.
+ wl_resource_post_event(resource, SERVERINFO_CONNECTION_ID, clientPair->connectionId);
+ LOG_DEBUG("WaylandBaseWindowSystem", "serverinfoIFCreateConnection() create connection id" << clientPair->connectionId << " for client " << clientPair->client);
+}
- void WaylandBaseWindowSystem::createServerinfo(WaylandBaseWindowSystem* windowSystem)
- {
- struct serverinfo* serverInfo;
+struct serverinfo_interface g_serverinfoImplementation = {
+ WaylandBaseWindowSystem::serverinfoIFCreateConnection,
+};
- serverInfo = (struct serverinfo*)malloc(sizeof *serverInfo);
- if (NULL == serverInfo){
- LOG_ERROR("WaylandBaseWindowSystem", "failed to alloc serverinfo");
- return;
- }
+void WaylandBaseWindowSystem::bindServerinfo(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+ LOG_DEBUG("WaylandBaseWindowSystem", "bindServerinfo client:" << client << ", data:" << data << ", version:" << version << ", id:" << id);
+ wl_client_add_object(client, &serverinfo_interface, &g_serverinfoImplementation, id, data);
+}
- serverInfo->base.object.interface = &serverinfo_interface;
- serverInfo->base.object.implementation = (void(**)(void)) &g_serverinfoImplementation;
- serverInfo->base.client = NULL;
- serverInfo->base.data = NULL;
- serverInfo->windowSystem = windowSystem;
+void WaylandBaseWindowSystem::createServerinfo(WaylandBaseWindowSystem* windowSystem)
+{
+ struct serverinfo* serverInfo;
- m_serverInfoGlobal = wl_display_add_global(windowSystem->m_wlDisplay, &serverinfo_interface, serverInfo, WaylandBaseWindowSystem::bindServerinfo);
- if (NULL == m_serverInfoGlobal)
- {
- LOG_ERROR("WaylandBaseWindowSystem", "failed wl_display_add_global");
- free(serverInfo);
- return;
- }
+ serverInfo = (struct serverinfo*)malloc(sizeof *serverInfo);
+ if (NULL == serverInfo)
+ {
+ LOG_ERROR("WaylandBaseWindowSystem", "failed to alloc serverinfo");
+ return;
+ }
- m_serverInfo = (void*)serverInfo;
+ serverInfo->base.object.interface = &serverinfo_interface;
+ serverInfo->base.object.implementation = (void(**)(void)) &g_serverinfoImplementation;
+ serverInfo->base.client = NULL;
+ serverInfo->base.data = NULL;
+ serverInfo->windowSystem = windowSystem;
+
+ m_serverInfoGlobal = wl_display_add_global(windowSystem->m_wlDisplay,
+ &serverinfo_interface,
+ serverInfo,
+ WaylandBaseWindowSystem::bindServerinfo);
+ if (NULL == m_serverInfoGlobal)
+ {
+ LOG_ERROR("WaylandBaseWindowSystem", "failed wl_display_add_global");
+ free(serverInfo);
+ return;
}
- int WaylandBaseWindowSystem::finishFrameHandler(void *data)
+ m_serverInfo = (void*)serverInfo;
+}
+
+int WaylandBaseWindowSystem::finishFrameHandler(void *data)
+{
+ BaseWindowSystem* windowSystem = static_cast<BaseWindowSystem*>(data);
+ if (windowSystem)
{
- BaseWindowSystem* windowSystem = static_cast<BaseWindowSystem*>(data);
- if (windowSystem)
- {
- windowSystem->finishFrame();
- }
- return 1;
+ windowSystem->finishFrame();
}
+ return 1;
+}
}
WaylandBaseWindowSystem::WaylandBaseWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager)
LayerListConstIterator iter = list.begin();
LayerListConstIterator iterEnd = list.end();
- for(; iter != iterEnd; ++iter)
+ for (; iter != iterEnd; ++iter)
{
Rectangle dest = (*iter)->getDestinationRegion();
debugmessage << " " << std::setw(4) << (*iter)->getID() << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << " " << std::setw(3) << (*iter)->opacity << "\n";
SurfaceListIterator surfaceIter = surfaceList.begin();
SurfaceListIterator surfaceIterEnd = surfaceList.end();
- for(; surfaceIter != surfaceIterEnd ; ++surfaceIter)
+ for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
{
Rectangle src = (*surfaceIter)->getSourceRegion();
Rectangle dest = (*surfaceIter)->getDestinationRegion();
- debugmessage << " " << std::setw(4) << (*surfaceIter)->getID() << " " << std::setprecision(3) << (*surfaceIter)->opacity<< " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
+ debugmessage << " " << std::setw(4) << (*surfaceIter)->getID() << " " << std::setprecision(3) << (*surfaceIter)->opacity << " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
}
}
- LOG_DEBUG("WaylandBaseWindowSystem",debugmessage.str());
+ LOG_DEBUG("WaylandBaseWindowSystem", debugmessage.str());
}
Surface* WaylandBaseWindowSystem::getSurfaceFromNativeSurface(struct native_surface* nativeSurface)
{
// go though all surfaces
- const std::map<unsigned int,Surface*> surfaces = m_pScene->getAllSurfaces();
- for(std::map<unsigned int, Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); ++currentS)
+ const std::map<unsigned int, Surface*> surfaces = m_pScene->getAllSurfaces();
+ for (std::map<unsigned int, Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); ++currentS)
{
Surface* currentSurface = (*currentS).second;
if (!currentSurface)
{
continue;
}
- WaylandPlatformSurface* nativePlatform = (WaylandPlatformSurface*)currentSurface->platform;
+ WaylandPlatformSurface* nativePlatform = (WaylandPlatformSurface*)currentSurface->platform;
if (!nativePlatform)
{
continue;
{
m_pScene->lockScene();
LayerList layers = m_pScene->getCurrentRenderOrder(0);
- for(LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
+ for (LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
{
SurfaceList surfaces = (*current)->getAllSurfaces();
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->hasNativeContent())
{
static struct timeval tv0_forRender;
-void WaylandBaseWindowSystem::calculateSurfaceFps(Surface *currentSurface, float time )
+void WaylandBaseWindowSystem::calculateSurfaceFps(Surface *currentSurface, float time)
{
- char floatStringBuffer[256];
- float surfaceUpdateFps = ((float)(currentSurface->updateCounter)) / time ;
- float surfaceDrawFps = ((float)(currentSurface->drawCounter)) / time ;
- sprintf(floatStringBuffer, "0x%08x update fps: %3.2f", currentSurface->getID(),surfaceUpdateFps);
- currentSurface->updateCounter = 0;
- LOG_INFO("WaylandBaseWindowSystem", "Surface " << floatStringBuffer);
- sprintf(floatStringBuffer, "0x%08x draw fps: %3.2f", currentSurface->getID(),surfaceDrawFps);
- currentSurface->drawCounter = 0;
- LOG_INFO("WaylandBaseWindowSystem", "Surface " << floatStringBuffer);
+ char floatStringBuffer[256];
+ float surfaceUpdateFps = ((float)(currentSurface->updateCounter)) / time;
+ float surfaceDrawFps = ((float)(currentSurface->drawCounter)) / time;
+ sprintf(floatStringBuffer, "0x%08x update fps: %3.2f", currentSurface->getID(), surfaceUpdateFps);
+ currentSurface->updateCounter = 0;
+ LOG_INFO("WaylandBaseWindowSystem", "Surface " << floatStringBuffer);
+ sprintf(floatStringBuffer, "0x%08x draw fps: %3.2f", currentSurface->getID(), surfaceDrawFps);
+ currentSurface->drawCounter = 0;
+ LOG_INFO("WaylandBaseWindowSystem", "Surface " << floatStringBuffer);
}
void WaylandBaseWindowSystem::calculateFps()
// {
//LOG_INFO("WaylandBaseWindowSystem", "tv.tv_sec:" << tv.tv_sec << ", tv.tv_usec:" << tv.tv_usec);
//LOG_INFO("WaylandBaseWindowSystem", "timeSinceLastCalc " << timeSinceLastCalc);
- FPS = ((float)(Frame)) / timeSinceLastCalc;
- char floatStringBuffer[256];
- sprintf(floatStringBuffer, "Overall fps: %f", FPS);
+ FPS = ((float)(Frame)) / timeSinceLastCalc;
+ char floatStringBuffer[256];
+ sprintf(floatStringBuffer, "Overall fps: %f", FPS);
- timeSinceLastCalc = (float)(tv.tv_sec-tv0_forRender.tv_sec) + 0.000001*((float)(tv.tv_usec-tv0_forRender.tv_usec));
- for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+ timeSinceLastCalc = (float)(tv.tv_sec-tv0_forRender.tv_sec) + 0.000001*((float)(tv.tv_usec-tv0_forRender.tv_usec));
+ for (std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+ {
+ SurfaceList surfaceList = (*current)->getAllSurfaces();
+ SurfaceListIterator surfaceIter = surfaceList.begin();
+ SurfaceListIterator surfaceIterEnd = surfaceList.end();
+ for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
{
- SurfaceList surfaceList = (*current)->getAllSurfaces();
- SurfaceListIterator surfaceIter = surfaceList.begin();
- SurfaceListIterator surfaceIterEnd = surfaceList.end();
- for(; surfaceIter != surfaceIterEnd ; ++surfaceIter)
- {
- calculateSurfaceFps((*surfaceIter),timeSinceLastCalc);
- }
+ calculateSurfaceFps((*surfaceIter), timeSinceLastCalc);
}
- LOG_INFO("WaylandBaseWindowSystem", floatStringBuffer);
- tv0 = tv;
- Frame = 0;
+ }
+ LOG_INFO("WaylandBaseWindowSystem", floatStringBuffer);
+ tv0 = tv;
+ Frame = 0;
// }
}
}
#endif /* WL_OMIT_CLEAR_GB */
}
- for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+ for (std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
{
if ((*current)->getLayerType() == Hardware)
{
LOG_DEBUG("WaylandBaseWindowSystem", "Taking screenshot");
RedrawAllLayers(true, false); // Do clear, Don't swap
}
- else if(m_takeScreenshot == ScreenshotOfLayer)
+ else if (m_takeScreenshot == ScreenshotOfLayer)
{
LOG_DEBUG("WaylandBaseWindowSystem", "Taking screenshot of layer");
Layer* layer = m_pScene->getLayer(m_screenShotLayerID);
graphicSystem->renderSWLayer(layer, true); // Do clear
}
}
- else if(m_takeScreenshot == ScreenshotOfSurface)
+ else if (m_takeScreenshot == ScreenshotOfSurface)
{
LOG_DEBUG("WaylandBaseWindowSystem", "Taking screenshot of surface");
Layer* layer = m_pScene->getLayer(m_screenShotLayerID);
/*LOG_INFO("WaylandBaseWindowSystem","UnLocking List");*/
}
-void WaylandBaseWindowSystem::destroyListenerSurfaceBuffer(struct wl_listener* listener,void *data)
+void WaylandBaseWindowSystem::destroyListenerSurfaceBuffer(struct wl_listener* listener, void *data)
{
LOG_DEBUG("WaylandBaseWindowSystem", "destroyListenerSurfaceBuffer listener:" << listener << "data :" << data);
struct native_surface *es = wl_container_of(listener, es, buffer_destroy_listener);
es->buffer = NULL;
}
-void WaylandBaseWindowSystem::destroyListenerSurfacePendingBuffer(struct wl_listener* listener,void *data)
+void WaylandBaseWindowSystem::destroyListenerSurfacePendingBuffer(struct wl_listener* listener, void *data)
{
LOG_DEBUG("WaylandBaseWindowSystem", "destroyListenerSurfacePendingBuffer listener:" << listener << "data :" << data);
struct native_surface *es = wl_container_of(listener, es, pending.buffer_destroy_listener);
LOG_ERROR("WaylandBaseWindowSystem", "failed to create native surface");
return NULL;
}
-
+
wl_signal_init(&surface->surface.resource.destroy_signal);
-
+
wl_list_init(&surface->link);
surface->surface.resource.client = NULL;
void WaylandBaseWindowSystem::destroySurfaceCallback(struct wl_resource* resource)
{
struct native_surface* nativeSurface = wl_container_of(resource, nativeSurface, surface.resource);
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*)nativeSurface->windowSystem);
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*)nativeSurface->windowSystem);
Surface* ilmSurface = windowSystem->getSurfaceFromNativeSurface(nativeSurface);
if (NULL != ilmSurface)
{
LOG_DEBUG("WaylandBaseWindowSystem", "attachBufferToNativeSurface IN");
struct native_surface* nativeSurface = (struct native_surface*)surface;
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*)nativeSurface->windowSystem);
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*)nativeSurface->windowSystem);
Surface* ilmSurface = windowSystem->getSurfaceFromNativeSurface(nativeSurface);
if (NULL == ilmSurface)
{
windowSystem->graphicSystem->activateGraphicContext();
windowSystem->graphicSystem->getTextureBinder()->createClientBuffer(ilmSurface);
windowSystem->graphicSystem->releaseGraphicContext();
- LOG_DEBUG("WaylandBaseWindowSystem","nativePlatformSurface->enable");
+ LOG_DEBUG("WaylandBaseWindowSystem", "nativePlatformSurface->enable");
nativePlatformSurface->enableRendering();
}
}
extern "C" void WaylandBaseWindowSystem::surfaceIFAttach(struct wl_client* client,
- struct wl_resource* resource,
- struct wl_resource* buffer_resource, int32_t x, int32_t y)
+ struct wl_resource* resource,
+ struct wl_resource* buffer_resource, int32_t x, int32_t y)
{
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFAttach client:" << client);
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFAttach IN");
}
extern "C" void WaylandBaseWindowSystem::surfaceIFDamage(struct wl_client *client,
- struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
+ struct wl_resource *resource,
+ int32_t x, int32_t y, int32_t width, int32_t height)
{
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFDamage client:" << client);
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFDamage IN");
}
extern "C" void WaylandBaseWindowSystem::surfaceIFFrame(struct wl_client *client,
- struct wl_resource *resource, uint32_t callback)
+ struct wl_resource *resource, uint32_t callback)
{
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFFrame IN");
struct native_frame_callback* cb;
{
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFCommit IN clinet:" << client);
struct native_surface* nativeSurface = (struct native_surface*)resource->data;
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*)nativeSurface->windowSystem);
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*)nativeSurface->windowSystem);
Surface* surface = windowSystem->getSurfaceFromNativeSurface(nativeSurface);
struct wl_buffer* buffer = NULL;
(struct wl_client *client, struct wl_resource* resource, uint32_t id)
{
LOG_DEBUG("WaylandBaseWindowSystem", "compositorIFCreateSurface IN");
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*) resource->data);
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*) resource->data);
struct native_surface* surface;
surface = windowSystem->createNativeSurface();
struct serverinfoClient* serverinfoPairNode;
- wl_list_for_each(serverinfoPairNode, &windowSystem->m_connectionList, link) {
+ wl_list_for_each(serverinfoPairNode, &windowSystem->m_connectionList, link)
+ {
if (serverinfoPairNode->client != client)
{
continue;
LOG_DEBUG("WaylandBaseWindowSystem", "compositorIFCreateSurface OUT");
}
-const static struct wl_compositor_interface g_compositorInterface =
+const static struct wl_compositor_interface g_compositorInterface =
{
WaylandBaseWindowSystem::compositorIFCreateSurface,
NULL
*/
extern "C" void* WaylandBaseWindowSystem::eventLoopCallback(void *ptr)
{
- WaylandBaseWindowSystem *windowsys = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*) ptr);
+ WaylandBaseWindowSystem *windowsys = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*) ptr);
return windowsys->eventLoop();
}
int WaylandBaseWindowSystem::signalEventOnTerm(int signal_number, void *data)
{
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*)data);
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*)data);
LOG_INFO("WaylandBaseWindowSystem", "caught signal " << signal_number);
windowSystem->cleanup();
status = createInputEvent();
if (false == status)
{
- LOG_WARNING("WaylandBaseWindowSystem", "WARNING: failed to create input event");
- status = true;
- } else {
- LOG_DEBUG("WaylandBaseWindowSystem", "SUCCESS:create InputEvent");
- }
+ LOG_WARNING("WaylandBaseWindowSystem", "WARNING: failed to create input event");
+ status = true;
+ }
+ else
+ {
+ LOG_DEBUG("WaylandBaseWindowSystem", "SUCCESS:create InputEvent");
+ }
this->m_success = status;
this->m_initialized = true;
// run the main event loop while rendering
gettimeofday(&tv0, NULL);
LOG_DEBUG("WaylandBaseWindowSystem", "Enter render loop");
-
+
if (wl_display_add_socket(m_wlDisplay, NULL))
{
LOG_ERROR("WaylandBaseWindowSystem", "failed to add socket");
- this->m_success = false;
- this->m_initialized = false;
- break;
+ this->m_success = false;
+ this->m_initialized = false;
+ break;
}
-
+
// clear screen to avoid garbage on startup
this->graphicSystem->clearBackground();
this->graphicSystem->swapBuffers();
-
-
wl_display_run(m_wlDisplay);
-
- } while(0);
+ } while (0);
this->cleanup();
LOG_DEBUG("WaylandBaseWindowSystem", "Renderer thread finished");
extern "C" void WaylandBaseWindowSystem::registryHandleGlobalClient(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
LOG_DEBUG("WaylandBaseWindowSystem", "version " << version);
- WaylandBaseWindowSystem* windowsys = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*) data);
+ WaylandBaseWindowSystem* windowsys = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*) data);
int ans_strcmp = 0;
do
windowsys->m_wlCompositorClient = (wl_compositor*)wl_registry_bind(registry, name, &wl_compositor_interface, 1);
break;
}
- } while(0);
+ } while (0);
}
extern "C" const struct wl_registry_listener g_registryListener = {
LOG_DEBUG("WaylandBaseWindowSystem", "create client surface");
return true;
- } while(0);
+ } while (0);
releaseWaylandClient();
while (false == m_initialized)
{
usleep(10000); // TODO
- LOG_DEBUG("WaylandBaseWindowSystem","Waiting start compositor complete " << m_initialized);
+ LOG_DEBUG("WaylandBaseWindowSystem", "Waiting start compositor complete " << m_initialized);
}
- LOG_INFO("WaylandBaseWindowSystem","Start complete [connect display]" << m_initialized << " success " << m_success);
+ LOG_INFO("WaylandBaseWindowSystem", "Start complete [connect display]" << m_initialized << " success " << m_success);
return m_success;
}
bool result = true;
LOG_DEBUG("WaylandBaseWindowSystem", "Starting / Creating thread");
// let thread actually run
- if ( m_error == false )
+ if (m_error == false)
{
pthread_mutex_unlock(&run_lock);
- } else {
+ }
+ else
+ {
pthread_mutex_unlock(&run_lock);
result = false;
}
void WaylandBaseWindowSystem::stop()
{
- LOG_INFO("WaylandBaseWindowSystem","Stopping..");
+ LOG_INFO("WaylandBaseWindowSystem", "Stopping..");
// needed if start was never called, we wake up thread, so it can immediatly finish
// this->signalRedrawEvent();
void WaylandBaseWindowSystem::allocatePlatformSurface(Surface* surface)
{
- LOG_INFO("WaylandBaseWindowSystem","allocatePlatformSurface begin");
+ LOG_INFO("WaylandBaseWindowSystem", "allocatePlatformSurface begin");
WaylandPlatformSurface* nativeSurface = (WaylandPlatformSurface*)surface->platform;
if (!nativeSurface)
{
- LOG_DEBUG("WaylandBaseWindowSystem","creating native surface for new window");
+ LOG_DEBUG("WaylandBaseWindowSystem", "creating native surface for new window");
// this surface does not have a native platform surface attached yet!
nativeSurface = (WaylandPlatformSurface*)graphicSystem->getTextureBinder()->createPlatformSurface(surface);
if (0 != nativeSurface)
{
unsigned int surfaceId = surface->getNativeContent();
- LOG_DEBUG("WaylandBaseWindowSystem","surface->getNativeContent() : " << surfaceId);
+ LOG_DEBUG("WaylandBaseWindowSystem", "surface->getNativeContent() : " << surfaceId);
nativeSurface->connectionId = (unsigned short)((surfaceId >> 16) & 0xFFFF);
nativeSurface->surfaceId = (unsigned short)(surfaceId & 0xFFFF);
surface->platform = nativeSurface;
}
else
{
- LOG_ERROR("WaylandBaseWindowSystem","failed to allocate platformsurface");
+ LOG_ERROR("WaylandBaseWindowSystem", "failed to allocate platformsurface");
}
}
- LOG_INFO("WaylandBaseWindowSystem","allocatePlatformSurface end");
+ LOG_INFO("WaylandBaseWindowSystem", "allocatePlatformSurface end");
}
void WaylandBaseWindowSystem::deallocatePlatformSurface(Surface* surface)
{
- LOG_DEBUG("WaylandBaseWindowSystem","deallocatePlatformSurface begin");
+ LOG_DEBUG("WaylandBaseWindowSystem", "deallocatePlatformSurface begin");
WaylandPlatformSurface* nativeSurface = (WaylandPlatformSurface*)surface->platform;
if (nativeSurface)
{
- LOG_DEBUG("WaylandBaseWindowSystem","destroyingnative surface");
+ LOG_DEBUG("WaylandBaseWindowSystem", "destroyingnative surface");
#if 0 // TODO
graphicSystem->activateGraphicContext();
graphicSystem->getTextureBinder()->destroyClientBuffer(surface);
surface->platform = NULL;
#endif
}
- LOG_DEBUG("WaylandBaseWindowSystem","deallocatePlatformSurface end");
+ LOG_DEBUG("WaylandBaseWindowSystem", "deallocatePlatformSurface end");
}
void WaylandBaseWindowSystem::doScreenShot(std::string fileName)
}
void WaylandBaseWindowSystem::manageWLInputEvent(const InputDevice type,
- const InputEventState state,
- const WLEvent *wlEvent)
+ const InputEventState state,
+ const WLEvent *wlEvent)
{
- if (!m_inputEvent){
+ if (!m_inputEvent)
+ {
LOG_WARNING("WaylandBaseWindowSystem", "InputEvent not available");
return;
}
native_surface *nativeSurface = NULL;
uint32_t time = getTime();
- switch (type){
+ switch (type)
+ {
case INPUT_DEVICE_KEYBOARD:
{
LOG_DEBUG("WaylandBaseWindowSystem",
- "INPUT_DEVICE_KEYBOARD: state = " << state <<
- ", keyCode = " << wlEvent->keyCode);
+ "INPUT_DEVICE_KEYBOARD: state = " << state <<
+ ", keyCode = " << wlEvent->keyCode);
surface = m_pInputManager->reportKeyboardEvent(state, wlEvent->keyCode);
- if (!surface){
+ if (!surface)
+ {
m_inputEvent->inputDevice().setKeyboardFocus(NULL);
break;
}
if (!nativeSurface)
break;
- switch (state){
+ switch (state)
+ {
case INPUT_STATE_PRESSED:
m_inputEvent->inputDevice().sendKeyPressEvent(
&nativeSurface->surface, time, wlEvent->keyCode);
case INPUT_DEVICE_POINTER:
{
LOG_DEBUG("WaylandBaseWindowSystem",
- "INPUT_DEVICE_POINTER: state = " << state <<
- ", x = " << wlEvent->x <<
- ", y = " << wlEvent->y);
+ "INPUT_DEVICE_POINTER: state = " << state <<
+ ", x = " << wlEvent->x <<
+ ", y = " << wlEvent->y);
Point globalPos = {state, wlEvent->x, wlEvent->y};
- Point localPos = globalPos;
+ Point localPos = globalPos;
surface = m_pInputManager->reportPointerEvent(localPos);
- if (!surface){
+ if (!surface)
+ {
LOG_WARNING("WaylandBaseWindowSystem", "NO FOUND SURFACE!");
break;
}
LOG_DEBUG("WaylandBaseWindowSystem",
- "Local coordinates: x = " << localPos.x <<
- ", y = " << localPos.y);
+ "Local coordinates: x = " << localPos.x <<
+ ", y = " << localPos.y);
nativeSurface = getNativeSurfaceFromSurface(surface);
if (!nativeSurface)
break;
- switch (state){
+ switch (state)
+ {
case INPUT_STATE_PRESSED:
m_inputEvent->inputDevice().sendMousePressEvent(
globalPos, localPos, wlEvent->button, time);
case INPUT_DEVICE_TOUCH:
{
LOG_DEBUG("WaylandBaseWindowSystem",
- "INPUT_DEVICE_TOUCH: state = " << state <<
- ", x = " << wlEvent->x <<
- ", y = " << wlEvent->y);
+ "INPUT_DEVICE_TOUCH: state = " << state <<
+ ", x = " << wlEvent->x <<
+ ", y = " << wlEvent->y);
Point pt = {state, wlEvent->x, wlEvent->y};
PointVect ptVec(1, pt);
surface = m_pInputManager->reportTouchEvent(ptVec);
if (!nativeSurface)
break;
- switch (state){
+ switch (state)
+ {
case INPUT_STATE_PRESSED:
case INPUT_STATE_MOTION:
case INPUT_STATE_RELEASED:
WaylandDrmWindowSystem::~WaylandDrmWindowSystem()
{
- if (m_gbm != NULL)
- gbm_device_destroy(m_gbm);
- if (m_fdDev >= 0)
- drmDropMaster(m_fdDev);
+ if (m_gbm != NULL)
+ gbm_device_destroy(m_gbm);
+ if (m_fdDev >= 0)
+ drmDropMaster(m_fdDev);
}
bool WaylandDrmWindowSystem::initGraphicSystem()
{
- graphicSystem->setBaseWindowSystem(this);
+ graphicSystem->setBaseWindowSystem(this);
bool ans = graphicSystem->init((void*)m_gbm, (void*)NULL);
if (true != ans)
{
bool WaylandDrmWindowSystem::createNativeContext()
{
- struct udev* udev;
- struct udev_device *device, *drm_device;
- struct udev_enumerate* e;
- struct udev_list_entry* entry;
- const char *path, *device_seat;
- const char *seat = default_seat;
-
- udev = udev_new();
- if (udev == NULL)
- {
- LOG_ERROR("WaylandDrmWindowSystem", "failed to initialize udev context.");
- return false;
- }
-
- e = udev_enumerate_new(udev);
- udev_enumerate_add_match_subsystem(e, "drm");
- udev_enumerate_add_match_sysname(e, "card[0-9]*");
-
- udev_enumerate_scan_devices(e);
- drm_device = NULL;
- udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e))
- {
- path = udev_list_entry_get_name(entry);
- device = udev_device_new_from_syspath(udev, path);
- device_seat = udev_device_get_property_value(device, "ID_SEAT");
- if (!device_seat)
- device_seat = default_seat;
- if (strcmp(device_seat, seat) == 0)
- {
- drm_device = device;
- break;
- }
- udev_device_unref(device);
- }
-
- if (drm_device == NULL)
- {
- LOG_ERROR("WaylandDrmWindowSystem", "no drm device found");
- return false;
- }
-
- const char* filename;
-
- filename = udev_device_get_devnode(drm_device);
- m_fdDev = open(filename, O_RDWR | O_CLOEXEC);
- if (m_fdDev < 0)
- {
+ struct udev* udev;
+ struct udev_device *device, *drm_device;
+ struct udev_enumerate* e;
+ struct udev_list_entry* entry;
+ const char *path, *device_seat;
+ const char *seat = default_seat;
+
+ udev = udev_new();
+ if (udev == NULL)
+ {
+ LOG_ERROR("WaylandDrmWindowSystem", "failed to initialize udev context.");
+ return false;
+ }
+
+ e = udev_enumerate_new(udev);
+ udev_enumerate_add_match_subsystem(e, "drm");
+ udev_enumerate_add_match_sysname(e, "card[0-9]*");
+
+ udev_enumerate_scan_devices(e);
+ drm_device = NULL;
+ udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e))
+ {
+ path = udev_list_entry_get_name(entry);
+ device = udev_device_new_from_syspath(udev, path);
+ device_seat = udev_device_get_property_value(device, "ID_SEAT");
+ if (!device_seat)
+ device_seat = default_seat;
+ if (strcmp(device_seat, seat) == 0)
+ {
+ drm_device = device;
+ break;
+ }
+ udev_device_unref(device);
+ }
+
+ if (drm_device == NULL)
+ {
+ LOG_ERROR("WaylandDrmWindowSystem", "no drm device found");
+ return false;
+ }
+
+ const char* filename;
+
+ filename = udev_device_get_devnode(drm_device);
+ m_fdDev = open(filename, O_RDWR | O_CLOEXEC);
+ if (m_fdDev < 0)
+ {
LOG_ERROR("WaylandDrmWindowSystem", "failed to open device");
return false;
- }
+ }
- LOG_DEBUG("WaylandDrmWindowSystem", "Device name: " << filename << " fd: " << m_fdDev);
+ LOG_DEBUG("WaylandDrmWindowSystem", "Device name: " << filename << " fd: " << m_fdDev);
- m_gbm = gbm_create_device(m_fdDev);
- if (m_gbm == NULL)
- {
+ m_gbm = gbm_create_device(m_fdDev);
+ if (m_gbm == NULL)
+ {
LOG_ERROR("WaylandDrmWindowSystem", "failed to create gbm device");
- return false;
- }
+ return false;
+ }
- udev_device_unref(drm_device);
+ udev_device_unref(drm_device);
LOG_DEBUG("WaylandDrmWindowSystem", "SUCCESS:create gbm device");
return true;
for (; iter != iterEnd; ++iter)
{
LayerList layers = m_pScene->getCurrentRenderOrder((*iter)->getID());
- for(LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
+ for (LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
{
SurfaceList surfaces = (*current)->getAllSurfaces();
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->hasNativeContent())
{
graphicSystem->clearBackground();
}
}
- for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+ for (std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
{
if ((*current)->getLayerType() == Hardware)
{
};
// Function prototypes
-void acceleratorFilter (struct motion_filter *, struct motion_params *, void *, uint32_t);
+void acceleratorFilter(struct motion_filter *, struct motion_params *, void *, uint32_t);
void acceleratorDestroy(struct motion_filter *);
struct motion_filter_interface accelerator_interface = {
static int
isMotionEvent(struct input_event *e)
{
- switch (e->type){
+ switch (e->type)
+ {
case EV_REL:
- switch (e->code){
+ switch (e->code)
+ {
case REL_X:
case REL_Y:
return 1;
}
break;
case EV_ABS:
- switch (e->code){
+ switch (e->code)
+ {
case ABS_X:
case ABS_Y:
case ABS_MT_POSITION_X:
if (ioctl(device->fd, EVIOCGID, &id) < 0)
return TOUCHPAD_MODEL_UNKNOWN;
- for (i = 0; i < sizeof(touchpad_spec_table); ++i){
+ for (i = 0; i < sizeof(touchpad_spec_table); ++i)
+ {
if (touchpad_spec_table[i].vendor == id.vendor &&
(!touchpad_spec_table[i].product ||
- touchpad_spec_table[i].product == id.product)){
+ touchpad_spec_table[i].product == id.product))
+ {
return touchpad_spec_table[i].model;
}
}
static void
configureTouchpadPressure(struct touchpad_dispatch *touchpad,
- int32_t pressure_min, int32_t pressure_max)
+ int32_t pressure_min, int32_t pressure_max)
{
int32_t range = pressure_max - pressure_min + 1;
touchpad->has_pressure = 1;
// Magic numbers from xf86-input-synaptics
- switch (touchpad->model){
+ switch (touchpad->model)
+ {
case TOUCHPAD_MODEL_ELANTECH:
- touchpad->pressure.touch_low = pressure_min + 1;
+ touchpad->pressure.touch_low = pressure_min + 1;
touchpad->pressure.touch_high = pressure_min + 1;
break;
default:
- touchpad->pressure.touch_low = pressure_min + range * (25.0/256.0);
+ touchpad->pressure.touch_low = pressure_min + range * (25.0/256.0);
touchpad->pressure.touch_high = pressure_min + range * (30.0/256.0);
break;
}
{
struct evdev_dispatch *dispatch =
(struct evdev_dispatch*)malloc(sizeof(*dispatch));
- if (dispatch == NULL)
+ if (dispatch == NULL)
return NULL;
dispatch->interface = &fallback_interface;
static void
processTouch(struct evdev_input_device *device, struct input_event *e,
- int screen_width, int screen_height)
+ int screen_width, int screen_height)
{
- switch (e->code) {
+ switch (e->code)
+ {
case ABS_MT_SLOT:
device->mt.slot = e->value;
break;
static void
processAbsoluteMotion(struct evdev_input_device *device, struct input_event *e,
- int screen_width, int screen_height)
+ int screen_width, int screen_height)
{
- switch (e->code) {
+ switch (e->code)
+ {
case ABS_X:
device->abs.x =
(e->value - device->abs.min_x) * screen_width /
static void
filterDispatch(struct motion_filter *filter, struct motion_params *motion,
- void *data, uint32_t time)
+ void *data, uint32_t time)
{
filter->interface->filter(filter, motion, data, time);
}
static void
filterMotion(struct touchpad_dispatch *touchpad,
- double *dx, double *dy, uint32_t time)
+ double *dx, double *dy, uint32_t time)
{
struct motion_filter *filter;
struct motion_params motion;
motion.dx = *dx;
motion.dy = *dy;
- wl_list_for_each(filter, &touchpad->motion_filters, link){
+ wl_list_for_each(filter, &touchpad->motion_filters, link)
+ {
filterDispatch(filter, &motion, touchpad, time);
}
getDirection(int dx, int dy)
{
int dir = UNDEFINED_DIRECTION;
- int d1, d2;
+ int d1;
+ int d2;
double r;
- if (abs(dx) < 2 && abs(dy) < 2) {
+ if (abs(dx) < 2 && abs(dy) < 2)
+ {
if (dx > 0 && dy > 0)
dir = S | SE | E;
else if (dx > 0 && dy < 0)
else if (dy < 0)
dir = NE | N | NW;
}
- else {
+ else
+ {
// Calculate r within the interval [0 to 8)
//
// r = [0 .. 2Ï€] where 0 is North
static void
feedTrackers(struct pointer_accelerator *accel,
- double dx, double dy, uint32_t time)
+ double dx, double dy, uint32_t time)
{
- int i, current;
+ int i;
+ int current;
struct pointer_tracker *trackers = accel->trackers;
- for (i = 0; i < NUM_POINTER_TRACKERS; ++i){
+ for (i = 0; i < NUM_POINTER_TRACKERS; ++i)
+ {
trackers[i].dx += dx;
trackers[i].dy += dy;
}
trackers[current].dx = 0.0;
trackers[current].dy = 0.0;
trackers[current].time = time;
- trackers[current].dir = getDirection(dx, dy);
+ trackers[current].dir = getDirection(dx, dy);
}
static struct pointer_tracker*
unsigned int dir = trackerByOffset(accel, 0)->dir;
// Find first velocity
- for (offset = 1; offset < NUM_POINTER_TRACKERS; offset++) {
+ for (offset = 1; offset < NUM_POINTER_TRACKERS; offset++)
+ {
tracker = trackerByOffset(accel, offset);
if (time <= tracker->time)
// Find least recent vector within a timelimit, maximum velocity diff
// and direction threshold.
- for (; offset < NUM_POINTER_TRACKERS; offset++) {
+ for (; offset < NUM_POINTER_TRACKERS; offset++)
+ {
tracker = trackerByOffset(accel, offset);
// Stop if too far away in time
static double
calculateAcceleration(struct pointer_accelerator *accel,
- void *data, double velocity, uint32_t time)
+ void *data, double velocity, uint32_t time)
{
double factor;
- factor = accelerationProfile(accel, data, velocity, time);
+ factor = accelerationProfile(accel, data, velocity, time);
factor += accelerationProfile(accel, data, accel->last_velocity, time);
factor += 4.0 *
- accelerationProfile(accel, data,
- (accel->last_velocity + velocity) / 2,
- time);
+ accelerationProfile(accel, data,
+ (accel->last_velocity + velocity) / 2,
+ time);
factor = factor / 6.0;
return factor;
}
static double
softenDelta(double lastDelta, double delta)
{
- if (delta < -1.0 || delta > 1.0){
+ if (delta < -1.0 || delta > 1.0)
+ {
if (delta > lastDelta)
return delta - 0.5;
else if (delta < lastDelta)
static void
applySoftening(struct pointer_accelerator *accel,
- struct motion_params *motion)
+ struct motion_params *motion)
{
motion->dx = softenDelta(accel->last_dx, motion->dx);
motion->dy = softenDelta(accel->last_dy, motion->dy);
void
acceleratorFilter(struct motion_filter *filter, struct motion_params *motion,
- void *data, uint32_t time)
+ void *data, uint32_t time)
{
struct pointer_accelerator *accel = (struct pointer_accelerator*)filter;
double velocity;
WaylandEvdevInputEvent::~WaylandEvdevInputEvent()
{
- if (m_udev){
+ if (m_udev)
+ {
udev_unref(m_udev);
}
struct evdev_input_device *device, *next;
- wl_list_for_each_safe(device, next, &m_deviceList, link){
+ wl_list_for_each_safe(device, next, &m_deviceList, link)
+ {
removeDevice(device);
}
}
WaylandInputEvent::setupInputEvent();
- m_screenWidth = m_windowSystem->getWindowWidth();
+ m_screenWidth = m_windowSystem->getWindowWidth();
m_screenHeight = m_windowSystem->getWindowHeight();
do {
bool bRet = addDevices();
- if (!bRet){
+ if (!bRet)
+ {
break;
}
} while (0);
{
if (!m_udev)
m_udev = udev_new();
- if (!m_udev){
+ if (!m_udev)
+ {
LOG_ERROR("WaylandEvdevInputEvent", "Failed to initialize udev context");
return false;
}
struct udev_list_entry *entry;
const char *path, *sysname;
struct udev_device *device;
- udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)){
+ udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e))
+ {
path = udev_list_entry_get_name(entry);
device = udev_device_new_from_syspath(m_udev, path);
sysname = udev_device_get_sysname(device);
- if (strncmp("event", sysname, 5) != 0){
+ if (strncmp("event", sysname, 5) != 0)
+ {
udev_device_unref(device);
continue;
}
notifyKeyboardFocus();
- if (wl_list_empty(&m_deviceList)){
+ if (wl_list_empty(&m_deviceList))
+ {
LOG_WARNING("WaylandEvdevInputEvent", "No input devices on entering service");
}
struct wl_event_loop *eventLoop;
device = (struct evdev_input_device*)malloc(sizeof(*device));
- if (device == NULL){
+ if (device == NULL)
+ {
return;
}
- device->master = this;
- device->isMt = 0;
- device->mtdev = NULL;
- device->devnode = strdup(path);
- device->mt.slot = -1;
- device->rel.dx = 0;
- device->rel.dy = 0;
+ device->master = this;
+ device->isMt = 0;
+ device->mtdev = NULL;
+ device->devnode = strdup(path);
+ device->mt.slot = -1;
+ device->rel.dx = 0;
+ device->rel.dy = 0;
device->dispatch = NULL;
device->fd = open(path, O_RDWR | O_NONBLOCK);
- if (device->fd < 0){
+ if (device->fd < 0)
+ {
goto err0;
}
- if (configureDevice(device) < 0){
+ if (configureDevice(device) < 0)
+ {
goto err1;
}
if (device->dispatch == NULL)
goto err1;
- if (device->isMt){
+ if (device->isMt)
+ {
device->mtdev = mtdev_new_open(device->fd);
- if (!device->mtdev){
+ if (!device->mtdev)
+ {
LOG_WARNING("WaylandEvdevInputEvent", "mtdev failed to open for " << path);
}
}
eventLoop = wl_display_get_event_loop(display);
device->source = wl_event_loop_add_fd(eventLoop, device->fd, WL_EVENT_READABLE,
- WaylandEvdevInputEvent::handleInputEvent,
- device);
- if (device->source == NULL){
+ WaylandEvdevInputEvent::handleInputEvent,
+ device);
+ if (device->source == NULL)
+ {
goto err2;
}
device->caps = 0;
ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
- if (TEST_BIT(ev_bits, EV_ABS)){
+ if (TEST_BIT(ev_bits, EV_ABS))
+ {
hasAbs = 1;
ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits);
- if (TEST_BIT(abs_bits, ABS_X)){
+ if (TEST_BIT(abs_bits, ABS_X))
+ {
ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
device->abs.min_x = absinfo.minimum;
device->abs.max_x = absinfo.maximum;
device->caps |= EVDEV_MOTION_ABS;
}
- if (TEST_BIT(abs_bits, ABS_Y)){
+ if (TEST_BIT(abs_bits, ABS_Y))
+ {
ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
device->abs.min_y = absinfo.minimum;
device->abs.max_y = absinfo.maximum;
device->caps |= EVDEV_MOTION_ABS;
}
- if (TEST_BIT(abs_bits, ABS_MT_SLOT)){
+ if (TEST_BIT(abs_bits, ABS_MT_SLOT))
+ {
device->isMt = 1;
device->mt.slot = 0;
device->caps |= EVDEV_TOUCH;
}
}
- if (TEST_BIT(ev_bits, EV_REL)){
+ if (TEST_BIT(ev_bits, EV_REL))
+ {
ioctl(device->fd, EVIOCGBIT(EV_REL, sizeof(rel_bits)), rel_bits);
- if (TEST_BIT(rel_bits, REL_X) || TEST_BIT(rel_bits, REL_Y)){
+ if (TEST_BIT(rel_bits, REL_X) || TEST_BIT(rel_bits, REL_Y))
+ {
device->caps |= EVDEV_MOTION_REL;
}
}
- if (TEST_BIT(ev_bits, EV_KEY)){
+ if (TEST_BIT(ev_bits, EV_KEY))
+ {
hasKey = 1;
ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits);
if (TEST_BIT(key_bits, BTN_TOOL_FINGER) &&
- !TEST_BIT(key_bits, BTN_TOOL_PEN) && hasAbs){
+ !TEST_BIT(key_bits, BTN_TOOL_PEN) && hasAbs)
+ {
device->dispatch = createTouchpad(device);
}
- for (i = KEY_ESC; i < KEY_MAX; ++i){
+ for (i = KEY_ESC; i < KEY_MAX; ++i)
+ {
if (i >= BTN_MISC && i < KEY_OK)
continue;
- if (TEST_BIT(key_bits, i)){
+ if (TEST_BIT(key_bits, i))
+ {
device->caps |= EVDEV_KEYBOARD;
break;
}
}
- for (i = BTN_MISC; i < KEY_OK; ++i){
- if (TEST_BIT(key_bits, i)){
+ for (i = BTN_MISC; i < KEY_OK; ++i)
+ {
+ if (TEST_BIT(key_bits, i))
+ {
device->caps |= EVDEV_BUTTON;
break;
}
}
}
- if (TEST_BIT(ev_bits, EV_LED)){
+ if (TEST_BIT(ev_bits, EV_LED))
+ {
device->caps |= EVDEV_KEYBOARD;
}
(device->caps & EVDEV_MOTION_ABS) ? "TRUE" : "FALSE",
(device->caps & EVDEV_MOTION_REL) ? "TRUE" : "FALSE",
(device->caps & EVDEV_TOUCH) ? "TRUE" : "FALSE");
- if (device->caps & EVDEV_MOTION_ABS){
+ if (device->caps & EVDEV_MOTION_ABS)
+ {
fprintf(stdout, " abs: min_x(%4d), min_y(%4d)\n", device->abs.min_x, device->abs.min_y);
fprintf(stdout, " max_x(%4d), max_y(%4d)\n", device->abs.max_x, device->abs.max_y);
fprintf(stdout, " x(%4d), y(%4d)\n", device->abs.x, device->abs.y);
fprintf(stdout, "\n");
#endif
- if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL | EVDEV_BUTTON))){
+ if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL | EVDEV_BUTTON)))
+ {
initPointerDevice();
}
- if ((device->caps & (EVDEV_KEYBOARD))){
+ if ((device->caps & (EVDEV_KEYBOARD)))
+ {
initKeyboardDevice(NULL);
}
- if ((device->caps & (EVDEV_TOUCH))){
+ if ((device->caps & (EVDEV_TOUCH)))
+ {
initTouchDevice();
}
int ret;
memset(all_keys, 0, sizeof(all_keys));
- wl_list_for_each(device, &m_deviceList, link){
+ wl_list_for_each(device, &m_deviceList, link)
+ {
memset(evdev_keys, 0, sizeof(evdev_keys));
ret = ioctl(device->fd, EVIOCGKEY(sizeof(evdev_keys)), evdev_keys);
- if (ret < 0){
+ if (ret < 0)
+ {
LOG_WARNING("WaylandEvdevInputEvent", "Failed to get keys for device: " <<
device->devnode);
continue;
}
- for (i = 0; i < ARRAY_LENGTH(evdev_keys); ++i){
+ for (i = 0; i < ARRAY_LENGTH(evdev_keys); ++i)
+ {
all_keys[i] |= evdev_keys[i];
}
}
wl_array_init(&keys);
- for (i = 0; i < KEY_CNT; ++i){
+ for (i = 0; i < KEY_CNT; ++i)
+ {
set = all_keys[i >> 3] & (1 << (i & 7));
- if (set){
+ if (set)
+ {
k = (uint32_t*)wl_array_add(&keys, sizeof(*k));
*k = i;
}
void
WaylandEvdevInputEvent::notifyKeyboardFocusIn(struct wl_array *keys,
- enum key_state_update updateState)
+ enum key_state_update updateState)
{
struct wl_seat *wlSeat;
- uint32_t *k, serial;
+ uint32_t *k;
+ uint32_t serial;
- if ((wlSeat = m_inputDevice->seat()) == NULL){
+ if ((wlSeat = m_inputDevice->seat()) == NULL)
+ {
return;
}
- if (!wlSeat->keyboard){
+ if (!wlSeat->keyboard)
+ {
return;
}
serial = wl_display_next_serial(m_inputDevice->display());
struct wl_array *array = &wlSeat->keyboard->keys;
for (k = (uint32_t*)array->data;
(const char*)k < (const char*)array->data + array->size;
- ++k){
- if (updateState == STATE_UPDATE_AUTOMATIC){
+ ++k)
+ {
+ if (updateState == STATE_UPDATE_AUTOMATIC)
+ {
updateModifierState(wlSeat, serial, *k, WL_KEYBOARD_KEY_STATE_PRESSED);
}
}
void
WaylandEvdevInputEvent::configureTouchpad(struct touchpad_dispatch *touchpad,
- struct evdev_input_device *device)
+ struct evdev_input_device *device)
{
struct motion_filter *accel;
// Configure pressure
ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits);
- if (TEST_BIT(abs_bits, ABS_PRESSURE)) {
+ if (TEST_BIT(abs_bits, ABS_PRESSURE))
+ {
ioctl(device->fd, EVIOCGABS(ABS_PRESSURE), &absinfo);
configureTouchpadPressure(touchpad,
- absinfo.minimum,
- absinfo.maximum);
+ absinfo.minimum,
+ absinfo.maximum);
}
// Configure acceleration factor
struct input_event ev[32];
int len;
do {
- if (device->mtdev){
+ if (device->mtdev)
+ {
len = mtdev_get(device->mtdev, fd, ev,
ARRAY_LENGTH(ev)) * sizeof(struct input_event);
}
- else {
+ else
+ {
len = read(fd, &ev, sizeof(ev));
}
- if (len < 0 || len % sizeof(ev[0]) != 0){
+ if (len < 0 || len % sizeof(ev[0]) != 0)
+ {
return 1;
}
WaylandEvdevInputEvent::processEvents(device, ev, len / sizeof(ev[0]));
-
} while (len > 0);
return 1;
void
WaylandEvdevInputEvent::processEvents(struct evdev_input_device *device,
- struct input_event *ev,
- int count)
+ struct input_event *ev,
+ int count)
{
struct evdev_dispatch *dispatch = device->dispatch;
struct input_event *e, *end;
e = ev;
end = e + count;
- for (; e < end; ++e){
+ for (; e < end; ++e)
+ {
time = e->time.tv_sec * 1000 + e->time.tv_usec / 1000;
- if (!isMotionEvent(e)){
+ if (!isMotionEvent(e))
+ {
WaylandEvdevInputEvent::flushMotion(device, time);
}
if (!inputEvent)
return;
- if (device->pending_events & EVDEV_RELATIVE_MOTION){
+ if (device->pending_events & EVDEV_RELATIVE_MOTION)
+ {
struct wl_seat *wlSeat = inputEvent->inputDevice().seat();
- if (wlSeat){
+ if (wlSeat)
+ {
// notify_motion
notifyMotion(device, time,
- wlSeat->pointer->x + device->rel.dx,
- wlSeat->pointer->y + device->rel.dy);
+ wlSeat->pointer->x + device->rel.dx,
+ wlSeat->pointer->y + device->rel.dy);
}
device->pending_events &= ~EVDEV_RELATIVE_MOTION;
device->rel.dx = 0;
device->rel.dy = 0;
}
- if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN){
+ if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN)
+ {
// notify_touch
notifyTouch(device);
device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
}
- if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION){
+ if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION)
+ {
// notify_touch
notifyTouch(device);
device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
}
- if (device->pending_events & EVDEV_ABSOLUTE_MT_UP){
+ if (device->pending_events & EVDEV_ABSOLUTE_MT_UP)
+ {
// notify_touch
notifyTouch(device);
device->pending_events &= ~EVDEV_ABSOLUTE_MT_UP;
}
- if (device->pending_events & EVDEV_ABSOLUTE_MOTION){
+ if (device->pending_events & EVDEV_ABSOLUTE_MOTION)
+ {
// notify_motion
notifyMotion(device, time,
- wl_fixed_from_int(device->abs.x),
- wl_fixed_from_int(device->abs.y));
+ wl_fixed_from_int(device->abs.x),
+ wl_fixed_from_int(device->abs.y));
device->pending_events &= ~EVDEV_ABSOLUTE_MOTION;
}
}
{
WL_UNUSED(dispatch);
- switch (e->type){
+ switch (e->type)
+ {
case EV_REL:
evdevProcessRelative(device, time, e);
break;
void
WaylandEvdevInputEvent::evdevProcessRelative(struct evdev_input_device *device,
- uint32_t /*time*/, struct input_event *e)
+ uint32_t /*time*/, struct input_event *e)
{
- switch (e->code){
+ switch (e->code)
+ {
case REL_X:
device->rel.dx += wl_fixed_from_int(e->value);
device->pending_events |= EVDEV_RELATIVE_MOTION;
int w = inputEvent->m_screenWidth;
int h = inputEvent->m_screenHeight;
- if (device->isMt){
+ if (device->isMt)
+ {
processTouch(device, e, w, h);
- } else {
+ }
+ else
+ {
processAbsoluteMotion(device, e, w, h);
}
}
if (e->value == 2)
return;
- switch (e->code){
+ switch (e->code)
+ {
case BTN_LEFT:
case BTN_RIGHT:
case BTN_MIDDLE:
{
struct touchpad_dispatch *touchpad = (struct touchpad_dispatch*)dispatch;
- switch (e->type){
+ switch (e->type)
+ {
case EV_SYN:
if (e->code == SYN_REPORT)
touchpad->event_mask |= TOUCHPAD_EVENT_REPORT;
struct motion_filter *filter;
struct motion_filter *next;
- wl_list_for_each_safe(filter, next, &touchpad->motion_filters, link){
+ wl_list_for_each_safe(filter, next, &touchpad->motion_filters, link)
+ {
filter->interface->destroy(filter);
}
{
WL_UNUSED(device);
- switch (e->code){
+ switch (e->code)
+ {
case ABS_PRESSURE:
if (e->value > touchpad->pressure.press)
touchpad->state = TOUCHPAD_STATE_PRESS;
else if (e->value > touchpad->pressure.touch_high)
touchpad->state = TOUCHPAD_STATE_TOUCH;
- else if (e->value < touchpad->pressure.touch_low){
+ else if (e->value < touchpad->pressure.touch_low)
+ {
if (touchpad->state > TOUCHPAD_STATE_NONE)
touchpad->reset = 1;
touchpad->state = TOUCHPAD_STATE_NONE;
}
break;
case ABS_X:
- if (touchpad->state >= TOUCHPAD_STATE_TOUCH){
+ if (touchpad->state >= TOUCHPAD_STATE_TOUCH)
+ {
touchpad->hw_abs.x = e->value;
touchpad->event_mask |= TOUCHPAD_EVENT_ABSOLUTE_ANY;
touchpad->event_mask |= TOUCHPAD_EVENT_ABSOLUTE_X;
}
break;
case ABS_Y:
- if (touchpad->state >= TOUCHPAD_STATE_TOUCH){
+ if (touchpad->state >= TOUCHPAD_STATE_TOUCH)
+ {
touchpad->hw_abs.y = e->value;
touchpad->event_mask |= TOUCHPAD_EVENT_ABSOLUTE_ANY;
touchpad->event_mask |= TOUCHPAD_EVENT_ABSOLUTE_Y;
struct input_event *e,
uint32_t time)
{
- switch (e->code){
+ switch (e->code)
+ {
case BTN_TOUCH:
- if (!touchpad->has_pressure){
- if (!e->value){
+ if (!touchpad->has_pressure)
+ {
+ if (!e->value)
+ {
touchpad->state = TOUCHPAD_STATE_NONE;
touchpad->reset = 1;
}
- else {
+ else
+ {
touchpad->state = e->value ? TOUCHPAD_STATE_TOUCH
: TOUCHPAD_STATE_NONE;
}
uint32_t time)
{
int motion_index;
- int center_x, center_y;
- double dx, dy;
+ int center_x;
+ int center_y;
+ double dx;
+ double dy;
if (touchpad->reset ||
- touchpad->last_finger_state != touchpad->finger_state) {
+ touchpad->last_finger_state != touchpad->finger_state)
+ {
touchpad->reset = 0;
touchpad->motion_count = 0;
touchpad->event_mask = TOUCHPAD_EVENT_NONE;
// Avoid noice by moving center only when delta reaches a threshold
// distance from the old center
- if (touchpad->motion_count > 0) {
+ if (touchpad->motion_count > 0)
+ {
center_x = hysteresis(touchpad->hw_abs.x,
touchpad->hysteresis.center_x,
touchpad->hysteresis.margin_x);
touchpad->hysteresis.center_y,
touchpad->hysteresis.margin_y);
}
- else {
+ else
+ {
center_x = touchpad->hw_abs.x;
center_y = touchpad->hw_abs.y;
}
if (touchpad->motion_count < 4)
touchpad->motion_count++;
- if (touchpad->motion_count >= 4) {
+ if (touchpad->motion_count >= 4)
+ {
touchpadGetDelta(touchpad, &dx, &dy);
filterMotion(touchpad, &dx, &dy, time);
wlSeat = inputEvent->inputDevice().seat();
serial = wl_display_next_serial(inputEvent->inputDevice().display());
- if (state == WL_POINTER_BUTTON_STATE_PRESSED){
- if (wlSeat->pointer->button_count == 0){
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
+ {
+ if (wlSeat->pointer->button_count == 0)
+ {
wlSeat->pointer->grab_button = button;
wlSeat->pointer->grab_time = time;
wlSeat->pointer->grab_x = wlSeat->pointer->x;
}
++wlSeat->pointer->button_count;
}
- else {
+ else
+ {
--wlSeat->pointer->button_count;
}
wlEvent.x = wl_fixed_to_int(wlSeat->pointer->x);
state == WL_POINTER_BUTTON_STATE_PRESSED ? INPUT_STATE_PRESSED :
INPUT_STATE_RELEASED, &wlEvent);
- if (wlSeat->pointer->button_count == 1){
+ if (wlSeat->pointer->button_count == 1)
+ {
wlSeat->pointer->grab_serial =
wl_display_get_serial(inputEvent->inputDevice().display());
}
WLEvent wlEvent;
struct wl_seat *wlSeat = NULL;
- int x, y;
+ int x;
+ int y;
//int old_x, old_y;
- int w, h;
+ int w;
+ int h;
WaylandEvdevInputEvent *inputEvent = static_cast<WaylandEvdevInputEvent*>(device->master);
if (!inputEvent)
WLEvent wlEvent;
struct wl_seat *wlSeat = NULL;
- uint32_t *k, *end;
+ uint32_t *k;
+ uint32_t *end;
WaylandEvdevInputEvent *inputEvent = static_cast<WaylandEvdevInputEvent*>(device->master);
if (!inputEvent)
return;
wlSeat = inputEvent->inputDevice().seat();
- if (state == WL_KEYBOARD_KEY_STATE_PRESSED){
+ if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
+ {
wlSeat->keyboard->grab_key = key;
wlSeat->keyboard->grab_time = time;
}
end = (uint32_t*)(((unsigned char*)wlSeat->keyboard->keys.data) + wlSeat->keyboard->keys.size);
- for (k = (uint32_t*)wlSeat->keyboard->keys.data; k < end; ++k){
- if (*k == key){
+ for (k = (uint32_t*)wlSeat->keyboard->keys.data; k < end; ++k)
+ {
+ if (*k == key)
+ {
// Ignore server-generated repeats
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
return;
}
}
wlSeat->keyboard->keys.size = end - (uint32_t*)wlSeat->keyboard->keys.data;
- if (state == WL_KEYBOARD_KEY_STATE_PRESSED){
+ if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
+ {
k = (uint32_t*)wl_array_add(&wlSeat->keyboard->keys, sizeof(*k));
*k = key;
}
if (!inputEvent)
return;
- if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN){
+ if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN)
+ {
wlEvent.x = (int)wl_fixed_from_int(device->mt.x[device->mt.slot]);
wlEvent.y = (int)wl_fixed_from_int(device->mt.y[device->mt.slot]);
wlEvent.touchId = device->mt.slot;
wlEvent.touchType = WL_TOUCH_DOWN;
eventState = INPUT_STATE_PRESSED;
- } else
- if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION){
+ }
+ else if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION)
+ {
wlEvent.x = (int)wl_fixed_from_int(device->mt.x[device->mt.slot]);
wlEvent.y = (int)wl_fixed_from_int(device->mt.y[device->mt.slot]);
wlEvent.touchId = device->mt.slot;
wlEvent.touchType = WL_TOUCH_MOTION;
eventState = INPUT_STATE_MOTION;
- } else
- if (device->pending_events & EVDEV_ABSOLUTE_MT_UP){
+ }
+ else if (device->pending_events & EVDEV_ABSOLUTE_MT_UP)
+ {
wlEvent.x = 0;
wlEvent.y = 0;
wlEvent.touchId = device->mt.slot;
wlEvent.touchType = WL_TOUCH_UP;
eventState = INPUT_STATE_RELEASED;
}
- else {
+ else
+ {
return;
}
void
WaylandEvdevInputEvent::notifyModifiers(struct wl_seat *wlSeat, uint32_t serial)
{
- uint32_t mods_depressed, mods_latched, mods_locked, group;
+ uint32_t mods_depressed;
+ uint32_t mods_latched;
+ uint32_t mods_locked;
+ uint32_t group;
uint32_t mods_lookup;
int changed = 0;
mods_depressed = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_DEPRESSED);
- mods_latched = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_LATCHED);
- mods_locked = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_LOCKED);
- group = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_EFFECTIVE);
+ mods_latched = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_LATCHED);
+ mods_locked = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_LOCKED);
+ group = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_EFFECTIVE);
if (mods_depressed != wlSeat->keyboard->modifiers.mods_depressed ||
- mods_latched != wlSeat->keyboard->modifiers.mods_latched ||
- mods_locked != wlSeat->keyboard->modifiers.mods_locked ||
- group != wlSeat->keyboard->modifiers.group){
+ mods_latched != wlSeat->keyboard->modifiers.mods_latched ||
+ mods_locked != wlSeat->keyboard->modifiers.mods_locked ||
+ group != wlSeat->keyboard->modifiers.group)
+ {
changed = 1;
}
wlSeat->keyboard->modifiers.mods_depressed = mods_depressed;
- wlSeat->keyboard->modifiers.mods_latched = mods_latched;
- wlSeat->keyboard->modifiers.mods_locked = mods_locked;
- wlSeat->keyboard->modifiers.group = group;
+ wlSeat->keyboard->modifiers.mods_latched = mods_latched;
+ wlSeat->keyboard->modifiers.mods_locked = mods_locked;
+ wlSeat->keyboard->modifiers.group = group;
// And update the modifier_state for bindings
mods_lookup = mods_depressed | mods_latched;
if (mods_lookup & (1 << m_xkbInfo.super_mod)) m_modifierState |= MODIFIER_SUPER;
if (mods_lookup & (1 << m_xkbInfo.shift_mod)) m_modifierState |= MODIFIER_SHIFT;
- if (changed){
+ if (changed)
+ {
m_inputDevice->sendModifiers(serial);
}
}
#include <iomanip>
#include "WindowSystems/WaylandEvdevInputEvent.h"
-WaylandFbdevWindowSystem::WaylandFbdevWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager)
+WaylandFbdevWindowSystem::WaylandFbdevWindowSystem(const char* displayname,
+ int width,
+ int height,
+ Scene* pScene,
+ InputManager* pInputManager)
: WaylandBaseWindowSystem(displayname, width, height, pScene, pInputManager)
, m_fdFB(-1)
{
findResourceForClient(struct wl_list *list, struct wl_client *client)
{
struct wl_resource *r;
- wl_list_for_each(r, list, link){
+ wl_list_for_each(r, list, link)
+ {
if (r->client == client)
return r;
}
{
wl_seat_init(&m_wlSeat);
wl_display_add_global(m_wlDisplay,
- &wl_seat_interface,
- this,
- WaylandInputDevice::bindInputDevice);
+ &wl_seat_interface,
+ this,
+ WaylandInputDevice::bindInputDevice);
}
WaylandInputDevice::~WaylandInputDevice()
WaylandInputDevice::destroyResource(struct wl_resource *resource)
{
WaylandInputDevice *inputDevice = static_cast<WaylandInputDevice*>(resource->data);
- if (inputDevice->keyboardDevice()->focus_resource == resource){
+ if (inputDevice->keyboardDevice()->focus_resource == resource)
+ {
inputDevice->keyboardDevice()->focus_resource = 0;
}
- if (inputDevice->pointerDevice()->focus_resource == resource){
+ if (inputDevice->pointerDevice()->focus_resource == resource)
+ {
inputDevice->pointerDevice()->focus_resource = 0;
}
uint32_t time, uint32_t code)
{
wl_keyboard *keyboard = keyboardDevice();
- if (!keyboard->focus){
+ if (!keyboard->focus)
+ {
setKeyboardFocus(surface);
}
- if (keyboard->focus_resource){
+ if (keyboard->focus_resource)
+ {
uint32_t serial = wl_display_next_serial(m_wlDisplay);
wl_keyboard_send_key(keyboard->focus_resource,
serial, time, code, 1);
uint32_t time, uint32_t code)
{
wl_keyboard *keyboard = keyboardDevice();
- if (keyboard->focus_resource){
+ if (keyboard->focus_resource)
+ {
uint32_t serial = wl_display_next_serial(m_wlDisplay);
wl_keyboard_send_key(keyboard->focus_resource,
- serial, time, code, 0);
+ serial, time, code, 0);
}
}
WaylandInputDevice::sendTouchPointEvent(struct wl_surface* surface, uint32_t time,
int touchId, int touchState, const Point& touchPos)
{
- switch (touchState){
+ switch (touchState)
+ {
case WL_TOUCH_DOWN:
++m_nTp;
- if (m_nTp == 1){
+ if (m_nTp == 1)
+ {
setTouchFocus(surface);
}
- if (m_wlTouchFocusResource && m_wlTouchFocus){
+ if (m_wlTouchFocusResource && m_wlTouchFocus)
+ {
wl_touch_send_down(m_wlTouchFocusResource,
- 0 /*serial*/, time,
- &m_wlTouchFocus->resource, touchId,
- wl_fixed_from_double(touchPos.x),
- wl_fixed_from_double(touchPos.y));
+ 0 /*serial*/, time,
+ &m_wlTouchFocus->resource, touchId,
+ wl_fixed_from_double(touchPos.x),
+ wl_fixed_from_double(touchPos.y));
}
break;
case WL_TOUCH_MOTION:
- if (!m_wlTouchFocus){
+ if (!m_wlTouchFocus)
+ {
break;
}
- if (m_wlTouchFocusResource){
+ if (m_wlTouchFocusResource)
+ {
wl_touch_send_motion(m_wlTouchFocusResource,
time, touchId,
wl_fixed_from_double(touchPos.x),
break;
case WL_TOUCH_UP:
--m_nTp;
- if (m_wlTouchFocusResource){
+ if (m_wlTouchFocusResource)
+ {
wl_touch_send_up(m_wlTouchFocusResource, 0 /*serial*/, time, touchId);
}
- if (m_nTp == 0){
+ if (m_nTp == 0)
+ {
setTouchFocus(NULL);
}
break;
{
wl_touch *touch = touchDevice();
wl_resource *resource = touch->focus_resource;
- if (resource){
+ if (resource)
+ {
wl_touch_send_frame(resource);
}
}
{
wl_touch *touch = touchDevice();
wl_resource *resource = touch->focus_resource;
- if (resource){
+ if (resource)
+ {
wl_touch_send_cancel(resource);
}
}
void
WaylandInputDevice::setMouseFocus(struct wl_surface* surface,
- const Point& globalPos,
- const Point& localPos)
+ const Point& globalPos,
+ const Point& localPos)
{
wl_pointer* pointer = pointerDevice();
pointer->x = wl_fixed_from_double(globalPos.x);
if (m_wlTouchFocus == surface)
return;
- if (surface){
+ if (surface)
+ {
resource = findResourceForClient(&m_wlSeat.touch->resource_list,
- surface->resource.client);
- if (!resource){
+ surface->resource.client);
+ if (!resource)
+ {
return;
}
m_wlSeat.touch->focus = surface;
m_wlSeat.touch->focus_resource = resource;
}
- else {
+ else
+ {
m_wlSeat.touch->focus = NULL;
m_wlSeat.touch->focus_resource = NULL;
}
struct wl_keyboard *keyboard = keyboardDevice();
struct wl_keyboard_grab *grab = keyboard->grab;
grab->interface->modifiers(grab, serial,
- keyboard->modifiers.mods_depressed,
- keyboard->modifiers.mods_latched,
- keyboard->modifiers.mods_locked,
- keyboard->modifiers.group);
+ keyboard->modifiers.mods_depressed,
+ keyboard->modifiers.mods_latched,
+ keyboard->modifiers.mods_locked,
+ keyboard->modifiers.group);
}
int fd;
#ifdef HAVE_MKOSTEMP
fd = mkostemp(tmpname, O_CLOEXEC);
- if (fd >= 0){
+ if (fd >= 0)
+ {
unlink(tmpname);
}
#else
fd = mkstemp(tmpname);
- if (fd >= 0){
+ if (fd >= 0)
+ {
fd = setCloexecOrClose(fd);
unlink(tmpname);
}
{
LOG_DEBUG("WaylandInputEvent", "initInputEvent IN");
m_inputDevice = new WaylandInputDevice(m_windowSystem->getNativeDisplayHandle());
- if (!m_inputDevice){
+ if (!m_inputDevice)
+ {
LOG_ERROR("WaylandInputEvent", "Failed to create WaylandInputDevice");
return;
}
void
WaylandInputEvent::setupInputEvent()
{
- if (!m_xkbContext){
+ if (!m_xkbContext)
+ {
m_xkbContext = xkb_context_new((enum xkb_context_flags)0);
- if (!m_xkbContext){
+ if (!m_xkbContext)
+ {
LOG_ERROR("WaylandInputEvent", "Failed to create XKB context");
return;
}
}
- m_xkbNames.rules = strdup("evdev");
- m_xkbNames.model = strdup("pc105");
+ m_xkbNames.rules = strdup("evdev");
+ m_xkbNames.model = strdup("pc105");
m_xkbNames.layout = strdup("us");
}
if (m_inputDevice->hasKeyboard())
return;
- if (keymap){
+ if (keymap)
+ {
m_xkbInfo.keymap = xkb_map_ref(keymap);
createNewKeymap();
- } else {
+ }
+ else
+ {
buildGlobalKeymap();
}
m_xkbState.state = xkb_state_new(m_xkbInfo.keymap);
- if (!m_xkbState.state){
+ if (!m_xkbState.state)
+ {
LOG_ERROR("WaylandInputEvent", "Failed to initialize XKB state");
return;
}
int fd;
path = getenv("XDG_RUNTIME_DIR");
- if (!path){
+ if (!path)
+ {
return -1;
}
name = (char*)malloc(strlen(path) + sizeof(temp));
- if (!name){
+ if (!name)
+ {
return -1;
}
fd = createTmpFileCloexec(name);
free(name);
- if (fd < 0){
+ if (fd < 0)
+ {
return -1;
}
- if (ftruncate(fd, size) < 0){
+ if (ftruncate(fd, size) < 0)
+ {
close(fd);
return -1;
}
void
WaylandInputEvent::createNewKeymap()
{
- m_xkbInfo.shift_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_SHIFT);
- m_xkbInfo.caps_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_CAPS);
- m_xkbInfo.ctrl_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_CTRL);
- m_xkbInfo.alt_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_ALT);
- m_xkbInfo.mod2_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod2");
- m_xkbInfo.mod3_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod3");
- m_xkbInfo.super_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_LOGO);
- m_xkbInfo.mod5_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod5");
- m_xkbInfo.num_led = xkb_map_led_get_index(m_xkbInfo.keymap, XKB_LED_NAME_NUM);
- m_xkbInfo.caps_led = xkb_map_led_get_index(m_xkbInfo.keymap, XKB_LED_NAME_CAPS);
+ m_xkbInfo.shift_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_SHIFT);
+ m_xkbInfo.caps_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_CAPS);
+ m_xkbInfo.ctrl_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_CTRL);
+ m_xkbInfo.alt_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_ALT);
+ m_xkbInfo.mod2_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod2");
+ m_xkbInfo.mod3_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod3");
+ m_xkbInfo.super_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, XKB_MOD_NAME_LOGO);
+ m_xkbInfo.mod5_mod = xkb_map_mod_get_index(m_xkbInfo.keymap, "Mod5");
+ m_xkbInfo.num_led = xkb_map_led_get_index(m_xkbInfo.keymap, XKB_LED_NAME_NUM);
+ m_xkbInfo.caps_led = xkb_map_led_get_index(m_xkbInfo.keymap, XKB_LED_NAME_CAPS);
m_xkbInfo.scroll_led = xkb_map_led_get_index(m_xkbInfo.keymap, XKB_LED_NAME_SCROLL);
char *keymapStr = xkb_map_get_as_string(m_xkbInfo.keymap);
- if (keymapStr == NULL){
+ if (keymapStr == NULL)
+ {
LOG_ERROR("WaylandX11InputEvent", "Failed to get string version of keymap");
return;
}
m_xkbInfo.keymap_size = strlen(keymapStr) + 1;
m_xkbInfo.keymap_fd = createAnonymousFile(m_xkbInfo.keymap_size);
- if (m_xkbInfo.keymap_fd < 0){
+ if (m_xkbInfo.keymap_fd < 0)
+ {
LOG_WARNING("WaylandX11InputEvent", "Creating a keymap file for " <<
(unsigned long)m_xkbInfo.keymap_size <<
" bytes failed");
MAP_SHARED,
m_xkbInfo.keymap_fd,
0);
- if (m_xkbInfo.keymap_area == MAP_FAILED){
+ if (m_xkbInfo.keymap_area == MAP_FAILED)
+ {
LOG_WARNING("WaylandX11InputEvent", "Failed to mmap() " <<
(unsigned long) m_xkbInfo.keymap_size <<
" bytes");
return;
m_xkbInfo.keymap = xkb_map_new_from_names(m_xkbContext,
- &m_xkbNames,
- static_cast<xkb_map_compile_flags>(0));
- if (m_xkbInfo.keymap == NULL){
+ &m_xkbNames,
+ static_cast<xkb_map_compile_flags>(0));
+ if (m_xkbInfo.keymap == NULL)
+ {
LOG_ERROR("WaylandInputEvent", "Failed to compile global XKB keymap");
LOG_ERROR("WaylandInputEvent", " tried rules: " << m_xkbNames.rules <<
- ", model: " << m_xkbNames.model <<
- ", layout: " << m_xkbNames.layout);
+ ", model: " << m_xkbNames.model <<
+ ", layout: " << m_xkbNames.layout);
return;
}
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
static const struct wl_interface *types[] = {
- NULL,
+ NULL,
};
static const struct wl_message serverinfo_requests[] = {
- { "get_connection_id", "", types + 0 },
+ { "get_connection_id", "", types + 0 },
};
static const struct wl_message serverinfo_events[] = {
- { "connection_id", "u", types + 0 },
+ { "connection_id", "u", types + 0 },
};
extern "C" WL_EXPORT const struct wl_interface serverinfo_interface = {
- "serverinfo", 1,
- ARRAY_LENGTH(serverinfo_requests), serverinfo_requests,
- ARRAY_LENGTH(serverinfo_events), serverinfo_events,
+ "serverinfo", 1,
+ ARRAY_LENGTH(serverinfo_requests), serverinfo_requests,
+ ARRAY_LENGTH(serverinfo_events), serverinfo_events,
};
extern "C"
{
- static int
- x11GetNextEvent(xcb_connection_t *conn, xcb_generic_event_t **event, uint32_t mask)
+static int
+x11GetNextEvent(xcb_connection_t *conn, xcb_generic_event_t **event, uint32_t mask)
+{
+ if (mask & WL_EVENT_READABLE)
+ {
+ *event = xcb_poll_for_event(conn);
+ }
+ else
{
- if (mask & WL_EVENT_READABLE){
- *event = xcb_poll_for_event(conn);
- } else {
#ifdef HAVE_XCB_POLL_FOR_QUEUED_EVENT
- *event = xcb_poll_for_queued_event(conn);
+ *event = xcb_poll_for_queued_event(conn);
#else
- *event = xcb_poll_for_event(conn);
+ *event = xcb_poll_for_event(conn);
#endif
- }
- return *event != NULL;
}
+ return *event != NULL;
+}
- static bool
- getButtonEvent(xcb_generic_event_t *event, WLEvent *wlEvent, int /*state*/)
+static bool
+getButtonEvent(xcb_generic_event_t *event, WLEvent *wlEvent, int /*state*/)
+{
+ xcb_button_press_event_t *buttonEvent = (xcb_button_press_event_t*)event;
+ switch (buttonEvent->detail)
{
- xcb_button_press_event_t *buttonEvent = (xcb_button_press_event_t*)event;
- switch (buttonEvent->detail){
- default:
- wlEvent->button = buttonEvent->detail + BTN_LEFT - 1;
- break;
- case 2:
- wlEvent->button = BTN_MIDDLE;
- break;
- case 3:
- wlEvent->button = BTN_RIGHT;
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- return false;
- }
- return true;
+ default:
+ wlEvent->button = buttonEvent->detail + BTN_LEFT - 1;
+ break;
+ case 2:
+ wlEvent->button = BTN_MIDDLE;
+ break;
+ case 3:
+ wlEvent->button = BTN_RIGHT;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ return false;
}
+ return true;
+}
}
/////////////////////////////////////////////////////////////////////////////
WaylandX11WindowSystem* x11WindowSystem
= dynamic_cast<WaylandX11WindowSystem*>(m_windowSystem);
- if (!x11WindowSystem){
+ if (!x11WindowSystem)
+ {
LOG_ERROR("WaylandX11InputEvent", "Invalid window system");
return;
}
m_x11Display = x11WindowSystem->x11Display();
- if (!m_x11Display){
+ if (!m_x11Display)
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: WindowSystem has not x11 display");
return;
}
m_xcbConn = XGetXCBConnection(m_x11Display);
XSetEventQueueOwner(m_x11Display, XCBOwnsEventQueue);
- if (xcb_connection_has_error(m_xcbConn)){
+ if (xcb_connection_has_error(m_xcbConn))
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: xcb connection has error.");
XCloseDisplay(m_x11Display);
return;
// Get resources
{
- static const struct {
+ static const struct
+ {
const char *name;
int offset;
- } atoms[] = {
- { "STRING", F(string) },
+ }
+ atoms[] = {
+ { "STRING", F(string) },
{ "_XKB_RULES_NAMES", F(xkbNames) }
};
xcb_intern_atom_cookie_t cookies[2];
xcb_intern_atom_reply_t *reply;
unsigned int i = 0;
- for (i = 0; i < ARRAY_LENGTH(atoms); ++i){
+ for (i = 0; i < ARRAY_LENGTH(atoms); ++i)
+ {
cookies[i] = xcb_intern_atom(m_xcbConn, 0,
strlen(atoms[i].name),
atoms[i].name);
}
- for (i = 0; i < ARRAY_LENGTH(atoms); ++i){
+ for (i = 0; i < ARRAY_LENGTH(atoms); ++i)
+ {
reply = xcb_intern_atom_reply(m_xcbConn, cookies[i], NULL);
*(xcb_atom_t*)((char *)(&m_atom) + atoms[i].offset) = reply->atom;
free(reply);
setupXkb();
struct xkb_keymap *keymap = getKeymap();
initKeyboardDevice(keymap);
- if (keymap){
+ if (keymap)
+ {
xkb_map_unref(keymap);
}
xcb_xkb_per_client_flags_reply_t *pcf_reply;
ext = xcb_get_extension_data(m_xcbConn, &xcb_xkb_id);
- if (!ext){
+ if (!ext)
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: XKB extension not available on "
"host X11 server");
return;
0,
NULL);
error = xcb_request_check(m_xcbConn, select);
- if (error){
+ if (error)
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: Failed to select XKB state events");
return;
}
0, 0, 0);
pcf_reply = xcb_xkb_per_client_flags_reply(m_xcbConn, pcf, &error);
free(pcf_reply);
- if (error){
+ if (error)
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: Failed to set XKB per-client flags, "
"not using detectable repeat");
return;
xcb_generic_error_t *error;
struct xkb_rule_names names;
struct xkb_keymap *ret;
- char *value_all, *value_part;
- int length_all, length_part;
+ char* value_all;
+ char* value_part;
+ int length_all;
+ int length_part;
memset(&names, 0x00, sizeof(names));
m_atom.string,
0, 1024);
reply = xcb_get_property_reply(m_xcbConn, cookie, &error);
- if (reply == NULL){
+ if (reply == NULL)
+ {
LOG_ERROR("WaylandX11InputEvent", "ERROR: xcb_get_property_reply");
return NULL;
}
- value_all = static_cast<char*>(xcb_get_property_value(reply));
+ value_all = static_cast<char*>(xcb_get_property_value(reply));
length_all = xcb_get_property_value_length(reply);
value_part = value_all;
xcb_generic_event_t *event;
xcb_motion_notify_event_t *motionNotify;
xcb_button_press_event_t *buttonEvent;
- xcb_key_press_event_t *keyPress, *keyRelease;
+ xcb_key_press_event_t *keyPress;
+ xcb_key_press_event_t *keyRelease;
InputDevice deviceType = INPUT_DEVICE_POINTER;
- InputEventState state = INPUT_STATE_MOTION;
+ InputEventState state = INPUT_STATE_MOTION;
int count = 0;
xcb_generic_event_t *prev = NULL;
- while (x11GetNextEvent(ins->connection(), &event, mask)){
- switch (prev ? prev->response_type & ~0x80 : 0x80){
+ while (x11GetNextEvent(ins->connection(), &event, mask))
+ {
+ switch (prev ? prev->response_type & ~0x80 : 0x80)
+ {
case XCB_KEY_RELEASE:
keyRelease = (xcb_key_press_event_t*)prev;
keyPress = (xcb_key_press_event_t*)event;
if ((event->response_type & ~0x80) == XCB_KEY_PRESS &&
keyRelease->time == keyPress->time &&
- keyRelease->detail == keyPress->detail){
+ keyRelease->detail == keyPress->detail)
+ {
// Don't deliver the held key release event or
// the new key press even.
free(event);
free(prev);
prev = NULL;
continue;
- } else {
+ }
+ else
+ {
free(prev);
prev = NULL;
break;
memset(&wlEvent, 0x00, sizeof(WLEvent));
- switch (event->response_type & ~0x80){
+ switch (event->response_type & ~0x80)
+ {
case XCB_KEY_PRESS:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] XCB_KEY_PRESS");
keyPress = (xcb_key_press_event_t *)event;
- wlEvent.keyCode = keyPress->detail - 8;
+ wlEvent.keyCode = keyPress->detail - 8;
wlEvent.keyState = WL_KEYBOARD_KEY_STATE_PRESSED;
deviceType = INPUT_DEVICE_KEYBOARD;
- state = INPUT_STATE_PRESSED;
+ state = INPUT_STATE_PRESSED;
break;
case XCB_KEY_RELEASE:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] XCB_KEY_RELEASE");
wlEvent.keyState = WL_KEYBOARD_KEY_STATE_RELEASED;
deviceType = INPUT_DEVICE_KEYBOARD;
- state = INPUT_STATE_RELEASED;
+ state = INPUT_STATE_RELEASED;
break;
case XCB_BUTTON_PRESS:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] XCB_BUTTON_PRESS");
- if (!getButtonEvent(event, &wlEvent, 1)){
+ if (!getButtonEvent(event, &wlEvent, 1))
+ {
continue; // not supported button event
}
buttonEvent = (xcb_button_press_event_t *)event;
wlEvent.buttonState = WL_POINTER_BUTTON_STATE_PRESSED;
deviceType = INPUT_DEVICE_POINTER;
- state = INPUT_STATE_PRESSED;
+ state = INPUT_STATE_PRESSED;
break;
case XCB_BUTTON_RELEASE:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] XCB_BUTTON_RELEASE");
- if (!getButtonEvent(event, &wlEvent, 0)){
+ if (!getButtonEvent(event, &wlEvent, 0))
+ {
continue; // not suported button event
}
buttonEvent = (xcb_button_press_event_t *)event;
wlEvent.buttonState = WL_POINTER_BUTTON_STATE_RELEASED;
deviceType = INPUT_DEVICE_POINTER;
- state = INPUT_STATE_RELEASED;
+ state = INPUT_STATE_RELEASED;
break;
case XCB_MOTION_NOTIFY:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] XCB_MOTION_NOTIFY");
wlEvent.y = motionNotify->event_y;
deviceType = INPUT_DEVICE_POINTER;
- state = INPUT_STATE_MOTION;
+ state = INPUT_STATE_MOTION;
break;
case XCB_EXPOSE:
case XCB_ENTER_NOTIFY:
case XCB_FOCUS_OUT:
default:
LOG_DEBUG("WaylandX11InputEvent", "[EVENT] Not supported (" <<
- (event->response_type & ~0x80) << ")");
- if (prev != event){
+ (event->response_type & ~0x80) << ")");
+ if (prev != event)
+ {
free(event);
}
continue;
}
++count;
- if (prev != event){
+ if (prev != event)
+ {
free(event);
}
}
- if (count == 0){
+ if (count == 0)
+ {
goto rtn;
}
- switch (prev ? prev->response_type & ~0x80 : 0x80){
+ switch (prev ? prev->response_type & ~0x80 : 0x80)
+ {
case XCB_KEY_RELEASE:
keyRelease = (xcb_key_press_event_t*)prev;
- wlEvent.keyCode = keyRelease->detail - 8;
+ wlEvent.keyCode = keyRelease->detail - 8;
wlEvent.keyState = WL_KEYBOARD_KEY_STATE_RELEASED;
deviceType = INPUT_DEVICE_KEYBOARD;
- state = INPUT_STATE_RELEASED;
+ state = INPUT_STATE_RELEASED;
free(prev);
prev = NULL;
break;
//. TODO: should not be here. graphicSystem should support.
EGLDisplay eglDisplayhandle = ((GLESGraphicsystem*)(graphicSystem))->getEGLDisplay();
PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplayWL = (PFNEGLBINDWAYLANDDISPLAYWL)eglGetProcAddress("eglBindWaylandDisplayWL");
- if( eglBindWaylandDisplayWL != NULL )
+ if (eglBindWaylandDisplayWL != NULL)
{
- eglBindWaylandDisplayWL( eglDisplayhandle, m_wlDisplay );
+ eglBindWaylandDisplayWL(eglDisplayhandle, m_wlDisplay);
}
else
{
const char X11WindowSystem::CompositorWindowTitle[] = "LayerManager";
bool X11WindowSystem::m_xerror = false;
-X11WindowSystem::X11WindowSystem(const char* displayname, int width, int height, Scene* pScene,InputManager* pInputManager,GetVisualInfoFunction func)
+X11WindowSystem::X11WindowSystem(const char* displayname,
+ int width,
+ int height,
+ Scene* pScene,
+ InputManager* pInputManager,
+ GetVisualInfoFunction func)
: BaseWindowSystem(pScene, pInputManager)
, takeScreenshot(ScreenShotNone)
, screenShotFile()
// init and take mutex, so windowsystem only does init phase until mutex is released again
pthread_mutex_init(&run_lock, NULL);
- pthread_cond_init(&run_condition,NULL);
- pthread_cond_init(&init_condition,NULL);
+ pthread_cond_init(&run_condition, NULL);
+ pthread_cond_init(&init_condition, NULL);
pthread_mutex_init(&init_lock, NULL);
}
if (windowVis)
{
windowVis->depth = DefaultDepth(dpy, DefaultScreen(dpy));
- if (!XMatchVisualInfo( dpy, 0, windowVis->depth, TrueColor, windowVis))
+ if (!XMatchVisualInfo(dpy, 0, windowVis->depth, TrueColor, windowVis))
{
LOG_ERROR("X11WindowSystem", "Error: Required visual not found\n");
delete windowVis;
{
m_displayEnvironment = getenv("DISPLAY");
- if (m_displayEnvironment == NULL )
+ if (m_displayEnvironment == NULL)
{
m_displayEnvironment = ":0.0";
- setenv("DISPLAY",m_displayEnvironment,1);
+ setenv("DISPLAY", m_displayEnvironment, 1);
}
x11Display = XOpenDisplay(m_displayEnvironment);
bool X11WindowSystem::checkForCompositeExtension()
{
- if (x11Display == NULL || !XQueryExtension (x11Display, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error))
+ if (x11Display == NULL || !XQueryExtension(x11Display, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error))
{
LOG_ERROR("X11WindowSystem", "No composite extension");
return false;
}
- XCompositeQueryVersion (x11Display, &composite_major, &composite_minor);
+ XCompositeQueryVersion(x11Display, &composite_major, &composite_minor);
LOG_DEBUG("X11WindowSystem", "Found composite extension: composite opcode: " << composite_opcode);
LOG_DEBUG("X11WindowSystem", "composite_major: " << composite_major);
LOG_DEBUG("X11WindowSystem", "composite_minor: " << composite_minor);
return true;
}
-bool X11WindowSystem::checkForDamageExtension(){
- if (x11Display == NULL || !XQueryExtension (x11Display, DAMAGE_NAME, &damage_opcode,
+bool X11WindowSystem::checkForDamageExtension()
+{
+ if (x11Display == NULL || !XQueryExtension(x11Display, DAMAGE_NAME, &damage_opcode,
&damage_event, &damage_error))
{
LOG_ERROR("X11WindowSystem", "No damage extension");
return false;
}
- XDamageQueryVersion (x11Display, &damage_major, &damage_minor);
+ XDamageQueryVersion(x11Display, &damage_major, &damage_minor);
LOG_DEBUG("X11WindowSystem", "Found damage extension: damage opcode: " << damage_opcode);
LOG_DEBUG("X11WindowSystem", "damage_major: " << damage_major);
LOG_DEBUG("X11WindowSystem", "damage_minor: " << damage_minor);
return true;
}
-void X11WindowSystem::printDebug(){
+void X11WindowSystem::printDebug()
+{
// print stuff about layerlist
std::stringstream debugmessage;
debugmessage << "Layer: ID | X | Y | W | H | Al. \n";
LayerListConstIterator iter = list.begin();
LayerListConstIterator iterEnd = list.end();
- for(; iter != iterEnd; ++iter)
+ for (; iter != iterEnd; ++iter)
{
Rectangle dest = (*iter)->getDestinationRegion();
debugmessage << " " << std::setw(4) << (*iter)->getID() << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << " " << std::setw(3) << (*iter)->opacity << "\n";
SurfaceListIterator surfaceIter = surfaceList.begin();
SurfaceListIterator surfaceIterEnd = surfaceList.end();
- for(; surfaceIter != surfaceIterEnd ; ++surfaceIter)
+ for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
{
Rectangle src = (*surfaceIter)->getSourceRegion();
Rectangle dest = (*surfaceIter)->getDestinationRegion();
- debugmessage << " " << std::setw(4) << (*surfaceIter)->getID() << " " << std::setprecision(3) << (*surfaceIter)->opacity<< " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
+ debugmessage << " " << std::setw(4) << (*surfaceIter)->getID() << " " << std::setprecision(3) << (*surfaceIter)->opacity << " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
}
}
- LOG_DEBUG("X11WindowSystem",debugmessage.str());
+ LOG_DEBUG("X11WindowSystem", debugmessage.str());
}
-Window * getListOfAllTopLevelWindows (Display *disp, unsigned int *len)
+Window * getListOfAllTopLevelWindows(Display *disp, unsigned int *len)
{
LOG_DEBUG("X11WindowSystem", "Getting list of all windows");
Window *children;
- Window root_return, parent_return;
- Window root = XDefaultRootWindow(disp);
- XQueryTree (disp, root, &root_return, &parent_return, &children, len);
+ Window root_return;
+ Window parent_return;
+ Window root = XDefaultRootWindow(disp);
+ XQueryTree(disp, root, &root_return, &parent_return, &children, len);
return children;
}
bool X11WindowSystem::isWindowValid(Window w)
{
// skip our own two windows
- return (w!=None && w != CompositorWindow);
+ return (w != None && w != CompositorWindow);
}
Surface* X11WindowSystem::getSurfaceForWindow(Window w)
{
// go though all surfaces
- const std::map<unsigned int,Surface*> surfaces = m_pScene->getAllSurfaces();
- for(std::map<unsigned int, Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); ++currentS)
+ const std::map<unsigned int, Surface*> surfaces = m_pScene->getAllSurfaces();
+ for (std::map<unsigned int, Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); ++currentS)
{
Surface* currentSurface = (*currentS).second;
if (!currentSurface)
}
if (currentSurface->getNativeContent() == static_cast<int>(w))
{
- return currentSurface;
+ return currentSurface;
}
}
LOG_DEBUG("X11WindowSystem", "could not find surface for window " << w);
{
m_pScene->lockScene();
LayerList layers = m_pScene->getCurrentRenderOrder(0);
- for(LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
+ for (LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
{
SurfaceList surfaces = (*current)->getAllSurfaces();
- for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+ for (SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
{
if ((*currentS)->hasNativeContent())
{
UnMapWindow(window);
MapWindow(window);
XWindowAttributes att;
- XGetWindowAttributes (x11Display, window, &att);
+ XGetWindowAttributes(x11Display, window, &att);
int winWidth = att.width;
int winHeight = att.height;
Surface* surface = getSurfaceForWindow(window);
if (!surface)
{
- LOG_WARNING("X11WindowSystem", "Could not find surface for window " << window);
+ LOG_WARNING("X11WindowSystem", "Could not find surface for window " << window);
return;
}
if (!surface->platform)
void X11WindowSystem::MapWindow(Window window)
{
- LOG_DEBUG("X11WindowSystem","Map window begin");
+ LOG_DEBUG("X11WindowSystem", "Map window begin");
if (isWindowValid(window))
{
XWindowAttributes att;
- XGetWindowAttributes (x11Display, window, &att);
+ XGetWindowAttributes(x11Display, window, &att);
/* LOG_DEBUG("X11WindowSystem", "XCompositeRedirectWindow()");
XCompositeRedirectWindow(x11Display, window, CompositeRedirectManual);
XSync(x11Display, 0);*/
- if (att.map_state == IsViewable && att.override_redirect==0)
+ if (att.map_state == IsViewable && att.override_redirect == 0)
{
LOG_DEBUG("X11WindowSystem", "Mapping surface to window " << window);
Surface* surface = getSurfaceForWindow(window);
}
x11surf->isMapped = true;
-
LOG_DEBUG("X11WindowSystem", "getting pixmap for window");
LOG_DEBUG("X11WindowSystem", "window width: " << att.width);
LOG_DEBUG("X11WindowSystem", "window height: " << att.height);
LOG_DEBUG("X11WindowSystem", "Mapping successfull");
}
}
- LOG_DEBUG("X11WindowSystem","Map window end");
+ LOG_DEBUG("X11WindowSystem", "Map window end");
}
void X11WindowSystem::UnMapWindow(Window window)
if (isWindowValid(window))
{
LOG_DEBUG("X11WindowSystem", "Unmapping surface from window " << window);
- Surface* surface = getSurfaceForWindow(window);
+ Surface* surface = getSurfaceForWindow(window);
if (!surface)
{
LOG_WARNING("X11WindowSystem", "Could not unmap window " << window);
}
x11surf->isMapped = false;
-
LOG_DEBUG("X11WindowSystem", "Destroying ClientBuffer");
graphicSystem->getTextureBinder()->destroyClientBuffer(surface);
XSync(x11Display, 0);
LOG_DEBUG("X11WindowSystem", "Creating Surface for new window " << window);
// get the windows attributes
XWindowAttributes att;
- int status = XGetWindowAttributes (x11Display, window, &att);
+ int status = XGetWindowAttributes(x11Display, window, &att);
LOG_DEBUG("X11WindowSystem", "Got window attrbutes");
char* name;
status = XFetchName(x11Display, window, &name);
{
LOG_DEBUG("X11WindowSystem", "Found window: " << window << " " << name);
char GuiTitle[] = "Layermanager Remote GUI\0";
- if (strcmp(name,GuiTitle)==0)
+ if (strcmp(name, GuiTitle) == 0)
{
LOG_DEBUG("X11WindowSystem", "Found gui window: repositioning it");
- XCompositeUnredirectWindow(x11Display,window,CompositeRedirectManual);
+ XCompositeUnredirectWindow(x11Display, window, CompositeRedirectManual);
XMoveWindow(x11Display, window, 50, 500);
XMapRaised(x11Display, window);
}
if (att.c_class == InputOutput)
{
- LOG_DEBUG("X11WindowSystem","Creating New Damage for window - " << window);
- XDamageCreate(x11Display,window,XDamageReportNonEmpty);
+ LOG_DEBUG("X11WindowSystem", "Creating New Damage for window - " << window);
+ XDamageCreate(x11Display, window, XDamageReportNonEmpty);
}
XFree(name);
- XLowerWindow(x11Display,window);
+ XLowerWindow(x11Display, window);
surface->setNativeContent(window);
XPlatformSurface * platformSurface = (XPlatformSurface*)graphicSystem->getTextureBinder()->createPlatformSurface(surface);
if (isWindowValid(window))
{
LOG_DEBUG("X11WindowSystem", "Destroying Surface for window " << window);
- Surface* surface = getSurfaceForWindow(window);
+ Surface* surface = getSurfaceForWindow(window);
if (!surface)
{
LOG_WARNING("X11WindowSystem", "Could not find surface for window " << window);
bool result = true;
LOG_DEBUG("X11WindowSystem", "redirecting all windows");
Window root = RootWindow(x11Display, DefaultScreen(x11Display));
- XCompositeRedirectSubwindows(x11Display,root,CompositeRedirectManual);
- XSync(x11Display,0);
+ XCompositeRedirectSubwindows(x11Display, root, CompositeRedirectManual);
+ XSync(x11Display, 0);
return result;
}
XSetWindowAttributes attr;
// draw a black background the full size of the resolution
attr.override_redirect = True;
- attr.event_mask = ExposureMask
+ attr.event_mask = ExposureMask
| StructureNotifyMask
| ButtonPressMask
| ButtonReleaseMask
attr.colormap = XCreateColormap(x11Display, root, windowVis->visual, AllocNone);
attr.override_redirect = True;
- Window compManager = XGetSelectionOwner(x11Display,XInternAtom(x11Display,"_NET_WM_CM_S0",0));
- if ( None != compManager )
+ Window compManager = XGetSelectionOwner(x11Display, XInternAtom(x11Display, "_NET_WM_CM_S0", 0));
+ if (None != compManager)
{
LOG_ERROR("X11WindowSystem", "Could not create compositor window, annother compisite manager is already running");
return false;
}
LOG_DEBUG("X11WindowSystem", "Created the Compositor Window");
- XSelectInput (x11Display, root,
+ XSelectInput(x11Display, root,
SubstructureNotifyMask|
ExposureMask|
StructureNotifyMask|
LOG_DEBUG("X11WindowSystem", "Created the window");
XSizeHints sizehints;
- sizehints.width = windowWidth;
+ sizehints.width = windowWidth;
sizehints.height = windowHeight;
sizehints.flags = USSize;
XSetNormalHints(x11Display, CompositorWindow, &sizehints);
static int Frame = 0;
-void X11WindowSystem::calculateSurfaceFps(Surface *currentSurface, float time )
+void X11WindowSystem::calculateSurfaceFps(Surface *currentSurface, float time)
{
- char floatStringBuffer[256];
- float surfaceUpdateFps = ((float)(currentSurface->updateCounter)) / time ;
- float surfaceDrawFps = ((float)(currentSurface->drawCounter)) / time ;
- sprintf(floatStringBuffer, "0x%08x update fps: %3.2f", currentSurface->getID(),surfaceUpdateFps);
- currentSurface->updateCounter = 0;
- LOG_INFO("X11WindowSystem", "Surface " << floatStringBuffer);
- sprintf(floatStringBuffer, "0x%08x draw fps: %3.2f", currentSurface->getID(),surfaceDrawFps);
- currentSurface->drawCounter = 0;
- LOG_INFO("X11WindowSystem", "Surface " << floatStringBuffer);
+ char floatStringBuffer[256];
+ float surfaceUpdateFps = ((float)(currentSurface->updateCounter)) / time;
+ float surfaceDrawFps = ((float)(currentSurface->drawCounter)) / time;
+ sprintf(floatStringBuffer, "0x%08x update fps: %3.2f", currentSurface->getID(), surfaceUpdateFps);
+ currentSurface->updateCounter = 0;
+ LOG_INFO("X11WindowSystem", "Surface " << floatStringBuffer);
+ sprintf(floatStringBuffer, "0x%08x draw fps: %3.2f", currentSurface->getID(), surfaceDrawFps);
+ currentSurface->drawCounter = 0;
+ LOG_INFO("X11WindowSystem", "Surface " << floatStringBuffer);
}
void X11WindowSystem::calculateFps()
FPS = ((float)(Frame)) / timeSinceLastCalc;
char floatStringBuffer[256];
sprintf(floatStringBuffer, "Overall fps: %f", FPS);
- for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+ for (std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
{
SurfaceList surfaceList = (*current)->getAllSurfaces();
SurfaceListIterator surfaceIter = surfaceList.begin();
SurfaceListIterator surfaceIterEnd = surfaceList.end();
- for(; surfaceIter != surfaceIterEnd ; ++surfaceIter)
+ for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
{
- calculateSurfaceFps((*surfaceIter),timeSinceLastCalc);
+ calculateSurfaceFps((*surfaceIter), timeSinceLastCalc);
}
}
LOG_INFO("X11WindowSystem", floatStringBuffer);
LayerList swLayers;
// Refresh HW Layers, find SW Layers
- for(LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
+ for (LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
{
if ((*current)->getLayerType() == Hardware)
{
LOG_DEBUG("X11WindowSystem", "Taking screenshot");
RedrawAllLayers(true, false); // Do clear, Don't swap
}
- else if(takeScreenshot == ScreenshotOfLayer)
+ else if (takeScreenshot == ScreenshotOfLayer)
{
LOG_DEBUG("X11WindowSystem", "Taking screenshot of layer");
Layer* layer = m_pScene->getLayer(screenShotLayerID);
graphicSystem->renderSWLayer(layer, true); // Do clear
}
}
- else if(takeScreenshot == ScreenshotOfSurface)
+ else if (takeScreenshot == ScreenshotOfSurface)
{
LOG_DEBUG("X11WindowSystem", "Taking screenshot of surface");
Layer* layer = m_pScene->getLayer(screenShotLayerID);
}
int
-X11WindowSystem::error (Display *dpy, XErrorEvent *ev)
+X11WindowSystem::error(Display *dpy, XErrorEvent *ev)
{
const char* name = NULL;
static char buffer[256];
if (!name)
{
buffer[0] = '\0';
- XGetErrorText (dpy, ev->error_code, buffer, sizeof (buffer));
+ XGetErrorText(dpy, ev->error_code, buffer, sizeof(buffer));
name = buffer;
}
- name = (strlen (name) > 0) ? name : "unknown";
+ name = (strlen(name) > 0) ? name : "unknown";
LOG_ERROR("X11WindowSystem", "X Error: " << (int)ev->error_code << " " << name << " request : " << (int)ev->request_code << " minor: " << (int)ev->minor_code << " serial: " << (int)ev->serial);
m_xerror = true;
return 0;
//setDisplayMode();
if (!CreateCompositorWindow())
{
- LOG_ERROR("X11WindowSystem", "Compositor Window creation failed " );
+ LOG_ERROR("X11WindowSystem", "Compositor Window creation failed ");
return false;
}
LOG_DEBUG("X11WindowSystem", "Compositor Window ID: " << CompositorWindow);
- if ( CreatePixmapsForAllWindows() )
+ if (CreatePixmapsForAllWindows())
{
//unredirect our window
#ifdef FULLSCREEN
#endif
XCompositeUnredirectWindow(x11Display, CompositorWindow, CompositeRedirectManual);
LOG_DEBUG("X11WindowSystem", "Initialised XServer connection complete");
- } else {
+ }
+ else
+ {
LOG_ERROR("X11WindowSystem", "Initialised XServer connection failed");
result = false;
}
*/
void * X11eventLoopCallback(void *ptr)
{
- X11WindowSystem *windowsys = static_cast<X11WindowSystem*>( (X11WindowSystem*) ptr);
+ X11WindowSystem *windowsys = static_cast<X11WindowSystem*>((X11WindowSystem*) ptr);
return windowsys->EventLoop();
}
// init own stuff
LOG_DEBUG("X11WindowSystem", "open display connection");
status &= this->OpenDisplayConnection();
- if ( status == false ) goto init_complete;
+ if (status == false) goto init_complete;
LOG_DEBUG("X11WindowSystem", "check for composite extension");
status &= this->checkForCompositeExtension();
- if ( status == false ) goto init_complete;
+ if (status == false) goto init_complete;
LOG_DEBUG("X11WindowSystem", "check for damage extension");
status &= this->checkForDamageExtension();
- if ( status == false ) goto init_complete;
+ if (status == false) goto init_complete;
LOG_DEBUG("X11WindowSystem", "init xserver");
status &= this->initXServer();
- if ( status == false ) goto init_complete;
+ if (status == false) goto init_complete;
LOG_INFO("X11WindowSystem", "XServer initialisation completed");
LOG_DEBUG("X11WindowSystem", "Graphicsystem initialisation");
- status &= this->graphicSystem->init(this->x11Display,this->CompositorWindow);
+ status &= this->graphicSystem->init(this->x11Display, this->CompositorWindow);
LOG_DEBUG("X11WindowSystem", "Graphicsystem initialisation complete");
init_complete:
this->m_success = status;
pthread_mutex_unlock(&this->init_lock);
// Done with init, wait for lock to actually run (ie start/stop method called)
LOG_DEBUG("X11WindowSystem", "Waiting for startup");
- pthread_cond_wait(&this->run_condition,&this->run_lock);
+ pthread_cond_wait(&this->run_condition, &this->run_lock);
pthread_mutex_unlock(&this->run_lock);
LOG_DEBUG("X11WindowSystem", "Starting Event loop");
Layer* defaultLayer = 0;
{
defaultLayer = this->m_pScene->createLayer(0, 0);
defaultLayer->setOpacity(1.0);
- defaultLayer->setDestinationRegion(Rectangle(0,0,this->resolutionWidth,this->resolutionHeight));
- defaultLayer->setSourceRegion(Rectangle(0,0,this->resolutionWidth,this->resolutionHeight));
+ defaultLayer->setDestinationRegion(Rectangle(0, 0, this->resolutionWidth, this->resolutionHeight));
+ defaultLayer->setSourceRegion(Rectangle(0, 0, this->resolutionWidth, this->resolutionHeight));
this->m_pScene->getCurrentRenderOrder(0).push_back(defaultLayer);
}
LOG_INFO("X11WindowSystem", "Enter render loop");
while (this->m_running)
{
- XEvent event;
- // blocking wait for event
- XNextEvent(this->x11Display, &event);
- this->m_pScene->lockScene();
- switch (event.type)
- {
- case CreateNotify:
+ XEvent event;
+ // blocking wait for event
+ XNextEvent(this->x11Display, &event);
+ this->m_pScene->lockScene();
+ switch (event.type)
+ {
+ case CreateNotify:
{
if (this->debugMode)
{
}
break;
}
- case ConfigureNotify:
- LOG_DEBUG("X11WindowSystem", "Configure notify Event");
- this->configureSurfaceWindow( event.xconfigure.window);
- checkRedraw = true;
- break;
-
- case DestroyNotify:
- LOG_DEBUG("X11WindowSystem", "Destroy Event");
- this->DestroyWindow(event.xdestroywindow.window);
- checkRedraw = true;
- break;
- case Expose:
- LOG_DEBUG("X11WindowSystem", "Expose Event");
- checkRedraw = true;
- break;
- case MapNotify:
- LOG_DEBUG("X11WindowSystem", "Map Event");
- this->MapWindow(event.xmap.window);
- checkRedraw = true;
- break;
- case UnmapNotify:
- LOG_DEBUG("X11WindowSystem", "Unmap Event");
- this->UnMapWindow(event.xunmap.window);
- checkRedraw = true;
- break;
- case ReparentNotify:
- LOG_DEBUG("X11WindowSystem", "Reparent Event");
- // if (event.xreparent.parent == root)
- // renderer->NewWindow(event.xreparent.window);
- // else
- // renderer->DestroyWindow(event.xreparent.window);
- break;
+ case ConfigureNotify:
+ LOG_DEBUG("X11WindowSystem", "Configure notify Event");
+ this->configureSurfaceWindow(event.xconfigure.window);
+ checkRedraw = true;
+ break;
- // Keyboard
- case KeyPress:
- ManageXInputEvent(INPUT_DEVICE_KEYBOARD, INPUT_STATE_PRESSED, &event);
- break;
- case KeyRelease:
- ManageXInputEvent(INPUT_DEVICE_KEYBOARD, INPUT_STATE_RELEASED, &event);
- break;
+ case DestroyNotify:
+ LOG_DEBUG("X11WindowSystem", "Destroy Event");
+ this->DestroyWindow(event.xdestroywindow.window);
+ checkRedraw = true;
+ break;
+ case Expose:
+ LOG_DEBUG("X11WindowSystem", "Expose Event");
+ checkRedraw = true;
+ break;
+ case MapNotify:
+ LOG_DEBUG("X11WindowSystem", "Map Event");
+ this->MapWindow(event.xmap.window);
+ checkRedraw = true;
+ break;
+ case UnmapNotify:
+ LOG_DEBUG("X11WindowSystem", "Unmap Event");
+ this->UnMapWindow(event.xunmap.window);
+ checkRedraw = true;
+ break;
+ case ReparentNotify:
+ LOG_DEBUG("X11WindowSystem", "Reparent Event");
+ // if (event.xreparent.parent == root)
+ // renderer->NewWindow(event.xreparent.window);
+ // else
+ // renderer->DestroyWindow(event.xreparent.window);
+ break;
- // Pointer
- case ButtonPress:
- ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_PRESSED, &event);
- break;
- case ButtonRelease:
- ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_RELEASED, &event);
- break;
- case MotionNotify:
- ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_MOTION, &event);
- break;
+ // Keyboard
+ case KeyPress:
+ ManageXInputEvent(INPUT_DEVICE_KEYBOARD, INPUT_STATE_PRESSED, &event);
+ break;
+ case KeyRelease:
+ ManageXInputEvent(INPUT_DEVICE_KEYBOARD, INPUT_STATE_RELEASED, &event);
+ break;
- // Touch
- // TODO. See @ref<X11WindowSystem-MultiTouch> at the end of this file
+ // Pointer
+ case ButtonPress:
+ ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_PRESSED, &event);
+ break;
+ case ButtonRelease:
+ ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_RELEASED, &event);
+ break;
+ case MotionNotify:
+ ManageXInputEvent(INPUT_DEVICE_POINTER, INPUT_STATE_MOTION, &event);
+ break;
+ // Touch
+ // TODO. See @ref<X11WindowSystem-MultiTouch> at the end of this file
- default:
- if (event.type == this->damage_event + XDamageNotify)
+ default:
+ if (event.type == this->damage_event + XDamageNotify)
+ {
+ XDamageSubtract(this->x11Display, ((XDamageNotifyEvent*)(&event))->damage, None, None);
+ Surface* currentSurface = this->getSurfaceForWindow(((XDamageNotifyEvent*)(&event))->drawable);
+ if (currentSurface == NULL)
+ {
+ LOG_WARNING("X11WindowSystem", "Surface empty during damage notification");
+ break;
+ }
+ else
{
- XDamageSubtract(this->x11Display, ((XDamageNotifyEvent*)(&event))->damage, None, None);
- Surface* currentSurface = this->getSurfaceForWindow(((XDamageNotifyEvent*)(&event))->drawable);
- if (currentSurface==NULL)
+ if (currentSurface->platform != NULL)
{
- LOG_WARNING("X11WindowSystem", "Surface empty during damage notification");
- break;
- } else {
- if (currentSurface->platform != NULL)
- {
- /* Enable Rendering for Surface, after damage Notification was send successfully */
- /* This will ensure, that the content is not dirty */
- ((XPlatformSurface *)(currentSurface->platform))->enableRendering();
- }
+ /* Enable Rendering for Surface, after damage Notification was send successfully */
+ /* This will ensure, that the content is not dirty */
+ ((XPlatformSurface *)(currentSurface->platform))->enableRendering();
}
- currentSurface->damaged = true;
- currentSurface->updateCounter++;
- checkRedraw = true;
}
- break;
+ currentSurface->damaged = true;
+ currentSurface->updateCounter++;
+ checkRedraw = true;
}
- this->m_pScene->unlockScene();
+ break;
+ }
+ this->m_pScene->unlockScene();
if (this->m_systemState == REDRAW_STATE)
{
this->checkForNewSurfaceNativeContent();
checkRedraw = true;
}
-
}
else if (this->m_systemState == WAKEUP_STATE)
{
void X11WindowSystem::ManageXInputEvent(InputDevice type, InputEventState state, XEvent *pevent)
- {
+{
Surface * surf;
switch (type)
{
- case INPUT_DEVICE_KEYBOARD:
+ case INPUT_DEVICE_KEYBOARD:
{
surf = m_pInputManager->reportKeyboardEvent(state, ((XKeyEvent *) pevent)->keycode);
if (surf != NULL)
}
break;
- case INPUT_DEVICE_POINTER:
+ case INPUT_DEVICE_POINTER:
{
Point p = {state, ((XButtonEvent*)pevent)->x, ((XButtonEvent*)pevent)->y};
surf = m_pInputManager->reportPointerEvent(p);
}
break;
- case INPUT_DEVICE_TOUCH:
- /* TODO */
- break;
-
+ case INPUT_DEVICE_TOUCH:
+ /* TODO */
+ break;
- default:
- case INPUT_DEVICE_ALL:
- break;
+ default:
+ case INPUT_DEVICE_ALL:
+ break;
}
}
static Display* displaySignal = NULL;
-void X11WindowSystem::wakeUpRendererThread()
+void X11WindowSystem::wakeUpRendererThread()
{
// send dummy expose event, to wake up blocking x11 event loop (XNextEvent)
LOG_DEBUG("X11WindowSystem", "Sending dummy event to wake up renderer thread");
- if (NULL == displaySignal )
+ if (NULL == displaySignal)
{
displaySignal = XOpenDisplay(m_displayEnvironment);
}
this->wakeUpRendererThread();
}
-void X11WindowSystem::cleanup(){
+void X11WindowSystem::cleanup()
+{
LOG_DEBUG("X11WindowSystem", "Cleanup");
if (None != CompositorWindow)
{
Window root = RootWindow(x11Display, DefaultScreen(x11Display));
- XCompositeUnredirectSubwindows(x11Display,root,CompositeRedirectManual);
- XDestroyWindow(x11Display,CompositorWindow);
+ XCompositeUnredirectSubwindows(x11Display, root, CompositeRedirectManual);
+ XDestroyWindow(x11Display, CompositorWindow);
}
if (windowVis)
delete windowVis;
}
- if ( NULL != displaySignal )
+ if (NULL != displaySignal)
{
XCloseDisplay(displaySignal);
}
pthread_mutex_unlock(&this->run_lock);
}
-bool X11WindowSystem::init(BaseGraphicSystem<Display*,Window>* base)
+bool X11WindowSystem::init(BaseGraphicSystem<Display*, Window>* base)
{
XInitThreads();
X11WindowSystem *renderer = this;
graphicSystem = base;
- LOG_INFO("X11WindowSystem","Initialization");
+ LOG_INFO("X11WindowSystem", "Initialization");
pthread_mutex_lock(&init_lock);
- int status = pthread_create( &renderThread, NULL, X11eventLoopCallback, (void*) renderer);
- if (0 != status )
+ int status = pthread_create(&renderThread, NULL, X11eventLoopCallback, (void*) renderer);
+ if (0 != status)
{
pthread_mutex_unlock(&init_lock);
return false;
}
mThreadId = renderThread;
-
- pthread_cond_wait(&init_condition,&init_lock);
+
+ pthread_cond_wait(&init_condition, &init_lock);
/* while (!m_initialized)
{
usleep(1000); // TODO
LOG_DEBUG("X11WindowSystem","Waiting start complete " << m_initialized);
- }
+ }
*/
pthread_mutex_unlock(&init_lock);
- LOG_INFO("X11WindowSystem","Initialization complete success :" << m_success);
+ LOG_INFO("X11WindowSystem", "Initialization complete success :" << m_success);
return m_success;
}
pthread_mutex_lock(&this->run_lock);
LOG_DEBUG("X11WindowSystem", "Startup");
// let thread actually run
- if ( m_xerror == false )
+ if (m_xerror == false)
{
this->m_running = true;
pthread_cond_signal(&this->run_condition);
pthread_mutex_unlock(&this->run_lock);
- } else {
+ }
+ else
+ {
this->m_running = false;
pthread_cond_signal(&this->run_condition);
pthread_mutex_unlock(&this->run_lock);
void X11WindowSystem::stop()
{
- LOG_INFO("X11WindowSystem","Stopping..");
+ LOG_INFO("X11WindowSystem", "Stopping..");
pthread_mutex_lock(&this->run_lock);
this->m_running = false;
// needed if start was never called, we wake up thread, so it can immediatly finish
this->signalRedrawEvent();
pthread_cond_signal(&this->run_condition);
pthread_mutex_unlock(&this->run_lock);
- pthread_join(renderThread,NULL);
+ pthread_join(renderThread, NULL);
}
void X11WindowSystem::allocatePlatformSurface(Surface* surface)
{
- LOG_DEBUG("X11WindowSystem","allocatePlatformSurface begin");
+ LOG_DEBUG("X11WindowSystem", "allocatePlatformSurface begin");
XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
if (!nativeSurface)
{
- LOG_DEBUG("X11WindowSystem","creating native surface for new window");
+ LOG_DEBUG("X11WindowSystem", "creating native surface for new window");
// this surface does not have a native platform surface attached yet!
NewWindow(surface, surface->getNativeContent());
MapWindow(surface->getNativeContent());
}
- LOG_DEBUG("X11WindowSystem","allocatePlatformSurface end");
+ LOG_DEBUG("X11WindowSystem", "allocatePlatformSurface end");
}
void X11WindowSystem::deallocatePlatformSurface(Surface* surface)
{
- LOG_DEBUG("X11WindowSystem","deallocatePlatformSurface begin");
+ LOG_DEBUG("X11WindowSystem", "deallocatePlatformSurface begin");
XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
if (nativeSurface)
{
- LOG_DEBUG("X11WindowSystem","destroyingnative surface");
+ LOG_DEBUG("X11WindowSystem", "destroyingnative surface");
graphicSystem->getTextureBinder()->destroyClientBuffer(surface);
if (nativeSurface->pixmap)
delete surface->platform;
surface->platform = NULL;
}
- LOG_DEBUG("X11WindowSystem","deallocatePlatformSurface end");
+ LOG_DEBUG("X11WindowSystem", "deallocatePlatformSurface end");
}
void X11WindowSystem::doScreenShot(std::string fileName)
* -> Via cmake ==> ?
* -> At runtime ==> http://who-t.blogspot.fr/2011/12/multitouch-in-x-getting-events.html
* - Register for XIDirectTouch. (No plan (yet?) to support XIDependentTouch)
- * - Call m_pInputManager->reportTouchEvent() from ManageXInputEvent() to translate screen wide touch coordinates into surface wide coordinates
+ * - Call m_pInputManager->reportTouchEvent() from ManageXInputEvent() to translate screen wide touch coordinates
+ * into surface wide coordinates
* - Forward the event to the native handle of the surface returned by m_pInputManager->reportTouchEvent()
*
* Further reading:
screenList.push_back(lmScreen);
// create X11 windows, register as composite manager etc
- m_pWindowSystem = new X11WindowSystem(displayname, width, height, m_pScene, m_pInputManager, GLXGraphicsystem::GetMatchingVisual);
+ m_pWindowSystem = new X11WindowSystem(displayname, width, height, m_pScene, m_pInputManager, GLXGraphicsystem::GetMatchingVisual);
m_pGraphicSystem = new GLXGraphicsystem(width, height);
m_pGraphicSystem->setBaseWindowSystem(m_pWindowSystem);
LOG_DEBUG("X11GLXRenderer", "init windowsystem");
- if ( m_pWindowSystem->init(m_pGraphicSystem ) )
+ if (m_pWindowSystem->init(m_pGraphicSystem))
{
Display* x11Display = m_pWindowSystem->getNativeDisplayHandle();
if (x11Display)
binder = new X11CopyGLX(x11Display);
}
#endif // WITH_FORCE_COPY
- if ( binder != NULL )
+ if (binder != NULL)
{
m_pGraphicSystem->setTextureBinder(binder);
result = m_pWindowSystem->start();
m_pWindowSystem->doScreenShot(fileToSave);
}
-void X11GLXRenderer::doScreenShotOfLayer(std::string fileToSave,uint id)
+void X11GLXRenderer::doScreenShotOfLayer(std::string fileToSave, uint id)
{
- m_pWindowSystem->doScreenShotOfLayer(fileToSave,id);
+ m_pWindowSystem->doScreenShotOfLayer(fileToSave, id);
}
-void X11GLXRenderer::doScreenShotOfSurface(std::string fileToSave, uint id, uint layer_id){
- m_pWindowSystem->doScreenShotOfSurface(fileToSave,id,layer_id);
+void X11GLXRenderer::doScreenShotOfSurface(std::string fileToSave, uint id, uint layer_id)
+{
+ m_pWindowSystem->doScreenShotOfSurface(fileToSave, id, layer_id);
}
uint X11GLXRenderer::getNumberOfHardwareLayers(uint screenID)
return m_pGraphicSystem->setOptimizationMode(id, (unsigned int)mode);
}
-DECLARE_LAYERMANAGEMENT_PLUGIN(X11GLXRenderer)
\ No newline at end of file
+DECLARE_LAYERMANAGEMENT_PLUGIN(X11GLXRenderer)
*
****************************************************************************/
-#ifndef DEBUGRENDERER_H_
-#define DEBUGRENDERER_H_
+#ifndef TEXTRENDERER_H_
+#define TEXTRENDERER_H_
#include "LayerList.h"
#include "BaseRenderer.h"
OptimizationModeType m_optimizationMode;
};
-#endif /* DEBUGRENDERER_H_ */
+#endif /* TEXTRENDERER_H_ */
screenList.push_back(lmScreen);
LOG_DEBUG("TextRenderer", "start("
- << "width=" << width
- << ", height=" << height
- << ", displayname=" << displayname << ")");
+ << "width=" << width
+ << ", height=" << height
+ << ", displayname=" << displayname << ")");
return true;
}
void TextRenderer::doScreenShot(std::string fileToSave)
{
LOG_DEBUG("TextRenderer", "doScreenShot("
- << "fileToSave=" << fileToSave << ")");
+ << "fileToSave=" << fileToSave << ")");
std::fstream file(fileToSave.c_str());
}
-void TextRenderer::doScreenShotOfLayer(std::string fileToSave,uint id)
+void TextRenderer::doScreenShotOfLayer(std::string fileToSave, uint id)
{
LOG_DEBUG("TextRenderer", "doScreenShotOfLayer("
- << "fileToSave=" << fileToSave
- << ", id=" << id << ")");
+ << "fileToSave=" << fileToSave
+ << ", id=" << id << ")");
std::fstream file(fileToSave.c_str());
}
void TextRenderer::doScreenShotOfSurface(std::string fileToSave, uint id, uint layer_id)
{
LOG_DEBUG("TextRenderer", "doScreenShotOfSurface("
- << "fileToSave=" << fileToSave
- << ", id=" << id
- << ", layer_id=" << layer_id << ")");
+ << "fileToSave=" << fileToSave
+ << ", id=" << id
+ << ", layer_id=" << layer_id << ")");
std::fstream file(fileToSave.c_str());
}
bool TextRenderer::setOptimizationMode(OptimizationType id, OptimizationModeType mode)
{
LOG_DEBUG("TextRenderer", "setOptimizationMode("
- << "id=" << id
- << ", mode=" << mode << ")");
+ << "id=" << id
+ << ", mode=" << mode << ")");
m_optimizationMode = mode;
return true;
}
{
(void)mode;
LOG_DEBUG("TextRenderer", "getOptimizationMode("
- << "id=" << id << ")");
+ << "id=" << id << ")");
*mode = m_optimizationMode;
return true;
}
/***************************************************************************
- *
+ *
* Copyright 2010-2012 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
/***************************************************************************
- *
+ *
* Copyright 2010-2012 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
/***************************************************************************
- *
+ *
* Copyright 2010-2012 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
/***************************************************************************
- *
+ *
* Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
return new GLESGraphicsystem(m_width, m_height, shaderProgram);
}
-DECLARE_LAYERMANAGEMENT_PLUGIN(WaylandFbdevGLESRenderer)
\ No newline at end of file
+DECLARE_LAYERMANAGEMENT_PLUGIN(WaylandFbdevGLESRenderer)
/***************************************************************************
*
-* Copyright 2010, 2011 BMW Car IT GmbH
+* Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
*
/***************************************************************************
*
-* Copyright 2010, 2011 BMW Car IT GmbH
+* Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
// create Wayland windows, register as composite manager etc
m_pWindowSystem = getWindowSystem(displayname);
- if( m_pWindowSystem == NULL )
+ if (m_pWindowSystem == NULL)
{
- LOG_ERROR("WaylandGLESRenderer", "Window system is not specified. Consider to specify WITH_WAYLAND_X11 or WITH_WAYLAND_FBDEV");
- goto fail; // TODO bad style
+ LOG_ERROR("WaylandGLESRenderer", "Window system is not specified. Consider to specify WITH_WAYLAND_X11 or WITH_WAYLAND_FBDEV");
+ goto fail; // TODO bad style
}
m_pGraphicSystem = getGraphicSystem(ShaderProgramGLES::createProgram);
}
return true;
- fail: // TODO bad style
+fail: // TODO bad style
LOG_ERROR("WaylandGLESRenderer", "Initialization failed !");
return false;
void WaylandGLESRenderer::stop()
{
m_pWindowSystem->stop();
- if(m_binder)
+ if (m_binder)
{
delete m_binder;
}
void WaylandGLESRenderer::doScreenShotOfLayer(std::string fileToSave, uint id)
{
- m_pWindowSystem->doScreenShotOfLayer(fileToSave,id);
+ m_pWindowSystem->doScreenShotOfLayer(fileToSave, id);
}
void WaylandGLESRenderer::doScreenShotOfSurface(std::string fileToSave, uint id, uint layer_id)
{
- m_pWindowSystem->doScreenShotOfSurface(fileToSave,id,layer_id);
+ m_pWindowSystem->doScreenShotOfSurface(fileToSave, id, layer_id);
}
uint WaylandGLESRenderer::getNumberOfHardwareLayers(uint screenID)
return BaseRenderer::pluginGetHealth();
}
-Shader* WaylandGLESRenderer::createShader(const string* vertexName, const string* fragmentName)
+Shader* WaylandGLESRenderer::createShader(const string* vertexName, const string* fragmentName)
{
Shader *result = NULL;
m_pWindowSystem->setSystemState(WAKEUP_STATE);
m_pWindowSystem->wakeUpRendererThread();
m_pGraphicSystem->activateGraphicContext();
- result = Shader::createShader(*vertexName,*fragmentName);
+ result = Shader::createShader(*vertexName, *fragmentName);
m_pGraphicSystem->releaseGraphicContext();
m_pWindowSystem->setSystemState(IDLE_STATE);
return result;
-}
\ No newline at end of file
+}
/***************************************************************************
- *
+ *
* Copyright 2010-2012 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
/***************************************************************************
- *
+ *
* Copyright 2010, 2011 BMW Car IT GmbH
* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
return new GLESGraphicsystem(m_width, m_height, shaderProgram);
}
-DECLARE_LAYERMANAGEMENT_PLUGIN(WaylandX11GLESRenderer)
\ No newline at end of file
+DECLARE_LAYERMANAGEMENT_PLUGIN(WaylandX11GLESRenderer)
*/
virtual void use(void) const;
- virtual int getUniformLocation(const char* name)
+ virtual int getUniformLocation(const char* name)
{
return glGetUniformLocation(m_progHandle, name);
}
ShaderProgram* ShaderProgramGLES::createProgram(const std::string& vertName, const std::string& fragName)
{
GLuint progHandle;
- ShaderProgramGLES* program = 0;
+ ShaderProgramGLES* program=0;
char defaultShaderDir[1024];
char fragmentShaderLocation[1024];
char vertexShaderLocation[1024];
- int multitex = 1;
-
- const char* pluginLookupPath = getenv("LM_PLUGIN_PATH");
- if (pluginLookupPath != NULL )
+ int multitex=1;
+
+ const char* pluginLookupPath=getenv("LM_PLUGIN_PATH");
+ if (pluginLookupPath!=NULL)
{
- strncpy(defaultShaderDir, pluginLookupPath, sizeof(defaultShaderDir) - 1);
+ strncpy(defaultShaderDir, pluginLookupPath, sizeof(defaultShaderDir)-1);
}
else
{
strncpy(defaultShaderDir, CMAKE_INSTALL_PREFIX"/lib/layermanager", sizeof(defaultShaderDir));
}
- strcat(defaultShaderDir,"/renderer");
+ strcat(defaultShaderDir, "/renderer");
if (vertName=="default")
{
- multitex = 1;
- strcpy(vertexShaderLocation,defaultShaderDir);
- strcat(vertexShaderLocation,"/renderer_vert.glslv");
+ multitex=1;
+ strcpy(vertexShaderLocation, defaultShaderDir);
+ strcat(vertexShaderLocation, "/renderer_vert.glslv");
}
else if (vertName=="default_2surf")
{
- multitex = 2;
- strcpy(vertexShaderLocation,defaultShaderDir);
- strcat(vertexShaderLocation,"/renderer_vert_2surf.glslv");
+ multitex=2;
+ strcpy(vertexShaderLocation, defaultShaderDir);
+ strcat(vertexShaderLocation, "/renderer_vert_2surf.glslv");
}
else if (vertName=="default_3surf")
{
- multitex = 3;
- strcpy(vertexShaderLocation,defaultShaderDir);
- strcat(vertexShaderLocation,"/renderer_vert_3surf.glslv");
+ multitex=3;
+ strcpy(vertexShaderLocation, defaultShaderDir);
+ strcat(vertexShaderLocation, "/renderer_vert_3surf.glslv");
}
else if (vertName=="default_4surf")
{
- multitex = 4;
- strcpy(vertexShaderLocation,defaultShaderDir);
- strcat(vertexShaderLocation,"/renderer_vert_4surf.glslv");
+ multitex=4;
+ strcpy(vertexShaderLocation, defaultShaderDir);
+ strcat(vertexShaderLocation, "/renderer_vert_4surf.glslv");
}
else
{
if (fragName=="default_clear")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_clear.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_clear.glslf");
}
else if (fragName=="default")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag.glslf");
}
else if (fragName=="default_no_blend")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_no_blend.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_no_blend.glslf");
}
else if (fragName=="default_no_uniform_alpha")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_no_ualpha.glslf");
- progHandle = RenderUtilLoadShaderSources(vertexShaderLocation,fragmentShaderLocation, GL_TRUE);
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_no_ualpha.glslf");
+ progHandle=RenderUtilLoadShaderSources(vertexShaderLocation, fragmentShaderLocation, GL_TRUE);
}
- else if (vertName=="default" && fragName=="default_add_uniform_chromakey")
+ else if (vertName=="default"&&fragName=="default_add_uniform_chromakey")
{
- strcpy(vertexShaderLocation,defaultShaderDir);
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(vertexShaderLocation,"/renderer_vert.glslv");
- strcat(fragmentShaderLocation,"/renderer_frag_add_uchromakey.glslf");
+ strcpy(vertexShaderLocation, defaultShaderDir);
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(vertexShaderLocation, "/renderer_vert.glslv");
+ strcat(fragmentShaderLocation, "/renderer_frag_add_uchromakey.glslf");
}
else if (fragName=="default_no_blend_no_uniform_alpha")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_no_blend_no_ualpha.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_no_blend_no_ualpha.glslf");
}
else if (fragName=="default_2surf")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf.glslf");
}
else if (fragName=="default_2surf_no_blend")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_blend.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_blend.glslf");
}
else if (fragName=="default_2surf_no_uniform_alpha")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_ualpha.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_ualpha.glslf");
}
else if (fragName=="default_2surf_no_blend_no_uniform_alpha")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_blend_no_ualpha.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_blend_no_ualpha.glslf");
}
else if (fragName=="default_2surf_no_uniform_alpha_0")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_ualpha_0.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_ualpha_0.glslf");
}
else if (fragName=="default_2surf_no_blend_no_uniform_alpha_0")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_blend_no_ualpha_0.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_blend_no_ualpha_0.glslf");
}
else if (fragName=="default_2surf_no_uniform_alpha_1")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_ualpha_1.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_ualpha_1.glslf");
}
else if (fragName=="default_2surf_no_blend_no_uniform_alpha_1")
{
- strcpy(fragmentShaderLocation,defaultShaderDir);
- strcat(fragmentShaderLocation,"/renderer_frag_2surf_no_blend_no_ualpha_1.glslf");
+ strcpy(fragmentShaderLocation, defaultShaderDir);
+ strcat(fragmentShaderLocation, "/renderer_frag_2surf_no_blend_no_ualpha_1.glslf");
}
else
{
strcpy(fragmentShaderLocation, fragName.c_str());
}
- progHandle = RenderUtilLoadShaderSources(vertexShaderLocation,fragmentShaderLocation, GL_TRUE);
+ progHandle=RenderUtilLoadShaderSources(vertexShaderLocation, fragmentShaderLocation, GL_TRUE);
- if (progHandle != 0)
+ if (progHandle!=0)
{
// bind attrib locations for vertex positions and texture coordinates
glBindAttribLocation(progHandle, 0, "aPosition");
// each texture has its own texCoord attribute
- for (int i = 1; i <= multitex; i++)
+ for (int i=1; i<=multitex; i++)
{
char attribName[15];
- if (i == 1)
+ if (i==1)
{
sprintf(attribName, "aTexCoords");
}
// re-link the program as we have changed the attrib bindings
glLinkProgram(progHandle);
- program = new ShaderProgramGLES(vertName, fragName, progHandle);
+ program=new ShaderProgramGLES(vertName, fragName, progHandle);
}
else
{
// create X11 windows, register as composite manager etc
m_pWindowSystem = new X11WindowSystem(displayname, width, height, m_pScene, m_pInputManager);
- m_pGraphicSystem = new GLESGraphicsystem(width,height, ShaderProgramGLES::createProgram);
+ m_pGraphicSystem = new GLESGraphicsystem(width, height, ShaderProgramGLES::createProgram);
if (!m_pWindowSystem->init(m_pGraphicSystem))
{
}
return true;
- fail: // TODO bad style
+fail: // TODO bad style
LOG_ERROR("X11GLESRenderer", "Initialization failed !");
return false;
{
delete m_binder;
}
-
}
void X11GLESRenderer::doScreenShot(std::string fileToSave)
void X11GLESRenderer::doScreenShotOfLayer(std::string fileToSave, uint id)
{
- m_pWindowSystem->doScreenShotOfLayer(fileToSave,id);
+ m_pWindowSystem->doScreenShotOfLayer(fileToSave, id);
}
void X11GLESRenderer::doScreenShotOfSurface(std::string fileToSave, uint id, uint layer_id)
{
- m_pWindowSystem->doScreenShotOfSurface(fileToSave,id,layer_id);
+ m_pWindowSystem->doScreenShotOfSurface(fileToSave, id, layer_id);
}
uint X11GLESRenderer::getNumberOfHardwareLayers(uint screenID)
m_pScene->unlockScene();
while (m_pWindowSystem->getSystemState() != IDLE_STATE);
m_pGraphicSystem->activateGraphicContext();
- result = Shader::createShader(*vertexName,*fragmentName);
+ result = Shader::createShader(*vertexName, *fragmentName);
m_pGraphicSystem->releaseGraphicContext();
m_pWindowSystem->setSystemState(WAKEUP_STATE);
m_pScene->lockScene();
* limitations under the License.
*
****************************************************************************/
-#ifndef _LAYERSCENE_H_
-#define _LAYERSCENE_H_
+#ifndef _EXAMPLEAPPIDS_H_
+#define _EXAMPLEAPPIDS_H_
typedef enum e_layers
{
SURFACE_EXAMPLE_VIDEO_APPLICATION = 40
} sceneSurfaces;
-#endif /* _LAYERSCENE_H_ */
+#endif /* _EXAMPLEAPPIDS_H_ */
* limitations under the License.
*
****************************************************************************/
-
-#ifndef _LAYERSCENE_PROVIDER_H_
-#define _LAYERSCENE_PROVIDER_H_
+
+#ifndef _EXAMPLESCENEPROVIDER_H_
+#define _EXAMPLESCENEPROVIDER_H_
#include "ISceneProvider.h"
#include "PluginBase.h"
class ExampleSceneProvider : public ISceneProvider, public PluginBase
{
public:
-
+
ExampleSceneProvider(ICommandExecutor& executor, Configuration& config);
virtual ~ExampleSceneProvider() {}
//from PluginBase
virtual t_ilm_const_string pluginGetName() const;
-
+
protected:
ICommandExecutor& mExecutor;
Configuration& mConfiguration;
};
-#endif /* _LAYERSCENE_PROVIDER_H_ */
+#endif /* _EXAMPLESCENEPROVIDER_H_ */
{
}
-typedef struct t_layerScene
+typedef struct t_layerScene
{
unsigned int layer;
bool visibility;
float opacity;
} layerScene;
-typedef struct t_surfaceScene
+typedef struct t_surfaceScene
{
unsigned int surface;
bool visibility;
} surfaceScene;
-static layerScene gInitialLayerScene[] =
+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[] =
+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 }
+ { 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 result = true;
pid_t layermanagerPid = getpid();
int i = 0;
- int numberOfLayers = sizeof(gInitialLayerScene) / sizeof (layerScene);
- int numberOfSurfaces = sizeof(gInitialSurfaceScene) / sizeof (surfaceScene);
+ int numberOfLayers = sizeof(gInitialLayerScene) / sizeof(layerScene);
+ int numberOfSurfaces = sizeof(gInitialSurfaceScene) / sizeof(surfaceScene);
unsigned int *renderOrder = new unsigned int [numberOfLayers];
unsigned int* screenResolution = mExecutor.getScreenResolution(0);
- if ( numberOfLayers > 0 )
+ if (numberOfLayers > 0)
{
/* setup inital layer scenery */
- for (i = 0;i<numberOfLayers;i++)
+ for (i = 0; i<numberOfLayers; i++)
{
- result &= mExecutor.execute(new LayerCreateCommand(layermanagerPid, screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer)));
- result &= mExecutor.execute(new LayerSetSourceRectangleCommand(layermanagerPid, gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
- result &= mExecutor.execute(new LayerSetDestinationRectangleCommand(layermanagerPid, gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
- result &= mExecutor.execute(new LayerSetOpacityCommand(layermanagerPid, gInitialLayerScene[i].layer, gInitialLayerScene[i].opacity) );
- result &= mExecutor.execute(new LayerSetVisibilityCommand(layermanagerPid, gInitialLayerScene[i].layer, gInitialLayerScene[i].visibility) );
+ result &= mExecutor.execute(new LayerCreateCommand(layermanagerPid,
+ screenResolution[0],
+ screenResolution[1],
+ &(gInitialLayerScene[i].layer)));
+ result &= mExecutor.execute(new LayerSetSourceRectangleCommand(layermanagerPid,
+ gInitialLayerScene[i].layer,
+ 0, 0,
+ screenResolution[0],
+ screenResolution[1]));
+ result &= mExecutor.execute(new LayerSetDestinationRectangleCommand(layermanagerPid,
+ gInitialLayerScene[i].layer,
+ 0, 0,
+ screenResolution[0],
+ screenResolution[1]));
+ result &= mExecutor.execute(new LayerSetOpacityCommand(layermanagerPid,
+ gInitialLayerScene[i].layer,
+ gInitialLayerScene[i].opacity));
+ result &= mExecutor.execute(new LayerSetVisibilityCommand(layermanagerPid,
+ gInitialLayerScene[i].layer,
+ gInitialLayerScene[i].visibility));
result &= mExecutor.execute(new CommitCommand(layermanagerPid));
renderOrder[i]=gInitialLayerScene[i].layer;
- }
+ }
/* Finally set the first executed renderorder */
result &= mExecutor.execute(new ScreenSetRenderOrderCommand(layermanagerPid, 0, renderOrder, numberOfLayers));
result &= mExecutor.execute(new CommitCommand(layermanagerPid));
}
-
- if ( numberOfSurfaces > 0 )
+
+ if (numberOfSurfaces > 0)
{
/* setup inital surface scenery */
- for (i = 0;i<numberOfSurfaces;i++)
+ for (i = 0; i<numberOfSurfaces; i++)
{
- result &= mExecutor.execute(new SurfaceCreateCommand(layermanagerPid, &(gInitialSurfaceScene[i].surface)));
- result &= mExecutor.execute(new SurfaceSetOpacityCommand(layermanagerPid, gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].opacity));
- result &= mExecutor.execute(new SurfaceSetVisibilityCommand(layermanagerPid, gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].visibility));
+ result &= mExecutor.execute(new SurfaceCreateCommand(layermanagerPid,
+ &(gInitialSurfaceScene[i].surface)));
+ result &= mExecutor.execute(new SurfaceSetOpacityCommand(layermanagerPid,
+ gInitialSurfaceScene[i].surface,
+ gInitialSurfaceScene[i].opacity));
+ result &= mExecutor.execute(new SurfaceSetVisibilityCommand(layermanagerPid,
+ gInitialSurfaceScene[i].surface,
+ gInitialSurfaceScene[i].visibility));
result &= mExecutor.execute(new CommitCommand(layermanagerPid));
- }
+ }
/* Finally set the first executed renderorder */
}
return result;
{
// monitor startup performance
unsigned int startupTimeInMs = 0;
- timeval start, end;
+ timeval start;
+ timeval end;
gettimeofday(&start, 0);
// collect all configuration settings
Log::dltLogLevel = (LOG_MODES)configuration.getLogLevelTrace();
LOG_INFO("LayerManagerService", "Starting Layermanager (version: " << ILM_VERSION << ")");
-
+
// log configuration options
configuration.logAllSettings();
* 3. This notice may not be removed or altered from any source distribution.
****************************************************************************/
-#ifndef _ILM_MATRIX_H_
-#define _ILM_MATRIX_H_
+#ifndef _ILMMATRIX_H_
+#define _ILMMATRIX_H_
#define MAT00 0
#define MAT01 1
void IlmMatrixProjection(IlmMatrix &mOut, const float fov, const float near, const float far, const float aspectRatio);
-#endif /* _ILMMATRIX_H*/
+#endif /* _ILMMATRIX_H_*/
create new messages
=============================================================================
*/
-t_ilm_message createMessage (t_ilm_const_string);
-t_ilm_message createResponse (t_ilm_message);
+t_ilm_message createMessage(t_ilm_const_string);
+t_ilm_message createResponse(t_ilm_message);
t_ilm_message createErrorResponse(t_ilm_message);
-t_ilm_message createNotification (t_ilm_const_string);
+t_ilm_message createNotification(t_ilm_const_string);
/*
=============================================================================
add content to message
=============================================================================
*/
-t_ilm_bool appendBool (t_ilm_message, const t_ilm_bool);
-t_ilm_bool appendDouble (t_ilm_message, const double);
-t_ilm_bool appendString (t_ilm_message, const char*);
-t_ilm_bool appendInt (t_ilm_message, const int);
-t_ilm_bool appendIntArray (t_ilm_message, const int*, int);
-t_ilm_bool appendUint (t_ilm_message, const unsigned int);
+t_ilm_bool appendBool(t_ilm_message, const t_ilm_bool);
+t_ilm_bool appendDouble(t_ilm_message, const double);
+t_ilm_bool appendString(t_ilm_message, const char*);
+t_ilm_bool appendInt(t_ilm_message, const int);
+t_ilm_bool appendIntArray(t_ilm_message, const int*, int);
+t_ilm_bool appendUint(t_ilm_message, const unsigned int);
t_ilm_bool appendUintArray(t_ilm_message, const unsigned int*, int);
/*
get message information
=============================================================================
*/
-t_ilm_const_string getMessageName (t_ilm_message);
-t_ilm_message_type getMessageType (t_ilm_message);
-t_ilm_const_string getSenderName (t_ilm_message);
+t_ilm_const_string getMessageName(t_ilm_message);
+t_ilm_message_type getMessageType(t_ilm_message);
+t_ilm_const_string getSenderName(t_ilm_message);
t_ilm_client_handle getSenderHandle(t_ilm_message);
/*
get content of message
=============================================================================
*/
-t_ilm_bool getBool (t_ilm_message, t_ilm_bool*);
-t_ilm_bool getDouble (t_ilm_message, double*);
-t_ilm_bool getString (t_ilm_message, char*);
-t_ilm_bool getInt (t_ilm_message, int*);
-t_ilm_bool getIntArray (t_ilm_message, int**, int*);
-t_ilm_bool getUint (t_ilm_message, unsigned int*);
+t_ilm_bool getBool(t_ilm_message, t_ilm_bool*);
+t_ilm_bool getDouble(t_ilm_message, double*);
+t_ilm_bool getString(t_ilm_message, char*);
+t_ilm_bool getInt(t_ilm_message, int*);
+t_ilm_bool getIntArray(t_ilm_message, int**, int*);
+t_ilm_bool getUint(t_ilm_message, unsigned int*);
t_ilm_bool getUintArray(t_ilm_message, unsigned int**, int*);
/*
#include <fstream>
#include <pthread.h>
#include <map>
-typedef enum {
+typedef enum
+{
LOG_DISABLED = 0,
LOG_ERROR = 1,
LOG_INFO = 2,
class Log
{
public:
-
+
typedef struct diagnosticCallbackData_t
{
unsigned int module_id;
void *userdata;
diagnosticInjectionCallback diagFunc;
} diagnosticCallbackData;
-
+
typedef std::map<unsigned int, diagnosticCallbackData*> DiagnosticCallbackMap;
-
+
virtual ~Log();
static LOG_MODES fileLogLevel;
static LOG_MODES consoleLogLevel;
static LOG_MODES dltLogLevel;
static Log* getInstance();
- static DiagnosticCallbackMap* getDiagnosticCallbackMap(){return getInstance()->m_diagnosticCallbackMap;};
- void warning (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
- void info (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
- void error (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
- void debug (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
+ static DiagnosticCallbackMap* getDiagnosticCallbackMap()
+ {
+ return getInstance()->m_diagnosticCallbackMap;
+ }
+ void warning(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
+ void info(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
+ void error(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
+ void debug(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output);
void log(LogContext logContext, LOG_MODES logMode, const std::string& moduleName, const std::basic_string<char>& output);
- void registerDiagnosticInjectionCallback( unsigned int module_id, diagnosticInjectionCallback diagFunc, void* userdata );
- void unregisterDiagnosticInjectionCallback( unsigned int module_id );
+ void registerDiagnosticInjectionCallback(unsigned int module_id, diagnosticInjectionCallback diagFunc, void* userdata);
+ void unregisterDiagnosticInjectionCallback(unsigned int module_id);
LogContext getLogContext();
static void closeInstance();
private:
Log();
void LogToFile(std::string logMode, const std::string& moduleName, const std::basic_string<char>& output);
- void LogToConsole(std::string logMode, const std::string& moduleName,const std::basic_string<char>& output);
- void LogToDltDaemon(LogContext logContext, LOG_MODES logMode,const std::string& moduleName,const std::basic_string<char>& output);
+ void LogToConsole(std::string logMode, const std::string& moduleName, const std::basic_string<char>& output);
+ void LogToDltDaemon(LogContext logContext, LOG_MODES logMode, const std::string& moduleName, const std::basic_string<char>& output);
private:
std::ofstream* m_fileStream;
pthread_mutex_t m_LogBufferMutex;
LogContext m_logContext;
static DiagnosticCallbackMap* m_diagnosticCallbackMap;
-
- static Log* m_instance;
+
+ static Log* m_instance;
};
//#define LOG_ERROR(logcontext,module, message)
class LogMessageBuffer
{
public:
- /**
- * Creates a new instance.
- */
- LogMessageBuffer();
- /**
- * Destructor.
- */
- ~LogMessageBuffer();
+ /**
+ * Creates a new instance.
+ */
+ LogMessageBuffer();
+ /**
+ * Destructor.
+ */
+ ~LogMessageBuffer();
- LogMessageBuffer& operator<<(const std::basic_string<char>& msg);
+ LogMessageBuffer& operator<<(const std::basic_string<char>& msg);
- LogMessageBuffer& operator<<(const char* msg);
+ LogMessageBuffer& operator<<(const char* msg);
- LogMessageBuffer& operator<<(char* msg);
+ LogMessageBuffer& operator<<(char* msg);
- LogMessageBuffer& operator<<(const char msg);
+ LogMessageBuffer& operator<<(const char msg);
- std::ostream& operator<<(ios_base_manip manip);
+ std::ostream& operator<<(ios_base_manip manip);
- std::ostream& operator<<(bool val);
+ std::ostream& operator<<(bool val);
- std::ostream& operator<<(short val);
+ std::ostream& operator<<(short val);
- std::ostream& operator<<(int val);
+ std::ostream& operator<<(int val);
- std::ostream& operator<<(unsigned int val);
+ std::ostream& operator<<(unsigned int val);
- std::ostream& operator<<(long val);
+ std::ostream& operator<<(long val);
- std::ostream& operator<<(unsigned long val);
+ std::ostream& operator<<(unsigned long val);
- std::ostream& operator<<(float val);
+ std::ostream& operator<<(float val);
- std::ostream& operator<<(double val);
+ std::ostream& operator<<(double val);
- std::ostream& operator<<(long double val);
+ std::ostream& operator<<(long double val);
- std::ostream& operator<<(void* val);
+ std::ostream& operator<<(void* val);
- /**
- * Cast to ostream.
- */
- operator std::basic_ostream<char>&();
+ /**
+ * Cast to ostream.
+ */
+ operator std::basic_ostream<char>&();
- const std::basic_string<char>& str(std::basic_ostream<char>& os);
+ const std::basic_string<char>& str(std::basic_ostream<char>& os);
- const std::basic_string<char>& str() const;
+ const std::basic_string<char>& str() const;
- bool hasStream() const;
+ bool hasStream() const;
private:
- /**
- * No default copy constructor.
- */
- LogMessageBuffer(const LogMessageBuffer&);
-
- /**
- * No assignment operator.
- */
- LogMessageBuffer& operator=(const LogMessageBuffer&);
-
- /**
- * Encapsulated std::string.
- */
- std::basic_string<char> buf;
-
- /**
- * Encapsulated stream, created on demand.
- */
- std::basic_ostringstream<char>* stream;
+ /**
+ * No default copy constructor.
+ */
+ LogMessageBuffer(const LogMessageBuffer&);
+
+ /**
+ * No assignment operator.
+ */
+ LogMessageBuffer& operator=(const LogMessageBuffer&);
+
+ /**
+ * Encapsulated std::string.
+ */
+ std::basic_string<char> buf;
+
+ /**
+ * Encapsulated stream, created on demand.
+ */
+ std::basic_ostringstream<char>* stream;
};
template<class V>
std::basic_ostream<char>& operator<<(LogMessageBuffer& os, const V& val)
{
- return ((std::basic_ostream<char>&) os) << val;
+ return ((std::basic_ostream<char>&) os) << val;
}
#endif /* _LOGMESSAGEBUFFER_H_ */
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
public:
ThreadBase();
virtual ~ThreadBase();
-
+
t_ilm_bool threadCreate();
t_ilm_bool threadInit();
t_ilm_bool threadStart();
t_ilm_bool threadStop();
-
+
pthread_t threadGetId() const;
t_ilm_bool threadIsRunning();
-
+
// override in inheriting class if required
virtual t_ilm_bool threadInitInThreadContext();
virtual t_ilm_bool threadDestroyInThreadContext();
-
+
// implement in inheriting class
virtual t_ilm_bool threadMainLoop() = 0;
-
+
private:
static unsigned int mGlobalThreadCount;
pthread_t mThreadId;
void writeBitmap(std::string FileName, char* imagedataRGB, int width, int height)
{
- LOG_DEBUG("Bitmap","writing Bitmap to file:" <<FileName);
+ LOG_DEBUG("Bitmap", "writing Bitmap to file:" << FileName);
BMPHeader bmpHeader;
InfoHeader header;
- int imagebytes=width*height*3;
+ int imagebytes = width*height*3;
char firstbytes[2];
- firstbytes[0]='B';
- firstbytes[1]='M';
- bmpHeader.size = 2+sizeof(BMPHeader)+sizeof(header)+imagebytes;
+ firstbytes[0] = 'B';
+ firstbytes[1] = 'M';
+ bmpHeader.size = 2 + sizeof(BMPHeader) + sizeof(header) + imagebytes;
bmpHeader.a = 0;
bmpHeader.b = 0;
- bmpHeader.offset = 2+sizeof(BMPHeader)+sizeof(header);
+ bmpHeader.offset = 2 + sizeof(BMPHeader) + sizeof(header);
header.headersize = sizeof(header);
header.width = width;
header.height = height;
// make sure parent directory exists
std::size_t currentPos = 0;
- std::size_t lastPos = FileName.find_first_of("/",currentPos);
+ std::size_t lastPos = FileName.find_first_of("/", currentPos);
while (lastPos != std::string::npos)
{
- std::string directory = FileName.substr(0,lastPos);
- LOG_DEBUG("Bitmap","Creating directory " << directory);
- mkdir(directory.c_str(),0755);
+ std::string directory = FileName.substr(0, lastPos);
+ LOG_DEBUG("Bitmap", "Creating directory " << directory);
+ mkdir(directory.c_str(), 0755);
currentPos = lastPos;
- lastPos = FileName.find_first_of("/",currentPos+1);
+ lastPos = FileName.find_first_of("/", currentPos + 1);
}
- FILE* file = fopen(FileName.c_str(),"wb");
+ FILE* file = fopen(FileName.c_str(), "wb");
if (file)
{
void IlmMatrixIdentity(IlmMatrix &mOut)
{
- mOut.f[0] = 1.0f; mOut.f[4] = 0.0f; mOut.f[8] = 0.0f; mOut.f[12] = 0.0f;
- mOut.f[1] = 0.0f; mOut.f[5] = 1.0f; mOut.f[9] = 0.0f; mOut.f[13] = 0.0f;
- mOut.f[2] = 0.0f; mOut.f[6] = 0.0f; mOut.f[10] = 1.0f; mOut.f[14] = 0.0f;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = 1.0f;
+ mOut.f[1] = 0.0f;
+ mOut.f[2] = 0.0f;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = 0.0f;
+ mOut.f[5] = 1.0f;
+ mOut.f[6] = 0.0f;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = 0.0f;
+ mOut.f[9] = 0.0f;
+ mOut.f[10] = 1.0f;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = 0.0f;
+ mOut.f[13] = 0.0f;
+ mOut.f[14] = 0.0f;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixMultiply(IlmMatrix &mOut, const IlmMatrix &mA, const IlmMatrix &mB)
void IlmMatrixTranslation(IlmMatrix &mOut, const float X, const float Y, const float Z)
{
- mOut.f[0] = 1.0f; mOut.f[4] = 0.0f; mOut.f[8] = 0.0f; mOut.f[12] = X;
- mOut.f[1] = 0.0f; mOut.f[5] = 1.0f; mOut.f[9] = 0.0f; mOut.f[13] = Y;
- mOut.f[2] = 0.0f; mOut.f[6] = 0.0f; mOut.f[10] = 1.0f; mOut.f[14] = Z;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = 1.0f;
+ mOut.f[1] = 0.0f;
+ mOut.f[2] = 0.0f;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = 0.0f;
+ mOut.f[5] = 1.0f;
+ mOut.f[6] = 0.0f;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = 0.0f;
+ mOut.f[9] = 0.0f;
+ mOut.f[10] = 1.0f;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = X;
+ mOut.f[13] = Y;
+ mOut.f[14] = Z;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixScaling(IlmMatrix &mOut, const float X, const float Y, const float Z)
{
- mOut.f[0] = X; mOut.f[4] = 0.0f; mOut.f[8] = 0.0f; mOut.f[12] = 0.0f;
- mOut.f[1] = 0.0f; mOut.f[5] = Y; mOut.f[9] = 0.0f; mOut.f[13] = 0.0f;
- mOut.f[2] = 0.0f; mOut.f[6] = 0.0f; mOut.f[10] = Z; mOut.f[14] = 0.0f;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = X;
+ mOut.f[1] = 0.0f;
+ mOut.f[2] = 0.0f;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = 0.0f;
+ mOut.f[5] = Y;
+ mOut.f[6] = 0.0f;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = 0.0f;
+ mOut.f[9] = 0.0f;
+ mOut.f[10] = Z;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = 0.0f;
+ mOut.f[13] = 0.0f;
+ mOut.f[14] = 0.0f;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixRotateX(IlmMatrix &mOut, const float angle)
float fSine = (float)sin(degToRad(angle));
// Create the trigonometric matrix corresponding to X Rotation
- mOut.f[0] = 1.0f; mOut.f[4] = 0.0f; mOut.f[8] = 0.0f; mOut.f[12] = 0.0f;
- mOut.f[1] = 0.0f; mOut.f[5] = fCosine; mOut.f[9] = fSine; mOut.f[13] = 0.0f;
- mOut.f[2] = 0.0f; mOut.f[6] = -fSine; mOut.f[10] = fCosine; mOut.f[14] = 0.0f;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = 1.0f;
+ mOut.f[1] = 0.0f;
+ mOut.f[2] = 0.0f;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = 0.0f;
+ mOut.f[5] = fCosine;
+ mOut.f[6] = -fSine;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = 0.0f;
+ mOut.f[9] = fSine;
+ mOut.f[10] = fCosine;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = 0.0f;
+ mOut.f[13] = 0.0f;
+ mOut.f[14] = 0.0f;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixRotateY(IlmMatrix &mOut, const float angle)
float fSine = (float)sin(degToRad(angle));
// Create the trigonometric matrix corresponding to Y Rotation
- mOut.f[0] = fCosine; mOut.f[4] = 0.0f; mOut.f[8] = -fSine; mOut.f[12] = 0.0f;
- mOut.f[1] = 0.0f; mOut.f[5] = 1.0f; mOut.f[9] = 0.0f; mOut.f[13] = 0.0f;
- mOut.f[2] = fSine; mOut.f[6] = 0.0f; mOut.f[10] = fCosine; mOut.f[14] = 0.0f;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = fCosine;
+ mOut.f[1] = 0.0f;
+ mOut.f[2] = fSine;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = 0.0f;
+ mOut.f[5] = 1.0f;
+ mOut.f[6] = 0.0f;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = -fSine;
+ mOut.f[9] = 0.0f;
+ mOut.f[10] = fCosine;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = 0.0f;
+ mOut.f[13] = 0.0f;
+ mOut.f[14] = 0.0f;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixRotateZ(IlmMatrix &mOut, const float angle)
float fSine = (float)sin(degToRad(angle));
// Create the trigonometric matrix corresponding to Z Rotation
- mOut.f[0] = fCosine; mOut.f[4] = fSine; mOut.f[8] = 0.0f; mOut.f[12] = 0.0f;
- mOut.f[1] = -fSine; mOut.f[5] = fCosine; mOut.f[9] = 0.0f; mOut.f[13] = 0.0f;
- mOut.f[2] = 0.0f; mOut.f[6] = 0.0f; mOut.f[10] = 1.0f; mOut.f[14] = 0.0f;
- mOut.f[3] = 0.0f; mOut.f[7] = 0.0f; mOut.f[11] = 0.0f; mOut.f[15] = 1.0f;
+ mOut.f[0] = fCosine;
+ mOut.f[1] = -fSine;
+ mOut.f[2] = 0.0f;
+ mOut.f[3] = 0.0f;
+
+ mOut.f[4] = fSine;
+ mOut.f[5] = fCosine;
+ mOut.f[6] = 0.0f;
+ mOut.f[7] = 0.0f;
+
+ mOut.f[8] = 0.0f;
+ mOut.f[9] = 0.0f;
+ mOut.f[10] = 1.0f;
+ mOut.f[11] = 0.0f;
+
+ mOut.f[12] = 0.0f;
+ mOut.f[13] = 0.0f;
+ mOut.f[14] = 0.0f;
+ mOut.f[15] = 1.0f;
}
void IlmMatrixProjection(IlmMatrix &mOut, const float fov, const float near, const float far, const float aspect)
{
- // Precompute borders for projection
- float range = near * tan(degToRad(fov) / 2.0);
- float left = -range * aspect;
- float right = range * aspect;
- float bottom = -range;
- float top = range;
-
- // Column 1
- mOut.f[0] = 2 * near / (right - left);
- mOut.f[1] = 0.0;
- mOut.f[2] = 0.0;
- mOut.f[3] = 0.0;
-
- // Column 2
- mOut.f[4] = 0.0;
- mOut.f[5] = 2 * near / (top - bottom);
- mOut.f[6] = 0.0;
- mOut.f[7] = 0.0;
-
- // Column 3
- mOut.f[8] = 0.0;
- mOut.f[9] = 0.0;
- mOut.f[10] = -(far + near) / (far - near);
- mOut.f[11] = -1;
-
- // Column 4
- mOut.f[12] = 0.0;
- mOut.f[13] = 0.0;
- mOut.f[14] = -(2 * far * near) / (far - near);
- mOut.f[15] = 0.0;
+ // Precompute borders for projection
+ float range = near * tan(degToRad(fov) / 2.0);
+ float left = -range * aspect;
+ float right = range * aspect;
+ float bottom = -range;
+ float top = range;
+
+ // Column 1
+ mOut.f[0] = 2 * near / (right - left);
+ mOut.f[1] = 0.0;
+ mOut.f[2] = 0.0;
+ mOut.f[3] = 0.0;
+
+ // Column 2
+ mOut.f[4] = 0.0;
+ mOut.f[5] = 2 * near / (top - bottom);
+ mOut.f[6] = 0.0;
+ mOut.f[7] = 0.0;
+
+ // Column 3
+ mOut.f[8] = 0.0;
+ mOut.f[9] = 0.0;
+ mOut.f[10] = -(far + near) / (far - near);
+ mOut.f[11] = -1;
+
+ // Column 4
+ mOut.f[12] = 0.0;
+ mOut.f[13] = 0.0;
+ mOut.f[14] = -(2 * far * near) / (far - near);
+ mOut.f[15] = 0.0;
}
struct ApiFunction ApiFunctionTable[] =
{
- { "initClientMode", (void**)&ipcModule->initClientMode },
- { "initServiceMode", (void**)&ipcModule->initServiceMode },
+ { "initClientMode", (void**)&ipcModule->initClientMode },
+ { "initServiceMode", (void**)&ipcModule->initServiceMode },
- { "createMessage", (void**)&ipcModule->createMessage },
- { "createResponse", (void**)&ipcModule->createResponse },
+ { "createMessage", (void**)&ipcModule->createMessage },
+ { "createResponse", (void**)&ipcModule->createResponse },
{ "createErrorResponse", (void**)&ipcModule->createErrorResponse },
- { "createNotification", (void**)&ipcModule->createNotification },
+ { "createNotification", (void**)&ipcModule->createNotification },
- { "appendBool", (void**)&ipcModule->appendBool },
- { "appendDouble", (void**)&ipcModule->appendDouble },
- { "appendString", (void**)&ipcModule->appendString },
- { "appendInt", (void**)&ipcModule->appendInt },
- { "appendIntArray", (void**)&ipcModule->appendIntArray },
- { "appendUint", (void**)&ipcModule->appendUint },
- { "appendUintArray", (void**)&ipcModule->appendUintArray },
+ { "appendBool", (void**)&ipcModule->appendBool },
+ { "appendDouble", (void**)&ipcModule->appendDouble },
+ { "appendString", (void**)&ipcModule->appendString },
+ { "appendInt", (void**)&ipcModule->appendInt },
+ { "appendIntArray", (void**)&ipcModule->appendIntArray },
+ { "appendUint", (void**)&ipcModule->appendUint },
+ { "appendUintArray", (void**)&ipcModule->appendUintArray },
- { "sendToClients", (void**)&ipcModule->sendToClients },
- { "sendToService", (void**)&ipcModule->sendToService },
+ { "sendToClients", (void**)&ipcModule->sendToClients },
+ { "sendToService", (void**)&ipcModule->sendToService },
- { "receive", (void**)&ipcModule->receive },
+ { "receive", (void**)&ipcModule->receive },
- { "getMessageName", (void**)&ipcModule->getMessageName },
- { "getMessageType", (void**)&ipcModule->getMessageType },
- { "getSenderName", (void**)&ipcModule->getSenderName },
- { "getSenderHandle", (void**)&ipcModule->getSenderHandle },
+ { "getMessageName", (void**)&ipcModule->getMessageName },
+ { "getMessageType", (void**)&ipcModule->getMessageType },
+ { "getSenderName", (void**)&ipcModule->getSenderName },
+ { "getSenderHandle", (void**)&ipcModule->getSenderHandle },
- { "getBool", (void**)&ipcModule->getBool },
- { "getDouble", (void**)&ipcModule->getDouble },
- { "getString", (void**)&ipcModule->getString },
- { "getInt", (void**)&ipcModule->getInt },
- { "getIntArray", (void**)&ipcModule->getIntArray },
- { "getUint", (void**)&ipcModule->getUint },
- { "getUintArray", (void**)&ipcModule->getUintArray },
+ { "getBool", (void**)&ipcModule->getBool },
+ { "getDouble", (void**)&ipcModule->getDouble },
+ { "getString", (void**)&ipcModule->getString },
+ { "getInt", (void**)&ipcModule->getInt },
+ { "getIntArray", (void**)&ipcModule->getIntArray },
+ { "getUint", (void**)&ipcModule->getUint },
+ { "getUintArray", (void**)&ipcModule->getUintArray },
- { "destroyMessage", (void**)&ipcModule->destroyMessage },
+ { "destroyMessage", (void**)&ipcModule->destroyMessage },
- { "destroy", (void**)&ipcModule->destroy }
+ { "destroy", (void**)&ipcModule->destroy }
};
- const unsigned int apiFunctionCount = sizeof (ApiFunctionTable) / sizeof(struct ApiFunction);
+ const unsigned int apiFunctionCount = sizeof(ApiFunctionTable) / sizeof(struct ApiFunction);
unsigned int symbolCount = 0;
t_ilm_bool returnValue = ILM_FALSE;
void* pluginLibHandle = 0;
char fullFilePath[1024];
fullFilePath[0] = '\0';
-
snprintf(fullFilePath, sizeof(fullFilePath), "%s/%s", path, file);
pluginLibHandle = dlopen(fullFilePath, RTLD_LAZY);
if (*func->funcPtr)
{
symbolCount++;
- /*printf("[ OK ] symbol %s\n", func->name);*/
+ /*printf("[ OK ] symbol %s\n", func->name);*/
}
else
{
- /*printf("[FAIL] symbol %s\n", func->name);*/
+ /*printf("[FAIL] symbol %s\n", func->name);*/
}
}
}
}
}
- /*
- Note: will break plugin. must be done during shutdown,
- but currently there is no unloadIpcModule
- dlclose(pluginLibHandle);
+ /*
+ * Note: will break plugin. must be done during shutdown,
+ * but currently there is no unloadIpcModule
+ * dlclose(pluginLibHandle);
*/
return returnValue;
char path[1024];
DIR *directory;
- /* find communicator client plugin*/
+ /* find communicator client plugin*/
char* pluginLookupPath = getenv("LM_PLUGIN_PATH");
- if (pluginLookupPath)
+ if (pluginLookupPath)
{
- gDefaultPluginLookupPath = pluginLookupPath;
+ gDefaultPluginLookupPath = pluginLookupPath;
}
-
snprintf(path, sizeof(path), "%s/%s", gDefaultPluginLookupPath,
gCommunicatorPluginDirectory);
directory = opendir(path);
if (directory)
{
- /* iterate content of directory*/
+ /* iterate content of directory*/
struct dirent *itemInDirectory = 0;
while ((itemInDirectory = readdir(directory)) && !result)
{
LOG_MODES Log::consoleLogLevel = LOG_INFO;
#ifdef WITH_DLT
LOG_MODES Log::dltLogLevel = LOG_DEBUG;
-#else
+#else
LOG_MODES Log::dltLogLevel = LOG_DISABLED;
#endif
pthread_mutex_init(&m_LogBufferMutex, NULL);
Log::m_diagnosticCallbackMap = new Log::DiagnosticCallbackMap;
#ifdef WITH_DLT
- m_logContext = new DltContext;
- DLT_REGISTER_APP("LMSA","LayerManagerService");
- DLT_REGISTER_CONTEXT(*((DltContext*)m_logContext),"LMSC","LayerManagerService");
+ m_logContext = new DltContext;
+ DLT_REGISTER_APP("LMSA", "LayerManagerService");
+ DLT_REGISTER_CONTEXT(*((DltContext*)m_logContext), "LMSC", "LayerManagerService");
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_DEFAULT);
#else
m_logContext = NULL;
#endif
-
-
}
Log* Log::getInstance()
{
- if ( m_instance == NULL )
+ if (m_instance == NULL)
{
m_instance = new Log();
-
}
return m_instance;
}
Log::m_instance = NULL;
#ifdef WITH_DLT
DLT_UNREGISTER_CONTEXT(*((DltContext*)m_logContext));
- delete ((DltContext*)m_logContext);
+ delete((DltContext*)m_logContext);
DLT_UNREGISTER_APP();
#endif
delete m_diagnosticCallbackMap;
m_logContext = NULL;
}
-void Log::warning (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
+void Log::warning(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
{
- log(logContext,LOG_WARNING, moduleName, output);
+ log(logContext, LOG_WARNING, moduleName, output);
}
-void Log::info (LogContext logContext,const std::string& moduleName, const std::basic_string<char>& output)
+void Log::info(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
{
log(logContext, LOG_INFO, moduleName, output);
}
-void Log::error (LogContext logContext,const std::string& moduleName, const std::basic_string<char>& output)
+void Log::error(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
{
log(logContext, LOG_ERROR, moduleName, output);
}
-void Log::debug (LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
+void Log::debug(LogContext logContext, const std::string& moduleName, const std::basic_string<char>& output)
{
- log(logContext, LOG_DEBUG, moduleName, output);
+ log(logContext, LOG_DEBUG, moduleName, output);
}
void Log::log(LogContext logContext, LOG_MODES logMode, const std::string& moduleName, const std::basic_string<char>& output)
{
(void)logContext;
- std::string logString[LOG_MAX_LEVEL] = {"","ERROR","INFO","WARNING","DEBUG"};
+ std::string logString[LOG_MAX_LEVEL] = {"", "ERROR", "INFO", "WARNING", "DEBUG"};
std::string logOutLevelString = logString[LOG_INFO];
pthread_mutex_lock(&m_LogBufferMutex);
- if ( logMode < LOG_MAX_LEVEL )
+ if (logMode < LOG_MAX_LEVEL)
{
logOutLevelString = logString[logMode];
}
- if ( consoleLogLevel >= logMode )
- {
+ if (consoleLogLevel >= logMode)
+ {
LogToConsole(logOutLevelString, moduleName, output);
}
- if ( fileLogLevel >= logMode )
+ if (fileLogLevel >= logMode)
{
LogToFile(logOutLevelString, moduleName, output);
- }
+ }
#ifdef WITH_DLT
- if ( dltLogLevel >= logMode )
+ if (dltLogLevel >= logMode)
{
LogToDltDaemon(logContext, logMode, moduleName, output);
- }
-#endif
+ }
+#endif
pthread_mutex_unlock(&m_LogBufferMutex);
}
-void Log::LogToFile(std::string logMode, const std::string& moduleName,const std::basic_string<char>& output)
+void Log::LogToFile(std::string logMode, const std::string& moduleName, const std::basic_string<char>& output)
{
static unsigned int maxLengthModuleName = 0;
static unsigned int maxLengthLogModeName = 0;
}
*m_fileStream << std::setw(maxLengthModuleName) << std::left << moduleName << " | "
- << std::setw(maxLengthLogModeName) << std::left << logMode << " | "
- << output << std::endl;
+ << std::setw(maxLengthLogModeName) << std::left << logMode << " | "
+ << output << std::endl;
}
void Log::LogToConsole(std::string logMode, const std::string& moduleName, const std::basic_string<char>& output)
}
std::cout << std::setw(maxLengthModuleName) << std::left << moduleName << " | "
- << std::setw(maxLengthLogModeName) << std::left << logMode << " | "
- << output << std::endl;
+ << std::setw(maxLengthLogModeName) << std::left << logMode << " | "
+ << output << std::endl;
}
LogContext Log::getLogContext()
{
return m_logContext;
}
+
#ifdef WITH_DLT
int dlt_injection_callback(unsigned int module_id, void *data, unsigned int length)
{
- LOG_DEBUG("LOG","Injection for service " << module_id << " called");
+ LOG_DEBUG("LOG", "Injection for service " << module_id << " called");
Log::diagnosticCallbackData *cbData = (*Log::getDiagnosticCallbackMap())[module_id];
- if ( NULL != cbData)
+ if (cbData)
{
cbData->diagFunc(module_id, data, length, cbData->userdata);
}
}
#endif
-
-void Log::registerDiagnosticInjectionCallback( unsigned int module_id, diagnosticInjectionCallback diagFunc, void* userdata )
+void Log::registerDiagnosticInjectionCallback(unsigned int module_id, diagnosticInjectionCallback diagFunc, void* userdata)
{
Log::diagnosticCallbackData *cbData = new Log::diagnosticCallbackData;
cbData->module_id = module_id;
cbData->userdata = userdata;
cbData->diagFunc = diagFunc;
- (*m_diagnosticCallbackMap)[module_id]=cbData;
-#ifdef WITH_DLT
+ (*m_diagnosticCallbackMap)[module_id] = cbData;
+#ifdef WITH_DLT
DLT_REGISTER_INJECTION_CALLBACK(*(DltContext*)m_logContext, module_id, dlt_injection_callback);
#endif
}
-
-void Log::unregisterDiagnosticInjectionCallback( unsigned int module_id )
+
+void Log::unregisterDiagnosticInjectionCallback(unsigned int module_id)
{
m_diagnosticCallbackMap->erase(module_id);
}
-
-
-#ifdef WITH_DLT
+#ifdef WITH_DLT
// DLT macros will fail using -pedantic with
// warning: ISO C++ forbids braced-groups within expressions
void Log::LogToDltDaemon(LogContext logContext, LOG_MODES logMode, const std::string& moduleName, const std::basic_string<char>& output)
{
-
std::stringstream oss;
std::string dltString;
static unsigned int maxLengthModuleName = 0;
maxLengthModuleName = moduleName.length();
}
oss << std::setw(maxLengthModuleName) << std::left << moduleName << " | "
- << output << std::endl;
- dltString = oss.str();
- switch ( logMode )
+ << output << std::endl;
+ dltString = oss.str();
+
+ switch (logMode)
{
- case LOG_INFO : DLT_LOG(*((DltContext*)logContext),DLT_LOG_INFO,DLT_STRING(dltString.c_str())); break;
- case LOG_ERROR : DLT_LOG(*((DltContext*)logContext),DLT_LOG_ERROR,DLT_STRING(dltString.c_str())); break;
- case LOG_DEBUG : DLT_LOG(*((DltContext*)logContext),DLT_LOG_DEBUG,DLT_STRING(dltString.c_str())); break;
- case LOG_WARNING : DLT_LOG(*((DltContext*)logContext),DLT_LOG_WARN,DLT_STRING(dltString.c_str())); break;
- default:
- DLT_LOG(*((DltContext*)logContext),DLT_LOG_INFO,DLT_STRING(dltString.c_str()));
+ case LOG_INFO:
+ DLT_LOG(*((DltContext*)logContext), DLT_LOG_INFO, DLT_STRING(dltString.c_str()));
+ break;
+
+ case LOG_ERROR:
+ DLT_LOG(*((DltContext*)logContext), DLT_LOG_ERROR, DLT_STRING(dltString.c_str()));
+ break;
+
+ case LOG_DEBUG:
+ DLT_LOG(*((DltContext*)logContext), DLT_LOG_DEBUG, DLT_STRING(dltString.c_str()));
+ break;
+
+ case LOG_WARNING:
+ DLT_LOG(*((DltContext*)logContext), DLT_LOG_WARN, DLT_STRING(dltString.c_str()));
+ break;
+
+ default:
+ DLT_LOG(*((DltContext*)logContext), DLT_LOG_INFO, DLT_STRING(dltString.c_str()));
}
}
-#endif
+#endif
LogMessageBuffer::~LogMessageBuffer()
{
- if (stream)
+ if (stream)
{
delete stream;
}
/***************************************************************************
- *
+ *
* Copyright 2010,2011 BMW Car IT GmbH
*
*
((ThreadArgument*)arg)->obj->threadDestroyInThreadContext();
pthread_mutex_unlock(((ThreadArgument*)arg)->runLock);
*(((ThreadArgument*)arg)->running) = ILM_FALSE;
- delete (ThreadArgument*)arg;
+ delete((ThreadArgument*)arg);
}
//===========================================================================
LOG_ERROR("ThreadBase", "invalid thread argument (arg)");
return NULL;
}
-
+
if (!((ThreadArgument*)arg)->obj)
{
LOG_ERROR("ThreadBase", "invalid thread argument (obj)");
return NULL;
}
-
+
if (!((ThreadArgument*)arg)->running)
{
LOG_ERROR("ThreadBase", "invalid thread argument (running)");
return NULL;
}
-
+
// register cleanup function
pthread_cleanup_push(threadBaseMainLoopCleanup, arg);
-
+
// init in thread context
*(((ThreadArgument*)arg)->running) = ((ThreadArgument*)arg)->obj->threadInitInThreadContext();
-
+
// indicate initialization complete
pthread_mutex_unlock(((ThreadArgument*)arg)->initLock);
-
+
// wait for start permit
pthread_mutex_lock(((ThreadArgument*)arg)->runLock);
-
+
// run thread
while (*(((ThreadArgument*)arg)->running))
{
*(((ThreadArgument*)arg)->running) = ((ThreadArgument*)arg)->obj->threadMainLoop();
}
-
+
// execute cleanup handlers
pthread_cleanup_pop(1);
-
+
return NULL;
}
{
pthread_mutex_init(&mRunLock, NULL);
pthread_mutex_lock(&mRunLock);
-
+
pthread_mutex_init(&mInitLock, NULL);
pthread_mutex_lock(&mInitLock);
}
{
pthread_mutex_unlock(&mInitLock);
pthread_mutex_destroy(&mInitLock);
-
+
pthread_mutex_unlock(&mRunLock);
pthread_mutex_destroy(&mRunLock);
}
t_ilm_bool ThreadBase::threadIsRunning()
{
- if(0 == pthread_mutex_trylock(&mRunLock))
+ if (0 == pthread_mutex_trylock(&mRunLock))
{
pthread_mutex_unlock(&mRunLock);
mRunning = ILM_FALSE;
pthread_attr_init(¬ificationThreadAttributes);
pthread_attr_setdetachstate(¬ificationThreadAttributes,
PTHREAD_CREATE_JOINABLE);
-
+
ThreadArgument* arg = new ThreadArgument();
arg->obj = this;
arg->runLock = &mRunLock;
arg->initLock = &mInitLock;
arg->running = &mRunning;
-
+
int ret = pthread_create(&mThreadId,
- ¬ificationThreadAttributes,
- threadBaseMainLoop,
- (void*)arg);
+ ¬ificationThreadAttributes,
+ threadBaseMainLoop,
+ (void*)arg);
if (0 != ret)
{
LOG_ERROR("ThreadBase", "Failed to start thread.");
LOG_DEBUG("ThreadBase", "Started thread (now " << mGlobalThreadCount << ")");
mRunning = ILM_TRUE;
}
-
+
return threadIsRunning();
}
t_ilm_bool ThreadBase::threadStop()
{
t_ilm_bool result = ILM_TRUE;
-
+
mRunning = threadIsRunning();
-
+
if (mRunning)
{
LOG_INFO("ThreadBase", "pthread_cancel");
}
}
}
-
+
if (result)
{
--mGlobalThreadCount;
LOG_DEBUG("ThreadBase", "Stopped thread (now " << mGlobalThreadCount << ")");
}
-
+
return result;
}