2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/adaptor-framework/native-image-source.h>
22 #include <dali/public-api/object/any.h>
25 #include <dali/internal/imaging/common/native-image-source-factory.h>
26 #include <dali/internal/imaging/common/native-image-source-impl.h>
30 NativeImageSourcePtr NativeImageSource::New(uint32_t width, uint32_t height, ColorDepth depth)
33 NativeImageSourcePtr image = new NativeImageSource(width, height, depth, empty);
37 Any NativeImageSource::GetNativeImageSource()
39 return mImpl->GetNativeImageSource();
42 NativeImageSourcePtr NativeImageSource::New(Any nativeImageSource)
44 NativeImageSourcePtr image = new NativeImageSource(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSource);
48 bool NativeImageSource::GetPixels(std::vector<uint8_t>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const
50 return mImpl->GetPixels(pixbuf, width, height, pixelFormat);
53 bool NativeImageSource::EncodeToFile(const std::string& filename) const
55 return mImpl->EncodeToFile(filename);
58 void NativeImageSource::SetSource(Any source)
60 mImpl->SetSource(source);
63 bool NativeImageSource::IsColorDepthSupported(ColorDepth colorDepth)
65 return mImpl->IsColorDepthSupported(colorDepth);
68 bool NativeImageSource::CreateResource()
70 return mImpl->CreateResource();
73 void NativeImageSource::DestroyResource()
75 mImpl->DestroyResource();
78 uint32_t NativeImageSource::TargetTexture()
80 return mImpl->TargetTexture();
83 void NativeImageSource::PrepareTexture()
85 mImpl->PrepareTexture();
88 uint32_t NativeImageSource::GetWidth() const
90 return mImpl->GetWidth();
93 uint32_t NativeImageSource::GetHeight() const
95 return mImpl->GetHeight();
98 bool NativeImageSource::RequiresBlending() const
100 return mImpl->RequiresBlending();
103 int NativeImageSource::GetTextureTarget() const
105 return mImpl->GetTextureTarget();
108 bool NativeImageSource::ApplyNativeFragmentShader(std::string& shader)
110 return mImpl->ApplyNativeFragmentShader(shader);
113 const char* NativeImageSource::GetCustomSamplerTypename() const
115 return mImpl->GetCustomSamplerTypename();
118 Any NativeImageSource::GetNativeImageHandle() const
120 return mImpl->GetNativeImageHandle();
123 bool NativeImageSource::SourceChanged() const
125 return mImpl->SourceChanged();
128 Rect<uint32_t> NativeImageSource::GetUpdatedArea()
130 return mImpl->GetUpdatedArea();
133 NativeImageInterface::Extension* NativeImageSource::GetExtension()
135 return mImpl->GetNativeImageInterfaceExtension();
138 NativeImageSource::NativeImageSource(uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSource)
140 auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
141 mImpl = factory->CreateNativeImageSource(width, height, depth, nativeImageSource).release();
144 NativeImageSource::~NativeImageSource()