X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fvisual-factory%2Fvisual-factory.h;h=cc62c2bb5986a01e076147d319ca701cc32651eb;hb=HEAD;hp=76e963c1ff8183723d0bc4318903330afd60590c;hpb=257a9991486e4e05335212b21ecc1f5a0aacbc63;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/visual-factory/visual-factory.h b/dali-toolkit/devel-api/visual-factory/visual-factory.h index 76e963c..13697d2 100644 --- a/dali-toolkit/devel-api/visual-factory/visual-factory.h +++ b/dali-toolkit/devel-api/visual-factory/visual-factory.h @@ -1,7 +1,8 @@ -#ifndef __DALI_TOOLKIT_RENDERER_FACTORY_H__ -#define __DALI_TOOLKIT_RENDERER_FACTORY_H__ +#ifndef DALI_TOOLKIT_VISUAL_FACTORY_H +#define DALI_TOOLKIT_VISUAL_FACTORY_H + /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -18,21 +19,20 @@ */ // EXTERNAL INCLUDES -#include #include +#include #include // INTERNAL INCLUDES -#include +#include namespace Dali { class Image; -class Vector4; +struct Vector4; namespace Toolkit { - namespace Internal DALI_INTERNAL { class VisualFactory; @@ -41,17 +41,24 @@ class VisualFactory; /** * @brief VisualFactory is a singleton object that provides and shares visuals between controls * - * By setting environment variable 'DALI_DEBUG_RENDERING', all concrete renderer is replaced with the debug renderer which renders a quad wireframe. + * By setting environment variable 'DALI_DEBUG_RENDERING', a debug visual is used which renders a quad wireframe. * - * The renderer type is required in the property map for requesting a control renderer. + * The visual type is required in the property map for requesting a visual. * - * | %Property Name | Type | - * |--------------------------|------------------| - * | rendererType | STRING | + * | %Property Name | Type | + * |--------------------------|-------------------| + * | visualType | INTEGER or STRING | + * | shader | MAP | */ -class DALI_IMPORT_API VisualFactory : public BaseHandle +class DALI_TOOLKIT_API VisualFactory : public BaseHandle { public: + enum CreationOptions + { + NONE = 0, + + IMAGE_VISUAL_LOAD_STATIC_IMAGES_ONLY = 1 << 0, ///< Load static images only when we use the image visual. + }; /** * @brief Create or retrieve VisualFactory singleton. @@ -79,7 +86,7 @@ public: * * @param[in] handle A reference to the copied handle. */ - VisualFactory( const VisualFactory& handle ); + VisualFactory(const VisualFactory& handle); /** * @brief This assignment operator is required for (smart) pointer semantics. @@ -87,86 +94,103 @@ public: * @param [in] handle A reference to the copied handle. * @return A reference to this. */ - VisualFactory& operator=( const VisualFactory& handle ); + VisualFactory& operator=(const VisualFactory& handle); /** - * @brief Request the control renderer + * @brief Request the visual * - * @param[in] propertyMap The map contains the properties required by the control renderer - * Depends on the content of the map, different kind of renderer would be returned. - * @return The pointer pointing to control renderer + * @param[in] propertyMap The map contains the properties required by the visual. + * The content of the map determines the type of visual that will be returned. + * @return The handle to the created visual */ - Visual CreateVisual( const Property::Map& propertyMap ); + Visual::Base CreateVisual(const Property::Map& propertyMap); /** - * @brief Request the control renderer to render the image. + * @brief Request the visual with some options * - * @param[in] image The image to be rendered. - * @return The pointer pointing to the control renderer + * @param[in] propertyMap The map contains the properties required by the visual. + * The content of the map determines the type of visual that will be returned. + * @param[in] creationOptions The creation option. + * @return The handle to the created visual */ - Visual CreateVisual( const Image& image ); + Visual::Base CreateVisual(const Property::Map& propertyMap, CreationOptions creationOptions); /** - * @brief Request the control renderer to render the given resource at the url. + * @brief Request the visual to render the given resource at the url. * * @param[in] url The URL to the resource to be rendered. * @param[in] size The width and height to fit the loaded image to. - * @return The pointer pointing to the control renderer + * @return The pointer pointing to the visual */ - Visual CreateVisual( const std::string& url, ImageDimensions size ); + Visual::Base CreateVisual(const std::string& url, ImageDimensions size); -private: + /** + * @brief Request the visual to render the given resource at the url with some options. + * + * @param[in] url The URL to the resource to be rendered. + * @param[in] size The width and height to fit the loaded image to. + * @param[in] creationOptions The creation option. + * @return The pointer pointing to the visual + */ + Visual::Base CreateVisual(const std::string& url, ImageDimensions size, CreationOptions creationOptions); - explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory *impl); + /** + * @brief Enable or disable premultiplying alpha in images and image visuals. + * + * The default is to enable pre-multiplication on load. + * + * Applications that have assets with pre-multiplied alpha already applied should turn this option off. + * + * @param[in] preMultiply True if loaded images for image visuals should have alpha multiplied into the color + * channels. + */ + void SetPreMultiplyOnLoad(bool preMultiply); -}; + /** + * @brief Get the setting for automatically pre-multiplying image visual images on load. + * + * @return True if loaded images have pre-multiplied alpha applied on load, false otherwise. + */ + bool GetPreMultiplyOnLoad() const; + /** + * @brief Set the default creation options when we skip the creation options parameter. + * + * @param[in] creationOptions The default creation options for the visual factory. + */ + void SetDefaultCreationOptions(CreationOptions creationOptions); -/** - * @brief Template to allow discard old renderer, 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 renderer will be replaced - * @param[in,out] renderer The renderer object to be replaced - * @param[in] param0 First template based argument passed to the renderer factory - * @param[in] param1 Second template based argument passed to the renderer factory - */ -template< class ParameterType0, class ParameterType1 > -void InitializeVisual( Actor& actor, Visual& renderer, ParameterType0& param0, ParameterType1& param1 ) -{ - renderer.RemoveAndReset( actor ); - renderer = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 ); - if( renderer && actor && actor.OnStage() ) - { - renderer.SetOnStage( actor ); - } -} + /** + * @brief Set the default creation options when we skip the creation options parameter. + * + * @return The default creation options for the visual factory. + */ + CreationOptions GetDefaultCreationOptions() const; -/** - * @brief Template to allow discard old renderer, 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 renderer will be replaced - * @param[in,out] renderer The renderer object to be replaced - * @param[in] param Template based argument passed to the renderer factory - */ -template< class ParameterType > -void InitializeVisual( Actor& actor, Visual& renderer, ParameterType& param ) -{ - renderer.RemoveAndReset( actor ); - renderer = Toolkit::VisualFactory::Get().CreateVisual( param ); - if( renderer && actor && actor.OnStage() ) - { - renderer.SetOnStage( actor ); - } -} + /** + * @brief Discard visual base. It will keep reference of visual until idle callback called. + * + * @param[in] visual Discarded visual base. + */ + void DiscardVisual(Visual::Base visual); + + /** + * @brief Compile the visual shader in advance. Afterwards, + * when a visual using a new shader is requested, the pre-compiled shader is used. + * + * @note It is recommended that this method be called at the top of the application code. + * @note Using precompiled shaders is helpful when the application is complex and uses + * many different styles of visual options. On the other hand,if most visuals are the same + * and the application is simple, it may use memory unnecessarily or slow down the application launching speed. + */ + void UsePreCompiledShader(); + +private: + explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory* impl); +}; } // namespace Toolkit } // namespace Dali - -#endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */ +#endif // DALI_TOOLKIT_VISUAL_FACTORY_H