• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "pixel_map.h"
17 
18 namespace {
19 int32_t g_mockPixelMapGetByteCountRet = 128;
20 }
21 
MockPixelMapGetByteCount(int32_t mockRet)22 void MockPixelMapGetByteCount(int32_t mockRet)
23 {
24     g_mockPixelMapGetByteCountRet = mockRet;
25 }
26 
MockResetPixelMapState()27 void MockResetPixelMapState()
28 {
29     g_mockPixelMapGetByteCountRet = 128; // 128 :initial test result
30 }
31 namespace OHOS {
32 namespace Media {
~PixelMap()33 PixelMap::~PixelMap()
34 {}
35 
FreePixelMap()36 void PixelMap::FreePixelMap() __attribute__((no_sanitize("cfi")))
37 {}
38 
ReleaseSharedMemory(void * addr,void * context,uint32_t size)39 void PixelMap::ReleaseSharedMemory(void *addr, void *context, uint32_t size)
40 {}
41 
SetPixelsAddr(void * addr,void * context,uint32_t size,AllocatorType type,CustomFreePixelMap func)42 void PixelMap::SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type, CustomFreePixelMap func)
43 {}
44 
Create(const uint32_t * colors,uint32_t colorLength,const InitializationOptions & opts)45 std::unique_ptr<PixelMap> PixelMap::Create(const uint32_t *colors, uint32_t colorLength,
46     const InitializationOptions &opts)
47 {
48     return nullptr;
49 }
50 
Create(const uint32_t * colors,uint32_t colorLength,int32_t offset,int32_t stride,const InitializationOptions & opts)51 std::unique_ptr<PixelMap> PixelMap::Create(const uint32_t *colors, uint32_t colorLength, int32_t offset,
52     int32_t stride, const InitializationOptions &opts)
53 {
54     return nullptr;
55 }
56 
CheckParams(const uint32_t * colors,uint32_t colorLength,int32_t offset,int32_t stride,const InitializationOptions & opts)57 bool PixelMap::CheckParams(const uint32_t *colors, uint32_t colorLength, int32_t offset, int32_t stride,
58                            const InitializationOptions &opts)
59 {
60     return true;
61 }
62 
Create(const InitializationOptions & opts)63 std::unique_ptr<PixelMap> PixelMap::Create(const InitializationOptions &opts)
64 {
65     return nullptr;
66 }
67 
UpdatePixelsAlpha(const AlphaType & alphaType,const PixelFormat & pixelFormat,uint8_t * dstPixels,PixelMap dstPixelMap)68 void PixelMap::UpdatePixelsAlpha(const AlphaType &alphaType, const PixelFormat &pixelFormat, uint8_t *dstPixels,
69                                  PixelMap dstPixelMap)
70 {}
71 
Create(PixelMap & source,const InitializationOptions & opts)72 std::unique_ptr<PixelMap> PixelMap::Create(PixelMap &source, const InitializationOptions &opts)
73 {
74     return nullptr;
75 }
76 
Create(PixelMap & source,const Rect & srcRect,const InitializationOptions & opts)77 std::unique_ptr<PixelMap> PixelMap::Create(PixelMap &source, const Rect &srcRect, const InitializationOptions &opts)
78 {
79     return nullptr;
80 }
81 
SourceCropAndConvert(PixelMap & source,const ImageInfo & srcImageInfo,const ImageInfo & dstImageInfo,const Rect & srcRect,PixelMap & dstPixelMap)82 bool PixelMap::SourceCropAndConvert(PixelMap &source, const ImageInfo &srcImageInfo, const ImageInfo &dstImageInfo,
83                                     const Rect &srcRect, PixelMap &dstPixelMap)
84 {
85     return true;
86 }
87 
ScalePixelMap(const Size & targetSize,const Size & dstSize,const ScaleMode & scaleMode,PixelMap & dstPixelMap)88 bool PixelMap::ScalePixelMap(const Size &targetSize, const Size &dstSize, const ScaleMode &scaleMode,
89                              PixelMap &dstPixelMap)
90 {
91     return true;
92 }
93 
InitDstImageInfo(const InitializationOptions & opts,const ImageInfo & srcImageInfo,ImageInfo & dstImageInfo)94 void PixelMap::InitDstImageInfo(const InitializationOptions &opts, const ImageInfo &srcImageInfo,
95                                 ImageInfo &dstImageInfo)
96 {}
97 
CopyPixelMap(PixelMap & source,PixelMap & dstPixelMap)98 bool PixelMap::CopyPixelMap(PixelMap &source, PixelMap &dstPixelMap)
99 {
100     return true;
101 }
102 
IsSameSize(const Size & src,const Size & dst)103 bool PixelMap::IsSameSize(const Size &src, const Size &dst)
104 {
105     return true;
106 }
107 
GetPixelFormatDetail(const PixelFormat format)108 bool PixelMap::GetPixelFormatDetail(const PixelFormat format)
109 {
110     return true;
111 }
112 
SetImageInfo(ImageInfo & info)113 uint32_t PixelMap::SetImageInfo(ImageInfo &info)
114 {
115     return 0;
116 }
117 
SetImageInfo(ImageInfo & info,bool isReused)118 uint32_t PixelMap::SetImageInfo(ImageInfo &info, bool isReused)
119 {
120     return 0;
121 }
122 
GetPixel8(int32_t x,int32_t y)123 const uint8_t *PixelMap::GetPixel8(int32_t x, int32_t y)
124 {
125     return nullptr;
126 }
127 
GetPixel16(int32_t x,int32_t y)128 const uint16_t *PixelMap::GetPixel16(int32_t x, int32_t y)
129 {
130     return nullptr;
131 }
132 
GetPixel32(int32_t x,int32_t y)133 const uint32_t *PixelMap::GetPixel32(int32_t x, int32_t y)
134 {
135     return nullptr;
136 }
137 
GetPixel(int32_t x,int32_t y)138 const uint8_t *PixelMap::GetPixel(int32_t x, int32_t y)
139 {
140     return nullptr;
141 }
142 
GetARGB32Color(int32_t x,int32_t y,uint32_t & color)143 bool PixelMap::GetARGB32Color(int32_t x, int32_t y, uint32_t &color)
144 {
145     return true;
146 }
147 
ALPHA8ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)148 bool PixelMap::ALPHA8ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
149 {
150     return true;
151 }
152 
RGB565ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)153 bool PixelMap::RGB565ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
154 {
155     return true;
156 }
157 
ARGB8888ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)158 bool PixelMap::ARGB8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
159 {
160     return true;
161 }
162 
RGBA8888ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)163 bool PixelMap::RGBA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
164 {
165     return true;
166 }
167 
BGRA8888ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)168 bool PixelMap::BGRA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
169 {
170     return true;
171 }
172 
RGB888ToARGB(const uint8_t * in,uint32_t inCount,uint32_t * out,uint32_t outCount)173 bool PixelMap::RGB888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount)
174 {
175     return true;
176 }
177 
GetPixelBytes()178 int32_t PixelMap::GetPixelBytes()
179 {
180     return 0;
181 }
182 
GetRowBytes()183 int32_t PixelMap::GetRowBytes()
184 {
185     return 0;
186 }
187 
GetByteCount()188 int32_t PixelMap::GetByteCount()
189 {
190     return g_mockPixelMapGetByteCountRet;
191 }
192 
GetWidth()193 int32_t PixelMap::GetWidth()
194 {
195     return 0;
196 }
197 
GetHeight()198 int32_t PixelMap::GetHeight()
199 {
200     return 0;
201 }
202 
GetBaseDensity()203 int32_t PixelMap::GetBaseDensity()
204 {
205     return 0;
206 }
207 
GetImageInfo(ImageInfo & imageInfo)208 void PixelMap::GetImageInfo(ImageInfo &imageInfo)
209 {}
210 
GetPixelFormat()211 PixelFormat PixelMap::GetPixelFormat()
212 {
213     return imageInfo_.pixelFormat;
214 }
215 
GetColorSpace()216 ColorSpace PixelMap::GetColorSpace()
217 {
218     return imageInfo_.colorSpace;
219 }
220 
GetAlphaType()221 AlphaType PixelMap::GetAlphaType()
222 {
223     return imageInfo_.alphaType;
224 }
225 
GetPixels()226 const uint8_t *PixelMap::GetPixels()
227 {
228     return data_;
229 }
230 
GetARGB32ColorA(uint32_t color)231 uint8_t PixelMap::GetARGB32ColorA(uint32_t color)
232 {
233     return 0;
234 }
235 
GetARGB32ColorR(uint32_t color)236 uint8_t PixelMap::GetARGB32ColorR(uint32_t color)
237 {
238     return 0;
239 }
240 
GetARGB32ColorG(uint32_t color)241 uint8_t PixelMap::GetARGB32ColorG(uint32_t color)
242 {
243     return 0;
244 }
245 
GetARGB32ColorB(uint32_t color)246 uint8_t PixelMap::GetARGB32ColorB(uint32_t color)
247 {
248     return 0;
249 }
250 
IsSameImage(const PixelMap & other)251 bool PixelMap::IsSameImage(const PixelMap &other)
252 {
253     return true;
254 }
255 
ReadPixels(const uint64_t & bufferSize,uint8_t * dst)256 uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, uint8_t *dst)
257 {
258     return 0;
259 }
260 
CheckPixelsInput(const uint8_t * dst,const uint64_t & bufferSize,const uint32_t & offset,const uint32_t & stride,const Rect & region)261 bool PixelMap::CheckPixelsInput(const uint8_t *dst, const uint64_t &bufferSize, const uint32_t &offset,
262                                 const uint32_t &stride, const Rect &region)
263 {
264     return true;
265 }
266 
ReadPixels(const uint64_t & bufferSize,const uint32_t & offset,const uint32_t & stride,const Rect & region,uint8_t * dst)267 uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset, const uint32_t &stride,
268                               const Rect &region, uint8_t *dst)
269 {
270     return 0;
271 }
272 
ReadPixel(const Position & pos,uint32_t & dst)273 uint32_t PixelMap::ReadPixel(const Position &pos, uint32_t &dst)
274 {
275     return 0;
276 }
277 
ResetConfig(const Size & size,const PixelFormat & format)278 uint32_t PixelMap::ResetConfig(const Size &size, const PixelFormat &format)
279 {
280     return 0;
281 }
282 
SetAlphaType(const AlphaType & alphaType)283 bool PixelMap::SetAlphaType(const AlphaType &alphaType)
284 {
285     return true;
286 }
287 
WritePixel(const Position & pos,const uint32_t & color)288 uint32_t PixelMap::WritePixel(const Position &pos, const uint32_t &color)
289 {
290     return 0;
291 }
292 
WritePixels(const uint8_t * source,const uint64_t & bufferSize,const uint32_t & offset,const uint32_t & stride,const Rect & region)293 uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize, const uint32_t &offset,
294                                const uint32_t &stride, const Rect &region)
295 {
296     return 0;
297 }
298 
WritePixels(const uint8_t * source,const uint64_t & bufferSize)299 uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize)
300 {
301     return 0;
302 }
303 
WritePixels(const uint32_t & color)304 bool PixelMap::WritePixels(const uint32_t &color)
305 {
306     return true;
307 }
308 
GetAllocatorType()309 AllocatorType PixelMap::GetAllocatorType()
310 {
311     return allocatorType_;
312 }
313 
GetFd() const314 void *PixelMap::GetFd() const
315 {
316     return context_;
317 }
318 
ReleaseMemory(AllocatorType allocType,void * addr,void * context,uint32_t size)319 void PixelMap::ReleaseMemory(AllocatorType allocType, void *addr, void *context, uint32_t size)
320 {}
321 
WriteImageData(Parcel & parcel,size_t size) const322 bool PixelMap::WriteImageData(Parcel &parcel, size_t size) const
323 {
324     return true;
325 }
326 
ReadImageData(Parcel & parcel,int32_t bufferSize)327 uint8_t *PixelMap::ReadImageData(Parcel &parcel, int32_t bufferSize)
328 {
329     return nullptr;
330 }
331 
WriteFileDescriptor(Parcel & parcel,int fd)332 bool PixelMap::WriteFileDescriptor(Parcel &parcel, int fd)
333 {
334     return true;
335 }
336 
ReadFileDescriptor(Parcel & parcel)337 int PixelMap::ReadFileDescriptor(Parcel &parcel)
338 {
339     return 0;
340 }
341 
WriteImageInfo(Parcel & parcel) const342 bool PixelMap::WriteImageInfo(Parcel &parcel) const
343 {
344     return true;
345 }
346 
Marshalling(Parcel & parcel) const347 bool PixelMap::Marshalling(Parcel &parcel) const
348 {
349     return true;
350 }
351 
ReadImageInfo(Parcel & parcel,ImageInfo & imgInfo)352 bool PixelMap::ReadImageInfo(Parcel &parcel, ImageInfo &imgInfo)
353 {
354     return true;
355 }
356 
Unmarshalling(Parcel & parcel)357 PixelMap *PixelMap::Unmarshalling(Parcel &parcel)
358 {
359     return nullptr;
360 }
361 
SetAlpha(const float percent)362 uint32_t PixelMap::SetAlpha(const float percent)
363 {
364     return 0;
365 }
366 
scale(float xAxis,float yAxis)367 void PixelMap::scale(float xAxis, float yAxis)
368 {}
369 
translate(float xAxis,float yAxis)370 void PixelMap::translate(float xAxis, float yAxis)
371 {}
372 
rotate(float degrees)373 void PixelMap::rotate(float degrees)
374 {}
375 
flip(bool xAxis,bool yAxis)376 void PixelMap::flip(bool xAxis, bool yAxis)
377 {}
378 
crop(const Rect & rect)379 uint32_t PixelMap::crop(const Rect &rect)
380 {
381     return 0;
382 }
383 } // namespace Media
384 } // namespace OHOS
385