X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fbase%2Fenvironment-options.cpp;h=0866eeb17927693c7fecae8fab011dfbe145540c;hb=4b464f187d39773bb79bd1b00a531af113e0dafd;hp=118eb29fcc8966ea79ce8df32f8eed173bca8083;hpb=66ba4fe9f36786424d655aca1ce3f523b960e5b4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/base/environment-options.cpp b/adaptors/base/environment-options.cpp index 118eb29..0866eeb 100644 --- a/adaptors/base/environment-options.cpp +++ b/adaptors/base/environment-options.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,6 +18,14 @@ // CLASS HEADER #include "environment-options.h" +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include + namespace Dali { @@ -30,52 +38,95 @@ namespace Adaptor 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; +} + +const char * GetCharEnvironmentVariable( const char * variable ) +{ + return std::getenv( variable ); +} + +} // unnamed namespace + EnvironmentOptions::EnvironmentOptions() -: mNetworkControl(0), - mFpsFrequency(0), - mUpdateStatusFrequency(0), - mPerformanceStatsLevel(0), - mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY), - mPerformanceTimeStampOutput(0), - mPanGestureLoggingLevel(0), - mPanGesturePredictionMode(-1), - mPanGesturePredictionAmount(-1), ///< only sets value in pan gesture if greater than 0 - mPanGestureMaxPredictionAmount(-1), - mPanGestureMinPredictionAmount(-1), - mPanGesturePredictionAmountAdjustment(-1), - mPanGestureSmoothingMode(-1), - mPanGestureSmoothingAmount(-1.0f), - mPanMinimumDistance(-1), - mPanMinimumEvents(-1), - mGlesCallTime(0), +: mWindowName(), + mWindowClassName(), + mNetworkControl( 0 ), + mFpsFrequency( 0 ), + mUpdateStatusFrequency( 0 ), + mObjectProfilerInterval( 0 ), + mPerformanceStatsLevel( 0 ), + mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY ), + mPerformanceTimeStampOutput( 0 ), + mPanGestureLoggingLevel( 0 ), + mPanGesturePredictionMode( -1 ), + mPanGesturePredictionAmount( -1 ), ///< only sets value in pan gesture if greater than 0 + mPanGestureMaxPredictionAmount( -1 ), + mPanGestureMinPredictionAmount( -1 ), + mPanGesturePredictionAmountAdjustment( -1 ), + mPanGestureSmoothingMode( -1 ), + mPanGestureSmoothingAmount( -1.0f ), + mPanGestureUseActualTimes( -1 ), + mPanGestureInterpolationTimeRange( -1 ), + mPanGestureScalarOnlyPredictionEnabled( -1 ), + mPanGestureTwoPointPredictionEnabled( -1 ), + mPanGestureTwoPointInterpolatePastTime( -1 ), + mPanGestureTwoPointVelocityBias( -1.0f ), + mPanGestureTwoPointAccelerationBias( -1.0f ), + mPanGestureMultitapSmoothingRange( -1 ), + mPanMinimumDistance( -1 ), + mPanMinimumEvents( -1 ), + mGlesCallTime( 0 ), mWindowWidth( 0 ), mWindowHeight( 0 ), + mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ), + mRenderRefreshRate( 1 ), + mGlesCallAccumulate( false ), mLogFunction( NULL ) { + 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 @@ -102,6 +153,11 @@ unsigned int EnvironmentOptions::GetUpdateStatusLoggingFrequency() const return mUpdateStatusFrequency; } +unsigned int EnvironmentOptions::GetObjectProfilerInterval() const +{ + return mObjectProfilerInterval; +} + unsigned int EnvironmentOptions::GetPerformanceStatsLoggingOptions() const { return mPerformanceStatsLevel; @@ -155,98 +211,303 @@ float EnvironmentOptions::GetPanGestureSmoothingAmount() const return mPanGestureSmoothingAmount; } -int EnvironmentOptions::GetMinimumPanDistance() const +int EnvironmentOptions::GetPanGestureUseActualTimes() const { - return mPanMinimumDistance; + return mPanGestureUseActualTimes; } -int EnvironmentOptions::GetMinimumPanEvents() const +int EnvironmentOptions::GetPanGestureInterpolationTimeRange() const { - return mPanMinimumEvents; + return mPanGestureInterpolationTimeRange; } -unsigned int EnvironmentOptions::GetWindowWidth() const +int EnvironmentOptions::GetPanGestureScalarOnlyPredictionEnabled() const { - return mWindowWidth; + return mPanGestureScalarOnlyPredictionEnabled; } -unsigned int EnvironmentOptions::GetWindowHeight() const +int EnvironmentOptions::GetPanGestureTwoPointPredictionEnabled() const { - return mWindowHeight; + return mPanGestureTwoPointPredictionEnabled; } -void EnvironmentOptions::SetPanGesturePredictionMode( unsigned int mode ) +int EnvironmentOptions::GetPanGestureTwoPointInterpolatePastTime() const { - mPanGesturePredictionMode = mode; + return mPanGestureTwoPointInterpolatePastTime; } -void EnvironmentOptions::SetPanGesturePredictionAmount( unsigned int amount ) +float EnvironmentOptions::GetPanGestureTwoPointVelocityBias() const { - mPanGesturePredictionAmount = amount; + return mPanGestureTwoPointVelocityBias; } -void EnvironmentOptions::SetPanGestureMaximumPredictionAmount( unsigned int amount ) +float EnvironmentOptions::GetPanGestureTwoPointAccelerationBias() const { - mPanGestureMaxPredictionAmount = amount; + return mPanGestureTwoPointAccelerationBias; } -void EnvironmentOptions::SetPanGestureMinimumPredictionAmount( unsigned int amount ) +int EnvironmentOptions::GetPanGestureMultitapSmoothingRange() const { - mPanGestureMinPredictionAmount = amount; + return mPanGestureMultitapSmoothingRange; } -void EnvironmentOptions::SetPanGesturePredictionAmountAdjustment( unsigned int amount ) +int EnvironmentOptions::GetMinimumPanDistance() const { - mPanGesturePredictionAmountAdjustment = amount; + return mPanMinimumDistance; } -void EnvironmentOptions::SetPanGestureSmoothingMode( unsigned int mode ) +int EnvironmentOptions::GetMinimumPanEvents() const { - mPanGestureSmoothingMode = mode; + return mPanMinimumEvents; } -void EnvironmentOptions::SetPanGestureSmoothingAmount( float amount ) +unsigned int EnvironmentOptions::GetWindowWidth() const { - mPanGestureSmoothingAmount = amount; + return mWindowWidth; } -void EnvironmentOptions::SetMinimumPanDistance( int distance ) +unsigned int EnvironmentOptions::GetWindowHeight() const { - mPanMinimumDistance = distance; + return mWindowHeight; } -void EnvironmentOptions::SetMinimumPanEvents( int events ) +int EnvironmentOptions::GetGlesCallTime() const { - mPanMinimumEvents = events; + return mGlesCallTime; } -void EnvironmentOptions::SetGlesCallTime( int time ) +bool EnvironmentOptions::GetGlesCallAccumulate() const { - mGlesCallTime = time; + return mGlesCallAccumulate; } -int EnvironmentOptions::GetGlesCallTime() const +const std::string& EnvironmentOptions::GetWindowName() const { - return mGlesCallTime; + return mWindowName; } -void EnvironmentOptions::SetWindowWidth( int width ) +const std::string& EnvironmentOptions::GetWindowClassName() const { - mWindowWidth = width; + return mWindowClassName; } -void EnvironmentOptions::SetWindowHeight( int height ) +ThreadingMode::Type EnvironmentOptions::GetThreadingMode() const { - mWindowHeight = height; + return mThreadingMode; +} + +unsigned int EnvironmentOptions::GetRenderRefreshRate() const +{ + return mRenderRefreshRate; } bool EnvironmentOptions::PerformanceServerRequired() const { - return ( (GetPerformanceStatsLoggingOptions() > 0) || + return ( ( GetPerformanceStatsLoggingOptions() > 0) || ( GetPerformanceTimeStampOutput() > 0 ) || ( GetNetworkControlMode() > 0) ); } +void EnvironmentOptions::ParseEnvironmentOptions() +{ + // get logging options + mFpsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 ); + mUpdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 ); + mObjectProfilerInterval = GetIntegerEnvironmentVariable( DALI_ENV_OBJECT_PROFILER_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) ) + { + mPanGesturePredictionMode = predictionMode; + } + int predictionAmount(-1); + if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) ) + { + if( predictionAmount < 0 ) + { + // do not support times in the past + predictionAmount = 0; + } + mPanGesturePredictionAmount = 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; + } + mPanGestureMinPredictionAmount = 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; + } + mPanGestureMaxPredictionAmount = maxPredictionAmount; + } + int predictionAmountAdjustment(-1); + if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) ) + { + if( predictionAmountAdjustment < 0 ) + { + // negative amount doesn't make sense + predictionAmountAdjustment = 0; + } + mPanGesturePredictionAmountAdjustment = predictionAmountAdjustment; + } + int smoothingMode; + if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) ) + { + mPanGestureSmoothingMode = smoothingMode; + } + float smoothingAmount = 1.0f; + if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) ) + { + smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f); + mPanGestureSmoothingAmount = smoothingAmount; + } + + int useActualTimes( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_USE_ACTUAL_TIMES, useActualTimes ) ) + { + mPanGestureUseActualTimes = useActualTimes == 0 ? 0 : 1; + } + + int interpolationTimeRange( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_INTERPOLATION_TIME_RANGE, interpolationTimeRange ) ) + { + if( interpolationTimeRange < 0 ) + { + interpolationTimeRange = 0; + } + mPanGestureInterpolationTimeRange = interpolationTimeRange; + } + + int scalarOnlyPredictionEnabled( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_SCALAR_ONLY_PREDICTION_ENABLED, scalarOnlyPredictionEnabled ) ) + { + mPanGestureScalarOnlyPredictionEnabled = scalarOnlyPredictionEnabled == 0 ? 0 : 1; + } + + int twoPointPredictionEnabled( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_PREDICTION_ENABLED, twoPointPredictionEnabled ) ) + { + mPanGestureTwoPointPredictionEnabled = twoPointPredictionEnabled == 0 ? 0 : 1; + } + + int twoPointPastInterpolateTime( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_PAST_INTERPOLATE_TIME, twoPointPastInterpolateTime ) ) + { + if( twoPointPastInterpolateTime < 0 ) + { + twoPointPastInterpolateTime = 0; + } + mPanGestureTwoPointInterpolatePastTime = twoPointPastInterpolateTime; + } + + float twoPointVelocityBias = -1.0f; + if( GetFloatEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_VELOCITY_BIAS, twoPointVelocityBias ) ) + { + twoPointVelocityBias = Clamp( twoPointVelocityBias, 0.0f, 1.0f ); + mPanGestureTwoPointVelocityBias = twoPointVelocityBias; + } + + float twoPointAccelerationBias = -1.0f; + if( GetFloatEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_ACCELERATION_BIAS, twoPointAccelerationBias ) ) + { + twoPointAccelerationBias = Clamp( twoPointAccelerationBias, 0.0f, 1.0f ); + mPanGestureTwoPointAccelerationBias = twoPointAccelerationBias; + } + + int multitapSmoothingRange( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_MULTITAP_SMOOTHING_RANGE, multitapSmoothingRange ) ) + { + if( multitapSmoothingRange < 0 ) + { + multitapSmoothingRange = 0; + } + mPanGestureMultitapSmoothingRange = multitapSmoothingRange; + } + + int minimumDistance(-1); + if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance )) + { + mPanMinimumDistance = minimumDistance; + } + + int minimumEvents(-1); + if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents )) + { + mPanMinimumEvents = minimumEvents; + } + + int glesCallTime(0); + if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime )) + { + mGlesCallTime = glesCallTime; + } + + int glesCallAccumulate( 0 ); + if ( GetIntegerEnvironmentVariable( DALI_GLES_CALL_ACCUMULATE, glesCallAccumulate ) ) + { + mGlesCallAccumulate = glesCallAccumulate != 0; + } + + int windowWidth(0), windowHeight(0); + if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) ) + { + mWindowWidth = windowWidth; + mWindowHeight = windowHeight; + } + + const char * windowName = GetCharEnvironmentVariable( DALI_WINDOW_NAME ); + if ( windowName ) + { + mWindowName = windowName; + } + + const char * windowClassName = GetCharEnvironmentVariable( DALI_WINDOW_CLASS_NAME ); + if ( windowClassName ) + { + mWindowClassName = windowClassName; + } + + int threadingMode(0); + if ( GetIntegerEnvironmentVariable( DALI_THREADING_MODE, threadingMode ) ) + { + switch( threadingMode ) + { + case ThreadingMode::SEPARATE_UPDATE_RENDER: + case ThreadingMode::COMBINED_UPDATE_RENDER: + case ThreadingMode::SINGLE_THREADED: + { + mThreadingMode = static_cast< ThreadingMode::Type >( threadingMode ); + break; + } + } + } + + int renderRefreshRate(0); + if ( GetIntegerEnvironmentVariable( DALI_REFRESH_RATE, renderRefreshRate ) ) + { + // Only change it if it's valid + if( renderRefreshRate > 1 ) + { + mRenderRefreshRate = renderRefreshRate; + } + } +} + } // Adaptor } // Internal