X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fproperty-input-impl.h;h=996fde754d9ca10e1d405cfd3372efbd958a1770;hb=0db05961b8c65b81ab2e8795f3264cd6fb5cc919;hp=c8fa3ad8eb565b33fb7a21a260f63ce299d0bc7e;hpb=6c63642f3e4c95c69c7bfbb1d142189efad6a5c9;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/property-input-impl.h b/dali/internal/event/common/property-input-impl.h index c8fa3ad..996fde7 100644 --- a/dali/internal/event/common/property-input-impl.h +++ b/dali/internal/event/common/property-input-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__ -#define __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__ +#ifndef DALI_INTERNAL_PROPERTY_INPUT_IMPL_H +#define DALI_INTERNAL_PROPERTY_INPUT_IMPL_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. @@ -31,6 +31,15 @@ #include #include +#if defined (ANDROID) || defined(WIN32) || defined(__APPLE__) +namespace std +{ + +uint64_t _Hash_bytes(const void* bytes, uint64_t size, uint64_t seed); + +} +#endif + namespace Dali { @@ -38,20 +47,6 @@ namespace Internal { /** - * These dummy values are used to handle PropertyInputImpl errors - */ -static const bool DUMMY_BOOLEAN_VALUE( false ); -static const float DUMMY_FLOAT_VALUE( 0.0f ); -static const int DUMMY_INTEGER_VALUE( 0 ); -static const unsigned int DUMMY_UNSIGNED_INTEGER_VALUE( 0u ); -static const Vector2 DUMMY_VECTOR2_VALUE( 0.0f, 0.0f ); -static const Vector3 DUMMY_VECTOR3_VALUE( 0.0f, 0.0f, 0.0f ); -static const Vector4 DUMMY_VECTOR4_VALUE( 0.0f, 0.0f, 0.0f, 0.0f ); -static const Matrix3 DUMMY_MATRIX3_VALUE; -static const Matrix DUMMY_MATRIX_VALUE; -static const Quaternion DUMMY_QUATERNION_VALUE( 1.0f, 0.0f, 0.0f, 0.0f ); - -/** * An abstract interface for receiving property values, and for querying whether * a property value has changed i.e. whether a constraint needs to be reapplied. */ @@ -62,9 +57,7 @@ public: /** * Virtual destructor. */ - virtual ~PropertyInputImpl() - { - } + virtual ~PropertyInputImpl() = default; /** * Query the type of property input. @@ -92,8 +85,8 @@ public: */ virtual const bool& GetBoolean( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_BOOLEAN_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -104,20 +97,8 @@ public: */ virtual const int& GetInteger( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_INTEGER_VALUE; - } - - /** - * Retrieve an integer value. - * @pre GetType() returns Property::UNSIGNED_INTEGER. - * @param[in] bufferIndex The buffer to read from. - * @return The integer value. - */ - virtual const unsigned int& GetUnsignedInteger( BufferIndex bufferIndex ) const - { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_UNSIGNED_INTEGER_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -128,8 +109,8 @@ public: */ virtual const float& GetFloat( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_FLOAT_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -140,8 +121,8 @@ public: */ virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_VECTOR2_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -152,8 +133,8 @@ public: */ virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_VECTOR3_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -164,8 +145,8 @@ public: */ virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_VECTOR4_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -176,8 +157,8 @@ public: */ virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_QUATERNION_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -188,8 +169,8 @@ public: */ virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_MATRIX3_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } /** @@ -200,8 +181,8 @@ public: */ virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const { - DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_MATRIX_VALUE; + // the return will never be executed, it's just to keep the compiler happy + return reinterpret_cast(*this); } // Accessors for Constraint functions @@ -233,19 +214,6 @@ public: } /** - * Retrieve an unsigned integer input for a constraint function. - * @note For inherited properties, this method should be overriden to return the value - * from the previous frame i.e. not from the current update buffer. - * @pre GetType() returns Property::UNSIGNED_INTEGER. - * @param[in] updateBufferIndex The current update buffer index. - * @return The integer value. - */ - virtual const unsigned int& GetConstraintInputUnsignedInteger( BufferIndex updateBufferIndex ) const - { - return GetUnsignedInteger( updateBufferIndex ); - } - - /** * Retrieve a float input for a constraint function. * @note For inherited properties, this method should be overriden to return the value * from the previous frame i.e. not from the current update buffer. @@ -337,6 +305,73 @@ public: } /** + * Query whether the property belongs to the + * transform manager or not. + * @return True if it is a transform manager property, false otherwise + */ + virtual bool IsTransformManagerProperty() const + { + return false; + } + + std::uint64_t Hash(BufferIndex bufferIndex, uint64_t seed) const + { + switch ( GetType() ) + { + case Property::BOOLEAN: + { + return std::_Hash_bytes(&GetBoolean(bufferIndex), sizeof(bool), seed); + } + + case Property::INTEGER: + { + return std::_Hash_bytes(&GetInteger(bufferIndex), sizeof(int), seed); + } + + case Property::FLOAT: + { + return std::_Hash_bytes(&GetFloat(bufferIndex), sizeof(float), seed); + } + + case Property::VECTOR2: + { + return std::_Hash_bytes(&GetVector2(bufferIndex), sizeof(Vector2), seed); + } + + case Property::VECTOR3: + { + return std::_Hash_bytes(&GetVector3(bufferIndex), sizeof(Vector3), seed); + } + + case Property::VECTOR4: + { + return std::_Hash_bytes(&GetVector4(bufferIndex), sizeof(Vector4), seed); + } + + case Property::ROTATION: + { + return std::_Hash_bytes(&GetQuaternion(bufferIndex), sizeof(Quaternion), seed); + } + + case Property::MATRIX: + { + return std::_Hash_bytes(&GetMatrix(bufferIndex), sizeof(Matrix), seed); + } + + case Property::MATRIX3: + { + return std::_Hash_bytes(&GetMatrix3(bufferIndex), sizeof(Matrix3), seed); + } + + default: + break; // print nothing + } + + return seed; + } + + + /** * Print the property value using a stream. * @param[in] debugStream The output stream. * @param[in] bufferIndex The buffer to read from. @@ -358,12 +393,6 @@ public: break; } - case Property::UNSIGNED_INTEGER: - { - debugStream << GetUnsignedInteger( bufferIndex ); - break; - } - case Property::FLOAT: { debugStream << GetFloat( bufferIndex ); @@ -416,4 +445,4 @@ public: } // namespace Dali -#endif // __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__ +#endif // DALI_INTERNAL_PROPERTY_INPUT_IMPL_H