1 /* 2 * Copyright (c) 2021-2022 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 UPDATER_UI_SURFACE_DEV_H 17 #define UPDATER_UI_SURFACE_DEV_H 18 #include <string> 19 #include "macros_updater.h" 20 #include "graphic_drv.h" 21 22 namespace Updater { 23 enum class DevType { 24 FB_DEVICE = 0, 25 DRM_DEVICE, 26 UNKNOW_DEVICE 27 }; 28 29 class SurfaceDev { 30 DISALLOW_COPY_MOVE(SurfaceDev); 31 public: 32 SurfaceDev() = default; 33 ~SurfaceDev(); 34 void Flip(const uint8_t* buf) const; 35 void GetScreenSize(uint16_t &w, uint16_t &h, GrSurface &surface) const; 36 bool Init(); 37 void Blank(bool blank); 38 void Exit(void); 39 static void AddFbDevice(const std::string &devicePath); 40 private: 41 DevType GetDevType() const; 42 std::unique_ptr<GraphicDrv> MakeDevDrv(DevType devType); 43 std::unique_ptr<GraphicDrv> drv_ {}; 44 static std::vector<std::string> fbDeviceList_; 45 }; 46 } // namespace Updater 47 #endif 48