4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <dali/public-api/adaptor-framework/native-image-source.h>
23 #include <dali/internal/imaging/common/native-image-source-impl.h>
24 #include <extern-definitions.h>
25 #include <CoreGraphics/CoreGraphics.h>
27 namespace Dali::Internal::Adaptor
30 class EglImageExtensions;
33 * Dali internal NativeImageSource.
35 class NativeImageSourceCocoa : public Internal::Adaptor::NativeImageSource
40 * Create a new NativeImageSource internally.
41 * Depending on hardware the width and height may have to be a power of two.
42 * @param[in] width The width of the image.
43 * @param[in] height The height of the image.
44 * @param[in] depth color depth of the image.
45 * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
46 * @return A smart-pointer to a newly allocated image.
48 static NativeImageSourceCocoa* New(
51 Dali::NativeImageSource::ColorDepth depth,
56 * @copydoc Dali::NativeImageSource::GetNativeImageSource()
58 Any GetNativeImageSource() const override;
61 * @copydoc Dali::NativeImageSource::GetPixels()
64 std::vector<unsigned char> &pixbuf,
67 Pixel::Format& pixelFormat
71 * @copydoc Dali::NativeImageSource::SetSource( Any source )
73 void SetSource( Any source ) override;
76 * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
78 bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
83 ~NativeImageSourceCocoa() override;
86 * @copydoc Dali::NativeImageSource::CreateResource()
88 bool CreateResource() override;
91 * @copydoc Dali::NativeImageSource::DestroyResource()
93 void DestroyResource() override;
96 * @copydoc Dali::NativeImageSource::TargetTexture()
98 unsigned int TargetTexture() override;
101 * @copydoc Dali::NativeImageSource::PrepareTexture()
103 void PrepareTexture() override;
106 * @copydoc Dali::NativeImageSource::GetWidth()
108 unsigned int GetWidth() const override;
111 * @copydoc Dali::NativeImageSource::GetHeight()
113 unsigned int GetHeight() const override;
116 * @copydoc Dali::NativeImageSource::RequiresBlending()
118 bool RequiresBlending() const override;
121 * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
123 const char* GetCustomFragmentPrefix() const override;
126 * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
128 const char* GetCustomSamplerTypename() const override;
131 * @copydoc Dali::NativeImageInterface::GetTextureTarget()
133 int GetTextureTarget() const override;
136 * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
138 Any GetNativeImageHandle() const override;
141 * @copydoc Dali::NativeImageInterface::SourceChanged()
143 bool SourceChanged() const override;
146 * @copydoc Dali::NativeImageInterface::GetExtension()
148 NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
154 * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
156 uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
159 * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
161 bool ReleaseBuffer() override;
166 * Private constructor; @see NativeImageSource::New()
167 * @param[in] width The width of the image.
168 * @param[in] height The height of the image.
169 * @param[in] colour depth of the image.
170 * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
172 NativeImageSourceCocoa(
175 Dali::NativeImageSource::ColorDepth depth,
176 Any nativeImageSource
180 CFRef<CGImageRef> mImage;
183 } // namespace Dali::Internal::Adaptor