/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef DRAWING_SAMPLE_H #define DRAWING_SAMPLE_H #include #include #include #include #include "hdi_backend.h" #include "hdi_layer_info.h" #include "hdi_output.h" #include "hdi_screen.h" #include "layer_context.h" namespace OHOS { namespace Rosen { namespace Drawing { class DrawingSample { public: using TestFunc = std::function; DrawingSample() = default; virtual ~DrawingSample() = default; void Init(); void Run(); inline DrawingSample& SetDraw(std::map> testFuncMap) { drawFuncMap_.swap(testFuncMap); return *this; } private: uint32_t freq_ = 30; uint32_t currScreenId_ = 0; // key is screenId std::unordered_map displayWidthsMap_; std::unordered_map displayHeightsMap_; uint32_t currentModeIndex_ = 0; std::vector displayModeInfos_; // key is screenId std::unordered_map> outputMap_; bool ready_ = false; bool initDeviceFinished_ = false; bool deviceConnected_ = false; bool postHotPlugEvent_ = false; HdiBackend* backend_ = nullptr; std::vector> screens_; std::shared_ptr curOutput_; // key is screenId std::unordered_map> drawLayersMap_; std::map> drawFuncMap_; std::shared_ptr mainThreadHandler_; void InitLayers(uint32_t screenId); void RequestSync(); void CreateShowLayers(); void Draw(); void Sync(int64_t, void* data); void DoPrepareCompleted(sptr surface, const struct PrepareCompleteParam& param); void OnHotPlug(std::shared_ptr& output, bool connected); void OnHotPlugEvent(std::shared_ptr& output, bool connected); uint32_t CreatePhysicalScreen(); static void OnScreenPlug(std::shared_ptr& output, bool connected, void* data); static void OnPrepareCompleted( sptr &surface, const struct PrepareCompleteParam& param, void* data); }; } // namespace Drawing } // namespace Rosen } // namespace OHOS #endif // DRAWING_SAMPLE_H