Add API for NativeImageQueue
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / native-image-source-queue.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/imaging/common/native-image-source-factory.h>
23 #include <dali/internal/imaging/common/native-image-source-queue-impl.h>
24
25 namespace Dali
26 {
27 NativeImageSourceQueuePtr NativeImageSourceQueue::New(uint32_t width, uint32_t height, ColorDepth depth)
28 {
29   Any                       empty;
30   NativeImageSourceQueuePtr image = new NativeImageSourceQueue(width, height, depth, empty);
31   if(image->mImpl)
32   {
33     return image;
34   }
35   return nullptr;
36 }
37
38 NativeImageSourceQueuePtr NativeImageSourceQueue::New(Any nativeImageSourceQueue)
39 {
40   NativeImageSourceQueuePtr image = new NativeImageSourceQueue(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSourceQueue);
41   if(image->mImpl)
42   {
43     return image;
44   }
45   return nullptr;
46 }
47
48 Any NativeImageSourceQueue::GetNativeImageSourceQueue()
49 {
50   return mImpl->GetNativeImageSourceQueue();
51 }
52
53 void NativeImageSourceQueue::SetSize(uint32_t width, uint32_t height)
54 {
55   return mImpl->SetSize(width, height);
56 }
57
58 void NativeImageSourceQueue::IgnoreSourceImage()
59 {
60   mImpl->IgnoreSourceImage();
61 }
62
63 bool NativeImageSourceQueue::CanDequeueBuffer()
64 {
65   return mImpl->CanDequeueBuffer();
66 }
67
68 uint8_t* NativeImageSourceQueue::DequeueBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
69 {
70   return mImpl->DequeueBuffer(width, height, stride);
71 }
72
73 bool NativeImageSourceQueue::EnqueueBuffer(uint8_t* buffer)
74 {
75   return mImpl->EnqueueBuffer(buffer);
76 }
77
78 bool NativeImageSourceQueue::CreateResource()
79 {
80   return mImpl->CreateResource();
81 }
82
83 void NativeImageSourceQueue::DestroyResource()
84 {
85   mImpl->DestroyResource();
86 }
87
88 uint32_t NativeImageSourceQueue::TargetTexture()
89 {
90   return mImpl->TargetTexture();
91 }
92
93 void NativeImageSourceQueue::PrepareTexture()
94 {
95   mImpl->PrepareTexture();
96 }
97
98 uint32_t NativeImageSourceQueue::GetWidth() const
99 {
100   return mImpl->GetWidth();
101 }
102
103 uint32_t NativeImageSourceQueue::GetHeight() const
104 {
105   return mImpl->GetHeight();
106 }
107
108 bool NativeImageSourceQueue::RequiresBlending() const
109 {
110   return mImpl->RequiresBlending();
111 }
112
113 int NativeImageSourceQueue::GetTextureTarget() const
114 {
115   return mImpl->GetTextureTarget();
116 }
117
118 const char* NativeImageSourceQueue::GetCustomFragmentPrefix() const
119 {
120   return mImpl->GetCustomFragmentPrefix();
121 }
122
123 bool NativeImageSourceQueue::ApplyNativeFragmentShader(std::string& shader)
124 {
125   return mImpl->ApplyNativeFragmentShader(shader);
126 }
127
128 const char* NativeImageSourceQueue::GetCustomSamplerTypename() const
129 {
130   return mImpl->GetCustomSamplerTypename();
131 }
132
133 Any NativeImageSourceQueue::GetNativeImageHandle() const
134 {
135   return mImpl->GetNativeImageHandle();
136 }
137
138 bool NativeImageSourceQueue::SourceChanged() const
139 {
140   return mImpl->SourceChanged();
141 }
142
143 NativeImageInterface::Extension* NativeImageSourceQueue::GetExtension()
144 {
145   return mImpl->GetNativeImageInterfaceExtension();
146 }
147
148 NativeImageSourceQueue::NativeImageSourceQueue(uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue)
149 {
150   auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
151   mImpl        = factory->CreateNativeImageSourceQueue(width, height, depth, nativeImageSourceQueue);
152 }
153
154 NativeImageSourceQueue::~NativeImageSourceQueue()
155 {
156 }
157
158 } // namespace Dali