Support *.pkm format file decode
[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) 2022 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
38   /**
39    * Constructor
40    * @param [in] buffer The raw buffer of image.
41    */
42   EncodedImageBuffer(const RawBufferType& buffer);
43
44   /**
45    * @copydoc Dali::EncodedImageBuffer::New
46    */
47   static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer);
48
49   /**
50    * @copydoc Dali::EncodedImageBuffer::GetRawBuffer
51    */
52   const RawBufferType& GetRawBuffer() const;
53
54   /**
55    * @copydoc Dali::EncodedImageBuffer::GetHash
56    */
57   const std::size_t GetHash() const;
58
59 protected:
60   /**
61    * Destructor
62    */
63   ~EncodedImageBuffer();
64
65 private:
66   // Undefined
67   EncodedImageBuffer(const EncodedImageBuffer& imageBuffer);
68
69   // Undefined
70   EncodedImageBuffer& operator=(const EncodedImageBuffer& imageBuffer);
71
72 private:
73   Dali::Vector<uint8_t> mBuffer;
74   std::size_t           mBufferHash;
75 };
76
77 } // namespace Internal
78
79 inline const Internal::EncodedImageBuffer& GetImplementation(const Dali::EncodedImageBuffer& encodedImageBuffer)
80 {
81   DALI_ASSERT_ALWAYS(encodedImageBuffer && "EncodedImageBuffer handle is empty");
82
83   const BaseObject& handle = encodedImageBuffer.GetBaseObject();
84
85   return static_cast<const Internal::EncodedImageBuffer&>(handle);
86 }
87
88 inline Internal::EncodedImageBuffer& GetImplementation(Dali::EncodedImageBuffer& encodedImageBuffer)
89 {
90   DALI_ASSERT_ALWAYS(encodedImageBuffer && "EncodedImageBuffer handle is empty");
91
92   BaseObject& handle = encodedImageBuffer.GetBaseObject();
93
94   return static_cast<Internal::EncodedImageBuffer&>(handle);
95 }
96
97 } // namespace Dali
98
99 #endif // DALI_ENCODED_IMAGE_BUFFER_IMPL_H