2ca0a45806c3a5af6bc1d60337eb2d217169fd43
[platform/core/uifw/dali-core.git] / dali / internal / render / data-providers / render-data-provider.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H
3
4 /*
5  * Copyright (c) 2020 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
21 #include <dali/public-api/common/vector-wrapper.h>
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/internal/render/data-providers/node-data-provider.h>
24 #include <dali/internal/render/data-providers/uniform-map-data-provider.h>
25 #include <dali/internal/render/renderers/render-sampler.h>
26 #include <dali/internal/render/renderers/render-texture.h>
27 #include <dali/internal/update/common/animatable-property.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33
34 struct BlendingOptions;
35
36 namespace SceneGraph
37 {
38 class Shader;
39 class Renderer;
40
41 /**
42  * Wraps all the data providers for the renderer. This allows the
43  * individual providers to change connections in the update thread without affecting
44  * the current render. It essentially provides double buffering of the
45  * provider accessor through the message system. It does not take ownership
46  * of any objects.
47  */
48 class RenderDataProvider
49 {
50 public:
51   typedef std::vector< Render::Sampler* > Samplers;
52
53   /**
54    * Constructor.
55    * The RendererAttachment that creates this object will initialize the members
56    * directly.
57    */
58   RenderDataProvider( AnimatableProperty< float >& opacity );
59
60   /**
61    * Destructor
62    */
63   ~RenderDataProvider();
64
65 public:
66
67   /**
68    * Set the uniform map data provider
69    * @param[in] uniformMapDataProvider The uniform map data provider
70    */
71   void SetUniformMap(const UniformMapDataProvider& uniformMapDataProvider);
72
73   /**
74    * Get the uniform map data provider
75    */
76   const UniformMapDataProvider& GetUniformMap() const;
77
78   /**
79    * Set the shader data provider
80    * @param[in] shader The shader data provider
81    */
82   void SetShader( Shader& shader );
83
84   /**
85    * Returns the shader
86    * @return The shader
87    */
88   Shader& GetShader() const;
89
90   /**
91    * Returns the list of samplers
92    * @return The list of samplers
93    */
94   Samplers& GetSamplers();
95
96   /**
97    * Returns the list of Textures
98    * @return The list of Textures
99    */
100   std::vector<Render::Texture*>& GetTextures();
101
102   /**
103    * Get the opacity
104    * @return The opacity
105    */
106   float GetOpacity( BufferIndex bufferIndex );
107
108 private:
109
110   const UniformMapDataProvider*    mUniformMapDataProvider;
111   Shader*                          mShader;
112   std::vector<Render::Texture*>    mTextures;
113   Samplers                         mSamplers;
114   AnimatableProperty< float >&     mOpacity;
115
116   // Give Renderer access to our private data to reduce copying vectors on construction.
117   friend class Renderer;
118 };
119
120 } // SceneGraph
121 } // Internal
122 } // Dali
123
124 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H