[dali_2.3.23] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / visual-factory / visual-factory.h
index 25c17cc..cc62c2b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_VISUAL_FACTORY_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -19,8 +19,8 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
 #include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/object/base-handle.h>
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
 namespace Dali
 {
 class Image;
-class Vector4;
+struct Vector4;
 
 namespace Toolkit
 {
-
 namespace Internal DALI_INTERNAL
 {
 class VisualFactory;
@@ -51,10 +50,9 @@ class VisualFactory;
  * | visualType               | INTEGER or STRING |
  * | shader                   | MAP               |
  */
-class DALI_IMPORT_API VisualFactory : public BaseHandle
+class DALI_TOOLKIT_API VisualFactory : public BaseHandle
 {
 public:
-
   /**
    * @brief Create or retrieve VisualFactory singleton.
    *
@@ -81,7 +79,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.
@@ -89,7 +87,7 @@ 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 visual
@@ -98,29 +96,56 @@ public:
    *            The content of the map determines the type of visual that will be returned.
    * @return The handle to the created visual
    */
-  Visual::Base CreateVisual( const Property::Map& propertyMap  );
+  Visual::Base CreateVisual(const Property::Map& propertyMap);
 
   /**
-   * @brief Request the visual to render the image.
+   * @brief Request the visual to render the given resource at the url.
    *
-   * @param[in] image The image to be rendered.
+   * @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 visual
    */
-  Visual::Base CreateVisual( const Image& image );
+  Visual::Base CreateVisual(const std::string& url, ImageDimensions size);
 
   /**
-   * @brief Request the visual to render the given resource at the url.
+   * @brief Enable or disable premultiplying alpha in images and image visuals.
    *
-   * @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 visual
+   * 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.
    */
-  Visual::Base CreateVisual( const std::string& url, ImageDimensions size );
+  void SetPreMultiplyOnLoad(bool preMultiply);
 
-private:
+  /**
+   * @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 Discard visual base. It will keep reference of visual until idle callback called.
+   *
+   * @param[in] visual Discarded visual base.
+   */
+  void DiscardVisual(Visual::Base visual);
 
-  explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory *impl);
+  /**
+   * @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