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=0e4dcb4bd2bed6ef5bd822d12004d7ba1eed2c5c;hp=484a688ca3f66d18c7bd36411e85833b34613ae2;hb=27de3fbcd7105d89cbe3854bcf908f80176b31f0;hpb=e6757fc2f8c05d6da32f329a874b0ae129abf3d4 diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index 484a688..0e4dcb4 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) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -23,6 +23,9 @@ // INTERNAL INCLUDES #include #include +#include +#include +#include namespace Dali { @@ -34,7 +37,7 @@ namespace Internal { class VisualFactoryCache; -typedef IntrusivePtr VisualFactoryCachePtr; +class ImageVisualShaderFactory; /** * @copydoc Toolkit::VisualFactory @@ -51,20 +54,42 @@ 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. + */ + void OnStyleChangedSignal( Toolkit::StyleManager styleManager, StyleChange::Type type ); + + /** + * @copydoc Toolkit::VisualFactory::CreateVisual( const Property::Map& ) */ Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap ); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& ) + * @copydoc Toolkit::VisualFactory::CreateVisual( const Image& ) */ Toolkit::Visual::Base CreateVisual( const Image& image ); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions ) + * @copydoc Toolkit::VisualFactory::CreateVisual( const std::string&, ImageDimensions ) */ Toolkit::Visual::Base CreateVisual( const std::string& image, ImageDimensions size ); + /** + * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad() + */ + void SetPreMultiplyOnLoad( bool preMultiply ); + + /** + * @copydoc Toolkit::VisualFactory::GetPreMultiplyOnLoad() + */ + bool GetPreMultiplyOnLoad() const; + + /** + * @return the reference to texture manager + */ + Internal::TextureManager& GetTextureManager(); protected: @@ -74,23 +99,76 @@ protected: virtual ~VisualFactory(); private: - /** - * Undefined copy constructor. + * Get the factory cache, creating it if necessary. */ - VisualFactory(const VisualFactory&); + Internal::VisualFactoryCache& GetFactoryCache(); /** - * Undefined assignment operator. + * Get the image visual shader factory, creating it if necessary. */ - VisualFactory& operator=(const VisualFactory& rhs); + ImageVisualShaderFactory& GetImageVisualShaderFactory(); -private: + VisualFactory(const VisualFactory&) = delete; - VisualFactoryCachePtr mFactoryCache; - bool mDebugEnabled; + VisualFactory& operator=(const VisualFactory& rhs) = delete; + +private: + 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).SetOffStage( actor ); + } + visual = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 ); + if( visual && actor && actor.OnStage() ) + { + Toolkit::GetImplementation(visual).SetOnStage(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).SetOffStage( actor ); + } + visual = Toolkit::VisualFactory::Get().CreateVisual( param ); + if( visual && actor && actor.OnStage() ) + { + Toolkit::GetImplementation(visual).SetOnStage(actor); + } +} + } // namespace Internal inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory)