{
return CreateBufferImage(4, 4, Color::WHITE);
}
+
+namespace Test
+{
+
+struct ObjectDestructionFunctor
+{
+ // Create a ObjectDestructionFunctor passing in a Dali::RefObject* to be monitored and a bool variable.
+ // Create ObjectRegistry instance and connect to the ObjectDestroyedSignal passing in the above functor for the callback.
+ // Get the ObjectPointer (Actor::GetObjectPtr) of the Actor to be checked for destruction and assign it to the Dali::RefObject*
+ // Check the bool variable which would be true when object destroyed.
+ ObjectDestructionFunctor( Dali::RefObject* objectPtr, bool& refObjectDestroyed )
+ : refObjectPointerToCheck( objectPtr ),
+ refObjectDestroyedBoolean( refObjectDestroyed )
+ {
+ refObjectDestroyed = false;
+ }
+
+ void operator()( const Dali::RefObject* objectPointer )
+ {
+ if ( refObjectPointerToCheck == objectPointer )
+ {
+ refObjectDestroyedBoolean = true;
+ }
+ }
+
+ Dali::RefObject* refObjectPointerToCheck;
+ bool& refObjectDestroyedBoolean;
+};
+
+ObjectDestructionTracker::ObjectDestructionTracker()
+ :mRefObjectDestroyed( false)
+{
+}
+
+void ObjectDestructionTracker::Start( Actor actor )
+{
+ ObjectDestructionFunctor destructionFunctor( actor.GetObjectPtr(), mRefObjectDestroyed );
+
+ ObjectRegistry objectRegistry = Stage::GetCurrent().GetObjectRegistry();
+ objectRegistry.ObjectDestroyedSignal().Connect( this, destructionFunctor );
+}
+
+bool ObjectDestructionTracker::IsDestroyed()
+{
+ return mRefObjectDestroyed;
+}
+
+} // namespace Test
BufferImage CreateBufferImage();
BufferImage CreateBufferImage(int width, int height, const Vector4& color);
+// Test namespace to prevent pollution of Dali namespace, add Test helper functions here
+namespace Test
+{
+/**
+ * @brief
+ *
+ * Helper to check object destruction occurred
+ * 1) In main part of code create an ObjectDestructionTracker
+ * 2) Within sub section of main create object Actor test and call Start with Actor to test for destruction
+ * 3) Perform code which is expected to destroy Actor
+ * 4) Back in main part of code use IsDestroyed() to test if Actor was destroyed
+ */
+class ObjectDestructionTracker : public ConnectionTracker
+{
+public:
+
+ /**
+ * @brief
+ *
+ * Call in main part of code
+ */
+ ObjectDestructionTracker();
+
+ /**
+ * @brief Call in sub bock of code where the Actor being checked is still alive.
+ *
+ * @param[in] actor Actor to be checked for destruction
+ */
+ void Start( Actor actor );
+
+ /**
+ * @brief Call to check if Actor alive or destroyed.
+ * @return bool true if Actor was destroyed
+ */
+ bool IsDestroyed();
+
+private:
+ bool mRefObjectDestroyed;
+};
+
+} // namespace Test
+
#endif // __DALI_TEST_SUITE_UTILS_H__
// ReRegister to self
dummyImpl.RegisterVisual( index, dummy, visual );
- tet_result(TET_PASS);
-
END_TEST;
}
{
ToolkitTestApplication application;
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+ Test::ObjectDestructionTracker objectDestructionTracker;
- Property::Index index =1;
- Actor placementActor = Actor::New();
+ {
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+ objectDestructionTracker.Start( dummy );
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
+ Property::Index index = 1;
+ Actor placementActor = Actor::New();
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
- // ReRegister to self
- dummyImpl.RegisterVisual( index, dummy, visual );
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
- tet_result(TET_PASS);
+ // Register to self
+ dummyImpl.RegisterVisual( index, dummy, visual );
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+ }
+
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
END_TEST;
}
-
int UtcDaliControlImplRegisterTwoVisuals(void)
{
ToolkitTestApplication application;
newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
secondVisual = visualFactory.CreateVisual( newMap );
+ DALI_TEST_CHECK( secondVisual );
// ReRegister with altered color visual
dummyImpl.RegisterVisual( index2, secondPlacementActor, secondVisual );
- tet_result(TET_PASS);
-
END_TEST;
}
// Unregister visual
dummyImpl.UnregisterVisual( index );
- tet_result(TET_PASS);
-
END_TEST;
}
// Batch Image visual
propertyMap.Clear();
- propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE );
- propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
batchImageVisual.SetSize( visualSize );
DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION );
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE );
- propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( BatchImageVisual::Property::DESIRED_WIDTH, 20 );
- propertyMap.Insert( BatchImageVisual::Property::DESIRED_HEIGHT, 30 );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( batchImageVisual );
// Check the property values from the returned map from visual
Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == Visual::BATCH_IMAGE );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
- value = resultMap.Find( BatchImageVisual::Property::URL, Property::STRING );
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
- value = resultMap.Find( BatchImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
+ value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 20 );
- value = resultMap.Find( BatchImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
+ value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 30 );
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE );
- propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
// Set the desired size to be larger than the atlas limit of 1024x1024.
- propertyMap.Insert( BatchImageVisual::Property::DESIRED_WIDTH, 2048 );
- propertyMap.Insert( BatchImageVisual::Property::DESIRED_HEIGHT, 2048 );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 );
// Create the visual.
Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE );
- propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
Visual::Base visual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
// Create a normal Image Visual.
propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
// Instruct the factory to change Image Visuals to Batch-Image Visuals.
- propertyMap.Insert( Visual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
// Properties for the Batch-Image Visual.
- propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
Visual::Base visual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::BATCH_IMAGE, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
Actor actor = Actor::New();
// Create a property-map that enables batching.
Property::Map propertyMap;
- propertyMap.Insert( Dali::Toolkit::BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( Visual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
// Create an ImageView, passing the property-map in to instruct it to use batching.
Toolkit::ImageView imageView = Toolkit::ImageView::New();
# For Open Source DALi API Reference
ALIASES += SINCE_1_0="@since 1.0"
ALIASES += SINCE_1_1="@since 1.1"
+ALIASES += SINCE_1_2="@since 1.2"
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
+ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
ALIASES += PLATFORM=""
ALIASES += PRIVLEVEL_PLATFORM=""
#include <dali-toolkit/public-api/text/rendering-backend.h>
-#include <dali-toolkit/public-api/visuals/batch-image-visual-properties.h>
#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
#include <dali/public-api/rendering/texture-set.h>
// INTERNAL HEADER
-#include <dali-toolkit/public-api/visuals/batch-image-visual-properties.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
void BatchImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
std::string oldImageUrl = mImageUrl;
- Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME );
+ Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME );
if( imageURLValue )
{
imageURLValue->Get( mImageUrl );
int desiredWidth = 0;
- Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH );
+ Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH );
if( desiredWidthValue )
{
desiredWidthValue->Get( desiredWidth );
}
int desiredHeight = 0;
- Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT );
+ Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT );
if( desiredHeightValue )
{
desiredHeightValue->Get( desiredHeight );
void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::BATCH_IMAGE );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
- map.Insert( Toolkit::BatchImageVisual::Property::URL, mImageUrl );
- map.Insert( Toolkit::BatchImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() );
- map.Insert( Toolkit::BatchImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
+ map.Insert( Toolkit::ImageVisual::Property::BATCHING_ENABLED, true );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() );
}
}
const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
+const char * const BATCHING_ENABLED( "batchingEnabled" );
// fitting modes
DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, MESH )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, PRIMITIVE )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, DEBUG )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, BATCH_IMAGE )
DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE )
const char * const VISUAL_TYPE( "visualType" );
const char * const BATCHING_ENABLED( "batchingEnabled" );
-
BaseHandle Create()
{
BaseHandle handle = Toolkit::VisualFactory::Get();
Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType );
}
- // If the type is IMAGE, either from a default or the TYPE value in the property-map, change it to a BatchImage if required.
- if( visualType == Toolkit::Visual::IMAGE )
- {
- bool batchingEnabled( false );
- Property::Value* value = propertyMap.Find( Toolkit::Visual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
- if( value )
- {
- value->Get( batchingEnabled );
- if( batchingEnabled )
- {
- visualType = Toolkit::Visual::BATCH_IMAGE;
- }
- }
- }
-
switch( visualType )
{
case Toolkit::Visual::BORDER:
std::string imageUrl;
if( imageURLValue && imageURLValue->Get( imageUrl ) )
{
- if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
+ Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
+ if( batchingEnabledValue )
+ {
+ bool batchingEnabled( false );
+ batchingEnabledValue->Get( batchingEnabled );
+ if( batchingEnabled )
+ {
+ CreateAtlasManager();
+ visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ break;
+ }
+ }
+ else if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
{
visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
}
break;
}
- case Toolkit::Visual::BATCH_IMAGE:
- {
- CreateAtlasManager();
- visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- break;
- }
}
if( visualPtr )
* In the case of the visual being an actor or control deeming controlRenderer not required then controlRenderer should be an empty handle.
* No parenting is done during registration, this should be done by derived class.
*
- * @SINCE_1_1.46
+ * @SINCE_1_2.0
*
* @param[in] index The Property index of the visual, used to reference visual
* @param[in] placementActor The actor used to by the visual.
* @brief Erase the entry matching the given index from the list of registered visuals
* @param[in] index The Property index of the visual, used to reference visual
*
- * @SINCE_1_1.46
+ * @SINCE_1_2.0
*/
void UnregisterVisual( Property::Index index );
$(public_api_src_dir)/controls/video-view/video-view.h
public_api_visuals_header_files = \
- $(public_api_src_dir)/visuals/batch-image-visual-properties.h \
$(public_api_src_dir)/visuals/border-visual-properties.h \
$(public_api_src_dir)/visuals/color-visual-properties.h \
$(public_api_src_dir)/visuals/gradient-visual-properties.h \
+++ /dev/null
-#ifndef DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_H
-#define DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_H
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace BatchImageVisual
-{
-
-namespace Property
-{
-
-enum
-{
- /**
- * @brief The URL of the image.
- * @details Name "url", type Property::STRING.
- * @SINCE_1_1.46
- * @note Mandatory.
- */
- URL = VISUAL_PROPERTY_START_INDEX,
-
- /**
- * @brief The image width.
- * @details Name "desiredWidth", type Property::INTEGER.
- * @SINCE_1_1.46
- * @note Optional. If not specified, the actual image width is used.
- */
- DESIRED_WIDTH,
-
- /**
- * @brief The image height.
- * @details Name "desiredHeight", type Property::INTEGER.
- * @SINCE_1_1.46
- * @note Optional. If not specified, the actual image height is used.
- */
- DESIRED_HEIGHT,
-};
-
-} // namespace Property
-
-} // namespace BatchImageVisual
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_H
* @note For N-Patch images only.
*/
BORDER_ONLY,
+
+ /**
+ * @brief This enables Image visuals to automatically be converted to Batch-Image visuals.
+ * @details Name "batchingEnabled", type Property::BOOLEAN.
+ * @SINCE_1_2.0
+ * @note Optional. For Image visuals only. Not to be used with NPatch or SVG images.
+ */
+ BATCHING_ENABLED,
};
} // namespace Property
MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45
PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45
DEBUG, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_1.45
- BATCH_IMAGE, ///< Renders an image in the geometry batching mode @SINCE_1_1.46
};
namespace Property
* @see Shader::Property
*/
SHADER,
-
- /**
- * @brief This enables Image visuals to automatically be converted to Batch-Image visuals.
- * @details Name "batchingEnabled", type Boolean.
- * @SINCE_1_1.46
- * @note Optional.
- */
- BATCHING_ENABLED,
};
} // namespace Property