Add NativeImageSurface
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / native-image-surface.h
1 #ifndef DALI_NATIVE_IMAGE_SURFACE_H
2 #define DALI_NATIVE_IMAGE_SURFACE_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/any.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class NativeImageSurface;
35 }
36 } // namespace Internal
37
38 class NativeImageSurface;
39
40 /**
41  * @brief Pointer to Dali::NativeImageSurface.
42  */
43 typedef Dali::IntrusivePtr<Dali::NativeImageSurface> NativeImageSurfacePtr;
44
45 /**
46  * Native image surface is a surface that GL can render.
47  * The surface is not a window, it's like a pixmap.
48  */
49 class DALI_ADAPTOR_API NativeImageSurface : public RefObject
50 {
51 public:
52   /**
53    * Creates a NativeImageSurface
54    *
55    * @param [in] queue the native image source queue handle
56    * @return A smart-pointer to a newly allocated native image surface
57    */
58   static NativeImageSurfacePtr New(Dali::NativeImageSourceQueuePtr queue);
59
60   /**
61    * @brief Gets the native renderable handle
62    * @return The native renderable handle
63    */
64   Any GetNativeRenderable();
65
66   /**
67    * @brief Initializes the graphics resources
68    */
69   void InitializeGraphics();
70
71   /**
72    * @brief Terminate the graphics resources
73    */
74   void TerminateGraphics();
75
76   /**
77    * @brief Invoked by render thread before rendering
78    */
79   void PreRender();
80
81   /**
82    * @brief Invoked by render thread after rendering
83    */
84   void PostRender();
85
86   /**
87    * @brief Checks to render
88    */
89   bool CanRender();
90
91   /**
92    * @brief Sets Graphics configuration to the surface
93    *
94    * @param[in] depth the flag of depth buffer. If true is set, 24bit depth buffer is enabled.
95    * @param[in] stencil the flag of stencil. it true is set, 8bit stencil buffer is enabled.
96    * @param[in] msaa the bit of msaa.
97    * @param[in] version the GLES version.
98    * @return True if the config exists, false otherwise.
99    */
100   bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version);
101
102 private:
103   /// @cond internal
104   /**
105    * @brief Private constructor.
106    * @param[in] queue the native image source queue handle
107    */
108   DALI_INTERNAL NativeImageSurface(Dali::NativeImageSourceQueuePtr queue);
109
110   /**
111    * @brief A reference counted object may only be deleted by calling Unreference().
112    */
113   DALI_INTERNAL ~NativeImageSurface() override;
114
115   /**
116    * @brief Undefined copy constructor.
117    *
118    * This avoids accidental calls to a default copy constructor.
119    * @param[in] nativeImageSurface A reference to the object to copy
120    */
121   DALI_INTERNAL NativeImageSurface(const NativeImageSurface& nativeImageSurface);
122
123   /**
124    * @brief Undefined assignment operator.
125    *
126    * This avoids accidental calls to a default assignment operator.
127    * @param[in] rhs A reference to the object to copy
128    */
129   DALI_INTERNAL NativeImageSurface& operator=(const NativeImageSurface& rhs);
130   /// @endcond
131
132 private:
133   std::unique_ptr<Internal::Adaptor::NativeImageSurface> mImpl; ///< Implementation pointer
134 };
135
136 } // namespace Dali
137
138 #endif // DALI_NATIVE_IMAGE_SURFACE_H