From 19347be8379f519b54ec5fb8881b4d8637478fa5 Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Sat, 7 Mar 2026 21:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=8C=96,view=E6=B2=A1=E6=9C=89=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp | 11 +++++------ entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp | 10 ++++++++++ .../src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp | 2 +- entry/src/main/cpp/NativeEGLOCCT/View/View.cpp | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp index fa8d6e2a..15e6e50d 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp @@ -81,6 +81,10 @@ std::string uuid_v4() { void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) { // [StartExclude plugin_on_surface_created] OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponent_Native", "OnSurfaceCreatedCB"); + //主动关闭CPU访问窗口缓冲区数据降低功耗 + uint64_t usage = 0; + int32_t ret2 = OH_NativeWindow_NativeWindowHandleOpt((OHNativeWindow*)window, SET_USAGE, usage); + int32_t ret; char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {}; uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1; @@ -163,12 +167,7 @@ void NativeManager::OnSurfaceChanged(OH_NativeXComponent *component, void *windo { std::lock_guard lock(mapMutex); if (renderThreadMap.find(id) != renderThreadMap.end()) { - HILOG_ERROR(NATIVE_TAG,"uint64_t Size:%{public}dX%{public}d",width_,height_); - uint32_t _width=static_cast(width_); - uint32_t _height=static_cast(height_); - HILOG_ERROR(NATIVE_TAG,"uint32_t Size:%{public}dX%{public}d",_width,_height); - ArkUI_NumberValue comSizeData[] = {{.u32=_width}, {.u32=_height}}; - ArkUI_AttributeItem comSizeItem = {comSizeData, 2}; + HILOG_ERROR(NATIVE_TAG,"uint32_t Size:%{public}dX%{public}d",width_,height_); renderThreadMap[id]->resizeWindow(width_, height_); } } diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp index d16b8f5a..28541f8d 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp @@ -3,6 +3,8 @@ #ifndef NATIVE_TAG #define NATIVE_TAG "NativeRender" #endif + +static std::mutex renderMutex; namespace NativeOpenCAX { NativeRender::NativeRender() @@ -141,10 +143,18 @@ void NativeRender::render() { } void NativeRender::resize(int width, int height) { + HILOG_ERROR(NATIVE_TAG,"Resize:(%{public}d,%{public}d)",width,height); rendOption.width = width; rendOption.height = height; if (!rendOption.view.IsNull()) { + rendOption.window->SetSize(rendOption.width, rendOption.height); + rendOption.window->DoResize(); rendOption.view->MustBeResized(); + rendOption.view->Redraw(); + Standard_Integer theWidth; + Standard_Integer theHeight; + rendOption.window->Size(theWidth,theHeight); + HILOG_ERROR(NATIVE_TAG,"Resize:(%{public}d,%{public}d)",theWidth,theHeight); } } diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp index 471bc1e5..86eedc27 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp @@ -63,8 +63,8 @@ void NativeRenderThread::renderLoop() { while (isRunning_) { RenderCommand command; bool hasCommand = false; - std::unique_lock lock(commandMutex_); { + std::unique_lock lock(commandMutex_); commandCondition_.wait_for(lock, std::chrono::milliseconds(16), [this] { return !commandQueue_.empty(); }); diff --git a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp index bc5190d8..859dbf73 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp @@ -48,5 +48,6 @@ bool InitView(RenderOption& opt) { } return false; } + void ChangeView() {} } \ No newline at end of file