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_TEST_UTILS_H 17#define DISPLAY_TEST_UTILS_H 18#include <vector> 19#include "display_test.h" 20#include "v1_0/include/idisplay_buffer.h" 21 22namespace OHOS { 23namespace HDI { 24namespace Display { 25namespace TEST { 26using namespace OHOS::HDI::Display::Composer::V1_0; 27 28const uint32_t DISPLAY_DEAULT_W = 480; 29const uint32_t DISPLAY_DEAULT_H = 960; 30const uint32_t RED = 0xff0000ff; 31const uint32_t GREEN = 0x00ff00ff; 32const uint32_t BLUE = 0x0000ffff; 33const uint32_t TRANSPARENT = 0; 34const uint32_t YELLOW = 0xffff29ff; 35const uint32_t PINK = 0xffc0cbff; 36const uint32_t PURPLE = 0x800080ff; 37const uint32_t CYAN = 0x00ffffff; 38 39struct FRect { 40 float x = 0; 41 float y = 0; 42 float w = 0; // ratio 43 float h = 0; // ratio 44}; 45 46struct BufferRatio { 47 float w; 48 float h; 49}; 50 51struct Size { 52 uint32_t w; 53 uint32_t h; 54}; 55 56struct LayerSettings { 57 IRect displayRect; 58 IRect displayCrop; 59 FRect rectRatio = { 0.0f }; 60 uint32_t color; 61 uint32_t zorder = 0; 62 Size bufferSize = { 0 }; 63 BufferRatio bufferRatio { 0 }; 64 int32_t alpha = -1; 65 Composer::V1_0::CompositionType compositionType = Composer::V1_0::CompositionType::COMPOSITION_DEVICE; 66 BlendType blendType = BLEND_SRC; 67 TransformType rotate = ROTATE_NONE; 68}; 69 70struct TestParemeter { 71 static TestParemeter& GetInstance() 72 { 73 static TestParemeter instance; 74 return instance; 75 } 76 int32_t mTestSleep = 0; 77}; 78 79using LayersSetting = std::vector<LayerSettings>; 80 81void SaveFile(const char* fileName, uint8_t* data, int size); 82void SetUint32(uint32_t& dst, uint32_t value); 83void SetPixel(const BufferHandle& handle, int x, int y, uint32_t color); 84void ClearColor(const BufferHandle& handle, uint32_t color); 85uint32_t GetPixelValue(const BufferHandle& handle, int x, int y); 86uint32_t CheckPixel(const BufferHandle& handle, int x, int y, uint32_t color); 87std::vector<IRect> SplitBuffer(const BufferHandle& handle, std::vector<uint32_t> &colors); 88} // OHOS 89} // HDI 90} // Display 91} // TEST 92 93#endif // HDI_TEST_RENDER_UTILS_H 94