Fixing static analysis error
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / pixel-buffer.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
20
21 // EXTERNAL INLCUDES
22 #include <stdlib.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/imaging/common/pixel-buffer-impl.h>
26
27 namespace Dali
28 {
29 namespace Devel
30 {
31 PixelBuffer PixelBuffer::New(uint32_t            width,
32                              uint32_t            height,
33                              Dali::Pixel::Format pixelFormat)
34 {
35   Internal::Adaptor::PixelBufferPtr internal =
36     Internal::Adaptor::PixelBuffer::New(width, height, pixelFormat);
37   return Devel::PixelBuffer(internal.Get());
38 }
39
40 Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer)
41 {
42   Dali::PixelData pixelData =
43     Internal::Adaptor::PixelBuffer::Convert(GetImplementation(pixelBuffer));
44   pixelBuffer.Reset();
45   return pixelData;
46 }
47
48 Dali::PixelData PixelBuffer::CreatePixelData() const
49 {
50   return GetImplementation(*this).CreatePixelData();
51 }
52
53 PixelBuffer::PixelBuffer()
54 {
55 }
56
57 PixelBuffer::~PixelBuffer()
58 {
59 }
60
61 PixelBuffer::PixelBuffer(Internal::Adaptor::PixelBuffer* internal)
62 : BaseHandle(internal)
63 {
64 }
65
66 PixelBuffer::PixelBuffer(const PixelBuffer& handle) = default;
67
68 PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs) = default;
69
70 PixelBuffer::PixelBuffer(PixelBuffer&& handle) = default;
71
72 PixelBuffer& PixelBuffer::operator=(PixelBuffer&& rhs) = default;
73
74 uint32_t PixelBuffer::GetWidth() const
75 {
76   return GetImplementation(*this).GetWidth();
77 }
78
79 uint32_t PixelBuffer::GetHeight() const
80 {
81   return GetImplementation(*this).GetHeight();
82 }
83
84 uint32_t PixelBuffer::GetStride() const
85 {
86   return GetImplementation(*this).GetStride();
87 }
88
89 Pixel::Format PixelBuffer::GetPixelFormat() const
90 {
91   return GetImplementation(*this).GetPixelFormat();
92 }
93
94 uint8_t* PixelBuffer::GetBuffer()
95 {
96   return GetImplementation(*this).GetBuffer();
97 }
98
99 const uint8_t* PixelBuffer::GetBuffer() const
100 {
101   return GetImplementation(*this).GetConstBuffer();
102 }
103
104 void PixelBuffer::ApplyMask(PixelBuffer mask, float contentScale, bool cropToMask)
105 {
106   GetImplementation(*this).ApplyMask(GetImplementation(mask), contentScale, cropToMask);
107 }
108
109 void PixelBuffer::ApplyGaussianBlur(const float blurRadius)
110 {
111   GetImplementation(*this).ApplyGaussianBlur(blurRadius);
112 }
113
114 void PixelBuffer::Crop(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
115 {
116   GetImplementation(*this).Crop(x, y, ImageDimensions(width, height));
117 }
118
119 void PixelBuffer::Resize(uint16_t width, uint16_t height)
120 {
121   GetImplementation(*this).Resize(ImageDimensions(width, height));
122 }
123
124 void PixelBuffer::MultiplyColorByAlpha()
125 {
126   GetImplementation(*this).MultiplyColorByAlpha();
127 }
128
129 bool PixelBuffer::GetMetadata(Property::Map& metadata) const
130 {
131   return GetImplementation(*this).GetMetadata(metadata);
132 }
133
134 bool PixelBuffer::Rotate(Degree angle)
135 {
136   return GetImplementation(*this).Rotate(angle);
137 }
138
139 bool PixelBuffer::IsAlphaPreMultiplied() const
140 {
141   return GetImplementation(*this).IsAlphaPreMultiplied();
142 }
143
144 uint32_t PixelBuffer::GetBrightness() const
145 {
146   return GetImplementation(*this).GetBrightness();
147 }
148
149 } // namespace Devel
150
151 } // namespace Dali