From 34fefc40b47cae104865de4882d3a0584667d330 Mon Sep 17 00:00:00 2001 From: zhangzhichao0091 Date: Wed, 20 May 2026 16:32:55 +0800 Subject: [PATCH] revert customized buffer consumer Signed-off-by: zhangzhichao0091 Change-Id: I394004f2100d29b043c01477e472796e4ba8cd91 --- frameworks/native/appkit/app/main_thread.cpp | 27 +++++++------------ .../kits/native/appkit/app/main_thread.h | 3 +-- .../include/mock_ui_content.h | 3 +-- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 84d4ba2c63..78de5e493f 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -2273,13 +2273,6 @@ void MainThread::ProcessExit(const ProcessExitInfo& info) } #if defined(NWEB) && defined(NWEB_GRAPHIC) -class CustomizedBufferConsumerListener : public IBufferConsumerListener { -public: - CustomizedBufferConsumerListener() {} - ~CustomizedBufferConsumerListener() {} - - void OnBufferAvailable() override {} -}; void MainThread::HandleNWebPreload() { if (!mainHandler_) { @@ -2292,21 +2285,21 @@ void MainThread::HandleNWebPreload() TAG_LOGE(AAFwkTag::APPKIT, "init NWebEngine failed"); return; } - cSurface_ = IConsumerSurface::Create(NWEB_SURFACE_NODE_NAME); - if (cSurface_ == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "create cSurface failed"); + Rosen::RSSurfaceNodeConfig config; + config.SurfaceNodeName = NWEB_SURFACE_NODE_NAME; + preloadSurfaceNode_ = Rosen::RSSurfaceNode::Create(config, false); + if (!preloadSurfaceNode_) { + TAG_LOGE(AAFwkTag::APPKIT, "preload surface node is nullptr"); return; } - auto producer = cSurface_->GetProducer(); - pSurface_ = Surface::CreateSurfaceAsProducer(producer); - if (pSurface_ == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "create pSurface failed"); + auto surface = preloadSurfaceNode_->GetSurface(); + if (!surface) { + TAG_LOGE(AAFwkTag::APPKIT, "preload surface is nullptr"); + preloadSurfaceNode_ = nullptr; return; } - sptr listener = sptr::MakeSptr(); - cSurface_->RegisterConsumerListener(listener); auto initArgs = std::make_shared(); - preloadNWeb_ = NWeb::NWebAdapterHelper::Instance().CreateNWeb(pSurface_, initArgs, + preloadNWeb_ = NWeb::NWebAdapterHelper::Instance().CreateNWeb(surface, initArgs, NWEB_SURFACE_SIZE, NWEB_SURFACE_SIZE, false); if (!preloadNWeb_) { TAG_LOGE(AAFwkTag::APPKIT, "create preLoadNWeb failed"); diff --git a/interfaces/kits/native/appkit/app/main_thread.h b/interfaces/kits/native/appkit/app/main_thread.h index e529a6cec5..108b737f5d 100644 --- a/interfaces/kits/native/appkit/app/main_thread.h +++ b/interfaces/kits/native/appkit/app/main_thread.h @@ -789,8 +789,7 @@ private: std::string pluginDefaultNamespaceLdDictionary_ = ""; RuntimeUpdateParam runtimeUpdateParam_; #if defined(NWEB) && defined(NWEB_GRAPHIC) - sptr cSurface_ = nullptr; - sptr pSurface_ = nullptr; + Rosen::RSSurfaceNode::SharedPtr preloadSurfaceNode_ = nullptr; std::shared_ptr preloadNWeb_ = nullptr; #endif diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h index 58ac36977e..1cefffb328 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h @@ -66,8 +66,7 @@ public: MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level)); MOCK_METHOD1(SetAppWindowTitle, void(const std::string &title)); MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr &pixelMap)); - MOCK_METHOD4(PreInitializeForm, void(OHOS::Rosen::Window *window, const std::string &url, napi_value storage, - sptr connectToRender)); + MOCK_METHOD3(PreInitializeForm, void(OHOS::Rosen::Window *window, const std::string &url, napi_value storage)); MOCK_METHOD0(RunFormPage, void()); MOCK_METHOD0(GetFormRootNode, std::shared_ptr()); MOCK_METHOD1(UpdateFormData, void(const std::string &data));