X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fcommon%2Fproperty-owner-messages.h;h=8668e4ead8257ea791df4152fda18944619ae016;hb=15e293571ecbf62a7cd7dfc30fb0ce4edc5bce44;hp=5f672f900df259cfa36542119ffd6b36af6c10f3;hpb=7dcb0a38005dd8c6d71e466c1ea0ec4d7d57239f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/common/property-owner-messages.h b/dali/internal/update/common/property-owner-messages.h old mode 100644 new mode 100755 index 5f672f9..8668e4e --- a/dali/internal/update/common/property-owner-messages.h +++ b/dali/internal/update/common/property-owner-messages.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__ +#ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H +#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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,44 +18,236 @@ * */ +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES +#include +#include #include -#include +#include namespace Dali { - namespace Internal { - namespace SceneGraph { +class UniformMap; +class PropertyOwner; + +// Property Messages for PropertyOwner + +/** + * A base class for property owner property messages. + * (For future optimization - see NodeMessageBase & Node.SetActive()) + */ +class PropertyOwnerMessageBase : public MessageBase +{ +public: + + /** + * Create a message. + */ + PropertyOwnerMessageBase(); + + /** + * Virtual destructor + */ + virtual ~PropertyOwnerMessageBase(); + +private: + + // Undefined + PropertyOwnerMessageBase(const PropertyOwnerMessageBase&); + PropertyOwnerMessageBase& operator=(const PropertyOwnerMessageBase& rhs); +}; + +/** + * Templated message which bakes a property. + */ +template< typename P > +class AnimatablePropertyMessage : public PropertyOwnerMessageBase +{ +public: + + typedef void(AnimatableProperty

::*MemberFunction)( BufferIndex, typename ParameterType< P >::PassingType ); + + /** + * Create a message. + * @note The scene object is expected to be const in the thread which sends this message. + * However it can be modified when Process() is called in a different thread. + * @param[in] eventThreadServices The object used to send messages to the scene graph + * @param[in] sceneObject The property owner scene object + * @param[in] property The property to bake. + * @param[in] member The member function of the object. + * @param[in] value The new value of the property. + */ + static void Send( EventThreadServices& eventThreadServices, + const PropertyOwner* sceneObject, + const AnimatableProperty

* property, + MemberFunction member, + typename ParameterType< P >::PassingType value ) + { + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyMessage ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) AnimatablePropertyMessage( sceneObject, property, member, value ); + } + + /** + * Virtual destructor + */ + virtual ~AnimatablePropertyMessage() + { + } + + /** + * @copydoc MessageBase::Process + */ + virtual void Process( BufferIndex updateBufferIndex ) + { + mSceneObject->SetPropertyDirty( true ); + (mProperty->*mMemberFunction)( updateBufferIndex, mParam ); + } + +private: + + /** + * Create a message. + * @note The property owner is expected to be const in the thread which sends this message. + * However it can be modified when Process() is called in a different thread. + * @param[in] sceneObject the property owner scene object + * @param[in] property The property to bake. + * @param[in] member The member function of the object. + * @param[in] value The new value of the property. + */ + AnimatablePropertyMessage( const PropertyOwner* sceneObject, + const AnimatableProperty

* property, + MemberFunction member, + typename ParameterType< P >::PassingType value ) + : PropertyOwnerMessageBase(), + mSceneObject( const_cast< PropertyOwner* >( sceneObject ) ), + mProperty( const_cast< AnimatableProperty

* >( property ) ), + mMemberFunction( member ), + mParam( value ) + { + } + +private: + + PropertyOwner* mSceneObject; + AnimatableProperty

* mProperty; + MemberFunction mMemberFunction; + typename ParameterType< P >::HolderType mParam; +}; + +/** + * Templated message which bakes a property. + */ +template< typename P > +class AnimatablePropertyComponentMessage : public PropertyOwnerMessageBase +{ +public: + + typedef void(AnimatableProperty

::*MemberFunction)( BufferIndex, float ); + + /** + * Send a message. + * @note The scene object is expected to be const in the thread which sends this message. + * However it can be modified when Process() is called in a different thread. + * @param[in] eventThreadServices The service object used for sending messages to the scene graph + * @param[in] sceneObject The property owner scene object + * @param[in] property The property to bake. + * @param[in] member The member function of the object. + * @param[in] value The new value of the X,Y,Z or W component. + */ + static void Send( EventThreadServices& eventThreadServices, + const PropertyOwner* sceneObject, + const AnimatableProperty

* property, + MemberFunction member, + float value ) + { + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyComponentMessage ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) AnimatablePropertyComponentMessage( sceneObject, property, member, value ); + } + + /** + * Virtual destructor + */ + virtual ~AnimatablePropertyComponentMessage() + { + } + + /** + * @copydoc MessageBase::Process + */ + virtual void Process( BufferIndex updateBufferIndex ) + { + mSceneObject->SetPropertyDirty( true ); + (mProperty->*mMemberFunction)( updateBufferIndex, mParam ); + } + +private: + + /** + * Create a message. + * @note The scene object is expected to be const in the thread which sends this message. + * However it can be modified when Process() is called in a different thread. + * @param[in] sceneObject The property owner scene object + * @param[in] property The property to bake. + * @param[in] member The member function of the object. + * @param[in] value The new value of the X,Y,Z or W component. + */ + AnimatablePropertyComponentMessage( const PropertyOwner* sceneObject, + const AnimatableProperty

* property, + MemberFunction member, + float value ) + : PropertyOwnerMessageBase(), + mSceneObject( const_cast< PropertyOwner* >( sceneObject ) ), + mProperty( const_cast< AnimatableProperty

* >( property ) ), + mMemberFunction( member ), + mParam( value ) + { + } + +private: + PropertyOwner* mSceneObject; + AnimatableProperty

* mProperty; + MemberFunction mMemberFunction; + float mParam; +}; + // Messages for PropertyOwner -inline void InstallCustomPropertyMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, PropertyBase& property ) +inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer& property ) { - typedef MessageValue1< PropertyOwner, PropertyBase* > LocalType; + typedef MessageValue1< PropertyOwner, OwnerPointer > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, &property ); + new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property ); } -inline void ApplyConstraintMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, ConstraintBase& constraint ) +inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer& constraint ) { typedef MessageValue1< PropertyOwner, OwnerPointer > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, &constraint ); + new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, constraint ); } -inline void RemoveConstraintMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, const ConstraintBase& constConstraint ) +inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint ) { // The update-thread can modify this object. ConstraintBase& constraint = const_cast< ConstraintBase& >( constConstraint ); @@ -63,16 +255,37 @@ inline void RemoveConstraintMessage( EventToUpdate& eventToUpdate, const Propert typedef MessageValue1< PropertyOwner, ConstraintBase* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &owner, &PropertyOwner::RemoveConstraint, &constraint ); } +inline void AddUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer< UniformPropertyMapping >& map ) +{ + typedef MessageValue1< PropertyOwner, OwnerPointer< UniformPropertyMapping > > LocalType; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &owner, &PropertyOwner::AddUniformMapping, map ); +} + +inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const std::string& uniformName ) +{ + typedef MessageValue1< PropertyOwner, std::string > LocalType; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &owner, &PropertyOwner::RemoveUniformMapping, uniformName ); +} + + } // namespace SceneGraph } // namespace Internal } // namespace Dali -#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__ +#endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H