Removing rendering backend
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / shader-cache.h
1 #ifndef DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_H
2 #define DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_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 #include <dali/integration-api/graphics/graphics.h>
21 #include <dali/graphics-api/graphics-api-accessor.h>
22 #include <dali/graphics-api/graphics-api-shader.h>
23 #include <dali/graphics-api/graphics-api-shader-details.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace SceneGraph
30 {
31
32 /**
33  * Caches graphics shaders as they are created by SceneGraph::Shader.
34  */
35 struct ShaderCache
36 {
37   struct Item
38   {
39     Item() = default;
40     ~Item() = default;
41     Dali::Graphics::API::Accessor<Dali::Graphics::API::Shader> shader{ nullptr };
42     Dali::Graphics::API::ShaderDetails::ShaderSource           vertexSource{""};
43     Dali::Graphics::API::ShaderDetails::ShaderSource           fragmentSource{""};
44   };
45
46   /**
47    * Constructor
48    *
49    * @param[in] controller The graphics controller
50    */
51   explicit ShaderCache( Dali::Graphics::API::Controller& controller );
52
53   /**
54    * Get a shader from it's source code
55    */
56   Dali::Graphics::API::Accessor<Dali::Graphics::API::Shader> GetShader(
57     const Dali::Graphics::API::ShaderDetails::ShaderSource& vsh,
58     const Dali::Graphics::API::ShaderDetails::ShaderSource& fsh );
59
60 private:
61   std::vector<Item> mItems;
62   Dali::Graphics::API::Controller& mController;
63 };
64
65 } // namespace SceneGraph
66 } // namespace Internal
67 } // namespace Dali
68
69 #endif //DALI_INTERNAL_UPDATE_RENDERING_SHADER_CACHE_H