Merge "Add BuildPickingRay to devel api" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / shader.h
index 468b88d..9c726af 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SHADER_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.
 
 namespace Dali
 {
+/**
+ * @addtogroup dali_core_rendering_effects
+ * @{
+ */
 
 namespace Internal DALI_INTERNAL
 {
@@ -68,33 +72,43 @@ class Shader;
  *
  * @SINCE_1_1.43
  */
-class DALI_IMPORT_API Shader : public Handle
+class DALI_CORE_API Shader : public Handle
 {
 public:
-
   /**
-   * @brief Hints for rendering/subdividing geometry.
-   * @SINCE_1_1.43
+   * @brief Hints for rendering.
+   * @SINCE_1_1.45
    */
-  enum ShaderHints
+  struct Hint
   {
-    HINT_NONE                     = 0x00, ///< No hints                                                                          @SINCE_1_1.43
-    HINT_OUTPUT_IS_TRANSPARENT    = 0x01, ///< Might generate transparent alpha from opaque inputs                               @SINCE_1_1.43
-    HINT_MODIFIES_GEOMETRY        = 0x02, ///< Might change position of vertices, this option disables any culling optimizations @SINCE_1_1.43
+    /**
+     * @brief Enumeration for the hint value.
+     * @SINCE_1_1.45
+     */
+    enum Value
+    {
+      NONE                  = 0x00, ///< No hints                                                                          @SINCE_1_1.45
+      OUTPUT_IS_TRANSPARENT = 0x01, ///< Might generate transparent alpha from opaque inputs                               @SINCE_1_1.45
+      MODIFIES_GEOMETRY     = 0x02, ///< Might change position of vertices, this option disables any culling optimizations @SINCE_1_1.45
+    };
   };
 
   /**
-   * @brief An enumeration of properties belonging to the Shader class.
+   * @brief Enumeration for instances of properties belonging to the Shader class.
    * @SINCE_1_1.43
    */
   struct Property
   {
+    /**
+     * @brief Enumeration for instances of properties belonging to the Shader class.
+     * @SINCE_1_1.43
+     */
     enum
     {
       /**
-       * @brief Name: "program", Type: MAP
-       * @note  The default value is empty
-       * @note  Format: {"vertex":"","fragment":"",hints:"","vertexPrefix":"","fragmentPrefix":""}
+       * @brief Name: "program", Type: MAP.
+       * @note The default value is empty.
+       * @note Format: {"vertex":"","fragment":"",hints:""}
        * @SINCE_1_1.43
        */
       PROGRAM = DEFAULT_OBJECT_PROPERTY_START_INDEX
@@ -102,27 +116,27 @@ public:
   };
 
   /**
-   * @brief Create Shader.
+   * @brief Creates Shader.
    *
    * @SINCE_1_1.43
-   * @param[in] vertexShader Vertex shader code for the effect. If you pass in an empty string, the default version will be used
-   * @param[in] fragmentShader fragment shader code for the effect. If you pass in an empty string, the default version will be used
-   * @param[in] hints GeometryHints to define the geometry of the rendered object
+   * @param[in] vertexShader Vertex shader code for the effect.
+   * @param[in] fragmentShader Fragment Shader code for the effect.
+   * @param[in] hints Hints to define the geometry of the rendered object
    * @return A handle to a shader effect
    */
-  static Shader New( const std::string& vertexShader,
-                     const std::string& fragmentShader,
-                     ShaderHints hints = ShaderHints( HINT_NONE ) );
+  static Shader New(std::string_view vertexShader,
+                    std::string_view fragmentShader,
+                    Hint::Value      hints = Hint::NONE);
 
   /**
-   * @brief Default constructor, creates an empty handle
+   * @brief Default constructor, creates an empty handle.
    *
    * @SINCE_1_1.43
    */
   Shader();
 
   /**
-   * @brief Destructor
+   * @brief Destructor.
    * This is non-virtual since derived Handle types must not contain data or virtual methods.
    *
    * @SINCE_1_1.43
@@ -130,43 +144,89 @@ public:
   ~Shader();
 
   /**
-   * @brief Copy constructor
+   * @brief Copy constructor.
    *
    * @SINCE_1_1.43
    * @param[in] handle A handle to a Shader object
    */
-  Shader( const Shader& handle );
+  Shader(const Shader& handle);
 
   /**
-   * @brief Downcast to a shader handle.
-   * If not a shader the returned shader handle is left uninitialized.
+   * @brief Downcasts to a shader handle.
+   * If not, a shader the returned shader handle is left uninitialized.
    *
    * @SINCE_1_1.43
    * @param[in] handle Handle to an object
    * @return Shader handle or an uninitialized handle
    */
-  static Shader DownCast( BaseHandle handle );
+  static Shader DownCast(BaseHandle handle);
 
   /**
-   * @brief Assignment operator, changes this handle to point at the same object
+   * @brief Assignment operator, changes this handle to point at the same object.
    *
    * @SINCE_1_1.43
    * @param[in] handle Handle to an object
    * @return Reference to the assigned object
    */
-  Shader& operator=( const Shader& handle );
+  Shader& operator=(const Shader& handle);
 
-public:
+  /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.22
+   * @param[in] rhs A reference to the moved handle
+   */
+  Shader(Shader&& rhs) noexcept;
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.22
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this
+   */
+  Shader& operator=(Shader&& rhs) noexcept;
+
+  /**
+   * @brief Get shader preprocessor of shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return shader preprocessor string.
+   */
+  static std::string GetShaderVersionPrefix();
+
+  /**
+   * @brief Get vertex shader preprocessor that includes shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return Vertex shader preprocessor string.
+   */
+  static std::string GetVertexShaderPrefix();
 
   /**
+   * @brief Get fragment shader preprocessor that includes shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return Fragment shader preprocessor string.
+   */
+  static std::string GetFragmentShaderPrefix();
+
+public:
+  /**
    * @brief This constructor is used by Dali New() methods.
    * @note  Not intended for application developers.
    * @SINCE_1_1.43
    * @param[in] effect A pointer to a newly allocated Dali resource.
    */
-  explicit DALI_INTERNAL Shader( Internal::Shader* effect );
+  explicit DALI_INTERNAL Shader(Internal::Shader* effect);
 };
 
+/**
+ * @}
+ */
 } // namespace Dali
 
 #endif // DALI_SHADER_H