Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / update / common / inherited-property.h
index a3f4bd7..eaea49a 100644 (file)
@@ -1,21 +1,22 @@
 #ifndef __DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H__
 #define __DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2018 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.
+ * 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.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/common/property-input-impl.h>
@@ -26,6 +27,7 @@
 #include <dali/public-api/object/property.h>
 #include <dali/public-api/object/property-input.h>
 #include <dali/public-api/object/property-types.h>
+#include <dali/public-api/math/math-utils.h> // Clamp
 
 namespace Dali
 {
@@ -36,32 +38,37 @@ namespace Internal
 namespace SceneGraph
 {
 
-template <class T>
-class InheritedProperty;
-
 /**
  * An inherited Vector3 property.
  */
-template <>
-class InheritedProperty<Vector3> : public PropertyInputImpl
+class InheritedVector3 : public PropertyInputImpl
 {
 public:
 
   /**
-   * Create an inherited property.
+   * Create an inherited Vector3.
+   */
+  InheritedVector3()
+  : mValue(),
+    mInheritedFlag( false ),
+    mReinheritedFlag( true )
+  {
+  }
+
+  /**
+   * Create an inherited Vector3.
    * @param [in] initialValue The initial value of the property.
    */
-  InheritedProperty( const Vector3& initialValue )
+  InheritedVector3( const Vector3& initialValue )
   : mValue( initialValue ),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
   }
-
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedProperty()
+  virtual ~InheritedVector3()
   {
   }
 
@@ -152,7 +159,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Vector3& Get(size_t bufferIndex)
+  Vector3& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -160,7 +167,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Vector3& Get(size_t bufferIndex) const
+  const Vector3& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -170,7 +177,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Vector3& operator[](size_t bufferIndex) const
+  const Vector3& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -178,10 +185,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty(const InheritedProperty& property);
+  InheritedVector3(const InheritedVector3& property);
 
   // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedVector3& operator=(const InheritedVector3& rhs);
 
 private:
 
@@ -323,7 +330,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Vector4& Get(size_t bufferIndex)
+  Vector4& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -331,7 +338,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Vector4& Get(size_t bufferIndex) const
+  const Vector4& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -341,7 +348,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Vector4& operator[](size_t bufferIndex) const
+  const Vector4& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -359,23 +366,20 @@ private:
 
   bool mInheritedFlag   :1; ///< Flag whether the value has ever been inherited
   bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
-
 };
 
 /**
  * An inherited Quaternion property.
  */
-template <>
-class InheritedProperty<Quaternion> : public PropertyInputImpl
+class InheritedQuaternion : public PropertyInputImpl
 {
 public:
 
   /**
    * Create an inherited property.
-   * @param [in] initialValue The initial value of the property.
    */
-  InheritedProperty( const Quaternion& initialValue )
-  : mValue( initialValue ),
+  InheritedQuaternion()
+  : mValue(),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
@@ -384,7 +388,7 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedProperty()
+  virtual ~InheritedQuaternion()
   {
   }
 
@@ -475,7 +479,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Quaternion& Get(size_t bufferIndex)
+  Quaternion& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -483,7 +487,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Quaternion& Get(size_t bufferIndex) const
+  const Quaternion& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -493,7 +497,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Quaternion& operator[](size_t bufferIndex) const
+  const Quaternion& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -501,13 +505,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty();
-
-  // Undefined
-  InheritedProperty(const InheritedProperty& property);
+  InheritedQuaternion(const InheritedQuaternion& property);
 
   // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedQuaternion& operator=(const InheritedQuaternion& rhs);
 
 private:
 
@@ -520,17 +521,15 @@ private:
 /**
  * An inherited Matrix property.
  */
-template <>
-class InheritedProperty<Matrix> : public PropertyInputImpl
+class InheritedMatrix : public PropertyInputImpl
 {
 public:
 
   /**
    * Create an inherited property.
-   * @param [in] initialValue The initial value of the property.
    */
-  InheritedProperty( const Matrix& initialValue )
-  : mValue( initialValue ),
+  InheritedMatrix()
+  : mValue(),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
@@ -539,7 +538,7 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedProperty()
+  virtual ~InheritedMatrix()
   {
   }
 
@@ -612,24 +611,6 @@ public:
   }
 
   /**
-   * @copydoc Dali::PropertyInput::GetQuaternion()
-   */
-  virtual const Quaternion& GetQuaternion() const
-  {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    return DUMMY_QUATERNION_VALUE;
-  }
-
-  /**
-   * @copydoc Dali::PropertyInput::GetQuaternion()
-   */
-  virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
-  {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    return DUMMY_QUATERNION_VALUE;
-  }
-
-  /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
    * @param[in] bufferIndex The buffer to write.
@@ -648,7 +629,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Matrix& Get(size_t bufferIndex)
+  Matrix& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -656,7 +637,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Matrix& Get(size_t bufferIndex) const
+  const Matrix& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -666,12 +647,12 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Matrix& operator[](size_t bufferIndex) const
+  const Matrix& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
 
-  void SetDirty(size_t bufferIndex)
+  void SetDirty( BufferIndex bufferIndex )
   {
     mReinheritedFlag = true;
 
@@ -682,13 +663,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty();
-
-  // Undefined
-  InheritedProperty(const InheritedProperty& property);
+  InheritedMatrix(const InheritedMatrix& property);
 
   // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedMatrix& operator=(const InheritedMatrix& rhs);
 
 private: