[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image-visual-shader-factory.h
index 58b4dd0..8b50669 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_IMAGE_VISUAL_SHADER_FACTORY_H
 
 /*
- * Copyright (c) 2018 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.
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/image-visual-shader-feature-builder.h>
+#include <string_view>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal
 {
 
@@ -37,9 +37,6 @@ namespace Internal
 class ImageVisualShaderFactory
 {
 public:
-
-public:
-
   /**
    * @brief Constructor
    */
@@ -51,27 +48,32 @@ public:
   ~ImageVisualShaderFactory();
 
   /**
-   * Get the standard image rendering shader.
+   * @brief Get the standard image rendering shader.
    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
-   * @param[in] atlasing Whether texture atlasing is applied.
-   * @param[in] defaultTextureWrapping Whether the default texture wrap mode is applied.
+   * @param[in] featureBuilder Collection of current image shader's features
+   * @return The standard image rendering shader with features.
    */
-  Shader GetShader( VisualFactoryCache& factoryCache, bool atlasing, bool defaultTextureWrapping );
+  Shader GetShader(VisualFactoryCache& factoryCache, ImageVisualShaderFeatureBuilder& featureBuilder);
 
   /**
-   * Request the default vertex shader source.
+   * @brief Request the default vertex shader source.
    * @return The default vertex shader source.
    */
-  const char* GetVertexShaderSource();
+  std::string_view GetVertexShaderSource();
 
   /**
-   * Request the default fragment shader source.
+   * @brief Request the default fragment shader source.
    * @return The default fragment shader source.
    */
-  const char* GetFragmentShaderSource();
+  std::string_view GetFragmentShaderSource();
 
-protected:
+  /**
+   * @brief Get the default shader source.
+   * @param[in] shaders shaderList for precompile
+   */
+  void GetPreCompiledShader(RawShaderData& shaders);
 
+protected:
   /**
    * Undefined copy constructor.
    */
@@ -83,6 +85,18 @@ protected:
   ImageVisualShaderFactory& operator=(const ImageVisualShaderFactory& rhs);
 
 private:
+  /**
+   * @brief Cached information whether native image should change fragment shader.
+   * Default it is ChangeFragmentShader::UNDECIDED.
+   * If we have any chance to check native image source apply fragment shader,
+   * this vaule will be changed one of these : ChangeFragmentShader::DONT_CHANGE or ChangeFragmentShader::NEED_CHANGE
+   *
+   * After result cached, this value will not be changed.
+   *
+   * If value is DONT_CHANGE, ImageVisualShaderFactory::GetShader never call ApplyNativeFragmentShader.
+   * Else, ImageVisualShaderFactory::GetShader will call ApplyNativeFragmentShader if native image source texture come.
+   */
+  ImageVisualShaderFeature::ChangeFragmentShader::Type mFragmentShaderNeedChange : 3;
 };
 
 } // namespace Internal