1e9297d28Sopenharmony_ci/* 2e9297d28Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3e9297d28Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e9297d28Sopenharmony_ci * you may not use this file except in compliance with the License. 5e9297d28Sopenharmony_ci * You may obtain a copy of the License at 6e9297d28Sopenharmony_ci * 7e9297d28Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e9297d28Sopenharmony_ci * 9e9297d28Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e9297d28Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e9297d28Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e9297d28Sopenharmony_ci * See the License for the specific language governing permissions and 13e9297d28Sopenharmony_ci * limitations under the License. 14e9297d28Sopenharmony_ci */ 15e9297d28Sopenharmony_ci 16e9297d28Sopenharmony_ci#ifndef HELLO_COMPOSER_H 17e9297d28Sopenharmony_ci#define HELLO_COMPOSER_H 18e9297d28Sopenharmony_ci 19e9297d28Sopenharmony_ci#include <surface.h> 20e9297d28Sopenharmony_ci#include <event_handler.h> 21e9297d28Sopenharmony_ci#include "hdi_backend.h" 22e9297d28Sopenharmony_ci#include "hdi_layer_info.h" 23e9297d28Sopenharmony_ci#include "hdi_output.h" 24e9297d28Sopenharmony_ci#include "hdi_screen.h" 25e9297d28Sopenharmony_ci#include "layer_context.h" 26e9297d28Sopenharmony_ci 27e9297d28Sopenharmony_cinamespace OHOS { 28e9297d28Sopenharmony_cinamespace Rosen { 29e9297d28Sopenharmony_ciclass HelloComposer { 30e9297d28Sopenharmony_cipublic: 31e9297d28Sopenharmony_ci HelloComposer() = default; 32e9297d28Sopenharmony_ci virtual ~HelloComposer() = default; 33e9297d28Sopenharmony_ci 34e9297d28Sopenharmony_ci void Init(); 35e9297d28Sopenharmony_ci void Run(const std::vector<std::string> &runArgs); 36e9297d28Sopenharmony_ci 37e9297d28Sopenharmony_ciprivate: 38e9297d28Sopenharmony_ci uint32_t freq_ = 30; 39e9297d28Sopenharmony_ci uint32_t currScreenId_ = 0; 40e9297d28Sopenharmony_ci // Draw color with PIXEL_FMT_YCBCR_420_SP format in LAYER_EXTRA layer, if YUVFormat_ is true 41e9297d28Sopenharmony_ci // Draw color with PIXEL_FMT_RGBA_8888 format in LAYER_EXTRA layer, if YUVFormat_ is false 42e9297d28Sopenharmony_ci bool yuvFormat_ = false; 43e9297d28Sopenharmony_ci bool dump_ = false; 44e9297d28Sopenharmony_ci bool ready_ = false; 45e9297d28Sopenharmony_ci bool initDeviceFinished_ = false; 46e9297d28Sopenharmony_ci bool deviceConnected_ = false; 47e9297d28Sopenharmony_ci bool postHotPlugEvent_ = false; 48e9297d28Sopenharmony_ci bool testClient_ = false; 49e9297d28Sopenharmony_ci bool testLayerRotate_ = false; 50e9297d28Sopenharmony_ci bool testLayerColor_ = false; 51e9297d28Sopenharmony_ci HdiBackend* backend_ = nullptr; 52e9297d28Sopenharmony_ci std::vector<std::unique_ptr<HdiScreen>> screens_; 53e9297d28Sopenharmony_ci std::shared_ptr<HdiOutput> curOutput_; 54e9297d28Sopenharmony_ci std::shared_ptr<OHOS::AppExecFwk::EventHandler> mainThreadHandler_; 55e9297d28Sopenharmony_ci 56e9297d28Sopenharmony_ci /* map: key is screenId */ 57e9297d28Sopenharmony_ci std::unordered_map<uint32_t, uint32_t> displayWidthsMap_; 58e9297d28Sopenharmony_ci std::unordered_map<uint32_t, uint32_t> displayHeightsMap_; 59e9297d28Sopenharmony_ci std::unordered_map<uint32_t, std::shared_ptr<HdiOutput>> outputMap_; 60e9297d28Sopenharmony_ci std::unordered_map<uint32_t, std::unique_ptr<HdiScreen>> screensMap_; 61e9297d28Sopenharmony_ci std::unordered_map<uint32_t, std::vector<std::unique_ptr<LayerContext>>> drawLayersMap_; 62e9297d28Sopenharmony_ci 63e9297d28Sopenharmony_ci void InitLayers(uint32_t screenId); 64e9297d28Sopenharmony_ci void RequestSync(); 65e9297d28Sopenharmony_ci void CreateLayers(); 66e9297d28Sopenharmony_ci void CreateShowLayers(); 67e9297d28Sopenharmony_ci void Draw(); 68e9297d28Sopenharmony_ci void Sync(int64_t, void *data); 69e9297d28Sopenharmony_ci void DoPrepareCompleted(sptr<Surface> surface, const struct PrepareCompleteParam ¶m); 70e9297d28Sopenharmony_ci void OnHotPlug(std::shared_ptr<HdiOutput> &output, bool connected); 71e9297d28Sopenharmony_ci void OnHotPlugEvent(std::shared_ptr<HdiOutput> &output, bool connected); 72e9297d28Sopenharmony_ci void ParseArgs(const std::vector<std::string> &runArgs); 73e9297d28Sopenharmony_ci void SetRunArgs(const std::unique_ptr<LayerContext> &drawLayer) const; 74e9297d28Sopenharmony_ci void RemoveOffScreenData(uint32_t offScreenId); 75e9297d28Sopenharmony_ci uint32_t CreatePhysicalScreen(); 76e9297d28Sopenharmony_ci 77e9297d28Sopenharmony_ci static void OnScreenPlug(std::shared_ptr<HdiOutput> &output, bool connected, void* data); 78e9297d28Sopenharmony_ci static void OnPrepareCompleted( 79e9297d28Sopenharmony_ci sptr<Surface> &surface, const struct PrepareCompleteParam ¶m, void* data); 80e9297d28Sopenharmony_ci}; 81e9297d28Sopenharmony_ci} // namespace Rosen 82e9297d28Sopenharmony_ci} // namespace OHOS 83e9297d28Sopenharmony_ci 84e9297d28Sopenharmony_ci#endif // HELLO_COMPOSER_H