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