- Extents is a collection of 4 uint16_t.
Change-Id: Ia39db06622d22775cc8a81e61d991508b0f760d3
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
utc-Dali-Degree.cpp
utc-Dali-DistanceField.cpp
utc-Dali-EncodedBufferImage.cpp
+ utc-Dali-Extents.cpp
utc-Dali-FrameBuffer.cpp
utc-Dali-FrameBufferImage.cpp
utc-Dali-Geometry.cpp
}
template <>
+inline bool CompareType<Extents>(Extents extents1, Extents extents2, float epsilon)
+{
+ return (extents1.start == extents2.start) &&
+ (extents1.end == extents2.end) &&
+ (extents1.top == extents2.top) &&
+ (extents1.bottom == extents2.bottom);
+}
+
+template <>
inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2, float epsilon)
{
Property::Type type = q1.GetType();
result = false;
break;
}
+ case Property::EXTENTS:
+ {
+ Extents a, b;
+ q1.Get(a);
+ q2.Get(b);
+ result = CompareType<Extents>( a, b, epsilon );
+ break;
+ }
case Property::NONE:
{
result = false;
--- /dev/null
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+/// Compare a uint16_t value with an unsigned int
+void DALI_TEST_EQUALS( uint16_t value1, unsigned int value2, const char* location )
+{
+ ::DALI_TEST_EQUALS< uint16_t >( value1, static_cast< uint16_t >( value2 ), location );
+}
+} // unnamed namespace
+
+void utc_dali_extents_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_extents_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliExtentsConstructor01(void)
+{
+ TestApplication application;
+
+ Extents extent;
+ DALI_TEST_EQUALS( extent.start, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.end, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.top, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.bottom, 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliExtentsConstructor02(void)
+{
+ TestApplication application;
+
+ Extents extent( 10u, 20u, 400u, 200u );
+ DALI_TEST_EQUALS( extent.start, 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.end, 20u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.top, 400u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.bottom, 200u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliExtentsConstructor03(void)
+{
+ TestApplication application;
+
+ Extents extent( 10u, 20u, 400u, 200u );
+
+ Extents e2 = extent;
+
+ DALI_TEST_EQUALS( e2.start, 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( e2.end, 20u, TEST_LOCATION );
+ DALI_TEST_EQUALS( e2.top, 400u, TEST_LOCATION );
+ DALI_TEST_EQUALS( e2.bottom, 200u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliExtentsCopyConstructor(void)
+{
+ TestApplication application;
+
+ Extents extent( 10u, 20u, 400u, 200u );
+
+ Extents extent2( extent );
+
+ DALI_TEST_EQUALS( extent2.start, 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent2.end, 20u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent2.top, 400u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent2.bottom, 200u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliExtentsCopyAssignment(void)
+{
+ TestApplication application;
+
+ Extents extent;
+
+ Extents extent2( 10u, 20u, 400u, 200u );
+ extent = extent2;
+
+ DALI_TEST_EQUALS( extent.start, 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.end, 20u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.top, 400u, TEST_LOCATION );
+ DALI_TEST_EQUALS( extent.bottom, 200u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliExtentsAssignP(void)
+{
+ Extents extent;
+ const uint16_t array[] = { 1u, 2u, 3u, 4u };
+ extent = (const uint16_t*)array;
+
+ DALI_TEST_EQUALS( extent.start, 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS( extent.end, 2u, TEST_LOCATION);
+ DALI_TEST_EQUALS( extent.top, 3u, TEST_LOCATION);
+ DALI_TEST_EQUALS( extent.bottom, 4u, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliExtentsOperatorNotEquals(void)
+{
+ TestApplication application;
+
+ Extents extent1( 10u, 20u, 200u, 200u );
+ Extents extent2( 10u, 120u, 200u, 200u );
+ Extents extent3( 10u, 80u, 200u, 200u );
+
+ DALI_TEST_CHECK( extent1 != extent2 );
+ DALI_TEST_CHECK( extent1 != extent3 );
+ END_TEST;
+}
+
+int UtcDaliExtentsOperatorEquals(void)
+{
+ TestApplication application;
+
+ Extents extent1( 10u, 20u, 200u, 200u );
+ Extents extent1p( 10u, 20u, 200u, 200u );
+
+ Extents extent2( 10u, 120u, 200u, 200u );
+ Extents extent3( 10u, 80u, 200u, 200u );
+
+ DALI_TEST_CHECK( extent1 == extent1p );
+ DALI_TEST_CHECK( extent1 == extent1 );
+ DALI_TEST_CHECK( !( extent1 == extent2 ) );
+ DALI_TEST_CHECK( !( extent1 == extent3 ) );
+
+ END_TEST;
+}
+
+int UtcDaliExtentsOStreamOperatorP(void)
+{
+ TestApplication application;
+ std::ostringstream oss;
+
+ Extents extent( 1u, 2u, 10u, 10u );
+
+ oss << extent;
+
+ std::string expectedOutput = "[1, 2, 10, 10]";
+
+ DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
+ END_TEST;
+}
END_TEST;
}
+int UtcDaliPropertyValueConstructorsExtentsTypeP(void)
+{
+ Property::Value value( Property::EXTENTS );
+
+ DALI_TEST_CHECK( value.GetType() == Property::EXTENTS );
+ DALI_TEST_CHECK( value.Get<Extents>() == Extents( 0u, 0u, 0u, 0u ) );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyValueConstructorsExtentsType2P(void)
+{
+ Property::Value value( Property::VECTOR4 );
+
+ DALI_TEST_CHECK( value.GetType() == Property::VECTOR4 );
+ DALI_TEST_CHECK( value.Get<Extents>() == Extents( 0u, 0u, 0u, 0u ) );
+
+ END_TEST;
+}
+
int UtcDaliPropertyValueCopyConstructorP(void)
{
Property::Value value;
END_TEST;
}
+int UtcDaliPropertyValueAssignmentOperatorExtentsP(void)
+{
+ Property::Value value;
+ value = Property::Value( Extents( 4, 3, 2, 1 ) ); // mismatch
+ DALI_TEST_CHECK( Extents( 4, 3, 2, 1 ) == value.Get<Extents>() );
+ Property::Value copy( Property::EXTENTS );
+ copy = value; // match
+ Extents copyExtents;
+ copy.Get(copyExtents);
+ DALI_TEST_CHECK( Extents( 4, 3, 2, 1 ) == copyExtents );
+ END_TEST;
+}
+
int UtcDaliPropertyValueGetTypeP(void)
{
Property::Value value;
END_TEST;
}
+int UtcDaliPropertyValueGetExtentsP(void)
+{
+ Property::Value value( Extents( 1u, 2u, 3u, 4u ) );
+ Extents result( 4u, 3u, 2u, 1u );
+ DALI_TEST_EQUALS( Extents( 1u, 2u, 3u, 4u ), value.Get<Extents>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Extents( 1u, 2u, 3u, 4u ), result, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliPropertyValueOutputStream(void)
{
TestApplication application;
DALI_TEST_CHECK( !stream.str().compare("Map(3) = {color:[1, 0.5, 1, 1], timePeriod:Map(2) = {key:value, duration:10}, texCoords:Array(4) = [[1, 0], [0, 1], [1, 0], [0, 0.5]]}"));
}
+ {
+ value = Property::Value( Extents( 1u, 2u, 3u, 4u ) );
+ std::ostringstream stream;
+ stream << value;
+ DALI_TEST_CHECK( stream.str() == "[1, 2, 3, 4]" );
+ }
END_TEST;
}
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::NONE:
{
DALI_ASSERT_ALWAYS( !"PropertyType is not animatable" );
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
{
// already handled by higher level code
}
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
{
// already handled by higher level code
}
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::BOOLEAN:
case Property::INTEGER:
case Property::FLOAT:
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::BOOLEAN:
case Property::INTEGER:
case Property::FLOAT:
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::MATRIX:
case Property::MATRIX3:
{
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::RECTANGLE:
case Property::ROTATION:
{
case Property::STRING:
case Property::ARRAY:
case Property::MAP:
+ case Property::EXTENTS:
case Property::RECTANGLE:
case Property::ROTATION:
{
${CMAKE_CURRENT_SOURCE_DIR}/common/constants.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/dali-common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/dali-vector.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/extents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/stage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/events/gesture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/events/gesture-detector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/constants.h
${CMAKE_CURRENT_SOURCE_DIR}/common/dali-common.h
${CMAKE_CURRENT_SOURCE_DIR}/common/dali-vector.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/extents.h
${CMAKE_CURRENT_SOURCE_DIR}/common/intrusive-ptr.h
${CMAKE_CURRENT_SOURCE_DIR}/common/loading-state.h
${CMAKE_CURRENT_SOURCE_DIR}/common/stage.h
--- /dev/null
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/common/extents.h>
+
+namespace Dali
+{
+
+Extents::Extents()
+: start(0),
+ end(0),
+ top(0),
+ bottom(0)
+ {
+ }
+
+Extents::Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom )
+: start( start ),
+ end( end ),
+ top( top ),
+ bottom( bottom )
+ {
+ }
+
+Extents& Extents::operator=( const uint16_t* array )
+{
+ start = array[0];
+ end = array[1];
+ top = array[2];
+ bottom = array[3];
+
+ return *this;
+}
+
+bool Extents::operator==( const Extents &rhs ) const
+{
+ return ( start == rhs.start )&&
+ ( end == rhs.end )&&
+ ( top == rhs.top )&&
+ ( bottom == rhs.bottom );
+}
+
+bool Extents::operator!=( const Extents &rhs ) const
+{
+ return !( *this == rhs );
+}
+
+std::ostream& operator<<( std::ostream& stream, const Extents& extents )
+{
+ return stream << "[" << extents.start << ", " << extents.end << ", " << extents.top << ", " << extents.bottom << "]";
+}
+
+} // Dali
--- /dev/null
+#ifndef DALI_EXTENTS_H
+#define DALI_EXTENTS_H
+
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstdint>
+#include <ostream>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_core_common
+ * @{
+ */
+
+/**
+ * @brief Structure describing the a collection of uint16_t.
+ * @SINCE_1_2.62
+ */
+struct DALI_EXPORT_API Extents
+{
+ /**
+ * @brief Default constructor which provides an initialized Dali::Extents( 0u, 0u, 0u, 0u ).
+ * @SINCE_1_2.62
+ */
+ Extents();
+
+ /**
+ * @brief Copy constructor.
+ * @SINCE_1_2.62
+ * @param[in] copy A reference to the copied Extents
+ */
+ Extents( const Extents& copy ) = default;
+
+ /**
+ * @brief Constructor.
+ *
+ * @SINCE_1_2.62
+ * @param[in] start Start extent
+ * @param[in] end End extent
+ * @param[in] top Top extent
+ * @param[in] bottom Bottom extent
+ */
+ Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom );
+
+ /**
+ * @brief Copy Assignment operator.
+ * @SINCE_1_2.62
+ * @param[in] copy A reference to the copied Extents
+ * @return Itself
+ */
+ Extents& operator=( const Extents& copy ) = default;
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @SINCE_1_2.62
+ * @param[in] array Array of uint16_t
+ * @return Itself
+ */
+ Extents& operator=( const uint16_t* array );
+
+ /**
+ * @brief Equality operator.
+ *
+ * @SINCE_1_2.62
+ * @param[in] rhs The Extents to test against
+ * @return True if the extents are equal
+ */
+ bool operator==( const Extents &rhs ) const;
+
+ /**
+ * @brief Inequality operator.
+ *
+ * @SINCE_1_2.62
+ * @param[in] rhs The Extents to test against
+ * @return True if the extents are not equal
+ */
+ bool operator!=( const Extents &rhs ) const;
+
+public:
+ uint16_t start; ///< The start extent. @SINCE_1_2.62
+ uint16_t end; ///< The end extent. @SINCE_1_2.62
+ uint16_t top; ///< The top extent. @SINCE_1_2.62
+ uint16_t bottom; ///< The bottom extent. @SINCE_1_2.62
+
+};
+
+/**
+ * @brief Converts the value of the extents into a string and insert in to an output stream.
+ *
+ * @SINCE_1_2.62
+ * @param[in] stream The output stream operator
+ * @param[in] extents The Extents to output
+ * @return The output stream operator
+ */
+DALI_EXPORT_API std::ostream& operator<<( std::ostream& stream, const Extents& extents );
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_EXTENTS_H
#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/extents.h>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/common/loading-state.h>
#include <dali/public-api/common/stage.h>
$(public_api_src_dir)/common/constants.cpp \
$(public_api_src_dir)/common/dali-common.cpp \
$(public_api_src_dir)/common/dali-vector.cpp \
+ $(public_api_src_dir)/common/extents.cpp \
$(public_api_src_dir)/common/stage.cpp \
$(public_api_src_dir)/events/gesture.cpp \
$(public_api_src_dir)/events/gesture-detector.cpp \
$(public_api_src_dir)/common/constants.h \
$(public_api_src_dir)/common/dali-common.h \
$(public_api_src_dir)/common/dali-vector.h \
+ $(public_api_src_dir)/common/extents.h \
$(public_api_src_dir)/common/intrusive-ptr.h \
$(public_api_src_dir)/common/loading-state.h \
$(public_api_src_dir)/common/stage.h \
"STRING",
"ARRAY",
"MAP",
+ "EXTENTS",
};
const unsigned int PROPERTY_TYPE_NAMES_COUNT = sizeof( PROPERTY_TYPE_NAMES ) / sizeof( const char* );
}
// INTERNAL INCLUDES
#include <dali/public-api/common/constants.h>
+#include <dali/public-api/common/extents.h>
#include <dali/public-api/math/angle-axis.h>
#include <dali/public-api/math/degree.h>
#include <dali/public-api/math/quaternion.h>
inline Property::Type Get<Property::Map>() { return Property::MAP; }
template <>
inline Property::Type Get<Property::Array>() { return Property::ARRAY; }
+template <>
+inline Property::Type Get<Extents>() { return Property::EXTENTS; }
}; // namespace PropertyTypes
#include <ostream>
// INTERNAL INCLUDES
+#include <dali/public-api/common/extents.h>
#include <dali/public-api/math/angle-axis.h>
#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector2.h>
{
}
+ Impl( const Extents& extentsValue )
+ : type( Property::EXTENTS ),
+ extentsValue( new Extents( extentsValue ) )
+ {
+ }
+
/**
* Destructor, takes care of releasing the dynamically allocated types
*/
delete mapValue;
break;
}
+ case Property::EXTENTS:
+ {
+ delete extentsValue;
+ break;
+ }
}
}
Rect<int>* rectValue;
Property::Array* arrayValue;
Property::Map* mapValue;
+ Extents* extentsValue;
};
private:
{
}
+Property::Value::Value( const Extents& extentsValue )
+: mImpl( new Impl( extentsValue ) )
+{
+}
+
Property::Value::Value( Type type )
: mImpl( NULL )
{
mImpl = new Impl( Property::Map() );
break;
}
+ case Property::EXTENTS:
+ {
+ mImpl = new Impl( Extents() );
+ break;
+ }
case Property::NONE:
{
mImpl = new Impl();
*mImpl->mapValue = *value.mImpl->mapValue; // type cannot change in mImpl so map is allocated
break;
}
+ case Property::EXTENTS:
+ {
+ *mImpl->extentsValue = *value.mImpl->extentsValue; // type cannot change in mImpl so extents is allocated
+ break;
+ }
case Property::NONE:
{ // mImpl will be NULL, there's no way to get to this case
}
newImpl = new Impl( *value.mImpl->mapValue ); // type cannot change in mImpl so map is allocated
break;
}
+ case Property::EXTENTS:
+ {
+ newImpl = new Impl( *value.mImpl->extentsValue ); // type cannot change in mImpl so extents is allocated
+ break;
+ }
case Property::NONE:
{ // NULL value will be used for "empty" value
}
return map;
}
+bool Property::Value::Get( Extents& extentsValue ) const
+{
+ bool converted = false;
+ if( mImpl )
+ {
+ if( mImpl->type == EXTENTS )
+ {
+ extentsValue = *(mImpl->extentsValue);
+ converted = true;
+ }
+ else if( mImpl->type == VECTOR4 )
+ {
+ extentsValue.start = static_cast< uint16_t >( mImpl->vector4Value->x );
+ extentsValue.end = static_cast< uint16_t >( mImpl->vector4Value->y );
+ extentsValue.top = static_cast< uint16_t >( mImpl->vector4Value->z );
+ extentsValue.bottom = static_cast< uint16_t >( mImpl->vector4Value->w );
+ converted = true;
+ }
+ }
+ return converted;
+}
+
std::ostream& operator<<( std::ostream& stream, const Property::Value& value )
{
if( value.mImpl )
stream << *(value.GetMap());
break;
}
+ case Dali::Property::EXTENTS:
+ {
+ stream << *impl.extentsValue;
+ break;
+ }
case Dali::Property::NONE:
{
stream << "undefined type";
struct Vector4;
class Matrix3;
class Matrix;
+struct Extents;
/**
* @brief A value-type representing a property value.
Value( Property::Map& mapValue );
/**
+ * @brief Creates an extents property value.
+ *
+ * @SINCE_1_2.62
+ * @param[in] extentsValue A collection of 4 uint16_t values
+ */
+ Value( const Extents& extentsValue );
+
+ /**
* @brief Explicitly sets a type and initialize it.
*
* @SINCE_1_0.0
Property::Map* GetMap() const;
/**
+ * @brief Retrieves an extents.
+ *
+ * @SINCE_1_2.62
+ * @param[out] extentsValue Extents, a collection of 4 uint16_t
+ * @return @c true if the value is successfully retrieved, @c false if the type is not convertible
+ * @pre GetType() is a type convertible to Extents.
+ */
+ bool Get( Extents& extentsValue ) const;
+
+ /**
* @brief Output to stream.
* @SINCE_1_0.0
*/
ROTATION, ///< either a quaternion or an axis angle rotation @SINCE_1_0.0
STRING, ///< A string type @SINCE_1_0.0
ARRAY, ///< an array of Property::Value @SINCE_1_0.0
- MAP ///< a string key to Property:value mapping @SINCE_1_0.0
+ MAP, ///< a string key to Property:value mapping @SINCE_1_0.0
+ EXTENTS ///< a collection of 4 x uint16_t @SINCE_1_2.62
};
/**