Fixing non-ecore X11 build
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / x11 / native-image-source-queue-impl-x.h
1 #ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
2 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
3
4 /*
5  * Copyright (c) 2024 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
23 // INTERNAL INCLUDES
24 #include <dali/internal/imaging/common/native-image-source-queue-impl.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 namespace Adaptor
31 {
32 class EglGraphics;
33 class EglImageExtensions;
34
35 /**
36  * Dali internal NativeImageSourceQueue.
37  */
38 class NativeImageSourceQueueX : public Internal::Adaptor::NativeImageSourceQueue
39 {
40 public:
41   /**
42    * Create a new NativeImageSourceQueueX internally.
43    * Depending on hardware the width and height may have to be a power of two.
44    * @param[in] queueCount The number of queue of the image. If it is 0, will use default.
45    * @param[in] width The width of the image.
46    * @param[in] height The height of the image.
47    * @param[in] colorFormat The color format of the image.
48    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
49    * @return A smart-pointer to a newly allocated image.
50    */
51   static NativeImageSourceQueueX* New(uint32_t queueCount, uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorFormat colorFormat, Any nativeImageSourceQueue);
52
53   /**
54    * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
55    */
56   Any GetNativeImageSourceQueue() const override;
57
58   /**
59    * @copydoc Dali::NativeImageSourceQueue::SetSize
60    */
61   void SetSize(uint32_t width, uint32_t height) override;
62
63   /**
64    * @copydoc Dali::NativeImageSourceQueue::IgnoreSourceImage
65    */
66   void IgnoreSourceImage() override;
67
68   /**
69    * @copydoc Dali::NativeImageSourceQueue::CanDequeueBuffer
70    */
71   bool CanDequeueBuffer() override;
72
73   /**
74    * @copydoc Dali::NativeImageSourceQueue::DequeueBuffer
75    */
76   uint8_t* DequeueBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
77
78   /**
79    * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
80    */
81   bool EnqueueBuffer(uint8_t* buffer) override;
82
83   /**
84    * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
85    */
86   void FreeReleasedBuffers() override;
87
88   /**
89    * destructor
90    */
91   ~NativeImageSourceQueueX() override;
92
93   /**
94    * @copydoc Dali::NativeImageInterface::CreateResource()
95    */
96   bool CreateResource() override;
97
98   /**
99    * @copydoc Dali::NativeImageInterface::DestroyResource()
100    */
101   void DestroyResource() override;
102
103   /**
104    * @copydoc Dali::NativeImageInterface::TargetTexture()
105    */
106   uint32_t TargetTexture() override;
107
108   /**
109    * @copydoc Dali::NativeImageInterface::PrepareTexture()
110    */
111   void PrepareTexture() override;
112
113   /**
114    * @copydoc Dali::NativeImageSourceQueue::GetQueueCount
115    */
116   uint32_t GetQueueCount() const override
117   {
118     return mQueueCount;
119   }
120
121   /**
122    * @copydoc Dali::NativeImageInterface::GetWidth()
123    */
124   uint32_t GetWidth() const override
125   {
126     return mWidth;
127   }
128
129   /**
130    * @copydoc Dali::NativeImageInterface::GetHeight()
131    */
132   uint32_t GetHeight() const override
133   {
134     return mHeight;
135   }
136
137   /**
138    * @copydoc Dali::NativeImageInterface::RequiresBlending()
139    */
140   bool RequiresBlending() const override
141   {
142     return true;
143   }
144
145   /**
146    * @copydoc Dali::NativeImageInterface::GetTextureTarget()
147    */
148   int GetTextureTarget() const override;
149
150   /**
151    * @copydoc Dali::NativeImageInterface::ApplyNativeFragmentShader()
152    */
153   bool ApplyNativeFragmentShader(std::string& shader) override;
154
155   /**
156    * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
157    */
158   const char* GetCustomSamplerTypename() const override;
159
160   /**
161    * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
162    */
163   Any GetNativeImageHandle() const override;
164
165   /**
166    * @copydoc Dali::NativeImageInterface::SourceChanged()
167    */
168   bool SourceChanged() const override;
169
170   /**
171    * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
172    */
173   Rect<uint32_t> GetUpdatedArea() override
174   {
175     return Rect<uint32_t>{0, 0, mWidth, mHeight};
176   }
177
178   /**
179    * @copydoc Dali::NativeImageInterface::GetExtension()
180    */
181   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
182   {
183     return nullptr;
184   }
185
186 private:
187   /**
188    * Private constructor; @see NativeImageSourceQueue::New()
189    * @param[in] queueCount The number of queue of the image. If it is 0, will use default.
190    * @param[in] width The width of the image.
191    * @param[in] height The height of the image.
192    * @param[in] colorFormat The color format of the image.
193    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
194    */
195   NativeImageSourceQueueX(uint32_t queueCount, uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorFormat colorFormat, Any nativeImageSourceQueue);
196
197 private:
198   uint32_t mQueueCount; ///< queue count
199   uint32_t mWidth;      ///< image width
200   uint32_t mHeight;     ///< image height
201 };
202
203 } // namespace Adaptor
204
205 } // namespace Internal
206
207 } // namespace Dali
208
209 #endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H