From 7d327ffa54792614237bed2d575fd6d07026d10b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 24 Sep 2024 22:37:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E5=9B=BE=E7=89=87=E5=9C=BA=E6=99=AF=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_external_texture_gl.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index a5f2ab3df7..3c4c9f91a2 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -224,10 +224,6 @@ void OHOSExternalTextureGL::OnTextureUnregistered() << ", Id()=" << Id() << ", nativeImage_=" << nativeImage_ << ", backGroundNativeImage_=" << backGroundNativeImage_; - if (state_ != AttachmentState::attached) { - FML_LOG(ERROR) << "OHOSExternalTextureGL::OnTextureUnregistered, the current status is not attached"; - return; - } first_update_ = false; if (nativeImage_ != nullptr) { OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); -- Gitee From 6c45b7c0515c5bea8c707191297fa5fc3c22e264 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 12:06:41 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=96=B9=E6=B3=95=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_main.cpp | 34 ------------------- .../platform/ohos/ohos_xcomponent_adapter.cpp | 4 +-- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index 90b6620729..6e5553f5cf 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -35,40 +35,6 @@ namespace flutter { -std::vector StringArrayToVector(napi_env env, - napi_value arrayValue) { - napi_status status; - uint32_t arrayLength = 0; - status = napi_get_array_length(env, arrayValue, &arrayLength); - LOGE("StringArrayToVector get array length %{pubilc}d", arrayLength); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_array_length error "); - } - std::vector stringArray; - for (uint32_t i = 0; i < arrayLength; i++) { - napi_value elementValue; - status = napi_get_element(env, arrayValue, i, &elementValue); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_element error"); - } - size_t stringLength; - status = napi_get_value_string_utf8(env, elementValue, nullptr, 0, - &stringLength); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_value_string_utf8 error"); - } - - std::string stringValue(stringLength, '\0'); - status = napi_get_value_string_utf8(env, elementValue, &stringValue[0], - stringLength + 1, nullptr); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_value_string_utf8 error"); - } - stringArray.push_back(stringValue); - } - return stringArray; -} - OhosMain::OhosMain(const flutter::Settings& settings) : settings_(settings), observatory_uri_callback_() {} diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 562e17f44b..4d49b0c753 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -345,14 +345,14 @@ void XComponentBase::OnSurfaceChanged(OH_NativeXComponent* component, void* wind int32_t ret = OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_); if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - LOGD("XComponent Current width:%{public}d,height:%{public}d", + LOGD("XComponentManger::OnSurfaceChanged Current width:%{public}d,height:%{public}d", static_cast(width_), static_cast(height_)); } if (isEngineAttached_) { PlatformViewOHOSNapi::SurfaceChanged(std::stoll(shellholderId_), width_, height_); } else { - LOGE("OnSurfaceChanged XComponentBase is not attached"); + LOGE("XComponentManger::OnSurfaceChanged XComponentBase is not attached"); } } -- Gitee From 63e0aed14ff083146fce100b9b550f61ea336864 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 12:08:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E7=BB=98=E5=88=B6=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../ohos/ohos_external_texture_gl.cpp | 34 +++++++------------ .../platform/ohos/ohos_external_texture_gl.h | 4 +-- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 3c4c9f91a2..c414e5c3ee 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -95,9 +95,9 @@ void OHOSExternalTextureGL::Attach() OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; + FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); + FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); if (nativeImage_ == nullptr) { nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); if (nativeImage_ == nullptr) { @@ -130,19 +130,14 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_LOG(ERROR) << "OHOSExternalTextureGL::Paint, the current status is detached"; return; } - if (state_ == AttachmentState::uninitialized) { - Attach(); - if (!freeze && new_frame_ready_ && pixelMap_ != nullptr) { + if (!freeze && new_frame_ready_) { + if (pixelMap_ != nullptr) { ProducePixelMapToNativeImage(); - Update(); } + Update(); new_frame_ready_ = false; } - if (!freeze && texture_update_ && pixelMap_ == nullptr) { - Update(); - } - GrGLTextureInfo textureInfo; if (!freeze && !first_update_ && !isEmulator_ && !new_frame_ready_ && pixelMap_ == nullptr) { @@ -189,13 +184,13 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, void OHOSExternalTextureGL::OnGrContextCreated() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextCreated"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextCreated"; state_ = AttachmentState::uninitialized; } void OHOSExternalTextureGL::OnGrContextDestroyed() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextDestroyed"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextDestroyed"; if (state_ == AttachmentState::attached) { Detach(); glDeleteTextures(1, &texture_name_); @@ -208,14 +203,12 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() void OHOSExternalTextureGL::MarkNewFrameAvailable() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::MarkNewFrameAvailable"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::MarkNewFrameAvailable"; new_frame_ready_ = true; - texture_update_ = true; - if (pixelMap_ == nullptr) { - Update(); - } else { - FML_DLOG(INFO) << "pixelMap_ is nullptr, texture_name_=" << texture_name_; + if (texture_name_ == 0) { + Attach(); } + Update(); } void OHOSExternalTextureGL::OnTextureUnregistered() @@ -248,7 +241,6 @@ void OHOSExternalTextureGL::Update() FML_LOG(ERROR) << "OHOSExternalTextureGL OH_NativeImage_UpdateSurfaceImage err code:" << ret; return; } - texture_update_ = false; first_update_ = true; UpdateTransform(nativeImage_); } @@ -296,7 +288,7 @@ void OHOSExternalTextureGL::DispatchImage(ImageNative* image) void OHOSExternalTextureGL::setBackground(int32_t width, int32_t height) { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::setBackground"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::setBackground"; if (backGroundNativeImage_ != nullptr) { return; } @@ -305,7 +297,7 @@ void OHOSExternalTextureGL::setBackground(int32_t width, int32_t height) OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; + FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &backGroundTextureName_); FML_DLOG(INFO) << "OHOSExternalTextureGL::setBackground, glGenTextures backGroundTextureName_=" << backGroundTextureName_; if (backGroundNativeImage_ == nullptr) { diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 495eb02594..5ac18743a6 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -92,12 +92,10 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - std::atomic state_; + AttachmentState state_; bool new_frame_ready_ = false; - bool texture_update_ = false; - GLuint texture_name_ = 0; GLuint backGroundTextureName_ = 0; -- Gitee From c009e39c0aa076f9dd98f61c40fc01b46bf8c77b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 20:38:25 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E7=BB=98=E5=88=B6=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_external_texture_gl.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index c414e5c3ee..92fdfd3441 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -130,17 +130,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_LOG(ERROR) << "OHOSExternalTextureGL::Paint, the current status is detached"; return; } - if (!freeze && new_frame_ready_) { - if (pixelMap_ != nullptr) { - ProducePixelMapToNativeImage(); - } - Update(); - new_frame_ready_ = false; - } GrGLTextureInfo textureInfo; - if (!freeze && !first_update_ && !isEmulator_ && !new_frame_ready_ && pixelMap_ == nullptr) { + if (!freeze && !first_update_ && !isEmulator_ && backGroundTextureName_ == 0 && pixelMap_ == nullptr) { setBackground(bounds.width(), bounds.height()); textureInfo = {GL_TEXTURE_EXTERNAL_OES, backGroundTextureName_, GL_RGBA8_OES}; } else { @@ -208,6 +201,9 @@ void OHOSExternalTextureGL::MarkNewFrameAvailable() if (texture_name_ == 0) { Attach(); } + if (pixelMap_ != nullptr) { // 外接纹理图片场景 + ProducePixelMapToNativeImage(); + } Update(); } -- Gitee From 30c31d91e79c33c6d467811df3428e4caa9366d7 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Mon, 30 Sep 2024 11:36:49 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_external_texture_gl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 92fdfd3441..46fa22e2a0 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -97,7 +97,8 @@ void OHOSExternalTextureGL::Attach() if (result->GetResult()) { FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); + FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" + << texture_name_ << ", Id()=" << Id(); if (nativeImage_ == nullptr) { nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); if (nativeImage_ == nullptr) { -- Gitee