Merge "Add the APIs of webview settings" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-context.h
1 #ifndef DALI_GRAPHICS_GLES_CONTEXT_H
2 #define DALI_GRAPHICS_GLES_CONTEXT_H
3
4 /*
5  * Copyright (c) 2021 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/graphics-api/graphics-command-buffer.h>
22 #include "gles-graphics-types.h"
23
24 namespace Dali::Graphics
25 {
26 class EglGraphicsController;
27 namespace GLES
28 {
29 class Pipeline;
30 class Texture;
31
32 /**
33  * @brief Context represents single GLES context
34  */
35 class Context
36 {
37 public:
38   explicit Context(EglGraphicsController& controller);
39
40   ~Context();
41
42   /**
43    * @brief Flushes the context
44    *
45    * Flushes the context by issuing GL calls to set the required
46    * state.
47    *
48    * @param[in] reset If true then state is reset unconditionally
49    */
50   void Flush(bool reset, const GLES::DrawCallDescriptor& drawCall);
51
52   /**
53    * @brief Returns context Id
54    * @return
55    */
56   uint32_t GetContextId() const
57   {
58     return 0;
59   }
60
61   /**
62    * @brief Binds textures to the context
63    *
64    * Bindings are merged, they are resolved at later time
65    * when the draw call is issued. Then the texture binding
66    * slots (GL active texture binding) are enabled/disabled accordingly
67    * to the uniform layout.
68    *
69    * @param[in] bindings List of bindings
70    *
71    */
72   void BindTextures(const std::vector<Graphics::TextureBinding>& bindings);
73
74   /**
75    * @brief Vertex buffers to bind
76    *
77    * The bindings are taken from a command buffer being
78    * currently processed and copied into the local storage.
79    */
80
81   void BindVertexBuffers(const std::vector<GLES::VertexBufferBindingDescriptor>& bindings);
82
83   /**
84    * @brief Binds index buffer
85    *
86    * @param indexBufferBinding
87    */
88   void BindIndexBuffer(const IndexBufferBindingDescriptor& indexBufferBinding);
89
90   /**
91    * @brief Binds pipeline to the context
92    * @param newPipeline
93    */
94   void BindPipeline(const GLES::Pipeline* newPipeline);
95
96   /**
97    * @brief Binds uniform buffers to the context
98    *
99    * @param[in] uboBindings real UBO binfins
100    * @param[in] standaloneBindings emulated (legacy) UBO object
101    */
102   void BindUniformBuffers(const std::vector<UniformBufferBindingDescriptor>& uboBindings, const UniformBufferBindingDescriptor& standaloneBindings);
103
104   /**
105    * @brief Resolves blend state on the currently attached pipeline
106    */
107   void ResolveBlendState();
108
109   /**
110    * @brief Resolves rasterization state on the currently attached pipeline
111    */
112   void ResolveRasterizationState();
113
114   /**
115    * @brief Resolves uniform buffers and binds data to the pipeline
116    */
117   void ResolveUniformBuffers();
118
119   /**
120    * @brief Special usecase for legacy shaders, called by ResolveUniformBuffers()
121    */
122   void ResolveStandaloneUniforms();
123
124 private:
125   /**
126    * @brief Clear current state
127    */
128   void ClearState();
129
130 private:
131   struct Impl;
132   std::unique_ptr<Impl> mImpl;
133 };
134 } // namespace GLES
135 } // namespace Dali::Graphics
136 #endif //DALI_GRAPHICS_GLES_CONTEXT_H