1 #ifndef DALI_NATIVE_IMAGE_SOURCE_DEVEL_H
\r
2 #define DALI_NATIVE_IMAGE_SOURCE_DEVEL_H
\r
4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
20 // EXTERNAL INCLUDES
\r
21 #include <dali/public-api/math/rect.h>
\r
23 // INTERNAL INCLUDES
\r
24 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
\r
25 #include <dali/public-api/adaptor-framework/native-image-source.h>
\r
29 namespace DevelNativeImageSource
\r
32 * @brief Converts the current pixel contents to either a JPEG or PNG format
\r
33 * and write that to the filesystem.
\r
35 * @param[in] image The instance of NativeImageSource.
\r
36 * @param[in] filename Identify the filesystem location at which to write the encoded image.
\r
37 * The extension determines the encoding used.
\r
38 * The two valid encoding are (".jpeg"|".jpg") and ".png".
\r
39 * @param[in] quality The value to control image quality for jpeg file format in the range [1, 100]
\r
40 * @return @c true if the pixels were written, and @c false otherwise
\r
42 DALI_ADAPTOR_API bool EncodeToFile(NativeImageSource& image, const std::string& filename, const uint32_t quality);
\r
45 * @brief Acquire buffer and information of an internal native image.
\r
47 * AcquireBuffer() and ReleaseBuffer() are a pair.
\r
48 * ReleaseBuffer() MUST be called after AcquireBuffer().
\r
49 * @param[in] image The instance of NativeImageSource.
\r
50 * @param[out] width The width of image
\r
51 * @param[out] height The height of image
\r
52 * @param[out] stride The stride of image
\r
53 * @return The buffer of an internal native image
\r
54 * @note This locks a mutex until ReleaseBuffer is called.
\r
56 DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint32_t& width, uint32_t& height, uint32_t& stride);
\r
59 * @brief Release information of an internal native image.
\r
61 * AcquireBuffer() and ReleaseBuffer() are a pair.
\r
62 * ReleaseBuffer() MUST be called after AcquireBuffer().
\r
63 * @param[in] image The instance of NativeImageSource.
\r
64 * @param[in] updatedArea The updated area of the buffer.
\r
65 * @return @c true If the buffer is released successfully, and @c false otherwise
\r
66 * @note The empty updatedArea means that the entire area has been changed.
\r
67 * @note This unlocks the mutex locked by AcquireBuffer.
\r
69 DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image, const Rect<uint32_t>& updatedArea);
\r
72 * @brief Set the Resource Destruction Callback object
\r
74 * @param[in] image The instance of NativeImageSource.
\r
75 * @param[in] callback The Resource Destruction callback
\r
76 * @note Ownership of the callback is passed onto this class.
\r
78 DALI_ADAPTOR_API void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback);
\r
81 * @brief Enable a back buffer.
\r
82 * @param[in] image The instance of NativeImageSource.
\r
83 * @param[in] enable Whether a back buffer is enabled.
\r
84 * @note The front buffer will be copied to the back buffer before rendering if the front buffer is updated by AcquireBuffer and ReleaseBuffer.
\r
86 DALI_ADAPTOR_API void EnableBackBuffer(NativeImageSource& image, bool enable);
\r
88 } // namespace DevelNativeImageSource
\r
92 #endif // DALI_NATIVE_IMAGE_SOURCE_DEVEL_H
\r