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 22 namespace OHOS { 23 namespace HDI { 24 namespace Display { 25 namespace TEST { 26 using namespace OHOS::HDI::Display::Composer::V1_0; 27 28 const uint32_t DISPLAY_DEAULT_W = 480; 29 const uint32_t DISPLAY_DEAULT_H = 960; 30 const uint32_t RED = 0xff0000ff; 31 const uint32_t GREEN = 0x00ff00ff; 32 const uint32_t BLUE = 0x0000ffff; 33 const uint32_t TRANSPARENT = 0; 34 const uint32_t YELLOW = 0xffff29ff; 35 const uint32_t PINK = 0xffc0cbff; 36 const uint32_t PURPLE = 0x800080ff; 37 const uint32_t CYAN = 0x00ffffff; 38 39 struct FRect { 40 float x = 0; 41 float y = 0; 42 float w = 0; // ratio 43 float h = 0; // ratio 44 }; 45 46 struct BufferRatio { 47 float w; 48 float h; 49 }; 50 51 struct Size { 52 uint32_t w; 53 uint32_t h; 54 }; 55 56 struct 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 70 struct TestParemeter { GetInstanceTestParemeter71 static TestParemeter& GetInstance() 72 { 73 static TestParemeter instance; 74 return instance; 75 } 76 int32_t mTestSleep = 0; 77 }; 78 79 using LayersSetting = std::vector<LayerSettings>; 80 81 void SaveFile(const char* fileName, uint8_t* data, int size); 82 void SetUint32(uint32_t& dst, uint32_t value); 83 void SetPixel(const BufferHandle& handle, int x, int y, uint32_t color); 84 void ClearColor(const BufferHandle& handle, uint32_t color); 85 uint32_t GetPixelValue(const BufferHandle& handle, int x, int y); 86 uint32_t CheckPixel(const BufferHandle& handle, int x, int y, uint32_t color); 87 std::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