From 6c9595228627f61b4f252a04ee425b8df962322e Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Thu, 15 Aug 2024 19:24:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=9B=9E=E9=80=80PR370?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- .../src/main/cpp/types/libflutter/index.d.ets | 2 - .../main/ets/embedding/engine/FlutterNapi.ets | 5 - .../engine/renderer/FlutterRenderer.ets | 4 - .../src/main/ets/view/TextureRegistry.ets | 1 - shell/platform/ohos/library_loader.cpp | 3 - .../ohos/napi/platform_view_ohos_napi.cpp | 17 --- .../ohos/napi/platform_view_ohos_napi.h | 4 - .../ohos/ohos_external_texture_gl.cpp | 113 ++---------------- .../platform/ohos/ohos_external_texture_gl.h | 12 +- shell/platform/ohos/platform_view_ohos.cpp | 11 -- shell/platform/ohos/platform_view_ohos.h | 2 - 11 files changed, 11 insertions(+), 163 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets index 142a41da70..f88f0688f8 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets @@ -123,6 +123,4 @@ export const nativeUnregisterTexture: (nativeShellHolderId: number, textureId: n export const nativeRegisterPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; -export const nativeSetTextureBackGroundPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; - export const nativeRegisterTexture: (nativeShellHolderId: number, textureId: number) => number; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets index 6fcf4a574f..bf10b17cab 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets @@ -467,11 +467,6 @@ export default class FlutterNapi { flutter.nativeRegisterPixelMap(this.nativeShellHolderId!, textureId, pixelMap); } - setTextureBackGroundPixelMap(textureId: number, pixelMap: PixelMap): void { - Log.d(TAG, "called setTextureBackGroundPixelMap "); - flutter.nativeSetTextureBackGroundPixelMap(this.nativeShellHolderId!, textureId, pixelMap); - } - registerTexture(textureId: number): number { Log.d(TAG, "called registerTexture "); if (!this.isAttached()) { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets index 5d9fe37697..c6bf632f88 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets @@ -62,10 +62,6 @@ export class FlutterRenderer implements TextureRegistry { return this.nextTextureId; } - setTextureBackGroundPixelMap(textureId: number, pixelMap: PixelMap): void { - this.flutterNapi.setTextureBackGroundPixelMap(textureId, pixelMap); - } - unregisterTexture(textureId: number): void { this.flutterNapi.unregisterTexture(textureId); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets index 8568b03568..fa79eb238c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets @@ -21,7 +21,6 @@ export interface TextureRegistry { registerTexture(textureId: number): SurfaceTextureEntry; registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; registerPixelMap(pixelMap: PixelMap): number; - setTextureBackGroundPixelMap(textureId: number, pixelMap: PixelMap): void; unregisterTexture(textureId: number): void; onTrimMemory(level: number) : void; } diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index c6289c3017..653cbc76f0 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -126,9 +126,6 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeRegisterPixelMap", flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), - DECLARE_NAPI_FUNCTION( - "nativeSetTextureBackGroundPixelMap", - flutter::PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap), }; diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index a3a3110cb0..2d0cc3adc6 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1529,23 +1529,6 @@ napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap( return nullptr; } -napi_value PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap( - napi_env env, - napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap"; - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder; - int64_t textureId; - NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); - NAPI_CALL(env, napi_get_value_int64(env, args[0], &shell_holder)); - NAPI_CALL(env, napi_get_value_int64(env, args[1], &textureId)); - NativePixelMap *nativePixelMap = OH_PixelMap_InitNativePixelMap(env, args[2]); - OHOS_SHELL_HOLDER->GetPlatformView()->SetExternalTextureBackGroundPixelMap(textureId, nativePixelMap); - return nullptr; -} - void PlatformViewOHOSNapi::SurfaceCreated(int64_t shell_holder, void* window) { auto native_window = fml::MakeRefCounted( static_cast(window)); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 09d3424d9e..b91367ae88 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -171,10 +171,6 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); - static napi_value nativeSetTextureBackGroundPixelMap( - napi_env env, - napi_callback_info info); - static napi_value nativeRegisterTexture( napi_env env, napi_callback_info info); diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 23f08e7292..8562db24ab 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -63,10 +63,6 @@ OHOSExternalTextureGL::~OHOSExternalTextureGL() glDeleteTextures(1, &texture_name_); texture_name_ = 0; } - if (backGroundTextureName_ != 0) { - glDeleteTextures(1, &backGroundTextureName_); - backGroundTextureName_ = 0; - } state_ = AttachmentState::uninitialized; nativeImage_ = nullptr; backGroundNativeImage_ = nullptr; @@ -193,9 +189,6 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() glDeleteTextures(1, &texture_name_); } state_ = AttachmentState::detached; - if (backGroundTextureName_ != 0) { - glDeleteTextures(1, &backGroundTextureName_); - } } void OHOSExternalTextureGL::MarkNewFrameAvailable() @@ -211,7 +204,6 @@ void OHOSExternalTextureGL::OnTextureUnregistered() first_update_ = false; OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); OH_NativeImage_Destroy(&nativeImage_); - OH_NativeImage_Destroy(&backGroundNativeImage_); } void OHOSExternalTextureGL::Update() @@ -222,7 +214,7 @@ void OHOSExternalTextureGL::Update() return; } first_update_ = true; - UpdateTransform(nativeImage_); + UpdateTransform(); } void OHOSExternalTextureGL::Detach() @@ -232,17 +224,15 @@ void OHOSExternalTextureGL::Detach() return; } OH_NativeImage_DetachContext(nativeImage_); - OH_NativeImage_DetachContext(backGroundNativeImage_); OH_NativeWindow_DestroyNativeWindow(nativeWindow_); - OH_NativeWindow_DestroyNativeWindow(backGroundNativeWindow_); nativeImage_ = nullptr; nativeWindow_ = nullptr; } -void OHOSExternalTextureGL::UpdateTransform(OH_NativeImage *image) +void OHOSExternalTextureGL::UpdateTransform() { float m[16] = { 0.0f }; - int32_t ret = OH_NativeImage_GetTransformMatrixV2(image, m); + int32_t ret = OH_NativeImage_GetTransformMatrixV2(nativeImage_, m); if (ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_GetTransformMatrixV2 err code:"<< ret; } @@ -291,23 +281,10 @@ void OHOSExternalTextureGL::setBackground(int32_t width, int32_t height) return; } } - int32_t ret = OH_NativeImage_AttachContext(backGroundNativeImage_, backGroundTextureName_); - if (ret != 0) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL::setBackground OH_NativeImage_AttachContext err code:"<< ret; - } } else { FML_DLOG(FATAL)<<"ResourceContextMakeCurrent failed"; } - if (backGroundPixelMap_ != nullptr) { - ProducePixelMapToBackGroundImage(); - } else { - ProduceColorToBackGroundImage(width, height); - } -} -void OHOSExternalTextureGL::ProduceColorToBackGroundImage(int32_t width, int32_t height) -{ - FML_DLOG(INFO) << "OHOSExternalTextureGL::ProduceColorToBackGroundImage"; int code = SET_BUFFER_GEOMETRY; int32_t ret = OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, code, width, height); if (ret != 0) { @@ -331,7 +308,7 @@ void OHOSExternalTextureGL::ProduceColorToBackGroundImage(int32_t width, int32_t uint32_t* destAddr = static_cast(mappedAddr); uint32_t value = 0xFFFFFFFF; - for (int32_t x = 0; x < handle->width; x++) { + for(int32_t x = 0; x < handle->width; x++) { for (int32_t y = 0; y < handle->height; y++) { *destAddr++ = value; } @@ -352,76 +329,11 @@ void OHOSExternalTextureGL::ProduceColorToBackGroundImage(int32_t width, int32_t ret = OH_NativeImage_UpdateSurfaceImage(backGroundNativeImage_); if (ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL::setBackground OH_NativeImage_UpdateSurfaceImage err code:"<< ret; - return; } } -void OHOSExternalTextureGL::ProducePixelMapToBackGroundImage() -{ - FML_DLOG(INFO) << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage"; - if (backGroundPixelMap_ == nullptr) { - FML_DLOG(INFO) << "backGroundPixelMap_ is nullptr"; - return; - } - int32_t ret = -1; - ret = OH_PixelMap_GetImageInfo(backGroundPixelMap_, &pixelMapInfo); - if (ret != 0) { - FML_DLOG(ERROR) - << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage " - "OH_PixelMap_GetImageInfo err:" - << ret; - return; - } - int code = SET_BUFFER_GEOMETRY; - ret = OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, code, pixelMapInfo.width, pixelMapInfo.height); - if (ret != 0) { - FML_DLOG(ERROR) - << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage " - "OH_NativeWindow_NativeWindowHandleOpt err:" - << ret; - return; - } - - int32_t usage = 0; - OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, GET_USAGE, &usage); - usage |= NATIVEBUFFER_USAGE_CPU_READ; - OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, SET_USAGE, usage); - - if (backGroundBuffer_ != nullptr) { - OH_NativeWindow_NativeWindowAbortBuffer(backGroundNativeWindow_, backGroundBuffer_); - backGroundBuffer_ = nullptr; - } - ret = OH_NativeWindow_NativeWindowRequestBuffer(backGroundNativeWindow_, &backGroundBuffer_, &backGroundFenceFd); - if (ret != 0) { - FML_DLOG(ERROR) - << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage " - "OH_NativeWindow_NativeWindowRequestBuffer err:" - << ret; - return; - } - HandlePixelMapBuffer(backGroundPixelMap_, backGroundBuffer_); - Region region{nullptr, 0}; - ret = OH_NativeWindow_NativeWindowFlushBuffer(backGroundNativeWindow_, backGroundBuffer_, backGroundFenceFd, region); - if (ret != 0) { - FML_DLOG(FATAL) - << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage " - "OH_NativeWindow_NativeWindowFlushBuffer err:" - << ret; - } - ret = OH_NativeImage_UpdateSurfaceImage(backGroundNativeImage_); - if (ret != 0) { - FML_DLOG(FATAL) - << "OHOSExternalTextureGL::ProducePixelMapToBackGroundImage " - "OH_NativeImage_UpdateSurfaceImage err code:" - << ret; - return; - } - UpdateTransform(backGroundNativeImage_); -} - -void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNativeWindowBuffer* buffer) -{ - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); +void OHOSExternalTextureGL::HandlePixelMapBuffer() + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer_); // get virAddr of bufferHandl by mmap sys interface uint32_t stride = handle->stride; FML_DLOG(INFO) << "OHOSExternalTextureGL stride:" << stride; @@ -432,7 +344,7 @@ void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNat } void *pixelAddr = nullptr; - int64_t ret = OH_PixelMap_AccessPixels(pixelMap, &pixelAddr); + int64_t ret = OH_PixelMap_AccessPixels(pixelMap_, &pixelAddr); if (ret != IMAGE_RESULT_SUCCESS) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_PixelMap_AccessPixels err:"<< ret; return; @@ -458,7 +370,7 @@ void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNat pixel += pixelMapInfo.width; } } - OH_PixelMap_UnAccessPixels(pixelMap); + OH_PixelMap_UnAccessPixels(pixelMap_); // munmap after use ret = munmap(mappedAddr, handle->size); if (ret == -1) { @@ -502,7 +414,7 @@ void OHOSExternalTextureGL::ProducePixelMapToNativeImage() if (ret != 0) { FML_DLOG(ERROR) << "OHOSExternalTextureGL OH_NativeWindow_NativeWindowRequestBuffer err:" << ret; } - HandlePixelMapBuffer(pixelMap_, buffer_); + HandlePixelMapBuffer(); Region region{nullptr, 0}; ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer_, fenceFd, region); if (ret != 0) { @@ -557,11 +469,4 @@ void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) } } -void OHOSExternalTextureGL::DispatchBackGroundPixelMap(NativePixelMap* pixelMap) -{ - if (pixelMap != nullptr) { - backGroundPixelMap_ = pixelMap; - } -} - } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 29d2e3eb9f..39999f7ef0 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -65,8 +65,6 @@ class OHOSExternalTextureGL : public flutter::Texture { void DispatchPixelMap(NativePixelMap* pixelMap); - void DispatchBackGroundPixelMap(NativePixelMap* pixelMap); - private: void Attach(); @@ -74,20 +72,16 @@ class OHOSExternalTextureGL : public flutter::Texture { void Detach(); - void UpdateTransform(OH_NativeImage *image); + void UpdateTransform(); EGLDisplay GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list); bool CheckEglExtension(const char *extensions, const char *extension); - void HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNativeWindowBuffer* buffer); + void HandlePixelMapBuffer(); void ProducePixelMapToNativeImage(); - void ProduceColorToBackGroundImage(int32_t width, int32_t height); - - void ProducePixelMapToBackGroundImage(); - enum class AttachmentState { uninitialized, attached, detached }; AttachmentState state_; @@ -110,8 +104,6 @@ class OHOSExternalTextureGL : public flutter::Texture { OHNativeWindowBuffer *backGroundBuffer_; - NativePixelMap* backGroundPixelMap_; - NativePixelMap* pixelMap_; ImageNative* lastImage_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index fe4c393b2c..a9d5921819 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -473,7 +473,6 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) FML_DLOG(ERROR) << "Error with OH_NativeImage_GetSurfaceId"; return surface_id; } - external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); } return surface_id; @@ -544,16 +543,6 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat } } -void PlatformViewOHOS::SetExternalTextureBackGroundPixelMap(int64_t texture_id, NativePixelMap* pixelMap) -{ - if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - auto iter = external_texture_gl_.find(texture_id); - if (iter != external_texture_gl_.end()) { - iter->second->DispatchBackGroundPixelMap(pixelMap); - } - } -} - void PlatformViewOHOS::OnTouchEvent(const std::shared_ptr touchPacketString, int size) { return napi_facade_->FlutterViewOnTouchEvent(touchPacketString, size); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index cccbc04846..8d0c3ef6be 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -95,8 +95,6 @@ class PlatformViewOHOS final : public PlatformView { uint64_t RegisterExternalTexture(int64_t texture_id); void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); - - void SetExternalTextureBackGroundPixelMap(int64_t texture_id, NativePixelMap* pixelMap); void UnRegisterExternalTexture(int64_t texture_id); -- Gitee From 83e11c0cdc3a45c17681b5508a7558dd0f566892 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Thu, 15 Aug 2024 19:55:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=9B=9E=E9=80=80PR398=E4=B8=AD=E5=AF=B9PR?= =?UTF-8?q?370=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 8562db24ab..60f8342eda 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -52,7 +52,6 @@ OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptrstride; -- Gitee From 0482aad5adffc4a1e30e0d489431c0ca3d6983f4 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Fri, 16 Aug 2024 18:17:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 60f8342eda..1130d5b3c3 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -223,7 +223,6 @@ void OHOSExternalTextureGL::Detach() } OH_NativeImage_DetachContext(nativeImage_); OH_NativeWindow_DestroyNativeWindow(nativeWindow_); - nativeImage_ = nullptr; nativeWindow_ = nullptr; } -- Gitee From 8a3cc2840529faa09f9a3bd249abf7a530f5f565 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Fri, 16 Aug 2024 20:27:38 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86c++=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 1130d5b3c3..aa9b14ca9a 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,7 +42,6 @@ constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) : Texture(id), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { - state_ = AttachmentState::uninitialized; nativeImage_ = nullptr; backGroundNativeImage_ = nullptr; nativeWindow_ = nullptr; @@ -60,27 +59,11 @@ OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { glDeleteTextures(1, &texture_name_); - texture_name_ = 0; } - state_ = AttachmentState::uninitialized; - nativeImage_ = nullptr; - backGroundNativeImage_ = nullptr; - nativeWindow_ = nullptr; - backGroundNativeWindow_ = nullptr; - eglContext_ = EGL_NO_CONTEXT; - eglDisplay_ = EGL_NO_DISPLAY; - buffer_ = nullptr; - backGroundBuffer_ = nullptr; - pixelMap_ = nullptr; - lastImage_ = nullptr; } void OHOSExternalTextureGL::Attach() { - if (state_ != AttachmentState::uninitialized) { - FML_LOG(ERROR) << "OHOSExternalTextureGL::Attach "; - return; - } OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); @@ -217,13 +200,8 @@ void OHOSExternalTextureGL::Update() void OHOSExternalTextureGL::Detach() { - if (state_ != AttachmentState::attached) { - FML_LOG(ERROR) << "OHOSExternalTextureGL::Detach "; - return; - } OH_NativeImage_DetachContext(nativeImage_); OH_NativeWindow_DestroyNativeWindow(nativeWindow_); - nativeWindow_ = nullptr; } void OHOSExternalTextureGL::UpdateTransform() @@ -383,10 +361,7 @@ void OHOSExternalTextureGL::ProducePixelMapToNativeImage() FML_DLOG(ERROR) << "OHOSExternalTextureGL AttachmentState err"; return; } - if (pixelMap_ == nullptr) { - FML_DLOG(ERROR) << "pixelMap_ is nullptr"; - return; - } + int32_t ret = -1; ret = OH_PixelMap_GetImageInfo(pixelMap_, &pixelMapInfo); if (ret != 0) { -- Gitee