2 * Copyright (c) 2020 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-impl.h>
26 #include <dali/internal/imaging/common/native-image-source-factory.h>
31 NativeImageSourcePtr NativeImageSource::New( unsigned int width, unsigned int height, ColorDepth depth )
34 NativeImageSourcePtr image = new NativeImageSource( width, height, depth, empty );
38 Any NativeImageSource::GetNativeImageSource()
40 return mImpl->GetNativeImageSource();
43 NativeImageSourcePtr NativeImageSource::New( Any nativeImageSource )
45 NativeImageSourcePtr image = new NativeImageSource(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSource);
49 bool NativeImageSource::GetPixels( std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
51 return mImpl->GetPixels( pixbuf, width, height, pixelFormat );
54 bool NativeImageSource::EncodeToFile(const std::string& filename) const
56 return mImpl->EncodeToFile( filename );
59 void NativeImageSource::SetSource( Any source )
61 mImpl->SetSource( source );
64 bool NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
66 return mImpl->IsColorDepthSupported( colorDepth );
69 bool NativeImageSource::CreateResource()
71 return mImpl->CreateResource();
74 void NativeImageSource::DestroyResource()
76 mImpl->DestroyResource();
79 unsigned int NativeImageSource::TargetTexture()
81 return mImpl->TargetTexture();
84 void NativeImageSource::PrepareTexture()
86 mImpl->PrepareTexture();
89 unsigned int NativeImageSource::GetWidth() const
91 return mImpl->GetWidth();
94 unsigned int NativeImageSource::GetHeight() const
96 return mImpl->GetHeight();
99 bool NativeImageSource::RequiresBlending() const
101 return mImpl->RequiresBlending();
104 int NativeImageSource::GetTextureTarget() const
106 return mImpl->GetTextureTarget();
109 const char* NativeImageSource::GetCustomFragmentPrefix() const
111 return mImpl->GetCustomFragmentPrefix();
114 const char* NativeImageSource::GetCustomSamplerTypename() const
116 return mImpl->GetCustomSamplerTypename();
119 Any NativeImageSource::GetNativeImageHandle() const
121 return mImpl->GetNativeImageHandle();
124 bool NativeImageSource::SourceChanged() const
126 return mImpl->SourceChanged();
129 NativeImageInterface::Extension* NativeImageSource::GetExtension()
131 return mImpl->GetNativeImageInterfaceExtension();
134 NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSource )
136 auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
137 mImpl = factory->CreateNativeImageSource( width, height, depth, nativeImageSource ).release();
140 NativeImageSource::~NativeImageSource()