/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// CLASS HEADER
#include "environment-options.h"
+// EXTERNAL INCLUDES
+#include <cstdlib>
+#include <dali/integration-api/render-controller.h>
+#include <dali/public-api/math/math-utils.h>
+
+// INTERNAL INCLUDES
+#include <base/environment-variables.h>
+
namespace Dali
{
namespace
{
const unsigned int DEFAULT_STATISTICS_LOG_FREQUENCY = 2;
+
+unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ // if the parameter exists convert it to an integer, else return the default value
+ unsigned int intValue = variableParameter ? std::atoi(variableParameter) : defaultValue;
+ return intValue;
+}
+
+bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ if( !variableParameter )
+ {
+ return false;
+ }
+ // if the parameter exists convert it to an integer, else return the default value
+ intValue = std::atoi(variableParameter);
+ return true;
+}
+
+bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ if( !variableParameter )
+ {
+ return false;
+ }
+ // if the parameter exists convert it to an integer, else return the default value
+ floatValue = std::atof(variableParameter);
+ return true;
+}
+
}
EnvironmentOptions::EnvironmentOptions()
: mNetworkControl(0),
mPanMinimumEvents(-1),
mGlesCallTime(0),
mWindowWidth( 0 ),
- mWindowHeight( 0 ),
- mLogFunction( NULL )
+ mWindowHeight( 0 )
{
+ ParseEnvironmentOptions();
}
EnvironmentOptions::~EnvironmentOptions()
{
}
-void EnvironmentOptions::SetLogOptions( const Dali::Integration::Log::LogFunction& logFunction,
- unsigned int networkControl,
- unsigned int logFrameRateFrequency,
- unsigned int logupdateStatusFrequency,
- unsigned int logPerformanceStats,
- unsigned int logPerformanceStatsFrequency,
- unsigned int performanceTimeStampOutput,
- unsigned int logPanGestureLevel )
+void EnvironmentOptions::SetLogFunction( const Dali::Integration::Log::LogFunction& logFunction )
{
mLogFunction = logFunction;
- mNetworkControl = networkControl;
- mFpsFrequency = logFrameRateFrequency;
- mUpdateStatusFrequency = logupdateStatusFrequency;
- mPerformanceStatsLevel = logPerformanceStats;
- mPerformanceStatsFrequency = logPerformanceStatsFrequency;
- mPerformanceTimeStampOutput= performanceTimeStampOutput;
- mPanGestureLoggingLevel = logPanGestureLevel;
}
void EnvironmentOptions::InstallLogFunction() const
( GetNetworkControlMode() > 0) );
}
+void EnvironmentOptions::ParseEnvironmentOptions()
+{
+ // get logging options
+ mFpsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
+ mUpdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
+ mPerformanceStatsLevel = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
+ mPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
+ mPerformanceTimeStampOutput = GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
+ mNetworkControl = GetIntegerEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 0 );
+ mPanGestureLoggingLevel = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
+
+ int predictionMode;
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
+ {
+ SetPanGesturePredictionMode(predictionMode);
+ }
+ int predictionAmount(-1);
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
+ {
+ if( predictionAmount < 0 )
+ {
+ // do not support times in the past
+ predictionAmount = 0;
+ }
+ SetPanGesturePredictionAmount(predictionAmount);
+ }
+ int minPredictionAmount(-1);
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, minPredictionAmount) )
+ {
+ if( minPredictionAmount < 0 )
+ {
+ // do not support times in the past
+ minPredictionAmount = 0;
+ }
+ SetPanGestureMinimumPredictionAmount(minPredictionAmount);
+ }
+ int maxPredictionAmount(-1);
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT, maxPredictionAmount) )
+ {
+ if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
+ {
+ // maximum amount should not be smaller than minimum amount
+ maxPredictionAmount = minPredictionAmount;
+ }
+ SetPanGestureMaximumPredictionAmount(maxPredictionAmount);
+ }
+ int predictionAmountAdjustment(-1);
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) )
+ {
+ if( predictionAmountAdjustment < 0 )
+ {
+ // negative amount doesn't make sense
+ predictionAmountAdjustment = 0;
+ }
+ SetPanGesturePredictionAmountAdjustment(predictionAmountAdjustment);
+ }
+ int smoothingMode;
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
+ {
+ SetPanGestureSmoothingMode(smoothingMode);
+ }
+ float smoothingAmount = 1.0f;
+ if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
+ {
+ smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
+ SetPanGestureSmoothingAmount(smoothingAmount);
+ }
+
+ int minimumDistance(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
+ {
+ SetMinimumPanDistance( minimumDistance );
+ }
+
+ int minimumEvents(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
+ {
+ SetMinimumPanEvents( minimumEvents );
+ }
+
+ int glesCallTime(0);
+ if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
+ {
+ SetGlesCallTime( glesCallTime );
+ }
+
+ int windowWidth(0), windowHeight(0);
+ if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
+ {
+ SetWindowWidth( windowWidth );
+ SetWindowHeight( windowHeight );
+ }
+
+}
+
} // Adaptor
} // Internal
#define __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
/**
- * Contains environment options which define settings and the ability to install a log function.
+ * This class provides the environment options which define settings as well as
+ * the ability to install a log function.
*
- * TODO: This file and adaptor needs cleaning up. There should not be any environment options in the adaptor class, only here!
*/
class EnvironmentOptions
{
/**
* @param logFunction logging function
- * @param networkControl whether network control is enabled
- * @param logFilterOptions bitmask of the logging options defined in intergration/debug.h (e.g.
- * @param logFrameRateFrequency frequency of how often FPS is logged out (e.g. 0 = off, 2 = every 2 seconds).
- * @param logupdateStatusFrequency frequency of how often the update status is logged in number of frames
- * @param logPerformanceStats performance statistics logging, 0 = disabled, 1+ = enabled
- * @param logPerformanceStatsFrequency statistics logging frequency in seconds
- * @param performanceTimeStampOutput where to output performance related time stamps to
- * @param logPanGestureLevel pan-gesture logging, 0 = disabled, 1 = enabled
- */
- void SetLogOptions( const Dali::Integration::Log::LogFunction& logFunction,
- unsigned int networkControl,
- unsigned int logFrameRateFrequency,
- unsigned int logupdateStatusFrequency,
- unsigned int logPerformanceStats,
- unsigned int logPerformanceStatsFrequency,
- unsigned int performanceTimeStampOutput,
- unsigned int logPanGestureLevel );
+ */
+ void SetLogFunction( const Dali::Integration::Log::LogFunction& logFunction );
/**
* Install the log function for the current thread.
*/
bool PerformanceServerRequired() const;
-private:
+private: // Internal
+
+ /**
+ * Parses the environment options.
+ * Called from the constructor
+ */
+ void ParseEnvironmentOptions();
+
+private: // Data
unsigned int mNetworkControl; ///< whether network control is enabled
unsigned int mFpsFrequency; ///< how often fps is logged out in seconds
#define __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_VARIABLES_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "adaptor-impl.h"
// EXTERNAL INCLUDES
-#include <boost/thread/tss.hpp>
#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/core.h>
// INTERNAL INCLUDES
#include <base/update-render-controller.h>
-#include <base/environment-variables.h>
#include <base/performance-logging/performance-interface-factory.h>
#include <base/lifecycle-observer.h>
#include <render-surface.h>
#include <tts-player-impl.h>
#include <accessibility-manager-impl.h>
-#include <timer-impl.h>
#include <events/gesture-manager.h>
#include <events/event-handler.h>
#include <feedback/feedback-controller.h>
namespace
{
-boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
-
-unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- // if the parameter exists convert it to an integer, else return the default value
- unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
- return intValue;
-}
-
-bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- if( !variableParameter )
- {
- return false;
- }
- // if the parameter exists convert it to an integer, else return the default value
- intValue = atoi(variableParameter);
- return true;
-}
-
-bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- if( !variableParameter )
- {
- return false;
- }
- // if the parameter exists convert it to an integer, else return the default value
- floatValue = atof(variableParameter);
- return true;
-}
-
+__thread Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
} // unnamed namespace
Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, const DeviceLayout& baseLayout,
return adaptor;
}
-void Adaptor::ParseEnvironmentOptions()
-{
- // get logging options
- unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
- unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
- unsigned int logPerformanceStats = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
- unsigned int logPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
- unsigned int performanceTimeStampOutput= GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
- unsigned int networkControl= GetIntegerEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 0 );
-
- unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
-
- // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
- Dali::Integration::Log::LogFunction logFunction(Dali::TizenPlatform::LogMessage);
-
- mEnvironmentOptions.SetLogOptions( logFunction, networkControl, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
-
- int predictionMode;
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
- {
- mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
- }
- int predictionAmount(-1);
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
- {
- if( predictionAmount < 0 )
- {
- // do not support times in the past
- predictionAmount = 0;
- }
- mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
- }
- int minPredictionAmount(-1);
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, minPredictionAmount) )
- {
- if( minPredictionAmount < 0 )
- {
- // do not support times in the past
- minPredictionAmount = 0;
- }
- mEnvironmentOptions.SetPanGestureMinimumPredictionAmount(minPredictionAmount);
- }
- int maxPredictionAmount(-1);
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT, maxPredictionAmount) )
- {
- if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
- {
- // maximum amount should not be smaller than minimum amount
- maxPredictionAmount = minPredictionAmount;
- }
- mEnvironmentOptions.SetPanGestureMaximumPredictionAmount(maxPredictionAmount);
- }
- int predictionAmountAdjustment(-1);
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) )
- {
- if( predictionAmountAdjustment < 0 )
- {
- // negative amount doesn't make sense
- predictionAmountAdjustment = 0;
- }
- mEnvironmentOptions.SetPanGesturePredictionAmountAdjustment(predictionAmountAdjustment);
- }
- int smoothingMode;
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
- {
- mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
- }
- float smoothingAmount = 1.0f;
- if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
- {
- smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
- mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
- }
-
- int minimumDistance(-1);
- if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
- {
- mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
- }
-
- int minimumEvents(-1);
- if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
- {
- mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
- }
- int glesCallTime(0);
- if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
- {
- mEnvironmentOptions.SetGlesCallTime( glesCallTime );
- }
-
- int windowWidth(0), windowHeight(0);
- if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
- {
- mEnvironmentOptions.SetWindowWidth( windowWidth );
- mEnvironmentOptions.SetWindowHeight( windowHeight );
- }
-
- mEnvironmentOptions.InstallLogFunction();
-}
-
-void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
+void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
{
- ParseEnvironmentOptions();
+ // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
+ Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
+ mEnvironmentOptions.SetLogFunction( logFunction );
+ mEnvironmentOptions.InstallLogFunction(); // install logging for main thread
mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
// Ensure stop status
Stop();
- // Release first as we do not want any access to Adaptor as it is being destroyed.
- gThreadLocalAdaptor.release();
+ // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
+ gThreadLocalAdaptor = NULL;
for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
{
Dali::Adaptor& Adaptor::Get()
{
- DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
+ DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
return gThreadLocalAdaptor->mAdaptor;
}
bool Adaptor::IsAvailable()
{
- return gThreadLocalAdaptor.get() != NULL;
+ return gThreadLocalAdaptor != NULL;
}
Dali::Integration::Core& Adaptor::GetCore()
mPerformanceInterface(NULL),
mObjectProfiler(NULL)
{
- DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
- gThreadLocalAdaptor.reset(this);
+ DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
+ gThreadLocalAdaptor = this;
}
// Stereoscopy
#define __DALI_INTERNAL_ADAPTOR_IMPL_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private:
/**
- * Helper to parse log options
- */
- void ParseEnvironmentOptions();
-
- /**
* Informs core the surface size has changed
*/
void SurfaceSizeChanged(const PositionSize& positionSize);