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;
+}
--- /dev/null
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_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 DevelVisual
+{
+
+/**
+ * @brief All the visual types.
+ */
+enum Type
+{
+ BORDER = Dali::Toolkit::Visual::BORDER,
+ COLOR = Dali::Toolkit::Visual::COLOR,
+ GRADIENT = Dali::Toolkit::Visual::GRADIENT,
+ IMAGE = Dali::Toolkit::Visual::IMAGE,
+ MESH = Dali::Toolkit::Visual::MESH,
+ PRIMITIVE = Dali::Toolkit::Visual::PRIMITIVE,
+ WIREFRAME = Dali::Toolkit::Visual::WIREFRAME,
+
+ TEXT = WIREFRAME + 1, ///< Renders text.
+};
+
+namespace Property
+{
+
+enum Type
+{
+ TYPE = Dali::Toolkit::Visual::Property::TYPE,
+ SHADER = Dali::Toolkit::Visual::Property::SHADER,
+
+ /**
+ * @brief The transform used by the visual.
+ * @details Name "transform", type Property::Map.
+
+ * @note Optional.
+ * @see DevelVisual::Transform::Property
+ */
+ 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
+
+namespace Transform
+{
+
+namespace Property
+{
+
+enum Type
+{
+ /**
+ * @brief Offset of the visual. It can be either relative (percentage of the parent)
+ * or absolute (in world units).
+ * @details Name "offset", type Property::VECTOR2
+ */
+ OFFSET,
+
+ /**
+ * @brief Size of the visual. It can be either relative (percentage of the parent)
+ * or absolute (in world units).
+ * @details Name "size", type Property::VECTOR2
+ */
+ SIZE,
+
+ /**
+ * @brief The origin of the visual within its control area.
+ * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING.
+ * @see Toolkit::Align
+ */
+ ORIGIN,
+
+ /**
+ * @brief The anchor-point of the visual
+ * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING.
+ * @see Toolkit::Align
+ */
+ ANCHOR_POINT,
+
+ /**
+ * @brief Indicates which components of the offset and size are relative
+ * (percentage of the parent) or absolute (in world units).
+ * 0 indicates the component is relative, and 1 absolute.
+ * @details Name "offsetSizeMode", type Property::VECTOR4
+ */
+ OFFSET_SIZE_MODE
+};
+
+} //namespace Property
+
+} // namespace Transform
+
+} // namespace DevelVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
#include <dali/integration-api/debug.h>
//INTERNAL HEARDER
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
void Base::Initialize( Actor& actor, const Property::Map& propertyMap )
{
+
Property::Value* customShaderValue = propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
if( customShaderValue )
{
}
}
+ Property::Value* premultipliedAlphaValue = propertyMap.Find( Toolkit::DevelVisual::Property::PREMULTIPLIED_ALPHA, PREMULTIPLIED_ALPHA );
+ if( premultipliedAlphaValue )
+ {
+ bool premultipliedAlpha( false );
+ if( premultipliedAlphaValue->Get( premultipliedAlpha ) )
+ {
+ EnablePreMultipliedAlpha( premultipliedAlpha );
+ }
+ }
+
DoInitialize( actor, propertyMap );
}
void Base::EnablePreMultipliedAlpha( bool preMultipled )
{
- if(preMultipled)
+ if( preMultipled )
{
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
{
mImpl->mCustomShader->CreatePropertyMap( map );
}
+
+ bool premultipliedAlpha( IsPreMultipliedAlphaEnabled() );
+ map.Insert( DevelVisual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha );
}
bool Base::GetIsOnStage() const
const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" );
const char * const CUSTOM_SHADER_HINTS( "hints" );
+// 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;
+// Premultiplied alpha
+extern const char * const PREMULTIPLIED_ALPHA;
+
// Image visual
extern const char * const IMAGE_URL_NAME;
extern const char * const ATLAS_RECT_UNIFORM_NAME;
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
void Control::SetBackground( const Property::Map& map )
{
Actor self( Self() );
- InitializeVisual( self, mImpl->mBackgroundVisual, map );
- if( mImpl->mBackgroundVisual )
+ Toolkit::Visual::Base backgroundVisual;
+ InitializeVisual( self, backgroundVisual, map );
+
+ // if new visual created, replace existing one
+ if( backgroundVisual )
{
+ mImpl->mBackgroundVisual = backgroundVisual;
mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
}
+ // ...otherwise process map and apply it to the existing visual
+ else if( mImpl->mBackgroundVisual )
+ {
+ Property::Value* premultipliedAlpha = map.Find( Toolkit::DevelVisual::Property::PREMULTIPLIED_ALPHA, Toolkit::Internal::PREMULTIPLIED_ALPHA );
+ if( premultipliedAlpha )
+ {
+ bool value( premultipliedAlpha->Get<bool>() );
+ Toolkit::GetImplementation( mImpl->mBackgroundVisual ).EnablePreMultipliedAlpha( value );
+ }
+ }
}
void Control::SetBackgroundImage( Image image )