Initial refactoring of graphics interface
[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    * Inform graphics interface that this is the first frame after a resume.
90    */
91   virtual void SetFirstFrameAfterResume() = 0;
92
93   /**
94    * Shut down the graphics implementation
95    */
96   virtual void Shutdown() = 0;
97
98   /**
99    * Destroy the Graphics implementation
100    */
101   virtual void Destroy() = 0;
102
103   /**
104    * Get whether the depth buffer is required
105    * @return TRUE if the depth buffer is required
106    */
107   Integration::DepthBufferAvailable& GetDepthBufferRequired()
108   {
109     return mDepthBufferRequired;
110   };
111
112   /**
113    * Get whether the stencil buffer is required
114    * @return TRUE if the stencil buffer is required
115    */
116   Integration::StencilBufferAvailable GetStencilBufferRequired()
117   {
118     return mStencilBufferRequired;
119   };
120
121   /**
122    * Get whether the stencil buffer is required
123    * @return TRUE if the stencil buffer is required
124    */
125   Integration::PartialUpdateAvailable GetPartialUpdateRequired()
126   {
127     return mPartialUpdateRequired;
128   };
129
130   /**
131    * @return true if advanced blending options are supported
132    */
133   virtual bool IsAdvancedBlendEquationSupported() = 0;
134
135   /**
136    * @return true if graphics subsystem is initialized
137    */
138   virtual bool IsInitialized() = 0;
139
140   /**
141    * @return true if a separate resource context is supported
142    */
143   virtual bool IsResourceContextSupported() = 0;
144
145   /**
146    * @return the maximum texture size
147    */
148   virtual uint32_t GetMaxTextureSize() = 0;
149
150   /**
151    * @return the version number of the shader language
152    */
153   virtual uint32_t GetShaderLanguageVersion() = 0;
154
155   /**
156    * Store cached configurations
157    */
158   virtual void CacheConfigurations(ConfigurationManager& configurationManager) = 0;
159
160 protected:
161   Integration::DepthBufferAvailable   mDepthBufferRequired;   ///< Whether the depth buffer is required
162   Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
163   Integration::PartialUpdateAvailable mPartialUpdateRequired; ///< Whether the partial update is required
164 };
165
166 } // namespace Adaptor
167
168 } // namespace Internal
169
170 } // namespace Dali
171
172 #endif // DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H