diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 199a20cbc6acd16dc494e195d9fe82cbd9e68a22..f160e09469ace687db0b6cd5c68f5cf8cd91e85a 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()) { @@ -291,10 +293,15 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() void OHOSExternalTextureGL::MarkNewFrameAvailable() { FML_DLOG(INFO) << " OHOSExternalTextureGL::MarkNewFrameAvailable"; + if (state_ == AttachmentState::attached) { + Update(); + } if (state_ == AttachmentState::uninitialized) { Attach(); - } - if (state_ == AttachmentState::attached) { + if (pixelMap_ != nullptr) { + // 外接纹理图片场景 + ProducePixelMapToNativeImage(); + } Update(); } } @@ -779,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 92c7edda716a0d43c1ade785783d810f267de0fa..24beb3279de48788e6d3b945b06c0caa96859db1 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 4fc99fd3d752bcc3f46e7448be714b9faea0d07c..b1aca3a69c025b1c28c7870d49ea4e43f4af1521 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);