Invalidate depth and stencil buffers after finishing the rendering
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / common / graphics-interface.h
1 #ifndef DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H
2 #define DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_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 // INTERNAL INCLUDES
22 #include <dali/graphics-api/graphics-controller.h>
23 #include <dali/integration-api/core-enumerations.h>
24 #include <dali/internal/system/common/environment-options.h>
25
26 namespace Dali
27 {
28 class RenderSurfaceInterface;
29
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class ConfigurationManager;
35
36 /**
37  * Factory interface for creating Graphics Factory implementation
38  */
39 class GraphicsInterface
40 {
41 public:
42   /**
43    * Constructor
44    */
45   GraphicsInterface()
46   : mDepthBufferRequired(Integration::DepthBufferAvailable::FALSE),
47     mStencilBufferRequired(Integration::StencilBufferAvailable::FALSE),
48     mPartialUpdateRequired(Integration::PartialUpdateAvailable::FALSE){};
49
50   /**
51    * Destructor
52    */
53   virtual ~GraphicsInterface() = default;
54
55   /**
56    * Returns controller object
57    * @return
58    */
59   virtual Dali::Graphics::Controller& GetController() = 0;
60
61   /**
62    * Initialize the graphics subsystem, configured from environment
63    */
64   virtual void Initialize() = 0;
65
66   /**
67    * Initialize the graphics subsystem, providing explicit parameters.
68    *
69    * @param[in] depth True if depth buffer is required
70    * @param[in] stencil True if stencil buffer is required
71    * @param[in] partialRendering True if partial rendering is required
72    * @param[in] msaa level of anti-aliasing required (-1 = off)
73    */
74   virtual void Initialize(bool depth, bool stencil, bool partialRendering, int msaa) = 0;
75
76   /**
77    * Configure the graphics surface
78    *
79    * @param[in] surface The surface to configure, or NULL if not present
80    */
81   virtual void ConfigureSurface(Dali::RenderSurfaceInterface* surface) = 0;
82
83   /**
84    * Activate the resource context
85    */
86   virtual void ActivateResourceContext() = 0;
87
88   /**
89    * Activate the surface context
90    *
91    * @param[in] surface The surface whose context to be switched to.
92    */
93   virtual void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) = 0;
94
95   /**
96    * Inform graphics interface that all the surfaces have been rendered.
97    *
98    * @note This should not be called if uploading resource only without rendering any surface.
99    */
100   virtual void PostRender() = 0;
101
102   /**
103    * Inform graphics interface that this is the first frame after a resume.
104    */
105   virtual void SetFirstFrameAfterResume() = 0;
106
107   /**
108    * Shut down the graphics implementation
109    */
110   virtual void Shutdown() = 0;
111
112   /**
113    * Destroy the Graphics implementation
114    */
115   virtual void Destroy() = 0;
116
117   /**
118    * Get whether the depth buffer is required
119    * @return TRUE if the depth buffer is required
120    */
121   Integration::DepthBufferAvailable& GetDepthBufferRequired()
122   {
123     return mDepthBufferRequired;
124   };
125
126   /**
127    * Get whether the stencil buffer is required
128    * @return TRUE if the stencil buffer is required
129    */
130   Integration::StencilBufferAvailable GetStencilBufferRequired()
131   {
132     return mStencilBufferRequired;
133   };
134
135   /**
136    * Get whether the stencil buffer is required
137    * @return TRUE if the stencil buffer is required
138    */
139   Integration::PartialUpdateAvailable GetPartialUpdateRequired()
140   {
141     return mPartialUpdateRequired;
142   };
143
144   /**
145    * @return true if advanced blending options are supported
146    */
147   virtual bool IsAdvancedBlendEquationSupported() = 0;
148
149   /**
150    * @return true if graphics subsystem is initialized
151    */
152   virtual bool IsInitialized() = 0;
153
154   /**
155    * @return true if a separate resource context is supported
156    */
157   virtual bool IsResourceContextSupported() = 0;
158
159   /**
160    * @return the maximum texture size
161    */
162   virtual uint32_t GetMaxTextureSize() = 0;
163
164   /**
165    * @return the version number of the shader language
166    */
167   virtual uint32_t GetShaderLanguageVersion() = 0;
168
169   /**
170    * Store cached configurations
171    */
172   virtual void CacheConfigurations(ConfigurationManager& configurationManager) = 0;
173
174 protected:
175   Integration::DepthBufferAvailable   mDepthBufferRequired;   ///< Whether the depth buffer is required
176   Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
177   Integration::PartialUpdateAvailable mPartialUpdateRequired; ///< Whether the partial update is required
178 };
179
180 } // namespace Adaptor
181
182 } // namespace Internal
183
184 } // namespace Dali
185
186 #endif // DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H