Set the image type of encoded image buffer
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / common / encoded-image-buffer-impl.h
1 #ifndef DALI_ENCODED_IMAGE_BUFFER_IMPL_H
2 #define DALI_ENCODED_IMAGE_BUFFER_IMPL_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/common/dali-vector.h>
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 class EncodedImageBuffer : public BaseObject
34 {
35 public:
36   using RawBufferType = Dali::EncodedImageBuffer::RawBufferType;
37   using ImageType     = Dali::EncodedImageBuffer::ImageType;
38
39   /**
40    * Constructor
41    * @param[in] buffer The raw buffer of image.
42    * @param[in] type The type of image.
43    */
44   EncodedImageBuffer(const RawBufferType& buffer, ImageType type);
45
46   /**
47    * @copydoc Dali::EncodedImageBuffer::New
48    */
49   static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer, ImageType type);
50
51   /**
52    * @copydoc Dali::EncodedImageBuffer::GetRawBuffer
53    */
54   const RawBufferType& GetRawBuffer() const;
55
56   /**
57    * @copydoc Dali::EncodedImageBuffer::GetHash
58    */
59   std::size_t GetHash() const;
60
61   /**
62    * @copydoc Dali::EncodedImageBuffer::SetImageType
63    */
64   void SetImageType(ImageType type);
65
66   /**
67    * @copydoc Dali::EncodedImageBuffer::GetImageType
68    */
69   ImageType GetImageType() const;
70
71 protected:
72   /**
73    * Destructor
74    */
75   ~EncodedImageBuffer();
76
77 private:
78   // Undefined
79   EncodedImageBuffer(const EncodedImageBuffer& imageBuffer);
80
81   // Undefined
82   EncodedImageBuffer& operator=(const EncodedImageBuffer& imageBuffer);
83
84 private:
85   Dali::Vector<uint8_t> mBuffer;
86   std::size_t           mBufferHash;
87   ImageType             mType;
88 };
89
90 } // namespace Internal
91
92 inline const Internal::EncodedImageBuffer& GetImplementation(const Dali::EncodedImageBuffer& encodedImageBuffer)
93 {
94   DALI_ASSERT_ALWAYS(encodedImageBuffer && "EncodedImageBuffer handle is empty");
95
96   const BaseObject& handle = encodedImageBuffer.GetBaseObject();
97
98   return static_cast<const Internal::EncodedImageBuffer&>(handle);
99 }
100
101 inline Internal::EncodedImageBuffer& GetImplementation(Dali::EncodedImageBuffer& encodedImageBuffer)
102 {
103   DALI_ASSERT_ALWAYS(encodedImageBuffer && "EncodedImageBuffer handle is empty");
104
105   BaseObject& handle = encodedImageBuffer.GetBaseObject();
106
107   return static_cast<Internal::EncodedImageBuffer&>(handle);
108 }
109
110 } // namespace Dali
111
112 #endif // DALI_ENCODED_IMAGE_BUFFER_IMPL_H