X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-impl.h;h=5ee3e8ef160e45cf1784a51774da363dff7d8fc3;hp=5a54a68d3c071782b92a23ac40f7710da6f5e276;hb=29540fc153880d6949c85786b78b8583ae8f1d37;hpb=1972f043026a3e1bdcaad71c17859a8f324d1e6d diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index 5a54a68..5ee3e8e 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.h +++ b/dali-toolkit/internal/visuals/visual-factory-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H /* - * Copyright (c) 2015 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. @@ -22,7 +22,10 @@ // INTERNAL INCLUDES #include -#include +#include +#include +#include +#include namespace Dali { @@ -34,10 +37,7 @@ namespace Internal { class VisualFactoryCache; -typedef IntrusivePtr VisualFactoryCachePtr; - -class ImageAtlasManager; -typedef IntrusivePtr ImageAtlasManagerPtr; +class ImageVisualShaderFactory; /** * @copydoc Toolkit::VisualFactory @@ -46,19 +46,6 @@ class VisualFactory : public BaseObject { public: - enum RendererType - { - COLOR, - BORDER, - GRADIENT, - IMAGE, - N_PATCH, - SVG, - MESH, - PRIMITIVE, - UNDEFINED - }; - /** * @brief Constructor * @@ -67,25 +54,37 @@ public: VisualFactory( bool debugEnabled ); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const Property::Map& ) + * @brief StyleChanged callback + * + * @param[in] styleManager Handle for style manager. + * @param[in] type Style change type. */ - Toolkit::Visual CreateVisual( const Property::Map& propertyMap ); + void OnStyleChangedSignal( Toolkit::StyleManager styleManager, StyleChange::Type type ); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& ) + * @copydoc Toolkit::VisualFactory::CreateVisual( const Property::Map& ) */ - Toolkit::Visual CreateVisual( const Image& image ); + Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap ); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions ) + * @copydoc Toolkit::VisualFactory::CreateVisual( const std::string&, ImageDimensions ) */ - Toolkit::Visual CreateVisual( const std::string& image, ImageDimensions size ); + Toolkit::Visual::Base CreateVisual( const std::string& image, ImageDimensions size ); -public: /** - * @brief Returns an image to be used when a renderer has failed to correctly render + * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad() */ - static Image GetBrokenRendererImage(); + void SetPreMultiplyOnLoad( bool preMultiply ); + + /** + * @copydoc Toolkit::VisualFactory::GetPreMultiplyOnLoad() + */ + bool GetPreMultiplyOnLoad() const; + + /** + * @return the reference to texture manager + */ + Internal::TextureManager& GetTextureManager(); protected: @@ -95,37 +94,76 @@ protected: virtual ~VisualFactory(); private: - /** - * Get the visual type from the property map. - * - * @param[in] propertyMap The map contains the properties of the visual - * @return The rendererType + * Get the factory cache, creating it if necessary. */ - RendererType GetRendererType( const Property::Map& propertyMap ); + Internal::VisualFactoryCache& GetFactoryCache(); /** - * Prepare the atlas manager + * Get the image visual shader factory, creating it if necessary. */ - void CreateAtlasManager(); + ImageVisualShaderFactory& GetImageVisualShaderFactory(); - /** - * Undefined copy constructor. - */ - VisualFactory(const VisualFactory&); + VisualFactory(const VisualFactory&) = delete; - /** - * Undefined assignment operator. - */ - VisualFactory& operator=(const VisualFactory& rhs); + VisualFactory& operator=(const VisualFactory& rhs) = delete; private: - - VisualFactoryCachePtr mFactoryCache; - ImageAtlasManagerPtr mAtlasManager; - bool mDebugEnabled; + std::unique_ptr< VisualFactoryCache > mFactoryCache; + std::unique_ptr< ImageVisualShaderFactory > mImageVisualShaderFactory; + SlotDelegate< VisualFactory > mSlotDelegate; + bool mDebugEnabled:1; + bool mPreMultiplyOnLoad:1; ///< Local store for this flag }; +/** + * @brief Template to allow discard old visual, get new one and set it on stage if possible + * + * @tparam ParameterType0 The type of first argument passed to the CreateVisual() + * @tparam ParameterType1 The type of second argument passed to the CreateVisual() + * @SINCE_1_0.39 + * @param[in] actor Actor for which the visual will be replaced + * @param[in,out] visual The visual to be replaced + * @param[in] param0 First template based argument passed to the visual factory + * @param[in] param1 Second template based argument passed to the visual factory + */ +template< class ParameterType0, class ParameterType1 > +void InitializeVisual( Actor& actor, Toolkit::Visual::Base& visual, ParameterType0& param0, ParameterType1& param1 ) +{ + if( actor ) + { + Toolkit::GetImplementation(visual).SetOffScene( actor ); + } + visual = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 ); + if( visual && actor && actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) + { + Toolkit::GetImplementation(visual).SetOnScene(actor); + } +} + +/** + * @brief Template to allow discard old visual, get new one and set it on stage if possible + * + * @tparam ParameterType The type of argument passed to the CreateVisual() + * @SINCE_1_0.39 + * @param[in] actor Actor for which the visual will be replaced + * @param[in,out] visual The visual to be replaced + * @param[in] param Template based argument passed to the visual factory + */ +template< class ParameterType > +void InitializeVisual( Actor& actor, Toolkit::Visual::Base& visual, ParameterType& param ) +{ + if( actor && visual ) + { + Toolkit::GetImplementation(visual).SetOffScene( actor ); + } + visual = Toolkit::VisualFactory::Get().CreateVisual( param ); + if( visual && actor && actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) + { + Toolkit::GetImplementation(visual).SetOnScene(actor); + } +} + } // namespace Internal inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory)