Merge "Size Relative feature: Implementation in dali-core plus UTC tests" into tizen
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 12 Feb 2015 10:14:55 +0000 (02:14 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 12 Feb 2015 10:14:56 +0000 (02:14 -0800)
automated-tests/src/dali/utc-Dali-PanGesture.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/public-api/dali-core-version.cpp
dali/public-api/events/pan-gesture.cpp
dali/public-api/events/pan-gesture.h
dali/public-api/object/ref-object.cpp
packaging/dali.spec

index 681da1d..814850f 100644 (file)
@@ -39,25 +39,30 @@ int UtcDaliPanGestureConstructor(void)
 {
   TestApplication application; // Reset all test adapter return codes
 
-  PanGesture gesture(Gesture::Started);
-  DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION);
+  PanGesture gesture;
+  DALI_TEST_EQUALS(Gesture::Clear, gesture.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION);
 
-  PanGesture gesture2(Gesture::Continuing);
-  DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION);
+  PanGesture gesture2(Gesture::Started);
+  DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION);
 
-  PanGesture gesture3(Gesture::Finished);
-  DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION);
+  PanGesture gesture3(Gesture::Continuing);
+  DALI_TEST_EQUALS(Gesture::Continuing, gesture3.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture3.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture3.type, TEST_LOCATION);
 
+  PanGesture gesture4(Gesture::Finished);
+  DALI_TEST_EQUALS(Gesture::Finished, gesture4.state, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, gesture4.numberOfTouches, TEST_LOCATION);
+  DALI_TEST_EQUALS(Gesture::Pan, gesture4.type, TEST_LOCATION);
+
   // Test copy constructor
-  gesture3.numberOfTouches = 3u;
+  gesture4.numberOfTouches = 3u;
 
-  PanGesture pan(gesture3);
+  PanGesture pan(gesture4);
   DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION);
   DALI_TEST_EQUALS(3u, pan.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION);
index 846a32c..aeb0282 100644 (file)
@@ -2156,14 +2156,14 @@ Actor::~Actor()
   delete mAnchorPoint;
 }
 
-void Actor::ConnectToStage( Stage& stage, int index )
+void Actor::ConnectToStage( int index )
 {
   // This container is used instead of walking the Actor hierachy.
   // It protects us when the Actor hierachy is modified during OnStageConnectionExternal callbacks.
   ActorContainer connectionList;
 
   // This stage is atomic i.e. not interrupted by user callbacks
-  RecursiveConnectToStage( stage, connectionList, index );
+  RecursiveConnectToStage( connectionList, index );
 
   // Notify applications about the newly connected actors.
   const ActorIter endIter = connectionList.end();
@@ -2174,7 +2174,7 @@ void Actor::ConnectToStage( Stage& stage, int index )
   }
 }
 
-void Actor::RecursiveConnectToStage( Stage& stage, ActorContainer& connectionList, int index )
+void Actor::RecursiveConnectToStage( ActorContainer& connectionList, int index )
 {
   DALI_ASSERT_ALWAYS( !OnStage() );
 
@@ -2195,7 +2195,7 @@ void Actor::RecursiveConnectToStage( Stage& stage, ActorContainer& connectionLis
     for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter )
     {
       Actor& actor = GetImplementation( *iter );
-      actor.RecursiveConnectToStage( stage, connectionList );
+      actor.RecursiveConnectToStage( connectionList );
     }
   }
 }
@@ -3450,10 +3450,8 @@ void Actor::SetParent(Actor* parent, int index)
     if ( Stage::IsInstalled() && // Don't emit signals or send messages during Core destruction
          parent->OnStage() )
     {
-      StagePtr stage = parent->mStage;
-
       // Instruct each actor to create a corresponding node in the scene graph
-      ConnectToStage(*stage, index);
+      ConnectToStage( index );
     }
   }
   else // parent being set to NULL
index 5b6fe64..da26675 100644 (file)
@@ -1107,16 +1107,15 @@ protected:
    * @param[in] stage The stage.
    * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
    */
-  void ConnectToStage(Stage& stage, int index = -1);
+  void ConnectToStage( int index = -1 );
 
   /**
    * Helper for ConnectToStage, to recursively connect a tree of actors.
    * This is atomic i.e. not interrupted by user callbacks.
-   * @param[in] stage The stage.
    * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
    * @param[out] connectionList On return, the list of connected actors which require notification.
    */
-  void RecursiveConnectToStage( Stage& stage, ActorContainer& connectionList, int index = -1 );
+  void RecursiveConnectToStage( ActorContainer& connectionList, int index = -1 );
 
   /**
    * Connect the Node associated with this Actor to the scene-graph.
index dfd74d2..388154c 100644 (file)
@@ -28,7 +28,7 @@ namespace Dali
 
 const unsigned int CORE_MAJOR_VERSION = 1;
 const unsigned int CORE_MINOR_VERSION = 0;
-const unsigned int CORE_MICRO_VERSION = 28;
+const unsigned int CORE_MICRO_VERSION = 29;
 const char * const CORE_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 3608d34..d5545a7 100644 (file)
 namespace Dali
 {
 
+PanGesture::PanGesture()
+: Gesture(Gesture::Pan, Gesture::Clear),
+  numberOfTouches(1)
+{
+}
+
 PanGesture::PanGesture(Gesture::State state)
 : Gesture(Gesture::Pan, state),
   numberOfTouches(1)
index 5be62b7..00b5baa 100644 (file)
@@ -46,6 +46,11 @@ struct DALI_IMPORT_API PanGesture: public Gesture
 
   /**
    * @brief Default Constructor.
+   */
+  PanGesture();
+
+  /**
+   * @brief Constructor.
    *
    * @param[in]  state  The state of the gesture
    */
index 7d0101b..ab296fe 100644 (file)
@@ -21,6 +21,9 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
 
+// EXTERNAL INCLUDES
+#include <stdint.h>
+
 namespace Dali
 {
 
@@ -52,14 +55,107 @@ RefObject& RefObject::operator=(const RefObject&)
 
 void RefObject::Reference()
 {
-  // gcc > 4.1 builtin atomic add and fetch (++mCount; return mCount)
-  __sync_add_and_fetch(&mCount, 1);
+  // The inline assembly below was tested on an ARMv8 64 bit platform on
+  // 2015-02-06 and found to run in 11.8 nanoseconds, whereas
+  // __sync_add_and_fetch( address, 1 ) required 18.8 nanoseconds.
+  // Including the assembly here produced one fewer assembly instruction than if
+  // it was wrapped in a function and inlined here by the compiler.
+#if defined __aarch64__
+
+  asm volatile(
+  "1:\tldxr  w1, %[address] \n\t"
+      "add   w1, w1, %[one] \n\t"
+      "stxr  w2,  w1, %[address] \n\t"
+      "cbnz  w2,  1b \n\t"
+      // Outputs:
+    : // Q = A memory address with no offset
+      // ( https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints )
+      [address] "+Q" (mCount)
+      // Inputs:
+    : [one] "Ir" (1)
+      // Clobbers: (explicitly clobber w1 register to hold the loaded value and
+      // register w2 to hold success/fail):
+    : "w1", "w2"
+  );
+
+  // 32 bit ARMv7 version of above:
+  // Better than the code emitted by GCC for __sync_add_and_fetch(), as that
+  // includes two dmb memory barrier instructions: one before and one after the
+  // loop.
+#elif defined __arm__
+
+  asm volatile(
+    "1:\tldrex r1, %[address] \n\t"
+        "add   r1, r1, %[one] \n\t"
+        "strex r2,  r1, %[address] \n\t"
+        "teq   r2,  %[zero] \n\t"
+        "bne   1b \n\t"
+        // Outputs:
+      : [address] "+Q" (mCount)
+        // Inputs:
+      : [zero] "Ir" (0),
+        [one]  "Ir" (1)
+        // Clobbers: (modified registers):
+      : "r1", "r2"
+    );
+
+#else
+
+  // gcc > 4.1 builtin atomic add and fetch:
+  __sync_add_and_fetch( &mCount, 1 );
+
+#endif
 }
 
 void RefObject::Unreference()
 {
+  // The output register:
+  int32_t newValue;
+
+#if defined __aarch64__
+
+  asm volatile(
+  "1:\ldxr   %w[newValue], %[address] \n\t"
+      "sub   %w[newValue], %w[newValue], %[one] \n\t"
+      "stxr  w2,  %w[newValue], %[address] \n\t"
+      "cbnz  w2,  1b \n\t"
+    // Outputs:
+  : [newValue] "=&r" (newValue),
+    // Q = A memory address with no offset
+    // ( https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints )
+    [address] "+Q" (mCount)
+    // Inputs:
+  : [one]  "Ir" (1)
+    // Clobbered: I.e., stuff that is modified.
+  : "w2"
+  );
+
+#elif defined __arm__
+
+  asm volatile(
+  "1:\tldrex %[newValue], %[address] \n\t"
+      "sub   %[newValue], %[newValue], %[one] \n\t"
+      "strex r2,  %[newValue], %[address] \n\t"
+      "teq   r2, %[zero] \n\t"
+      "bne   1b \n\t"
+    // Outputs:
+  : [newValue] "=&r" (newValue),
+    [address] "+Q" (mCount)
+    // Inputs:
+    : [zero] "Ir" (0),
+      [one]  "Ir" (1)
+    // Clobbered:
+  : "r2"
+  );
+
+#else
+
   // gcc > 4.1 builtin atomic subtract and fetch (--mCount; return mCount)
-  if (__sync_sub_and_fetch(&mCount, 1) == 0)
+  newValue = __sync_sub_and_fetch( &mCount, 1 );
+
+#endif
+
+  if( newValue == 0 )
   {
     delete this;
   }
index 765a0c9..89754b4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali
 Summary:    The OpenGLES Canvas Core Library
-Version:    1.0.28
+Version:    1.0.29
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0