[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-buffer-impl.h
index e8846c5..2f57eaf 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_PROPERTY_BUFFER_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/property-map.h> // Dali::Property::Map
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/render/renderers/render-property-buffer.h>
 
 namespace Dali
 {
 namespace Internal
 {
-namespace SceneGraph
-{
-class PropertyBuffer;
-}
 
 class PropertyBuffer;
 typedef IntrusivePtr<PropertyBuffer> PropertyBufferPtr;
@@ -42,151 +38,81 @@ typedef IntrusivePtr<PropertyBuffer> PropertyBufferPtr;
  * PropertyBuffer is an object that contains an array of structures of values that
  * can be accessed as properties.
  */
-class PropertyBuffer : public Object, public Connectable
+class PropertyBuffer : public BaseObject
 {
 public:
 
   /**
    * @copydoc PropertBuffer::New()
    */
-  static PropertyBufferPtr New();
-
-  /**
-   * @copydoc PropertBuffer::SetSize()
-   */
-  void SetSize( std::size_t size );
-
-  /**
-   * @copydoc PropertBuffer::GetSize()
-   */
-  std::size_t GetSize() const;
+  static PropertyBufferPtr New( Dali::Property::Map& format );
 
   /**
    * @copydoc PropertBuffer::SetData()
    */
-  void SetData( void* data );
+  void SetData( const void* data, uint32_t size );
 
   /**
-   * @copydoc PropertBuffer::GetPropertyIndex()
-   */
-  Dali::Property::Index GetPropertyIndex( const std::string name, std::size_t index );
-
-  /**
-   * @brief Get the propertyBuffer scene object
-   *
-   * @return the propertyBuffer scene object
+   * @copydoc PropertBuffer::GetSize()
    */
-  const SceneGraph::PropertyBuffer* GetPropertyBufferSceneObject() const;
+  uint32_t GetSize() const;
 
 public: // Default property extensions from Object
 
   /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
-   */
-  virtual unsigned int GetDefaultPropertyCount() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
-   */
-  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
-   */
-  virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
-   */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
-   */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
-   */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
-   */
-  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
-   */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::SetDefaultProperty()
-   */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
-  /**
-   * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
-   */
-  virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultProperty()
-   */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyOwner()
-   */
-  virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObject()
-   */
-  virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
-   */
-  virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
-   */
-  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+   * @brief Get the render thread side of the PropertyBuffer
+   *
+   * @return The render thread side of this PropertyBuffer
    */
-  virtual int GetPropertyComponentIndex( Property::Index index ) const;
+  const Render::PropertyBuffer* GetRenderObject() const;
 
-public: // Functions from Connectable
+protected:
   /**
-   * @copydoc Dali::Internal::Connectable::OnStage()
+   * @brief Destructor
    */
-  virtual bool OnStage() const;
+  ~PropertyBuffer();
 
+private: // implementation
   /**
-   * @copydoc Dali::Internal::Connectable::Connect()
+   * @brief Default constructor
    */
-  virtual void Connect();
+  PropertyBuffer();
 
   /**
-   * @copydoc Dali::Internal::Connectable::Disconnect()
+   * Second stage initialization
    */
-  virtual void Disconnect();
-
-private: // implementation
-  PropertyBuffer();
+  void Initialize( Dali::Property::Map& format );
 
 private: // unimplemented methods
   PropertyBuffer( const PropertyBuffer& );
   PropertyBuffer& operator=( const PropertyBuffer& );
 
 private: // data
-  SceneGraph::PropertyBuffer* mSceneObject;
-  bool mOnStage;
+  EventThreadServices& mEventThreadServices;    ///<Used to send messages to the render thread via update thread
+  Render::PropertyBuffer* mRenderObject;        ///<Render side object
+  uint32_t mBufferFormatSize;
+  uint32_t mSize; ///< Number of elements in the buffer
+};
+
+/**
+ * Get the implementation type from a Property::Type
+ */
+template<Property::Type type> struct PropertyImplementationType
+{
+  // typedef ... Type; not defined, only support types declared bellow
 };
+template<> struct PropertyImplementationType< Property::BOOLEAN > { typedef bool Type; };
+template<> struct PropertyImplementationType< Property::FLOAT > { typedef float Type; };
+template<> struct PropertyImplementationType< Property::INTEGER > { typedef int Type; };
+template<> struct PropertyImplementationType< Property::VECTOR2 > { typedef Vector2 Type; };
+template<> struct PropertyImplementationType< Property::VECTOR3 > { typedef Vector3 Type; };
+template<> struct PropertyImplementationType< Property::VECTOR4 > { typedef Vector4 Type; };
+template<> struct PropertyImplementationType< Property::MATRIX3 > { typedef Matrix3 Type; };
+template<> struct PropertyImplementationType< Property::MATRIX > { typedef Matrix Type; };
+template<> struct PropertyImplementationType< Property::RECTANGLE > { typedef Rect<int> Type; };
+template<> struct PropertyImplementationType< Property::ROTATION > { typedef Quaternion Type; };
+
+uint32_t GetPropertyImplementationSize( Property::Type& propertyType );
 
 } // namespace Internal