修复主窗口最大化,view没有同步问题
This commit is contained in:
parent
406cd03b02
commit
19347be837
@ -81,6 +81,10 @@ std::string uuid_v4() {
|
|||||||
void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) {
|
void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) {
|
||||||
// [StartExclude plugin_on_surface_created]
|
// [StartExclude plugin_on_surface_created]
|
||||||
OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponent_Native", "OnSurfaceCreatedCB");
|
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;
|
int32_t ret;
|
||||||
char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {};
|
char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {};
|
||||||
uint64_t idSize = 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<std::mutex> lock(mapMutex);
|
std::lock_guard<std::mutex> lock(mapMutex);
|
||||||
if (renderThreadMap.find(id) != renderThreadMap.end()) {
|
if (renderThreadMap.find(id) != renderThreadMap.end()) {
|
||||||
HILOG_ERROR(NATIVE_TAG,"uint64_t Size:%{public}dX%{public}d",width_,height_);
|
HILOG_ERROR(NATIVE_TAG,"uint32_t Size:%{public}dX%{public}d",width_,height_);
|
||||||
uint32_t _width=static_cast<uint32_t>(width_);
|
|
||||||
uint32_t _height=static_cast<uint32_t>(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};
|
|
||||||
renderThreadMap[id]->resizeWindow(width_, height_);
|
renderThreadMap[id]->resizeWindow(width_, height_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#ifndef NATIVE_TAG
|
#ifndef NATIVE_TAG
|
||||||
#define NATIVE_TAG "NativeRender"
|
#define NATIVE_TAG "NativeRender"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static std::mutex renderMutex;
|
||||||
namespace NativeOpenCAX {
|
namespace NativeOpenCAX {
|
||||||
|
|
||||||
NativeRender::NativeRender()
|
NativeRender::NativeRender()
|
||||||
@ -141,10 +143,18 @@ void NativeRender::render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeRender::resize(int width, int height) {
|
void NativeRender::resize(int width, int height) {
|
||||||
|
HILOG_ERROR(NATIVE_TAG,"Resize:(%{public}d,%{public}d)",width,height);
|
||||||
rendOption.width = width;
|
rendOption.width = width;
|
||||||
rendOption.height = height;
|
rendOption.height = height;
|
||||||
if (!rendOption.view.IsNull()) {
|
if (!rendOption.view.IsNull()) {
|
||||||
|
rendOption.window->SetSize(rendOption.width, rendOption.height);
|
||||||
|
rendOption.window->DoResize();
|
||||||
rendOption.view->MustBeResized();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,8 +63,8 @@ void NativeRenderThread::renderLoop() {
|
|||||||
while (isRunning_) {
|
while (isRunning_) {
|
||||||
RenderCommand command;
|
RenderCommand command;
|
||||||
bool hasCommand = false;
|
bool hasCommand = false;
|
||||||
std::unique_lock<std::mutex> lock(commandMutex_);
|
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(commandMutex_);
|
||||||
commandCondition_.wait_for(lock, std::chrono::milliseconds(16), [this] {
|
commandCondition_.wait_for(lock, std::chrono::milliseconds(16), [this] {
|
||||||
return !commandQueue_.empty();
|
return !commandQueue_.empty();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -48,5 +48,6 @@ bool InitView(RenderOption& opt) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeView() {}
|
void ChangeView() {}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user