From 2c818aee1ab6a8e9934706ac44bdb7fe2574db55 Mon Sep 17 00:00:00 2001 From: liujiake Date: Thu, 5 Dec 2024 10:39:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujiake --- shell/platform/ohos/ohos_external_texture_gl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 199a20cbc6..924b9bdc9d 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -291,12 +291,17 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() void OHOSExternalTextureGL::MarkNewFrameAvailable() { FML_DLOG(INFO) << " OHOSExternalTextureGL::MarkNewFrameAvailable"; - if (state_ == AttachmentState::uninitialized) { - Attach(); - } if (state_ == AttachmentState::attached) { Update(); } + if (state_ == AttachmentState::uninitialized) { + Attach(); + if (pixelMap_ != nullptr) { + // 外接纹理图片场景 + ProducePixelMapToNativeImage(); + Update(); + } + } } void OHOSExternalTextureGL::OnTextureUnregistered() -- Gitee From 4d08374243df9e08bee3276be7b2659ddbc2477c Mon Sep 17 00:00:00 2001 From: liujiake Date: Thu, 5 Dec 2024 11:49:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E6=89=A7=E8=A1=8C=E7=BA=BF=E7=A8=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E5=BC=82=E5=B8=B8=E6=8A=A5=E9=94=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujiake --- shell/platform/ohos/ohos_external_texture_gl.cpp | 11 ++++++++--- shell/platform/ohos/ohos_external_texture_gl.h | 4 +++- shell/platform/ohos/platform_view_ohos.cpp | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 924b9bdc9d..7fd3498d16 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -85,9 +85,11 @@ static bool IsPixelMapYUVFormat(PIXEL_FORMAT format) OHOSExternalTextureGL::OHOSExternalTextureGL( int64_t id, const std::shared_ptr& ohos_surface, - PlatformView::Delegate& delegate) + PlatformView::Delegate& delegate, + const TaskRunners& task_runners) : Texture(id), delegate_(delegate), + task_runners_(task_runners), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { @@ -784,8 +786,11 @@ OhosImageFrameData::~OhosImageFrameData() void OhosImageFrameData::OnPlatformViewMarkTextureFrameAvailable() { if (ohosExternalTextureGL != nullptr) { - PlatformView::Delegate& dalegate = ohosExternalTextureGL->delegate_; - dalegate.OnPlatformViewMarkTextureFrameAvailable(textureId_); + fml::TaskRunner::RunNowOrPostTask( + ohosExternalTextureGL->task_runners_.GetPlatformTaskRunner(), [textureId = textureId_, this]() { + PlatformView::Delegate& dalegate = this->ohosExternalTextureGL->delegate_; + dalegate.OnPlatformViewMarkTextureFrameAvailable(textureId); + }); } } diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 92c7edda71..24beb3279d 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -40,12 +40,14 @@ class OHOSExternalTextureGL : public flutter::Texture { public: explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface); explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface, - PlatformView::Delegate& delegate); + PlatformView::Delegate& delegate, const TaskRunners& task_runners); ~OHOSExternalTextureGL() override; PlatformView::Delegate& delegate_; + const TaskRunners& task_runners_; + OH_NativeImage *nativeImage_; OH_NativeImage *backGroundNativeImage_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 4fc99fd3d7..b1aca3a69c 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -433,7 +433,7 @@ void PlatformViewOHOS::RegisterExternalTextureByImage(int64_t texture_id, iter->second->DispatchImage(image); } else { std::shared_ptr ohos_external_gl = - std::make_shared(texture_id, ohos_surface_, delegate_); + std::make_shared(texture_id, ohos_surface_, delegate_, task_runners_); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchImage(image); @@ -454,7 +454,7 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) int ret = -1; if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { std::shared_ptr ohos_external_gl = - std::make_shared(texture_id, ohos_surface_, delegate_); + std::make_shared(texture_id, ohos_surface_, delegate_, task_runners_); ohos_external_gl->nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); if (ohos_external_gl->nativeImage_ == nullptr) { @@ -504,7 +504,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap( iter->second->DispatchPixelMap(pixelMap); } else { std::shared_ptr ohos_external_gl = - std::make_shared(texture_id, ohos_surface_, delegate_); + std::make_shared(texture_id, ohos_surface_, delegate_, task_runners_); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchPixelMap(pixelMap); -- Gitee From 1ef956f6fd65bfac2be61e3d183aad455a3aa542 Mon Sep 17 00:00:00 2001 From: liujiake Date: Thu, 5 Dec 2024 12:17:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9update=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E6=9C=BA=EF=BC=8C=E4=BF=AE=E5=A4=8Dwebview=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujiake --- shell/platform/ohos/ohos_external_texture_gl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 7fd3498d16..f160e09469 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -301,8 +301,8 @@ void OHOSExternalTextureGL::MarkNewFrameAvailable() if (pixelMap_ != nullptr) { // 外接纹理图片场景 ProducePixelMapToNativeImage(); - Update(); } + Update(); } } -- Gitee