The property enables/disables premultiplied alpha on the Visual.
Example:
control.SetProperty( Toolkit::Control::Property::BACKGROUND,
Property::Map().
Add( "premultipliedAlpha", true ));
Change-Id: I8c8af1b781109256e04f7f3806e9698b34bce40b
END_TEST;
}
+
+int UtcDaliVisualPremultipliedAlpha(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualPremultipliedAlpha" );
+
+ VisualFactory factory = VisualFactory::Get();
+
+ // image visual, test default value ( false )
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), false, TEST_LOCATION );
+ }
+
+ // image visual, override premultiplied
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME )
+ .Add( DevelVisual::Property::PREMULTIPLIED_ALPHA, true ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION);
+ }
+
+ // svg visual ( premultiplied alpha by default is true )
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
* @note Optional.
* @see DevelVisual::Transform::Property
*/
- TRANSFORM = SHADER+1//Dali::Toolkit::Visual::Property::SHADER+1
+ TRANSFORM = SHADER + 1, // Dali::Toolkit::Visual::Property::SHADER + 1
+
+ /**
+ * @brief Enables/disables premultiplied alpha.
+ * The premultiplied alpha is false by default unless this behaviour is modified
+ * by the derived Visual type.
+
+ * @details Name "premultipliedAlpha", type Property::Boolean.
+
+ * @note Optional.
+ */
+ PREMULTIPLIED_ALPHA = SHADER + 2, // Dali::Toolkit::Visual::Property::SHADER + 2
};
} //namespace Property
void Visual::Base::SetProperties( const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( DevelVisual::Property::SHADER, CUSTOM_SHADER );
- if( customShaderValue )
+ for( size_t i = 0; i < propertyMap.Count(); ++i )
{
- Property::Map shaderMap;
- if( customShaderValue->Get( shaderMap ) )
+ const KeyValuePair& pair = propertyMap.GetKeyValue( i );
+ const Property::Key& key = pair.first;
+ const Property::Value& value = pair.second;
+ switch( key.indexKey )
{
- SetCustomShader( shaderMap );
- }
- }
-
- Property::Value* transform = propertyMap.Find( DevelVisual::Property::TRANSFORM, TRANSFORM );
- if( transform )
- {
- Property::Map map;
- if( transform->Get( map ) )
- {
- mImpl->mTransform.SetPropertyMap( map );
+ case DevelVisual::Property::SHADER:
+ {
+ Property::Map shaderMap;
+ if( value.Get( shaderMap ) )
+ {
+ SetCustomShader( shaderMap );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::TRANSFORM:
+ {
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ mImpl->mTransform.SetPropertyMap( map );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::PREMULTIPLIED_ALPHA:
+ {
+ bool premultipliedAlpha( premultipliedAlpha );
+ if( value.Get( premultipliedAlpha ) )
+ {
+ EnablePreMultipliedAlpha( premultipliedAlpha );
+ }
+ break;
+ }
}
}
Property::Map transform;
mImpl->mTransform.GetPropertyMap( transform );
map.Insert( DevelVisual::Property::TRANSFORM, transform );
+
+ bool premultipliedAlpha( IsPreMultipliedAlphaEnabled() );
+ map.Insert( DevelVisual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha );
}
void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled )
{
- if(preMultipled)
+ if( preMultipled )
{
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
extern const char * const ORIGIN( "origin" );
extern const char * const ANCHOR_POINT( "anchorPoint" );
+// Premultipled alpha
+extern const char * const PREMULTIPLIED_ALPHA( "premultipliedAlpha" );
+
// Image visual
const char * const IMAGE_URL_NAME( "url" );
const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
extern const char * const CUSTOM_SUBDIVIDE_GRID_Y;
extern const char * const CUSTOM_SHADER_HINTS;
-//Transform
+// Transform
extern const char * const TRANSFORM;
extern const char * const SIZE;
extern const char * const OFFSET;
extern const char * const ORIGIN;
extern const char * const ANCHOR_POINT;
+// Premultiplied alpha
+extern const char * const PREMULTIPLIED_ALPHA;
// Image visual
extern const char * const IMAGE_URL_NAME;