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