1 /*
2 * Copyright (c) 2023 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 #ifndef DISPLAY_COMMON_FUZZER_H
17 #define DISPLAY_COMMON_FUZZER_H
18
19 #include "v1_1/include/idisplay_buffer.h"
20 #include "v1_0/display_composer_type.h"
21 #include "v1_0/display_buffer_type.h"
22 #include "buffer_handle.h"
23 #include "hdf_log.h"
24
25 namespace OHOS {
26 using namespace OHOS::HDI::Display::Buffer::V1_0;
27 using namespace OHOS::HDI::Display::Composer::V1_0;
28 const size_t THRESHOLD = 10;
29 const int32_t ALPHA_VALUE_RANGE = 256; // ranging from 0 to 255
30 const uint32_t WIDTH = 128;
31 const uint32_t HEIGHT = 128;
32
33 const PixelFormat CONVERT_TABLE_FORMAT[] = {
34 PIXEL_FMT_CLUT8, PIXEL_FMT_CLUT1,
35 PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565,
36 PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444,
37 PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444,
38 PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551,
39 PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888,
40 PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888,
41 PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444,
42 PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551,
43 PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888,
44 PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I,
45 PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP,
46 PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP,
47 PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P,
48 PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P,
49 PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG,
50 PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG,
51 PIXEL_FMT_VENDER_MASK, PIXEL_FMT_BUTT,
52 };
53
54 const BufferUsage CONVERT_TABLE_USAGE[] = {
55 HBM_USE_CPU_READ, HBM_USE_CPU_WRITE,
56 HBM_USE_MEM_MMZ, HBM_USE_MEM_DMA,
57 HBM_USE_MEM_SHARE, HBM_USE_MEM_MMZ_CACHE,
58 HBM_USE_MEM_FB, HBM_USE_ASSIGN_SIZE,
59 HBM_USE_HW_RENDER, HBM_USE_HW_TEXTURE,
60 HBM_USE_HW_COMPOSER, HBM_USE_PROTECTED,
61 HBM_USE_CAMERA_READ, HBM_USE_CAMERA_WRITE,
62 HBM_USE_VIDEO_ENCODER, HBM_USE_VIDEO_DECODER,
63 HBM_USE_VENDOR_PRI0, HBM_USE_VENDOR_PRI1,
64 HBM_USE_VENDOR_PRI2, HBM_USE_VENDOR_PRI3,
65 HBM_USE_VENDOR_PRI4, HBM_USE_VENDOR_PRI5,
66 HBM_USE_VENDOR_PRI6, HBM_USE_VENDOR_PRI7,
67 HBM_USE_VENDOR_PRI8, HBM_USE_VENDOR_PRI9,
68 HBM_USE_VENDOR_PRI10, HBM_USE_VENDOR_PRI11,
69 HBM_USE_VENDOR_PRI12, HBM_USE_VENDOR_PRI13,
70 HBM_USE_VENDOR_PRI14, HBM_USE_VENDOR_PRI15,
71 HBM_USE_VENDOR_PRI16, HBM_USE_VENDOR_PRI17,
72 HBM_USE_VENDOR_PRI18, HBM_USE_VENDOR_PRI19,
73 };
74
75 template<class T>
GetArrLength(T & arr)76 uint32_t GetArrLength(T& arr)
77 {
78 if (arr == nullptr) {
79 HDF_LOGE("%{public}s: The array length is equal to 0", __func__);
80 return 0;
81 }
82 return sizeof(arr) / sizeof(arr[0]);
83 }
84
85 } // OHOS
86 #endif // DISPLAY_COMMON_FUZZER_H
87