From 2524cfd6f930498a2dd5ac284b1d3b1b9703fda9 Mon Sep 17 00:00:00 2001 From: Alexey Khoraskin Date: Wed, 3 Sep 2025 16:31:42 +0300 Subject: [PATCH] Support Standalone Previewer. Signed-off-by: Alexey Khoraskin Change-Id: Ief0c9e2693d43c0a7fec39496fdcf9d6ccef2580 --- previewer/BUILD.gn | 6 ++++-- previewer/include/vsync_station.h | 9 ++++++--- previewer/include/window.h | 2 +- previewer/src/window_impl.cpp | 1 - previewer/src/window_scene.cpp | 3 +++ previewer/window_stage_modules/BUILD.gn | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 336f4f6caf..6e7f8d41fb 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -118,7 +118,6 @@ if (!ispreview) { "../interfaces/kits/napi/window_runtime/window_napi/js_window.cpp", "../interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp", "../interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp", - "../utils/src/window_manager_hilog.cpp", # mock "mock/js_transition_controller.cpp", @@ -128,6 +127,9 @@ if (!ispreview) { "mock/pixel_map_napi.cpp", "mock/window_manager_napi/js_window_manager.cpp", "mock/window_manager_napi/window_manager_module.cpp", + + # utils + "../utils/src/window_manager_hilog.cpp", ] include_dirs = [ @@ -188,7 +190,7 @@ if (!ispreview) { "/window/window_manager/libpreviewer_window" + suffix ] deps = [ ":previewer_window" ] - if (current_os == "mingw" || current_os == "mac") { + if (current_os == "mingw" || current_os == "mac" || current_os == "linux") { deps += [ ":window_stage_copy_modules" ] shared_library_path = get_label_info(":previewer_window_napi", "root_out_dir") diff --git a/previewer/include/vsync_station.h b/previewer/include/vsync_station.h index 7daa428721..0a5e8c58b5 100644 --- a/previewer/include/vsync_station.h +++ b/previewer/include/vsync_station.h @@ -36,8 +36,11 @@ public: explicit VsyncStation(NodeId nodeId); ~VsyncStation() { - std::lock_guard lock(mtx_); - destroyed_ = true; + { + std::lock_guard lock(mtx_); + destroyed_ = true; + } + receiver_.reset(); } void RequestVsync(const std::shared_ptr& vsyncCallback); @@ -65,4 +68,4 @@ private: }; } // namespace Rosen } // namespace OHOS -#endif // OHOS_VSYNC_STATION_H \ No newline at end of file +#endif // OHOS_VSYNC_STATION_H diff --git a/previewer/include/window.h b/previewer/include/window.h index acc37486b1..dbbabab02f 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -427,7 +427,7 @@ public: virtual WMError IsMainWindowFullScreenAcrossDisplays( bool& isAcrossDisplays) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual float GetVirtualPixelRatio() { return 1.0f; } - virtual void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type); + virtual void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) = 0; virtual void SetContentInfoCallback(const ContentInfoCallback& callback) = 0; virtual WMError SetResizeByDragEnabled(bool dragEnabled) = 0; diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index c4ff86be05..595cdc2ac6 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -54,7 +54,6 @@ WindowImpl::~WindowImpl() { WLOGFI("windowName: %{public}s, windowId: %{public}d, deConstructorCnt: %{public}d", GetWindowName().c_str(), GetWindowId(), ++deConstructorCnt); - Destroy(); } void WindowImpl::CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) diff --git a/previewer/src/window_scene.cpp b/previewer/src/window_scene.cpp index f1f4a79672..f06a63692a 100644 --- a/previewer/src/window_scene.cpp +++ b/previewer/src/window_scene.cpp @@ -29,6 +29,9 @@ constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowS } WindowScene::~WindowScene() { + if (mainWindow_ != nullptr) { + mainWindow_->Destroy(); + } } WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr& context, diff --git a/previewer/window_stage_modules/BUILD.gn b/previewer/window_stage_modules/BUILD.gn index 7adc8f747e..dc5c57446d 100644 --- a/previewer/window_stage_modules/BUILD.gn +++ b/previewer/window_stage_modules/BUILD.gn @@ -29,7 +29,7 @@ template("gen_js_src_binary") { gen_obj(target_name + "_js") { input = invoker.js_source - if (is_mac || is_mingw) { + if (is_mac || is_mingw || is_linux) { output = target_out_dir + "/" + invoker.target_name + "_js.c" } else { output = target_out_dir + "/" + invoker.target_name + "_js.o" @@ -43,7 +43,7 @@ template("gen_js_src_binary") { get_label_info(":gen_abc_" + invoker.target_name, "target_out_dir") + "/" + get_path_info(invoker.js_source, "name") + ".abc" - if (is_mac || is_mingw) { + if (is_mac || is_mingw || is_linux) { output = target_out_dir + "/" + invoker.target_name + "_abc.c" } else { output = target_out_dir + "/" + invoker.target_name + "_abc.o" -- Gitee