X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Ftransform-manager-property.h;h=6e8821d9ec73b9e9a0f97d9be92add2b30d24c0e;hb=857999ccc4786403ee174a361a5d3d7e250435b7;hp=fc1583b01142d01f5b986509290db32d52315102;hpb=80a17733af457e9c4609b2b86f6fa0ec90d53151;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/manager/transform-manager-property.h b/dali/internal/update/manager/transform-manager-property.h index fc1583b..6e8821d 100644 --- a/dali/internal/update/manager/transform-manager-property.h +++ b/dali/internal/update/manager/transform-manager-property.h @@ -2,7 +2,7 @@ #define TRANSFORM_MANAGER_PROPERTY_H_ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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,8 +18,8 @@ * */ -#include #include +#include namespace Dali { @@ -27,17 +27,13 @@ namespace Internal { namespace SceneGraph { - -template +template struct TransformManagerPropertyHandler : public AnimatablePropertyBase { /** * Constructor */ - TransformManagerPropertyHandler() - :mTxManager(nullptr), - mId( INVALID_TRANSFORM_ID ) - {} + TransformManagerPropertyHandler() = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -47,23 +43,32 @@ struct TransformManagerPropertyHandler : public AnimatablePropertyBase /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - virtual T& Get( BufferIndex bufferIndex ) = 0; + virtual T& Get(BufferIndex bufferIndex) = 0; /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - virtual const T& Get( BufferIndex bufferIndex ) const = 0; + virtual const T& Get(BufferIndex bufferIndex) const = 0; /** * @copydoc Dali::PropertyInput::GetVector3() */ - const Vector3& GetVector3( BufferIndex bufferIndex ) const override{ return Vector3::ZERO; } + const Vector3& GetVector3(BufferIndex bufferIndex) const override + { + return Vector3::ZERO; + } /** * Retrieve a component of property * @param[in] component The component of the property */ - virtual const float& GetFloatComponent(uint32_t component)=0; + virtual const float& GetFloatComponent(uint32_t component) const + { + DALI_ASSERT_DEBUG(0 && "Invalid call"); + + static const float value = 0.0f; + return value; + } /** * Set the property value. This will only persist for the current frame; the property @@ -78,7 +83,9 @@ struct TransformManagerPropertyHandler : public AnimatablePropertyBase * @param[in] value The new value of the component * @param[in] component The component of the property */ - virtual void SetFloatComponent( float value, uint32_t component){} + virtual void SetFloatComponent(float value, uint32_t component) + { + } /** * @copydoc Dali::AnimatableProperty::Bake() @@ -90,22 +97,30 @@ struct TransformManagerPropertyHandler : public AnimatablePropertyBase * @param[in] value The new value of the component * @param[in] component The component of the property */ - virtual void BakeFloatComponent( float value, uint32_t component){} + virtual void BakeFloatComponent(float value, uint32_t component) + { + } /** * @copydoc Dali::AnimatableProperty::BakeX() */ - virtual void BakeX(BufferIndex bufferIndex, float value){} + virtual void BakeX(BufferIndex bufferIndex, float value) + { + } /** * @copydoc Dali::AnimatableProperty::BakeY() */ - virtual void BakeY(BufferIndex bufferIndex, float value){} + virtual void BakeY(BufferIndex bufferIndex, float value) + { + } /** * @copydoc Dali::AnimatableProperty::BakeZ() */ - virtual void BakeZ(BufferIndex bufferIndex, float value){} + virtual void BakeZ(BufferIndex bufferIndex, float value) + { + } /** * @copydoc Dali::AnimatableProperty::BakeRelative() @@ -120,22 +135,27 @@ struct TransformManagerPropertyHandler : public AnimatablePropertyBase /** * @copydoc Dali::AnimatableProperty::ResetToBaseValue() */ - void ResetToBaseValue(BufferIndex updateBufferIndex) override{} + void ResetToBaseValue(BufferIndex updateBufferIndex) override + { + } /** * @copydoc Dali::AnimatableProperty::IsClean() */ - bool IsClean() const override{ return false; } + bool IsClean() const override + { + return false; + } /** * Initializes the property * @param[in] transformManager Pointer to the transform manager * @param[in] Id of the transformation the property is associated with */ - void Initialize( TransformManager* transformManager, TransformId id ) + void Initialize(TransformManagerData* data) { - mTxManager = transformManager; - mId = id; + DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr); + mTxManagerData = data; } /** @@ -146,149 +166,138 @@ struct TransformManagerPropertyHandler : public AnimatablePropertyBase return true; } - TransformManager* mTxManager; - TransformId mId; + TransformManagerData* mTxManagerData{nullptr}; }; -struct TransformManagerPropertyVector3 : public TransformManagerPropertyHandler +template +struct TransformManagerPropertyVector3 final : public TransformManagerPropertyHandler { - - TransformManagerPropertyVector3(TransformManagerProperty property) - :TransformManagerPropertyHandler(), - mProperty( property ) - {} + TransformManagerPropertyVector3() = default; Dali::Property::Type GetType() const override { return Dali::PropertyTypes::Get(); } - Vector3& Get( BufferIndex bufferIndex ) override + Vector3& Get(BufferIndex bufferIndex) override { - return mTxManager->GetVector3PropertyValue( mId, mProperty ); + return mTxManagerData->Manager()->GetVector3PropertyValue(mTxManagerData->Id(), PropertyT); } - const Vector3& Get( BufferIndex bufferIndex ) const override + const Vector3& Get(BufferIndex bufferIndex) const override { - return mTxManager->GetVector3PropertyValue( mId, mProperty ); + return mTxManagerData-> + Manager()-> + GetVector3PropertyValue( + mTxManagerData->Id(), + PropertyT); } - const Vector3& GetVector3( BufferIndex bufferIndex ) const override + const Vector3& GetVector3(BufferIndex bufferIndex) const override { return Get(bufferIndex); } - const float& GetFloatComponent( uint32_t component ) override + const float& GetFloatComponent(uint32_t component) const override { - return mTxManager->GetVector3PropertyComponentValue( mId, mProperty, component ); + return mTxManagerData->Manager()->GetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, component); } void Set(BufferIndex bufferIndex, const Vector3& value) override { - mTxManager->SetVector3PropertyValue( mId, mProperty, value ); + mTxManagerData->Manager()->SetVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } void SetComponent(BufferIndex bufferIndex, float value, uint32_t component) { - mTxManager->SetVector3PropertyComponentValue( mId, mProperty, value, component); + mTxManagerData->Manager()->SetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component); } void BakeComponent(BufferIndex bufferIndex, float value, uint32_t component) { - mTxManager->BakeVector3PropertyComponentValue( mId, mProperty, value, component); + mTxManagerData->Manager()->BakeVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component); } void Bake(BufferIndex bufferIndex, const Vector3& value) override { - mTxManager->BakeVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } void BakeX(BufferIndex bufferIndex, float value) override { - mTxManager->BakeXVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeXVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } void BakeY(BufferIndex bufferIndex, float value) override { - mTxManager->BakeYVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeYVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } void BakeZ(BufferIndex bufferIndex, float value) override { - mTxManager->BakeZVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeZVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } - void SetFloatComponent( float value, uint32_t component) override + void SetFloatComponent(float value, uint32_t component) override { - mTxManager->SetVector3PropertyComponentValue( mId, mProperty, value, component); + mTxManagerData->Manager()->SetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component); } - void BakeFloatComponent( float value, uint32_t component ) override + void BakeFloatComponent(float value, uint32_t component) override { - mTxManager->BakeVector3PropertyComponentValue( mId, mProperty, value, component); + mTxManagerData->Manager()->BakeVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component); } void BakeRelative(BufferIndex bufferIndex, const Vector3& value) override { - mTxManager->BakeRelativeVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeRelativeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } void BakeRelativeMultiply(BufferIndex bufferIndex, const Vector3& value) override { - mTxManager->BakeMultiplyVector3PropertyValue(mId, mProperty, value ); + mTxManagerData->Manager()->BakeMultiplyVector3PropertyValue(mTxManagerData->Id(), PropertyT, value); } - - TransformManagerProperty mProperty; }; -class TransformManagerPropertyQuaternion : public TransformManagerPropertyHandler +class TransformManagerPropertyQuaternion final : public TransformManagerPropertyHandler { public: - - TransformManagerPropertyQuaternion() - :TransformManagerPropertyHandler() - {} + TransformManagerPropertyQuaternion() = default; Dali::Property::Type GetType() const override { return Dali::PropertyTypes::Get(); } - Quaternion& Get( BufferIndex bufferIndex ) override + Quaternion& Get(BufferIndex bufferIndex) override { - return mTxManager->GetQuaternionPropertyValue( mId ); + return mTxManagerData->Manager()->GetQuaternionPropertyValue(mTxManagerData->Id()); } - const Quaternion& Get( BufferIndex bufferIndex ) const override + const Quaternion& Get(BufferIndex bufferIndex) const override { - return mTxManager->GetQuaternionPropertyValue( mId ); - } - - const float& GetFloatComponent( uint32_t component) override - { - return mTxManager->GetQuaternionPropertyValue( mId ).mVector[component]; + return mTxManagerData->Manager()->GetQuaternionPropertyValue(mTxManagerData->Id()); } void Set(BufferIndex bufferIndex, const Quaternion& value) override { - return mTxManager->SetQuaternionPropertyValue( mId, value ); + return mTxManagerData->Manager()->SetQuaternionPropertyValue(mTxManagerData->Id(), value); } void Bake(BufferIndex bufferIndex, const Quaternion& value) override { - return mTxManager->BakeQuaternionPropertyValue( mId, value ); + return mTxManagerData->Manager()->BakeQuaternionPropertyValue(mTxManagerData->Id(), value); } void BakeRelative(BufferIndex bufferIndex, const Quaternion& value) override { - return mTxManager->BakeRelativeQuaternionPropertyValue( mId, value ); + return mTxManagerData->Manager()->BakeRelativeQuaternionPropertyValue(mTxManagerData->Id(), value); } - const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override + const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override { return Get(bufferIndex); } - }; /** @@ -297,23 +306,19 @@ public: class TransformManagerVector3Input : public PropertyInputImpl { public: - /** * Create an TransformManagerVector3Input */ - TransformManagerVector3Input( TransformManagerProperty property, const Vector3& initialValue ) - :mTxManager(nullptr), - mId(INVALID_TRANSFORM_ID), - mProperty(property), - mValue(initialValue) - {} + TransformManagerVector3Input(TransformManagerProperty property, const Vector3& initialValue) + : mProperty(property), + mValue(initialValue) + { + } /** * Virtual destructor. */ - ~TransformManagerVector3Input() override - { - } + ~TransformManagerVector3Input() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -354,17 +359,17 @@ public: */ void ComputeTransformComponent() const { - if( mTxManager ) + if(mTxManagerData) { - const Matrix& worldMatrix = mTxManager->GetWorldMatrix(mId); + const Matrix& worldMatrix = mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id()); - if( mProperty == TRANSFORM_PROPERTY_WORLD_POSITION ) + if(mProperty == TRANSFORM_PROPERTY_WORLD_POSITION) { mValue = worldMatrix.GetTranslation3(); } - else if( mProperty == TRANSFORM_PROPERTY_WORLD_SCALE ) + else if(mProperty == TRANSFORM_PROPERTY_WORLD_SCALE) { - Vector3 position; + Vector3 position; Quaternion orientation; worldMatrix.GetTransformComponents(position, orientation, mValue); } @@ -374,7 +379,7 @@ public: /** * @copydoc Dali::PropertyInput::GetVector3() */ - const Vector3& GetVector3( BufferIndex bufferIndex ) const override + const Vector3& GetVector3(BufferIndex bufferIndex) const override { ComputeTransformComponent(); return mValue; @@ -383,7 +388,7 @@ public: /** * @copydoc Dali::PropertyInput::GetConstraintInputVector3() */ - const Vector3& GetConstraintInputVector3( BufferIndex bufferIndex ) const override + const Vector3& GetConstraintInputVector3(BufferIndex bufferIndex) const override { ComputeTransformComponent(); return mValue; @@ -392,7 +397,7 @@ public: /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - Vector3& Get( BufferIndex bufferIndex ) + Vector3& Get(BufferIndex bufferIndex) { ComputeTransformComponent(); return mValue; @@ -401,7 +406,7 @@ public: /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - const Vector3& Get( BufferIndex bufferIndex ) const + const Vector3& Get(BufferIndex bufferIndex) const { ComputeTransformComponent(); return mValue; @@ -412,7 +417,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Vector3& operator[]( BufferIndex bufferIndex ) const + const Vector3& operator[](BufferIndex bufferIndex) const { ComputeTransformComponent(); return mValue; @@ -423,10 +428,10 @@ public: * @param[in] transformManager Pointer to the transform manager * @param[in] Id of the transformation the property is associated with */ - void Initialize( TransformManager* transformManager, TransformId id ) + void Initialize(TransformManagerData* data) { - mTxManager = transformManager; - mId = id; + DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr); + mTxManagerData = data; } /** @@ -438,7 +443,6 @@ public: } private: - // Undefined TransformManagerVector3Input(const TransformManagerVector3Input& property); @@ -446,36 +450,21 @@ private: TransformManagerVector3Input& operator=(const TransformManagerVector3Input& rhs); public: - - TransformManager* mTxManager; - TransformId mId; + TransformManagerData* mTxManagerData{nullptr}; TransformManagerProperty mProperty; - mutable Vector3 mValue; + mutable Vector3 mValue; }; /** * A Quaternion property used as input. */ -class TransformManagerQuaternionInput : public PropertyInputImpl +class TransformManagerQuaternionInput final : public PropertyInputImpl { public: - /** * Constructor */ - TransformManagerQuaternionInput() - :mTxManager(nullptr), - mId(INVALID_TRANSFORM_ID), - mValue(1.0f,0.0f,0.0f,0.0f) - { - } - - /** - * Virtual destructor. - */ - ~TransformManagerQuaternionInput() override - { - } + TransformManagerQuaternionInput() = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -516,10 +505,10 @@ public: */ void ComputeTransformComponent() const { - if( mTxManager ) + if(mTxManagerData) { - const Matrix& worldMatrix = mTxManager->GetWorldMatrix(mId); - Vector3 position, scale; + const Matrix& worldMatrix = mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id()); + Vector3 position, scale; worldMatrix.GetTransformComponents(position, mValue, scale); } } @@ -527,7 +516,7 @@ public: /** * @copydoc Dali::PropertyInput::GetQuaternion() */ - const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override + const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override { ComputeTransformComponent(); return mValue; @@ -536,7 +525,7 @@ public: /** * @copydoc Dali::PropertyInput::GetConstraintInputQuaternion() */ - const Quaternion& GetConstraintInputQuaternion( BufferIndex bufferIndex ) const override + const Quaternion& GetConstraintInputQuaternion(BufferIndex bufferIndex) const override { ComputeTransformComponent(); return mValue; @@ -545,7 +534,7 @@ public: /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - Quaternion& Get( BufferIndex bufferIndex ) + Quaternion& Get(BufferIndex bufferIndex) { ComputeTransformComponent(); return mValue; @@ -554,7 +543,7 @@ public: /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - const Quaternion& Get( BufferIndex bufferIndex ) const + const Quaternion& Get(BufferIndex bufferIndex) const { ComputeTransformComponent(); return mValue; @@ -565,7 +554,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Quaternion& operator[]( BufferIndex bufferIndex) const + const Quaternion& operator[](BufferIndex bufferIndex) const { ComputeTransformComponent(); return mValue; @@ -576,10 +565,10 @@ public: * @param[in] transformManager Pointer to the transform manager * @param[in] Id of the transformation the property is associated with */ - void Initialize( TransformManager* transformManager, TransformId id ) + void Initialize(TransformManagerData* data) { - mTxManager = transformManager; - mId = id; + DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr); + mTxManagerData = data; } /** @@ -591,7 +580,6 @@ public: } private: - // Undefined TransformManagerQuaternionInput(const TransformManagerQuaternionInput& property); @@ -599,34 +587,20 @@ private: TransformManagerQuaternionInput& operator=(const TransformManagerQuaternionInput& rhs); public: - - TransformManager* mTxManager; - TransformId mId; - mutable Quaternion mValue; + TransformManagerData* mTxManagerData{nullptr}; + mutable Quaternion mValue; }; /** * A Matrix property used as input. */ -class TransformManagerMatrixInput : public PropertyInputImpl +class TransformManagerMatrixInput final : public PropertyInputImpl { public: - /** * Constructor */ - TransformManagerMatrixInput() - :mTxManager(nullptr), - mId(INVALID_TRANSFORM_ID) - { - } - - /** - * Virtual destructor. - */ - ~TransformManagerMatrixInput() override - { - } + TransformManagerMatrixInput() = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -664,11 +638,11 @@ public: /** * @copydoc Dali::PropertyInput::GetMatrix() */ - const Matrix& GetMatrix( BufferIndex bufferIndex ) const override + const Matrix& GetMatrix(BufferIndex bufferIndex) const override { - if( mTxManager ) + if(mTxManagerData) { - return mTxManager->GetWorldMatrix(mId); + return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id()); } return Matrix::IDENTITY; @@ -677,11 +651,11 @@ public: /** * @copydoc Dali::PropertyInput::GetConstraintInputMatrix() */ - const Matrix& GetConstraintInputMatrix( BufferIndex bufferIndex ) const override + const Matrix& GetConstraintInputMatrix(BufferIndex bufferIndex) const override { - if( mTxManager ) + if(mTxManagerData) { - return mTxManager->GetWorldMatrix(mId); + return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id()); } return Matrix::IDENTITY; @@ -690,18 +664,18 @@ public: /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - Matrix& Get( BufferIndex bufferIndex ) + Matrix& Get(BufferIndex bufferIndex) { - DALI_ASSERT_ALWAYS( mTxManager != nullptr ); - return mTxManager->GetWorldMatrix(mId); + DALI_ASSERT_ALWAYS(mTxManagerData != nullptr); + return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id()); } /** * @copydoc Dali::SceneGraph::PropertyInterface::Get() */ - const Matrix& Get( BufferIndex bufferIndex ) const + const Matrix& Get(BufferIndex bufferIndex) const { - return GetMatrix( bufferIndex ); + return GetMatrix(bufferIndex); } /** @@ -709,15 +683,15 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Matrix& operator[]( BufferIndex bufferIndex ) const + const Matrix& operator[](BufferIndex bufferIndex) const { - return GetMatrix( bufferIndex ); + return GetMatrix(bufferIndex); } - void Initialize( TransformManager* transformManager, TransformId id ) + void Initialize(TransformManagerData* data) { - mTxManager = transformManager; - mId = id; + DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr); + mTxManagerData = data; } /** @@ -729,7 +703,6 @@ public: } private: - // Undefined TransformManagerMatrixInput(const TransformManagerMatrixInput& property); @@ -737,12 +710,9 @@ private: TransformManagerMatrixInput& operator=(const TransformManagerMatrixInput& rhs); public: - - TransformManager* mTxManager; - TransformId mId; + TransformManagerData* mTxManagerData{nullptr}; }; - } //namespace SceneGraph } //namespace Internal } //namespace Dali