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 #ifndef UTILS_INCLUDE_CPUDRAW_EXPORT_CPUDRAW_H 17 #define UTILS_INCLUDE_CPUDRAW_EXPORT_CPUDRAW_H 18 19 #include <cstdint> 20 21 struct CpudrawRect { 22 double x; 23 double y; 24 double w; 25 double h; 26 27 bool Contain(int32_t x2, int32_t y2); 28 }; 29 30 class Cpudraw { 31 public: 32 Cpudraw(uint32_t *vaddr, int32_t width, int32_t height); 33 34 void SetColor(const uint32_t &color); 35 void SetBorder(const int32_t &border); 36 37 void DrawBorder(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h); 38 void DrawBorder(const struct CpudrawRect &rect); 39 40 void DrawRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h); 41 void DrawRect(const struct CpudrawRect &rect); 42 43 private: 44 int32_t Min(const int32_t &a, const int32_t &b); 45 int32_t Max(const int32_t &a, const int32_t &b); 46 47 uint32_t *addr = nullptr; 48 int32_t width = 0; 49 int32_t height = 0; 50 uint32_t color = 0xffffffff; 51 int32_t border = 0; 52 }; 53 54 #endif // UTILS_INCLUDE_CPUDRAW_EXPORT_CPUDRAW_H 55