[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image-visual-shader-factory.h
1 #ifndef DALI_TOOLKIT_IMAGE_VISUAL_SHADER_FACTORY_H
2 #define DALI_TOOLKIT_IMAGE_VISUAL_SHADER_FACTORY_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21
22 // INTERNAL INCLUDES
23 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
24 #include <dali-toolkit/internal/visuals/image-visual-shader-feature-builder.h>
25 #include <string_view>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33
34 /**
35  * ImageVisualShaderFactory is an object that provides and shares shaders between image visuals
36  */
37 class ImageVisualShaderFactory
38 {
39 public:
40   /**
41    * @brief Constructor
42    */
43   ImageVisualShaderFactory();
44
45   /**
46    * @brief Destructor
47    */
48   ~ImageVisualShaderFactory();
49
50   /**
51    * @brief Get the standard image rendering shader.
52    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
53    * @param[in] featureBuilder Collection of current image shader's features
54    * @return The standard image rendering shader with features.
55    */
56   Shader GetShader(VisualFactoryCache& factoryCache, ImageVisualShaderFeatureBuilder& featureBuilder);
57
58   /**
59    * @brief Request the default vertex shader source.
60    * @return The default vertex shader source.
61    */
62   std::string_view GetVertexShaderSource();
63
64   /**
65    * @brief Request the default fragment shader source.
66    * @return The default fragment shader source.
67    */
68   std::string_view GetFragmentShaderSource();
69
70   /**
71    * @brief Get the default shader source.
72    * @param[in] shaders shaderList for precompile
73    */
74   void GetPreCompiledShader(RawShaderData& shaders);
75
76 protected:
77   /**
78    * Undefined copy constructor.
79    */
80   ImageVisualShaderFactory(const ImageVisualShaderFactory&);
81
82   /**
83    * Undefined assignment operator.
84    */
85   ImageVisualShaderFactory& operator=(const ImageVisualShaderFactory& rhs);
86
87 private:
88   /**
89    * @brief Cached information whether native image should change fragment shader.
90    * Default it is ChangeFragmentShader::UNDECIDED.
91    * If we have any chance to check native image source apply fragment shader,
92    * this vaule will be changed one of these : ChangeFragmentShader::DONT_CHANGE or ChangeFragmentShader::NEED_CHANGE
93    *
94    * After result cached, this value will not be changed.
95    *
96    * If value is DONT_CHANGE, ImageVisualShaderFactory::GetShader never call ApplyNativeFragmentShader.
97    * Else, ImageVisualShaderFactory::GetShader will call ApplyNativeFragmentShader if native image source texture come.
98    */
99   ImageVisualShaderFeature::ChangeFragmentShader::Type mFragmentShaderNeedChange : 3;
100 };
101
102 } // namespace Internal
103
104 } // namespace Toolkit
105
106 } // namespace Dali
107
108 #endif // DALI_TOOLKIT_IMAGE_VISUAL_SHADER_FACTORY_H