1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License. 5e0dac50fSopenharmony_ci * You may obtain a copy of the License at 6e0dac50fSopenharmony_ci * 7e0dac50fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0dac50fSopenharmony_ci * 9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and 13e0dac50fSopenharmony_ci * limitations under the License. 14e0dac50fSopenharmony_ci */ 15e0dac50fSopenharmony_ci 16e0dac50fSopenharmony_ci#ifndef FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 17e0dac50fSopenharmony_ci#define FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 18e0dac50fSopenharmony_ci 19e0dac50fSopenharmony_ci#include <securec.h> 20e0dac50fSopenharmony_ci 21e0dac50fSopenharmony_ci#include "display_manager.h" 22e0dac50fSopenharmony_ci#include "screen_manager.h" 23e0dac50fSopenharmony_ci#include "display_property.h" 24e0dac50fSopenharmony_ci#include "display.h" 25e0dac50fSopenharmony_ci#include "screen.h" 26e0dac50fSopenharmony_ci#include "display_info.h" 27e0dac50fSopenharmony_ci#include "wm_common.h" 28e0dac50fSopenharmony_ci#include "dm_common.h" 29e0dac50fSopenharmony_ci#include "iconsumer_surface.h" 30e0dac50fSopenharmony_ci#include "window_manager_hilog.h" 31e0dac50fSopenharmony_ci#include "unique_fd.h" 32e0dac50fSopenharmony_ci#include "ui/rs_surface_node.h" 33e0dac50fSopenharmony_ci#include "ui/rs_display_node.h" 34e0dac50fSopenharmony_ci 35e0dac50fSopenharmony_cinamespace OHOS { 36e0dac50fSopenharmony_cinamespace Rosen { 37e0dac50fSopenharmony_ciclass DisplayTestUtils { 38e0dac50fSopenharmony_cipublic: 39e0dac50fSopenharmony_ci ~DisplayTestUtils(); 40e0dac50fSopenharmony_ci static bool SizeEqualToDisplay(const sptr<Display>& display, const Media::Size cur); 41e0dac50fSopenharmony_ci static bool SizeEqual(const Media::Size dst, const Media::Size cur); 42e0dac50fSopenharmony_ci void init(); 43e0dac50fSopenharmony_ci bool CreateSurface(); 44e0dac50fSopenharmony_ci void SetDefaultWH(const sptr<Display>& display); 45e0dac50fSopenharmony_ci class BufferListener : public IBufferConsumerListener { 46e0dac50fSopenharmony_ci public: 47e0dac50fSopenharmony_ci explicit BufferListener(DisplayTestUtils &displayTestUtils): utils_(displayTestUtils) 48e0dac50fSopenharmony_ci { 49e0dac50fSopenharmony_ci } 50e0dac50fSopenharmony_ci ~BufferListener() noexcept override = default; 51e0dac50fSopenharmony_ci void OnBufferAvailable() override 52e0dac50fSopenharmony_ci { 53e0dac50fSopenharmony_ci utils_.OnVsync(); 54e0dac50fSopenharmony_ci } 55e0dac50fSopenharmony_ci 56e0dac50fSopenharmony_ci private: 57e0dac50fSopenharmony_ci DisplayTestUtils &utils_; 58e0dac50fSopenharmony_ci }; 59e0dac50fSopenharmony_ci friend class BufferListener; 60e0dac50fSopenharmony_ci 61e0dac50fSopenharmony_ci void OnVsync(); 62e0dac50fSopenharmony_ci uint32_t successCount_ = 0; 63e0dac50fSopenharmony_ci uint32_t failCount_ = 0; 64e0dac50fSopenharmony_ci uint32_t defaultWidth_ = 0; 65e0dac50fSopenharmony_ci uint32_t defaultHeight_ = 0; 66e0dac50fSopenharmony_ci sptr<IBufferConsumerListener> listener_ = nullptr; 67e0dac50fSopenharmony_ci sptr<IConsumerSurface> csurface_ = nullptr; // cosumer surface 68e0dac50fSopenharmony_ci sptr<Surface> psurface_ = nullptr; // producer surface 69e0dac50fSopenharmony_ci sptr<SurfaceBuffer> prevBuffer_ = nullptr; 70e0dac50fSopenharmony_ci BufferHandle *bufferHandle_ = nullptr; 71e0dac50fSopenharmony_ci 72e0dac50fSopenharmony_ciprivate: 73e0dac50fSopenharmony_ci std::mutex mutex_; 74e0dac50fSopenharmony_ci}; 75e0dac50fSopenharmony_ci} // namespace ROSEN 76e0dac50fSopenharmony_ci} // namespace OHOS 77e0dac50fSopenharmony_ci#endif // FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 78