[Tizen] Apply precompile shader
[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/image-visual-shader-feature-builder.h>
24 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
25 #include <string_view>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33 /**
34  * ImageVisualShaderFactory is an object that provides and shares shaders between image visuals
35  */
36 class ImageVisualShaderFactory
37 {
38 public:
39   /**
40    * @brief Constructor
41    */
42   ImageVisualShaderFactory();
43
44   /**
45    * @brief Destructor
46    */
47   ~ImageVisualShaderFactory();
48
49   /**
50    * @brief Get the standard image rendering shader.
51    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
52    * @param[in] featureBuilder Collection of current image shader's features
53    * @return The standard image rendering shader with features.
54    */
55   Shader GetShader(VisualFactoryCache& factoryCache, ImageVisualShaderFeatureBuilder& featureBuilder);
56
57   /**
58    * @brief Request the default vertex shader source.
59    * @return The default vertex shader source.
60    */
61   std::string_view GetVertexShaderSource();
62
63   /**
64    * @brief Request the default fragment shader source.
65    * @return The default fragment shader source.
66    */
67   std::string_view GetFragmentShaderSource();
68
69   /**
70    * @brief Get the default shader source.
71    * @param[in] shaders shaderList for precompile
72    */
73   void GetPrecompiledShader(RawShaderData& shaders);
74
75 protected:
76   /**
77    * Undefined copy constructor.
78    */
79   ImageVisualShaderFactory(const ImageVisualShaderFactory&);
80
81   /**
82    * Undefined assignment operator.
83    */
84   ImageVisualShaderFactory& operator=(const ImageVisualShaderFactory& rhs);
85
86 private:
87   /**
88    * @brief Cached information whether native image should change fragment shader.
89    * Default it is ChangeFragmentShader::UNDECIDED.
90    * If we have any chance to check native image source apply fragment shader,
91    * this vaule will be changed one of these : ChangeFragmentShader::DONT_CHANGE or ChangeFragmentShader::NEED_CHANGE
92    *
93    * After result cached, this value will not be changed.
94    *
95    * If value is DONT_CHANGE, ImageVisualShaderFactory::GetShader never call ApplyNativeFragmentShader.
96    * Else, ImageVisualShaderFactory::GetShader will call ApplyNativeFragmentShader if native image source texture come.
97    */
98   ImageVisualShaderFeature::ChangeFragmentShader::Type mFragmentShaderNeedChange : 3;
99 };
100
101 } // namespace Internal
102
103 } // namespace Toolkit
104
105 } // namespace Dali
106
107 #endif // DALI_TOOLKIT_IMAGE_VISUAL_SHADER_FACTORY_H