Merge "DALi Version 1.2.36" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 21 Apr 2017 11:38:43 +0000 (04:38 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 21 Apr 2017 11:38:43 +0000 (04:38 -0700)
automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.h
dali-toolkit/internal/styling/style-manager-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/third-party/nanosvg/nanosvg.cc
plugins/dali-swig/manual/cpp/event-thread-callback-wrap.cpp [changed mode: 0644->0755]

index d6128c5..983ac77 100644 (file)
@@ -29,6 +29,7 @@ namespace
 const char* const TEST_FILE( "test.mp4" );
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
+const char* const RENDERING_TYPE( "renderingTarget" );
 
 }
 
@@ -201,20 +202,21 @@ int UtcDaliVideoViewProperty4(void)
   left = right = 0.f;
 
   Property::Map map;
-  map.Insert( VOLUME_LEFT, 1.0f );
+  map.Insert( VOLUME_LEFT, 0.5f );
   map.Insert( VOLUME_RIGHT, 0.5f );
 
-  Property::Map map2;
   view.SetProperty( VideoView::Property::VOLUME, map );
-  Property::Value val4 = view.GetProperty( VideoView::Property::VOLUME );
-  DALI_TEST_CHECK( val4.Get( map2 ) );
+  Property::Value val = view.GetProperty( VideoView::Property::VOLUME );
+
+  Property::Map map2;
+  DALI_TEST_CHECK( val.Get( map2 ) );
 
-  Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
-  Property::Value* volumeRight = map.Find( VOLUME_RIGHT );
+  Property::Value* volumeLeft = map2.Find( VOLUME_LEFT );
+  Property::Value* volumeRight = map2.Find( VOLUME_RIGHT );
 
   DALI_TEST_CHECK( volumeLeft && volumeLeft->Get( left ) );
   DALI_TEST_CHECK( volumeRight && volumeRight->Get( right ) );
-  DALI_TEST_CHECK( left == 1.0f );
+  DALI_TEST_CHECK( left == 0.5f );
   DALI_TEST_CHECK( right == 0.5f );
 
   END_TEST;
@@ -275,3 +277,38 @@ int UtcDaliVideoViewMethodsForCoverage(void)
 
   END_TEST;
 }
+
+int UtcDaliVideoViewMethodsForRenderType(void)
+{
+  ToolkitTestApplication application;
+  VideoView videoView = VideoView::New();
+  DALI_TEST_CHECK( videoView );
+
+  Property::Map windowSurfaceTarget;
+  Property::Map nativeImageTarget;
+
+  windowSurfaceTarget.Insert( RENDERING_TYPE, "windowSurfaceTarget" );
+  nativeImageTarget.Insert( RENDERING_TYPE, "nativeImageTarget" );
+
+  Property::Map map;
+  Property::Value value;
+  videoView.SetProperty( VideoView::Property::VIDEO, windowSurfaceTarget );
+
+  value = videoView.GetProperty( VideoView::Property::VIDEO );
+  DALI_TEST_CHECK( value.Get( map ) );
+
+  Property::Value* type = map.Find( RENDERING_TYPE );
+  DALI_TEST_CHECK( type );
+  DALI_TEST_EQUALS( "windowSurfaceTarget", type->Get<std::string>(), TEST_LOCATION );
+
+  videoView.SetProperty( VideoView::Property::VIDEO, nativeImageTarget );
+
+  value = videoView.GetProperty( VideoView::Property::VIDEO );
+  DALI_TEST_CHECK( value.Get( map ) );
+  type = map.Find( RENDERING_TYPE );
+
+  DALI_TEST_CHECK( type );
+  DALI_TEST_EQUALS( "nativeImageTarget", type->Get<std::string>(), TEST_LOCATION );
+
+  END_TEST;
+}
index 2ec07ef..1fd4be5 100644 (file)
@@ -67,7 +67,7 @@ DALI_TYPE_REGISTRATION_END()
 
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
-const char* const RENDERING_TARGET( "RENDERING_TARGET" );
+const char* const RENDERING_TARGET( "renderingTarget" );
 const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
 const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
 
@@ -76,7 +76,7 @@ const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
 VideoView::VideoView()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
   mCurrentVideoPlayPosition( 0 ),
-  mSetRenderingTarget( false ),
+  mIsNativeImageTarget( true ),
   mIsPlay( false ),
   mIsPause( false )
 {
@@ -97,23 +97,31 @@ Toolkit::VideoView VideoView::New()
   return handle;
 }
 
+void VideoView::OnInitialize()
+{
+  Any source;
+  Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
+  mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
+
+  mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
+  mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+}
+
 void VideoView::SetUrl( const std::string& url )
 {
   if( mUrl != url || !mPropertyMap.Empty() )
   {
-    mPropertyMap.Clear();
-
     mUrl = url;
+    mPropertyMap.Clear();
   }
 
-  if( mSetRenderingTarget )
-  {
-    mVideoPlayer.SetUrl( mUrl );
-  }
-  else
+  if( mIsNativeImageTarget )
   {
-    SetNativeImageTarget();
+    Actor self( Self() );
+    Internal::InitializeVisual( self, mVisual, mNativeImage );
   }
+
+  mVideoPlayer.SetUrl( mUrl );
 }
 
 void VideoView::SetPropertyMap( Property::Map map )
@@ -505,8 +513,6 @@ void VideoView::SetWindowSurfaceTarget()
   Actor self = Self();
   int curPos = mVideoPlayer.GetPlayPosition();
 
-  mSetRenderingTarget = true;
-
   if( mVisual )
   {
     Toolkit::GetImplementation(mVisual).SetOffStage(self);
@@ -515,7 +521,8 @@ void VideoView::SetWindowSurfaceTarget()
 
   mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
   mVideoPlayer.SetUrl( mUrl );
-  mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+
+  mIsNativeImageTarget = false;
 
   if( mIsPlay )
   {
@@ -534,17 +541,15 @@ void VideoView::SetNativeImageTarget()
   Actor self( Self() );
   int curPos = mVideoPlayer.GetPlayPosition();
 
-  mSetRenderingTarget = true;
-
   Any source;
   Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
   mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
 
   mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
   mVideoPlayer.SetUrl( mUrl );
-  mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
 
   Internal::InitializeVisual( self, mVisual, mNativeImage );
+  mIsNativeImageTarget = true;
 
   if( mIsPlay )
   {
index 57641cd..a662802 100644 (file)
@@ -185,7 +185,6 @@ public:
    */
   void SetDepthIndex( int depthIndex );
 
-
   /**
    * @brief Performs actions as requested using the action name.
    * @SINCE_1_1.38
@@ -201,6 +200,11 @@ public:
 private: // From Control
 
   /**
+   * @copydoc Toolkit::Control::OnInitialize()
+   */
+  virtual void OnInitialize();
+
+  /**
    * @copydoc Toolkit::Control::OnStageConnect()
    */
   virtual void OnStageConnection( int depth );
@@ -246,7 +250,7 @@ private:
   Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
   std::string mUrl;
   int mCurrentVideoPlayPosition;
-  bool mSetRenderingTarget;
+  bool mIsNativeImageTarget;
   bool mIsPlay;
   bool mIsPause;
 };
index b38d23b..98596eb 100644 (file)
@@ -34,7 +34,7 @@
 namespace
 {
 
-const char* LANDSCAPE_QUALIFIER = "landscape";
+//const char* LANDSCAPE_QUALIFIER = "landscape";
 const char* PORTRAIT_QUALIFIER  = "portrait";
 const char* FONT_SIZE_QUALIFIER = "fontsize";
 
@@ -295,23 +295,16 @@ bool StyleManager::LoadJSON( Toolkit::Builder builder, const std::string& jsonFi
 static void CollectQualifiers( std::vector<std::string>& qualifiersOut )
 {
   // Append the relevant qualifier for orientation
-  int orientation = 0; // Get the orientation from the system
-  switch( orientation )
-  {
-    case 90:
-    case 270:
-    {
-      qualifiersOut.push_back( std::string( LANDSCAPE_QUALIFIER ) );
-      break;
-    }
-    case 180:
-    case 0: // fall through
-    default:
-    {
-      qualifiersOut.push_back( std::string( PORTRAIT_QUALIFIER ) );
-      break;
-    }
-  }
+  // int orientation = 0; // Get the orientation from the system
+  /*
+  //// To Do /////
+  Getting orientation from the system, and determine Qualifie LANDSCAPE or PORTRAIT
+  orientation  0, 180 : PORTRAIT_QUALIFIER (default)
+  orientation 90, 270 : LANDSCAPE_QUALIFIER
+  */
+
+  qualifiersOut.push_back( std::string( PORTRAIT_QUALIFIER ) );
+
 }
 
 /**
index 275f569..d483ef5 100644 (file)
@@ -521,8 +521,11 @@ void Visual::Base::AnimateProperty(
   Property::Map map;
   DoCreatePropertyMap( map );
   Property::Value* valuePtr = map.Find( Toolkit::DevelVisual::Property::TYPE );
-  int visualType;
-  valuePtr->Get(visualType);
+  int visualType = -1;
+  if( valuePtr )
+  {
+    valuePtr->Get( visualType );
+  }
 
   if( animator.propertyKey == Toolkit::DevelVisual::Property::MIX_COLOR ||
       animator.propertyKey == MIX_COLOR ||
@@ -540,7 +543,7 @@ void Visual::Base::AnimateProperty(
   }
   else if( mImpl->mRenderer )
   {
-    AnimateRendererProperty(transition, animator);
+    AnimateRendererProperty( transition, animator );
   }
 }
 
index 9643567..d3ffc40 100644 (file)
@@ -1035,7 +1035,12 @@ static unsigned int nsvg__parseColorRGB(const char* str)
 {
     int r = -1, g = -1, b = -1;
     char s1[32]="", s2[32]="";
-    sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b);
+
+    /**
+     * In the original file, the formatted data reading did not specify the string with width limitation.
+     * To prevent the possible overflow, we replace '%s' with '%32s' here.
+     */
+    sscanf(str + 4, "%d%32[%%, \t]%d%32[%%, \t]%d", &r, s1, &g, s2, &b);
     if (strchr(s1, '%')) {
         return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
     } else {
old mode 100644 (file)
new mode 100755 (executable)
index 736c697..ced564b
@@ -39,14 +39,17 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_EventThreadCallback(SWIG_CallbackM
       result = (Dali::EventThreadCallback *)new Dali::EventThreadCallback((Dali::CallbackBase *)Dali::MakeCallback(arg1));
     } catch (std::out_of_range& e) {
       {
+        delete result;
         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
       };
     } catch (std::exception& e) {
       {
+        delete result;
         SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
       };
     } catch (...) {
       {
+        delete result;
         SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
       };
     }