/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
+ int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
+ int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
+ int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
+ DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
+ DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
+ DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
+ DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
+
+ textureTrace.Reset();
+
+ // Make a new visual with the same image
+ Visual::Base newVisual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( newVisual );
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ DummyControl newActor = DummyControl::New();
+ DummyControlImpl& newDummyImpl = static_cast< DummyControlImpl& >( newActor.GetImplementation() );
+ newDummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, newVisual );
+
+ newActor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( newActor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( newActor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( newActor.GetRendererCount(), 1u, TEST_LOCATION );
+ auto newRenderer = newActor.GetRendererAt( 0 );
+ preMultipliedIndex = newRenderer.GetPropertyIndex( "preMultipliedAlpha" );
+ DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
+ preMultipliedAlpha = newRenderer.GetProperty< bool >( preMultipliedIndex );
+ preMultipliedAlpha2 = newRenderer.GetProperty< bool >( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+
+ DALI_TEST_EQUALS( preMultipliedAlpha, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( preMultipliedAlpha2, false, TEST_LOCATION );
+
+ srcFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
+ destFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
+ srcFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
+ destFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
+ DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
+ DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
+ DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
+ DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
+
Stage::GetCurrent().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
Stage::GetCurrent().Add( actor );
// loading started
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
Stage::GetCurrent().Add( actor );
// loading started
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
Stage::GetCurrent().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
application.Render(2000u); // Halfway point between blue and white
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "uColor", Vector4( 1.0f, 1.0f, 1.0f, 0.5f ) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>( "mixColor", Vector3( TARGET_MIX_COLOR ) ), true, TEST_LOCATION );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
Stage::GetCurrent().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
tet_infoline( "Test that the opacity doesn't animate when actor not staged" );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
Stage::GetCurrent().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
END_TEST;
}
+int UtcDaliImageVisualSynchronousLoadAlphaMask(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Request image visual with a Property::Map containing an Alpha mask with synchronous loading" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+
+ // Do not wait for any EventThreadTrigger in synchronous alpha mask.
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
+
+ dummyImpl.UnregisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1 );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliImageVisualRemoteAlphaMask(void)
{
ToolkitTestApplication application;
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( "alphaMaskUrl", MASK_IMAGE );
+ propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, MASK_IMAGE );
Visual::Base visual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
Property::Map testMap;
visual.CreatePropertyMap(testMap);
+
DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(MASK_IMAGE), TEST_LOCATION );
// For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
DummyControl actor = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
actor.SetSize( 200.f, 200.f );
END_TEST;
}
-
int UtcDaliImageVisualAlphaMaskCrop(void)
{
ToolkitTestApplication application;
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
Stage::GetCurrent().Add( dummy );
application.SendNotification();
Impl::DummyControl& dummyImpl1 = static_cast< Impl::DummyControl& >( dummy1.GetImplementation() );
dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual1 );
dummy1.SetSize( 200, 200 );
- dummy1.SetParentOrigin( ParentOrigin::CENTER );
+ dummy1.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
Stage::GetCurrent().Add( dummy1 );
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();