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=f038301252c978c057cf2ff07caed3d07c06cb1e;hp=484a688ca3f66d18c7bd36411e85833b34613ae2;hb=7018f61b640b6fcf9cb576b537bafcb6bb8240e8;hpb=2cf32ac170f397aacce527efd34909b3fd62efda diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index 484a688..f038301 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) 2021 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. @@ -21,20 +21,20 @@ #include // INTERNAL INCLUDES -#include +#include #include +#include +#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - class VisualFactoryCache; -typedef IntrusivePtr VisualFactoryCachePtr; +class ImageVisualShaderFactory; /** * @copydoc Toolkit::VisualFactory @@ -42,60 +42,128 @@ typedef IntrusivePtr VisualFactoryCachePtr; class VisualFactory : public BaseObject { public: - /** * @brief Constructor * * @param[in] debugEnabled If true, use debug renderer to replace all the concrete renderer. */ - VisualFactory( bool debugEnabled ); + VisualFactory(bool debugEnabled); + + /** + * @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 Property::Map& ) + * @copydoc Toolkit::VisualFactory::CreateVisual( const std::string&, ImageDimensions ) */ - Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap ); + Toolkit::Visual::Base CreateVisual(const std::string& image, ImageDimensions size); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& ) + * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad() */ - Toolkit::Visual::Base CreateVisual( const Image& image ); + void SetPreMultiplyOnLoad(bool preMultiply); /** - * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions ) + * @copydoc Toolkit::VisualFactory::GetPreMultiplyOnLoad() */ - Toolkit::Visual::Base CreateVisual( const std::string& image, ImageDimensions size ); + bool GetPreMultiplyOnLoad() const; + /** + * @return the reference to texture manager + */ + Internal::TextureManager& GetTextureManager(); protected: - /** * A reference counted object may only be deleted by calling Unreference() */ - virtual ~VisualFactory(); + ~VisualFactory() override; 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 mFactoryCache; + std::unique_ptr mImageVisualShaderFactory; + SlotDelegate 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 +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(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 +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(Actor::Property::CONNECTED_TO_SCENE)) + { + Toolkit::GetImplementation(visual).SetOnScene(actor); + } +} + } // namespace Internal inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory) { - DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" ); + DALI_ASSERT_ALWAYS(factory && "VisualFactory handle is empty"); const BaseObject& handle = factory.GetBaseObject(); @@ -104,7 +172,7 @@ inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFac inline Internal::VisualFactory& GetImplementation(Toolkit::VisualFactory& factory) { - DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" ); + DALI_ASSERT_ALWAYS(factory && "VisualFactory handle is empty"); BaseObject& handle = factory.GetBaseObject();