410395c6ec01d15ba1fbfa52ed6dcf39903b68f6
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-graphics.h
1 #ifndef DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
2 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
3
4 /*
5  * Copyright (c) 2019 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/integration-api/adaptor-framework/egl-interface.h>
23 #include <dali/internal/graphics/common/egl-image-extensions.h>
24 #include <dali/internal/graphics/common/graphics-interface.h>
25 #include <dali/internal/graphics/gles/gl-implementation.h>
26 #include <dali/internal/graphics/gles/gl-proxy-implementation.h>
27 #include <dali/internal/graphics/gles/egl-context-helper-implementation.h>
28 #include <dali/internal/graphics/gles/egl-implementation.h>
29 #include <dali/internal/graphics/gles/egl-sync-implementation.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 class EglGraphics : public GraphicsInterface
41 {
42 public:
43
44   /**
45    * Constructor
46    */
47   EglGraphics();
48
49   /**
50    * Destructor
51    */
52   virtual ~EglGraphics();
53
54   /**
55    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
56    */
57   void Initialize( EnvironmentOptions* environmentOptions ) override;
58
59   /**
60    * Creates the graphics interface for EGL
61    * @return The graphics interface for EGL
62    */
63   EglInterface* Create();
64
65   /**
66    * Set gles version
67    * Default version is gles 3.0
68    */
69   void SetGlesVersion( const int32_t glesVersion );
70
71   /**
72    * Set whether the surfaceless context is supported
73    * @param[in] isSupported Whether the surfaceless context is supported
74    */
75   void SetIsSurfacelessContextSupported( const bool isSupported );
76
77   /**
78    * Gets the GL abstraction
79    * @return The GL abstraction
80    */
81   Integration::GlAbstraction& GetGlAbstraction() const;
82
83   /**
84    * Gets the implementation of EGL
85    * @return The implementation of EGL
86    */
87   EglImplementation& GetEglImplementation() const;
88
89   /**
90    * Gets the graphics interface for EGL
91    * @return The graphics interface for EGL
92    */
93   EglInterface& GetEglInterface() const;
94
95   /**
96    * @copydoc Dali::Integration::GlAbstraction& GetGlesInterface()
97    */
98   GlImplementation& GetGlesInterface();
99
100   /**
101    * Gets the implementation of GlSyncAbstraction for EGL.
102    * @return The implementation of GlSyncAbstraction for EGL.
103    */
104   EglSyncImplementation& GetSyncImplementation();
105
106   /**
107    * Gets the implementation of GlContextHelperAbstraction for EGL.
108    * @return The implementation of GlContextHelperAbstraction for EGL.
109    */
110   EglContextHelperImplementation& GetContextHelperImplementation();
111
112   /**
113    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
114    */
115   Integration::DepthBufferAvailable& GetDepthBufferRequired();
116
117   /**
118    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetStencilBufferRequired()
119    */
120   Integration::StencilBufferAvailable GetStencilBufferRequired();
121
122   /**
123    * Gets the EGL image extension
124    * @return The EGL image extension
125    */
126   EglImageExtensions* GetImageExtensions();
127
128   /**
129    * Sets fixed damaged areas for partial rendering. This overrides automatic partial rendering.
130    */
131   void SetDamagedAreas( std::vector<Dali::Rect<int>>& areas );
132
133   /**
134    * Instructs egl implementation to do full swap regardless of stored data, resets the data.
135    */
136   void SetFullSwapNextFrame();
137
138   /**
139    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
140    */
141   void Destroy() override;
142
143 private:
144   // Eliminate copy and assigned operations
145   EglGraphics(const EglGraphics& rhs) = delete;
146   EglGraphics& operator=(const EglGraphics& rhs) = delete;
147
148
149 private:
150   std::unique_ptr< GlImplementation > mGLES;                    ///< GL implementation
151   std::unique_ptr< EglImplementation > mEglImplementation;      ///< EGL implementation
152   std::unique_ptr< EglImageExtensions > mEglImageExtensions;    ///< EGL image extension
153   std::unique_ptr< EglSyncImplementation > mEglSync;            ///< GlSyncAbstraction implementation for EGL
154   std::unique_ptr< EglContextHelperImplementation > mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
155
156   int mMultiSamplingLevel;                                      ///< The multiple sampling level
157 };
158
159 } // namespace Adaptor
160
161 } // namespace Internal
162
163 } // namespace Dali
164
165 #endif // DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H