[Tizen] Add API for setting resource destruction callback
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / native-image-source-devel.h
1 #ifndef DALI_NATIVE_IMAGE_SOURCE_DEVEL_H\r
2 #define DALI_NATIVE_IMAGE_SOURCE_DEVEL_H\r
3 /*\r
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
5  *\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
9  *\r
10  * http://www.apache.org/licenses/LICENSE-2.0\r
11  *\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
17  *\r
18  */\r
19 \r
20 // EXTERNAL INCLUDES\r
21 #include <dali/public-api/adaptor-framework/native-image-source.h>\r
22 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>\r
23 \r
24 \r
25 namespace Dali\r
26 {\r
27 namespace DevelNativeImageSource\r
28 {\r
29 /**\r
30  * @brief Converts the current pixel contents to either a JPEG or PNG format\r
31  * and write that to the filesystem.\r
32  *\r
33  * @param[in] image The instance of NativeImageSource.\r
34  * @param[in] filename Identify the filesystem location at which to write the encoded image.\r
35  *                     The extension determines the encoding used.\r
36  *                     The two valid encoding are (".jpeg"|".jpg") and ".png".\r
37  * @param[in] quality The value to control image quality for jpeg file format in the range [1, 100]\r
38  * @return    @c true if the pixels were written, and @c false otherwise\r
39  */\r
40 DALI_ADAPTOR_API bool EncodeToFile(NativeImageSource& image, const std::string& filename, const uint32_t quality);\r
41 \r
42 /**\r
43  * @brief Acquire buffer and information of an internal native image.\r
44  *\r
45  * AcquireBuffer() and ReleaseBuffer() are a pair.\r
46  * It should be call ReleaseBuffer() after AcquireBuffer().\r
47  * @param[in] image The instance of NativeImageSource.\r
48  * @param[out] width The width of image\r
49  * @param[out] height The height of image\r
50  * @param[out] stride The stride of image\r
51  * @return     The buffer of an internal native image\r
52  */\r
53 DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint16_t& width, uint16_t& height, uint16_t& stride);\r
54 \r
55 /**\r
56  * @brief Release information of an internal native image.\r
57  *\r
58  * AcquireBuffer() and ReleaseBuffer() are a pair.\r
59  * It should be call ReleaseBuffer() after AcquireBuffer().\r
60  * @param[in] image The instance of NativeImageSource.\r
61  * @return     @c true If the buffer is released successfully, and @c false otherwise\r
62  */\r
63 DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image);\r
64 \r
65 /**\r
66  * @brief Set the Resource Destruction Callback object\r
67  *\r
68  * @param image The instance of NativeImageSource.\r
69  * @param callback The Resource Destruction callback\r
70  * @note Ownership of the callback is passed onto this class.\r
71  */\r
72 DALI_ADAPTOR_API void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback);\r
73 \r
74 } // namespace DevelNativeImageSource\r
75 \r
76 } // namespace Dali\r
77 \r
78 #endif // DALI_NATIVE_IMAGE_SOURCE_DEVEL_H\r