From 0059f9ba045e250e0a690f0e6b3d7830c6c85af2 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Thu, 28 Dec 2023 16:15:16 +0800 Subject: [PATCH 01/69] =?UTF-8?q?Engine=E5=AE=9E=E7=8E=B0ohos=E5=A4=96?= =?UTF-8?q?=E6=8E=A5=E7=BA=B9=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/platform/ohos/BUILD.gn | 2 + shell/platform/ohos/library_loader.cpp | 9 ++ .../ohos/napi/platform_view_ohos_napi.cpp | 43 +++++++++ .../ohos/napi/platform_view_ohos_napi.h | 9 ++ .../ohos/ohos_external_texture_gl.cpp | 87 +++++++++++++++++-- .../platform/ohos/ohos_external_texture_gl.h | 13 ++- shell/platform/ohos/platform_view_ohos.cpp | 22 +++++ shell/platform/ohos/platform_view_ohos.h | 8 ++ 8 files changed, 185 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 8d18085468..3d631d79e0 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,6 +220,8 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] + ldflags += ["-limage_ndk.z"] + ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 7f88815b7b..f6c3d03588 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,6 +101,15 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), + DECLARE_NAPI_FUNCTION( + "nativeInitNativeImage", + flutter::PlatformViewOHOSNapi::nativeInitNativeImage), + DECLARE_NAPI_FUNCTION( + "nativeUnregisterTexture", + flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), + DECLARE_NAPI_FUNCTION( + "nativeMarkTextureFrameAvailable", + flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 3da5999832..8ce1a396f4 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,6 +26,8 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" +#include +#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1418,6 +1420,47 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeInitNativeImage( + napi_env env, napi_callback_info info) +{ + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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)); + ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); + // std::unique_ptr uImage; + OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTexture(textureId, imageNative); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( + napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( + napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); + return nullptr; +} + int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index d32a6fe996..42fd730314 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,6 +143,15 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 + static napi_value nativeInitNativeImage(napi_env env, + napi_callback_info info); + + static napi_value nativeUnregisterTexture(napi_env env, + napi_callback_info info); + + static napi_value nativeMarkTextureFrameAvailable(napi_env env, + napi_callback_info info); + // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index f2ffccbaa8..21ab4d36fb 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,7 +14,6 @@ */ #include "ohos_external_texture_gl.h" -#include #include @@ -25,13 +24,18 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" +#include +#include + namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int id) - : Texture(id), transform(SkMatrix::I()) {} +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) + : Texture(id),transform(SkMatrix::I()) { +} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { + glDeleteTextures(1, &texture_name_); } } @@ -43,6 +47,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { + glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -50,7 +55,8 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, + GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -87,6 +93,8 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); + glDeleteTextures(1, &texture_name_); + OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -100,22 +108,89 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - // do nothing + OH_NativeImage_AttachContext(nativeImage, textureName); } void OHOSExternalTextureGL::Update() { + OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - // do nothing + OH_NativeImage_DetachContext(nativeImage); } void OHOSExternalTextureGL::UpdateTransform() { + float m[16] = { 0.0f }; + OH_NativeImage_GetTransformMatrix(nativeImage, m); + //transform ohos 4x4 matrix to skia 3x3 matrix + SkScalar matrix3[] = { + m[0], m[4], m[12], // + m[1], m[5], m[13], // + m[3], m[7], m[15], // + }; + transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } + +void OHOSExternalTextureGL::DispatchImage(ImageNative* image) +{ + if(image == nullptr) { + return; + } + + if (state_ == AttachmentState::detached) { + return; + } + if (state_ == AttachmentState::uninitialized) { + glGenTextures(1, &texture_name_); + Attach(static_cast(texture_name_)); + state_ = AttachmentState::attached; + } + OhosImageComponent componentNative; + if (IMAGE_RESULT_SUCCESS != + OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { + FML_DLOG(FATAL)<<"get native component failed"; + return; + } + if(nativeImage == nullptr) { + nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); + } + OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); + int code = SET_BUFFER_GEOMETRY; + uint32_t width = componentNative.rowStride; + uint32_t height = componentNative.size / componentNative.rowStride; + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); + //get NativeWindowBuffer from NativeWindow + OHNativeWindowBuffer *buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + //get virAddr of bufferHandl by mmap sys interface + void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"mmap failed"; + return; + } + + uint8_t *value = componentNative.byteBuffer; + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + *pixel++ = *value++; + } + } + + //munmap after use + int result = munmap(mappedAddr, handle->size); + if (result == -1) { + FML_DLOG(FATAL)<<"munmap failed"; + } + +} + } // 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 aa08880048..66f8b068bd 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,17 +15,20 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" +#include +#include +#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int id); + explicit OHOSExternalTextureGL(int64_t id); ~OHOSExternalTextureGL() override; @@ -42,6 +45,8 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; + void DispatchImage(ImageNative* image); + private: void Attach(int textureName); @@ -53,6 +58,8 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; + // ImageNative* image_; + AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -61,6 +68,8 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; + OH_NativeImage *nativeImage; + FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 3fc6b6b1a6..c17dbeefc8 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,4 +386,26 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } +void PlatformViewOHOS::RegisterExternalTexture( + int64_t texture_id, + ImageNative* image) { + if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + auto iter = external_texture_gl_.find(texture_id); + if(iter != external_texture_gl_.end()) { + iter->second->DispatchImage(image); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchImage(image); + } + } +} + +void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) +{ + external_texture_gl_.erase(texture_id); + UnregisterTexture(texture_id); +} + } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index a1b863ed34..02d48e15b0 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,6 +31,8 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" +#include +#include "ohos_external_texture_gl.h" namespace flutter { @@ -84,6 +86,11 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); + void RegisterExternalTexture( + int64_t texture_id, + ImageNative* image); + + void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -117,6 +124,7 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; + std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 28e3fb71d2c28fafee10c34553a7872694f53d49 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Fri, 29 Dec 2023 14:29:22 +0800 Subject: [PATCH 02/69] add external texture register in embedding Signed-off-by: 18719058668 <718092089@qq.com> --- .../src/main/cpp/types/libflutter/index.d.ets | 4 +- .../ets/embedding/engine/FlutterEngine.ets | 9 +- .../FlutterEngineConnectionRegistry.ets | 2 +- .../main/ets/embedding/engine/FlutterNapi.ets | 5 ++ .../engine/plugins/FlutterPlugin.ets | 9 +- .../engine/renderer/FlutterRenderer.ets | 85 +++++++++++++++++++ .../engine/renderer/SurfaceTextureWrapper.ets | 15 ++++ .../src/main/ets/view/TextureRegistry.ets | 11 ++- 8 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets 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 0190226484..418dd07905 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 @@ -86,4 +86,6 @@ export const nativeSetViewportMetrics: (nativeShellHolderId: number, devicePixel export const nativeImageDecodeCallback: (width: number, height: number, imageGeneratorPointer: number, pixelMap : image.PixelMap | null) => void; -export const nativeGetSystemLanguages: (nativeShellHolderId: number, languages: Array) => void; \ No newline at end of file +export const nativeGetSystemLanguages: (nativeShellHolderId: number, languages: Array) => void; + +export const nativeInitNativeImage: (textureId: number, aImage: image.Image) => void; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index bd31355072..3254625d1e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -42,7 +42,7 @@ import PlatformViewsController from '../../plugin/platform/PlatformViewsControll import { FlutterPlugin } from './plugins/FlutterPlugin'; import List from '@ohos.util.List'; import GeneratedPluginRegister from './plugins/util/GeneratedPluginRegister'; - +import { FlutterRenderer } from './renderer/FlutterRenderer'; const TAG = "FlutterEngine"; @@ -68,6 +68,7 @@ export default class FlutterEngine implements EngineLifecycleListener{ private accessibilityChannel: AccessibilityChannel | null = null; private localeChannel: LocalizationChannel | null = null; private flutterNapi: FlutterNapi; + private renderer: FlutterRenderer; private pluginRegistry: FlutterEngineConnectionRegistry | null = null; private textInputPlugin: TextInputPlugin | null = null; private localizationPlugin: LocalizationPlugin | null = null; @@ -99,6 +100,8 @@ export default class FlutterEngine implements EngineLifecycleListener{ } this.flutterLoader = flutterLoader; + this.renderer = new FlutterRenderer(this.flutterNapi); + if(platformViewsController == null) { platformViewsController = new PlatformViewsController(); } @@ -218,6 +221,10 @@ export default class FlutterEngine implements EngineLifecycleListener{ return this.flutterNapi; } + getFlutterRenderer(): FlutterRenderer { + return this.renderer; + } + getDartExecutor(): DartExecutor { return this.dartExecutor } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets index be25395a31..90044b0dfc 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets @@ -55,7 +55,7 @@ export default class FlutterEngineConnectionRegistry implements PluginRegistry, constructor(appContext: common.Context, flutterEngine: FlutterEngine, flutterLoader: FlutterLoader) { this.flutterEngine = flutterEngine; - this.pluginBinding = new FlutterPluginBinding(appContext, flutterEngine, flutterEngine.getDartExecutor(), new DefaultFlutterAssets(flutterLoader), flutterEngine.getPlatformViewsController()?.getRegistry()); + this.pluginBinding = new FlutterPluginBinding(appContext, flutterEngine, flutterEngine.getDartExecutor(), new DefaultFlutterAssets(flutterLoader), flutterEngine.getFlutterRenderer(), flutterEngine.getPlatformViewsController()?.getRegistry()); } add(plugin: FlutterPlugin): void { 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 11f1b234fb..83215cda54 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 @@ -353,6 +353,11 @@ export default class FlutterNapi { } flutter.nativeGetSystemLanguages(this.nativeShellHolderId!, systemLanguages); } + + initNativeImage(textureId: number, aImage: image.Image) { + Log.d(TAG, "called initNativeImage ") + flutter.nativeInitNativeImage(textureId, aImage); + } } export interface AccessibilityDelegate { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets index 1b8ea40a05..92e08f8dd9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets @@ -17,6 +17,7 @@ import common from '@ohos.app.ability.common'; import { BinaryMessenger } from '../../../plugin/common/BinaryMessenger'; import PlatformViewFactory from '../../../plugin/platform/PlatformViewFactory'; import PlatformViewRegistry from '../../../plugin/platform/PlatformViewRegistry'; +import { TextureRegistry } from '../../../view/TextureRegistry'; import FlutterEngine from '../FlutterEngine'; export interface FlutterPlugin { @@ -52,13 +53,15 @@ export class FlutterPluginBinding { private flutterEngine: FlutterEngine; private binaryMessenger: BinaryMessenger; private flutterAssets: FlutterAssets; + private textureRegistry: TextureRegistry; private platformViewRegistry: PlatformViewRegistry; - constructor(applicationContext: common.Context, flutterEngine: FlutterEngine, binaryMessenger: BinaryMessenger, flutterAssets: FlutterAssets, platformViewRegistry?: PlatformViewRegistry) { + constructor(applicationContext: common.Context, flutterEngine: FlutterEngine, binaryMessenger: BinaryMessenger, flutterAssets: FlutterAssets, textureRegistry: TextureRegistry, platformViewRegistry?: PlatformViewRegistry) { this.applicationContext = applicationContext; this.flutterEngine = flutterEngine; this.binaryMessenger = binaryMessenger; this.flutterAssets = flutterAssets; + this.textureRegistry = textureRegistry; this.platformViewRegistry = platformViewRegistry ?? new EmptyPlatformViewRegistry(); } @@ -78,6 +81,10 @@ export class FlutterPluginBinding { return this.flutterAssets; } + getTextureRegistry(): TextureRegistry { + return this.textureRegistry; + } + public getPlatformViewRegistry(): PlatformViewRegistry { return this.platformViewRegistry; } 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 new file mode 100644 index 0000000000..0c23bbe174 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets @@ -0,0 +1,85 @@ +import image from '@ohos.multimedia.image'; +import { BusinessError } from '@ohos.base'; +import { SurfaceTextureEntry, TextureRegistry } from '../../../view/TextureRegistry'; +import { FlutterAbility } from '../../ohos/FlutterAbility'; +import FlutterNapi from '../FlutterNapi'; +import { SurfaceTextureWrapper } from './SurfaceTextureWrapper'; + +export class FlutterRenderer implements TextureRegistry { + private nextTextureId: number = 0; + private flutterNapi: FlutterNapi; + + constructor(flutterNapi: FlutterNapi) { + this.flutterNapi = flutterNapi; + } + createSurfaceTexture(): SurfaceTextureEntry { + let receiver: image.ImageReceiver = this.getImageReceiver(); + return this.registerSurfaceTexture(receiver); + } + + registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry { + this.nextTextureId = this.nextTextureId + 1; + let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId, receiver); + this.registerTexture(surfaceTextureRegistryEntry.id(), surfaceTextureRegistryEntry.textureWrapper()); + return surfaceTextureRegistryEntry; + } + + onTrimMemory(level: number) { + throw new Error('Method not implemented.'); + } + + private getImageReceiver(): image.ImageReceiver { + let receiver: image.ImageReceiver = image.createImageReceiver(640, 480, 4, 8); + if (receiver !== undefined) { + console.info('[camera test] ImageReceiver is ok'); + } else { + console.info('[camera test] ImageReceiver is not ok'); + } + return receiver; + } + private registerTexture(id: number, surfaceTextureWrapper: SurfaceTextureWrapper): void { + let receiver = surfaceTextureWrapper.getImageReceiver(); + receiver.on('imageArrival', () => { + receiver.readNextImage((err: BusinessError, nextImage: image.Image) => { + if (err || nextImage === undefined) { + return; + } + this.flutterNapi.initNativeImage(id, nextImage); + console.log("[camera test] format: " + nextImage.format); + nextImage.release((err : BusinessError) =>{ + if (err != undefined) { + console.log('Failed to release the image source instance.'); + } else { + console.log('Succeeded in releasing the image source instance.'); + } + }); + }) + }) + } +} + +export class SurfaceTextureRegistryEntry implements SurfaceTextureEntry { + private textureId: number; + private surfaceTextureWrapper: SurfaceTextureWrapper; + private released: boolean = false; + + constructor(id: number, receiver: image.ImageReceiver) { + this.textureId = id; + this.surfaceTextureWrapper = new SurfaceTextureWrapper(receiver); + } + + getImageReceiver(): image.ImageReceiver { + return this.surfaceTextureWrapper.getImageReceiver(); + } + + id(): number { + return this.textureId; + } + + textureWrapper(): SurfaceTextureWrapper { + return this.surfaceTextureWrapper; + } + release() { + throw new Error('Method not implemented.'); + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets new file mode 100644 index 0000000000..cbb7e8f64d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets @@ -0,0 +1,15 @@ +import image from '@ohos.multimedia.image'; + +export class SurfaceTextureWrapper { + private receiver: image.ImageReceiver; + private released: boolean = false; + private attached: boolean = false; + + constructor(receiver: image.ImageReceiver) { + this.receiver = receiver; + } + + getImageReceiver(): image.ImageReceiver { + return this.receiver; + } +} \ No newline at end of file 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 a37ab971b7..be74a221a0 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 @@ -12,25 +12,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import image from '@ohos.multimedia.image'; export interface TextureRegistry { createSurfaceTexture(): SurfaceTextureEntry; - registerSurfaceTexture(): SurfaceTextureEntry; + registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; onTrimMemory(level: number) : void; } -interface SurfaceTextureEntry { +export interface SurfaceTextureEntry { id(): number; + getImageReceiver(): image.ImageReceiver; + release(): void; } -interface OnFrameConsumedListener { +export interface OnFrameConsumedListener { onFrameConsumed(): void; } -interface OnTrimMemoryListener { +export interface OnTrimMemoryListener { onTrimMemory(level: number) : void; } \ No newline at end of file -- Gitee From dd9839a1671565d10a36abe411b46511bc6d8f00 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 8 Jan 2024 15:12:54 +0800 Subject: [PATCH 03/69] add registerpixelmap --- .../src/main/cpp/types/libflutter/index.d.ets | 6 +++++- .../src/main/ets/embedding/engine/FlutterNapi.ets | 14 ++++++++++++-- .../embedding/engine/renderer/FlutterRenderer.ets | 13 +++++++++++-- .../flutter/src/main/ets/view/TextureRegistry.ets | 3 ++- 4 files changed, 30 insertions(+), 6 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 418dd07905..67ede582ab 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 @@ -88,4 +88,8 @@ export const nativeImageDecodeCallback: (width: number, height: number, imageGen export const nativeGetSystemLanguages: (nativeShellHolderId: number, languages: Array) => void; -export const nativeInitNativeImage: (textureId: number, aImage: image.Image) => void; \ No newline at end of file +export const nativeInitNativeImage: (nativeShellHolderId: number, textureId: number, aImage: image.Image) => void; + +export const nativeUnregisterTexture: (nativeShellHolderId: number, textureId: number) => void; + +export const nativeRegisterPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; \ No newline at end of file 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 83215cda54..68228017bf 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 @@ -355,8 +355,18 @@ export default class FlutterNapi { } initNativeImage(textureId: number, aImage: image.Image) { - Log.d(TAG, "called initNativeImage ") - flutter.nativeInitNativeImage(textureId, aImage); + Log.d(TAG, "called initNativeImage "); + flutter.nativeInitNativeImage(this.nativeShellHolderId!, textureId, aImage); + } + + unregisterTexture(textureId: number): void { + Log.d(TAG, "called unregisterTexture "); + flutter.nativeUnregisterTexture(this.nativeShellHolderId!, textureId); + } + + registerPixelMap(textureId: number, pixelMap: PixelMap): void { + Log.d(TAG, "called registerPixelMap "); + flutter.nativeRegisterPixelMap(this.nativeShellHolderId!, textureId, pixelMap); } } 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 0c23bbe174..00755a33a9 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 @@ -24,6 +24,15 @@ export class FlutterRenderer implements TextureRegistry { return surfaceTextureRegistryEntry; } + registerPixelMap(pixelMap: PixelMap): number { + let textureId = this.nextTextureId + 1; + this.flutterNapi.registerPixelMap(textureId, pixelMap); + return textureId; + } + + unregisterTexture(textureId: number): void { + this.flutterNapi.unregisterTexture(textureId); + } onTrimMemory(level: number) { throw new Error('Method not implemented.'); } @@ -37,14 +46,14 @@ export class FlutterRenderer implements TextureRegistry { } return receiver; } - private registerTexture(id: number, surfaceTextureWrapper: SurfaceTextureWrapper): void { + private registerTexture(textureId: number, surfaceTextureWrapper: SurfaceTextureWrapper): void { let receiver = surfaceTextureWrapper.getImageReceiver(); receiver.on('imageArrival', () => { receiver.readNextImage((err: BusinessError, nextImage: image.Image) => { if (err || nextImage === undefined) { return; } - this.flutterNapi.initNativeImage(id, nextImage); + this.flutterNapi.initNativeImage(textureId, nextImage); console.log("[camera test] format: " + nextImage.format); nextImage.release((err : BusinessError) =>{ if (err != undefined) { 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 be74a221a0..28d95be297 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 @@ -18,7 +18,8 @@ export interface TextureRegistry { createSurfaceTexture(): SurfaceTextureEntry; registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; - + registerPixelMap(pixelMap: PixelMap): number; + unregisterTexture(textureId: number): void; onTrimMemory(level: number) : void; } -- Gitee From 3e3ecc553f1145a44d10004bf95efd4eacdc5295 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Mon, 8 Jan 2024 16:11:51 +0800 Subject: [PATCH 04/69] =?UTF-8?q?Revert=20"Engine=E5=AE=9E=E7=8E=B0ohos?= =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0059f9ba045e250e0a690f0e6b3d7830c6c85af2. --- shell/platform/ohos/BUILD.gn | 2 - shell/platform/ohos/library_loader.cpp | 9 -- .../ohos/napi/platform_view_ohos_napi.cpp | 43 --------- .../ohos/napi/platform_view_ohos_napi.h | 9 -- .../ohos/ohos_external_texture_gl.cpp | 87 ++----------------- .../platform/ohos/ohos_external_texture_gl.h | 13 +-- shell/platform/ohos/platform_view_ohos.cpp | 22 ----- shell/platform/ohos/platform_view_ohos.h | 8 -- 8 files changed, 8 insertions(+), 185 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 3d631d79e0..8d18085468 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,8 +220,6 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] - ldflags += ["-limage_ndk.z"] - ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index f6c3d03588..7f88815b7b 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,15 +101,6 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), - DECLARE_NAPI_FUNCTION( - "nativeInitNativeImage", - flutter::PlatformViewOHOSNapi::nativeInitNativeImage), - DECLARE_NAPI_FUNCTION( - "nativeUnregisterTexture", - flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), - DECLARE_NAPI_FUNCTION( - "nativeMarkTextureFrameAvailable", - flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 8ce1a396f4..3da5999832 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,8 +26,6 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" -#include -#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1420,47 +1418,6 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } -napi_value PlatformViewOHOSNapi::nativeInitNativeImage( - napi_env env, napi_callback_info info) -{ - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder, 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)); - ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); - // std::unique_ptr uImage; - OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTexture(textureId, imageNative); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( - napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( - napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); - return nullptr; -} - int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 42fd730314..d32a6fe996 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,15 +143,6 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 - static napi_value nativeInitNativeImage(napi_env env, - napi_callback_info info); - - static napi_value nativeUnregisterTexture(napi_env env, - napi_callback_info info); - - static napi_value nativeMarkTextureFrameAvailable(napi_env env, - napi_callback_info info); - // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 21ab4d36fb..f2ffccbaa8 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,6 +14,7 @@ */ #include "ohos_external_texture_gl.h" +#include #include @@ -24,18 +25,13 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" -#include -#include - namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) - : Texture(id),transform(SkMatrix::I()) { -} +OHOSExternalTextureGL::OHOSExternalTextureGL(int id) + : Texture(id), transform(SkMatrix::I()) {} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { - glDeleteTextures(1, &texture_name_); } } @@ -47,7 +43,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -55,8 +50,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, - GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -93,8 +87,6 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); - glDeleteTextures(1, &texture_name_); - OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -108,89 +100,22 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - OH_NativeImage_AttachContext(nativeImage, textureName); + // do nothing } void OHOSExternalTextureGL::Update() { - OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - OH_NativeImage_DetachContext(nativeImage); + // do nothing } void OHOSExternalTextureGL::UpdateTransform() { - float m[16] = { 0.0f }; - OH_NativeImage_GetTransformMatrix(nativeImage, m); - //transform ohos 4x4 matrix to skia 3x3 matrix - SkScalar matrix3[] = { - m[0], m[4], m[12], // - m[1], m[5], m[13], // - m[3], m[7], m[15], // - }; - transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } - -void OHOSExternalTextureGL::DispatchImage(ImageNative* image) -{ - if(image == nullptr) { - return; - } - - if (state_ == AttachmentState::detached) { - return; - } - if (state_ == AttachmentState::uninitialized) { - glGenTextures(1, &texture_name_); - Attach(static_cast(texture_name_)); - state_ = AttachmentState::attached; - } - OhosImageComponent componentNative; - if (IMAGE_RESULT_SUCCESS != - OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { - FML_DLOG(FATAL)<<"get native component failed"; - return; - } - if(nativeImage == nullptr) { - nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); - } - OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); - int code = SET_BUFFER_GEOMETRY; - uint32_t width = componentNative.rowStride; - uint32_t height = componentNative.size / componentNative.rowStride; - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); - //get NativeWindowBuffer from NativeWindow - OHNativeWindowBuffer *buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - //get virAddr of bufferHandl by mmap sys interface - void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - FML_DLOG(FATAL)<<"mmap failed"; - return; - } - - uint8_t *value = componentNative.byteBuffer; - uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < width; x++) { - for (uint32_t y = 0; y < height; y++) { - *pixel++ = *value++; - } - } - - //munmap after use - int result = munmap(mappedAddr, handle->size); - if (result == -1) { - FML_DLOG(FATAL)<<"munmap failed"; - } - -} - } // 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 66f8b068bd..aa08880048 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,20 +15,17 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" -#include -#include -#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id); + explicit OHOSExternalTextureGL(int id); ~OHOSExternalTextureGL() override; @@ -45,8 +42,6 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; - void DispatchImage(ImageNative* image); - private: void Attach(int textureName); @@ -58,8 +53,6 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - // ImageNative* image_; - AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -68,8 +61,6 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; - OH_NativeImage *nativeImage; - FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index c17dbeefc8..3fc6b6b1a6 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,26 +386,4 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } -void PlatformViewOHOS::RegisterExternalTexture( - int64_t texture_id, - ImageNative* image) { - if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - auto iter = external_texture_gl_.find(texture_id); - if(iter != external_texture_gl_.end()) { - iter->second->DispatchImage(image); - } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); - external_texture_gl_[texture_id] = ohos_external_gl; - RegisterTexture(ohos_external_gl); - ohos_external_gl->DispatchImage(image); - } - } -} - -void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) -{ - external_texture_gl_.erase(texture_id); - UnregisterTexture(texture_id); -} - } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 02d48e15b0..a1b863ed34 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,8 +31,6 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" -#include -#include "ohos_external_texture_gl.h" namespace flutter { @@ -86,11 +84,6 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); - void RegisterExternalTexture( - int64_t texture_id, - ImageNative* image); - - void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -124,7 +117,6 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; - std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 5a3b05f1099df0163748d198b63b49b8640ee1d6 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Mon, 8 Jan 2024 16:13:46 +0800 Subject: [PATCH 05/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86Engin?= =?UTF-8?q?e=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yihuiyang --- shell/platform/ohos/BUILD.gn | 2 + shell/platform/ohos/library_loader.cpp | 12 ++ .../ohos/napi/platform_view_ohos_napi.cpp | 61 ++++++++ .../ohos/napi/platform_view_ohos_napi.h | 12 ++ .../ohos/ohos_external_texture_gl.cpp | 148 +++++++++++++++++- .../platform/ohos/ohos_external_texture_gl.h | 16 +- shell/platform/ohos/platform_view_ohos.cpp | 37 +++++ shell/platform/ohos/platform_view_ohos.h | 11 ++ 8 files changed, 291 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 8d18085468..3d631d79e0 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,6 +220,8 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] + ldflags += ["-limage_ndk.z"] + ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 7f88815b7b..214dc62cf7 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,6 +101,18 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), + DECLARE_NAPI_FUNCTION( + "nativeInitNativeImage", + flutter::PlatformViewOHOSNapi::nativeInitNativeImage), + DECLARE_NAPI_FUNCTION( + "nativeUnregisterTexture", + flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), + DECLARE_NAPI_FUNCTION( + "nativeMarkTextureFrameAvailable", + flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), + DECLARE_NAPI_FUNCTION( + "nativeRegisterPixelMap", + flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 3da5999832..a3101ad5c7 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,6 +26,9 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" +#include +#include +#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1418,6 +1421,64 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeInitNativeImage( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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)); + ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); + // std::unique_ptr uImage; + OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTextureByImage(textureId, imageNative); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeUnregisterTexture"; + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( + napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, + napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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()->RegisterExternalTextureByPixelMap(textureId, nativePixelMap); + return nullptr; +} + int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index d32a6fe996..7919577527 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,6 +143,18 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 + static napi_value nativeInitNativeImage(napi_env env, + napi_callback_info info); + + static napi_value nativeUnregisterTexture(napi_env env, + napi_callback_info info); + + static napi_value nativeMarkTextureFrameAvailable(napi_env env, + napi_callback_info info); + + static napi_value nativeRegisterPixelMap(napi_env env, + napi_callback_info info); + // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index f2ffccbaa8..6486763cb9 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,7 +14,6 @@ */ #include "ohos_external_texture_gl.h" -#include #include @@ -25,13 +24,19 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" +#include +#include + namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int id) - : Texture(id), transform(SkMatrix::I()) {} +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) + : Texture(id),transform(SkMatrix::I()) { + nativeImage = nullptr; +} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { + glDeleteTextures(1, &texture_name_); } } @@ -39,10 +44,12 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { return; } if (state_ == AttachmentState::uninitialized) { + glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -50,7 +57,8 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, + GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -87,6 +95,8 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); + glDeleteTextures(1, &texture_name_); + OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -100,22 +110,148 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - // do nothing + OH_NativeImage_AttachContext(nativeImage, textureName); } void OHOSExternalTextureGL::Update() { + OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - // do nothing + OH_NativeImage_DetachContext(nativeImage); } void OHOSExternalTextureGL::UpdateTransform() { + FML_DLOG(INFO)<<"OHOSExternalTextureGL::UpdateTransform"; + float m[16] = { 0.0f }; + OH_NativeImage_GetTransformMatrix(nativeImage, m); + //transform ohos 4x4 matrix to skia 3x3 matrix + SkScalar matrix3[] = { + m[0], m[4], m[12], // + m[1], m[5], m[13], // + m[3], m[7], m[15], // + }; + transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } + +void OHOSExternalTextureGL::DispatchImage(ImageNative* image) +{ + if(image == nullptr) { + return; + } + + if (state_ == AttachmentState::detached) { + return; + } + if(nativeImage == nullptr) { + glGenTextures(1, &texture_name_); + nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); + } + if (state_ == AttachmentState::uninitialized) { + // glGenTextures(1, &texture_name_); + Attach(static_cast(texture_name_)); + state_ = AttachmentState::attached; + } + OhosImageComponent componentNative; + if (IMAGE_RESULT_SUCCESS != + OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { + FML_DLOG(FATAL)<<"get native component failed"; + return; + } + OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); + int code = SET_BUFFER_GEOMETRY; + uint32_t width = componentNative.rowStride; + uint32_t height = componentNative.size / componentNative.rowStride; + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); + //get NativeWindowBuffer from NativeWindow + OHNativeWindowBuffer *buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + //get virAddr of bufferHandl by mmap sys interface + void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"mmap failed"; + return; + } + + uint8_t *value = componentNative.byteBuffer; + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + *pixel++ = *value++; + } + } + + //munmap after use + int result = munmap(mappedAddr, handle->size); + if (result == -1) { + FML_DLOG(FATAL)<<"munmap failed"; + } + +} + +void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) +{ + FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap enter"; + if(pixelMap == nullptr) { + FML_DLOG(FATAL)<<"pixelMap in null"; + return; + } + if (state_ == AttachmentState::detached) { + FML_DLOG(FATAL)<<"DispatchPixelMap AttachmentState err"; + return; + } + if(nativeImage == nullptr) { + glGenTextures(1, &texture_name_); + nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); + FML_DLOG(INFO)<<"texture_name_:"<(texture_name_); + FML_DLOG(INFO)<<"nativeImage addr:"<(texture_name_)); + state_ = AttachmentState::attached; + } + FML_DLOG(INFO)<<"Attach after"; + OhosPixelMapInfos pixelMapInfo; + OH_PixelMap_GetImageInfo(pixelMap, &pixelMapInfo); + OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); + int code = SET_BUFFER_GEOMETRY; + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, pixelMapInfo.width, pixelMapInfo.height); + OHNativeWindowBuffer *buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + //get virAddr of bufferHandl by mmap sys interface + void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"mmap failed"; + return; + } + void *pixelAddr = nullptr; + OH_PixelMap_AccessPixels(pixelMap, &pixelAddr); + uint8_t *value = static_cast(pixelAddr); + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < pixelMapInfo.width; x++) { + for (uint32_t y = 0; y < pixelMapInfo.height; y++) { + *pixel++ = *value++; + } + } + OH_PixelMap_UnAccessPixels(pixelMap); + //munmap after use + int result = munmap(mappedAddr, handle->size); + if (result == -1) { + FML_DLOG(FATAL)<<"munmap failed"; + } + FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap finish"; + +} + } // 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 aa08880048..85e37633d7 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,17 +15,21 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" +#include +#include +#include +#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int id); + explicit OHOSExternalTextureGL(int64_t id); ~OHOSExternalTextureGL() override; @@ -42,6 +46,10 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; + void DispatchImage(ImageNative* image); + + void DispatchPixelMap(NativePixelMap* pixelMap); + private: void Attach(int textureName); @@ -53,6 +61,8 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; + // ImageNative* image_; + AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -61,6 +71,8 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; + OH_NativeImage *nativeImage; + FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 3fc6b6b1a6..fd25e8a268 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,4 +386,41 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } +void PlatformViewOHOS::RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image) { + if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + auto iter = external_texture_gl_.find(texture_id); + if(iter != external_texture_gl_.end()) { + iter->second->DispatchImage(image); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchImage(image); + } + } +} + +void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) +{ + external_texture_gl_.erase(texture_id); + UnregisterTexture(texture_id); +} + +void PlatformViewOHOS::RegisterExternalTextureByPixelMap(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->DispatchPixelMap(pixelMap); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchPixelMap(pixelMap); + } + } +} + } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index a1b863ed34..bee41ca1dc 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,6 +31,9 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" +#include +#include "ohos_external_texture_gl.h" +#include namespace flutter { @@ -84,6 +87,13 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); + void RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image); + + void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); + + void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -117,6 +127,7 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; + std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From a8790ebd6854d355823de6b061cc55f060b55cc5 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Mon, 8 Jan 2024 16:31:07 +0800 Subject: [PATCH 06/69] =?UTF-8?q?Revert=20"=E5=A4=96=E6=8E=A5=E7=BA=B9?= =?UTF-8?q?=E7=90=86Engine=E5=AE=9E=E7=8E=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 5a3b05f1099df0163748d198b63b49b8640ee1d6. --- shell/platform/ohos/BUILD.gn | 2 - shell/platform/ohos/library_loader.cpp | 12 -- .../ohos/napi/platform_view_ohos_napi.cpp | 61 -------- .../ohos/napi/platform_view_ohos_napi.h | 12 -- .../ohos/ohos_external_texture_gl.cpp | 148 +----------------- .../platform/ohos/ohos_external_texture_gl.h | 16 +- shell/platform/ohos/platform_view_ohos.cpp | 37 ----- shell/platform/ohos/platform_view_ohos.h | 11 -- 8 files changed, 8 insertions(+), 291 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 3d631d79e0..8d18085468 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,8 +220,6 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] - ldflags += ["-limage_ndk.z"] - ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 214dc62cf7..7f88815b7b 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,18 +101,6 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), - DECLARE_NAPI_FUNCTION( - "nativeInitNativeImage", - flutter::PlatformViewOHOSNapi::nativeInitNativeImage), - DECLARE_NAPI_FUNCTION( - "nativeUnregisterTexture", - flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), - DECLARE_NAPI_FUNCTION( - "nativeMarkTextureFrameAvailable", - flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), - DECLARE_NAPI_FUNCTION( - "nativeRegisterPixelMap", - flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index a3101ad5c7..3da5999832 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,9 +26,6 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" -#include -#include -#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1421,64 +1418,6 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } -napi_value PlatformViewOHOSNapi::nativeInitNativeImage( - napi_env env, napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder, 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)); - ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); - // std::unique_ptr uImage; - OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTextureByImage(textureId, imageNative); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( - napi_env env, napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeUnregisterTexture"; - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( - napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, - napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder, 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()->RegisterExternalTextureByPixelMap(textureId, nativePixelMap); - return nullptr; -} - int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 7919577527..d32a6fe996 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,18 +143,6 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 - static napi_value nativeInitNativeImage(napi_env env, - napi_callback_info info); - - static napi_value nativeUnregisterTexture(napi_env env, - napi_callback_info info); - - static napi_value nativeMarkTextureFrameAvailable(napi_env env, - napi_callback_info info); - - static napi_value nativeRegisterPixelMap(napi_env env, - napi_callback_info info); - // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 6486763cb9..f2ffccbaa8 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,6 +14,7 @@ */ #include "ohos_external_texture_gl.h" +#include #include @@ -24,19 +25,13 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" -#include -#include - namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) - : Texture(id),transform(SkMatrix::I()) { - nativeImage = nullptr; -} +OHOSExternalTextureGL::OHOSExternalTextureGL(int id) + : Texture(id), transform(SkMatrix::I()) {} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { - glDeleteTextures(1, &texture_name_); } } @@ -44,12 +39,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { return; } if (state_ == AttachmentState::uninitialized) { - glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -57,8 +50,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, - GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -95,8 +87,6 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); - glDeleteTextures(1, &texture_name_); - OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -110,148 +100,22 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - OH_NativeImage_AttachContext(nativeImage, textureName); + // do nothing } void OHOSExternalTextureGL::Update() { - OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - OH_NativeImage_DetachContext(nativeImage); + // do nothing } void OHOSExternalTextureGL::UpdateTransform() { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::UpdateTransform"; - float m[16] = { 0.0f }; - OH_NativeImage_GetTransformMatrix(nativeImage, m); - //transform ohos 4x4 matrix to skia 3x3 matrix - SkScalar matrix3[] = { - m[0], m[4], m[12], // - m[1], m[5], m[13], // - m[3], m[7], m[15], // - }; - transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } - -void OHOSExternalTextureGL::DispatchImage(ImageNative* image) -{ - if(image == nullptr) { - return; - } - - if (state_ == AttachmentState::detached) { - return; - } - if(nativeImage == nullptr) { - glGenTextures(1, &texture_name_); - nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); - } - if (state_ == AttachmentState::uninitialized) { - // glGenTextures(1, &texture_name_); - Attach(static_cast(texture_name_)); - state_ = AttachmentState::attached; - } - OhosImageComponent componentNative; - if (IMAGE_RESULT_SUCCESS != - OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { - FML_DLOG(FATAL)<<"get native component failed"; - return; - } - OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); - int code = SET_BUFFER_GEOMETRY; - uint32_t width = componentNative.rowStride; - uint32_t height = componentNative.size / componentNative.rowStride; - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); - //get NativeWindowBuffer from NativeWindow - OHNativeWindowBuffer *buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - //get virAddr of bufferHandl by mmap sys interface - void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - FML_DLOG(FATAL)<<"mmap failed"; - return; - } - - uint8_t *value = componentNative.byteBuffer; - uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < width; x++) { - for (uint32_t y = 0; y < height; y++) { - *pixel++ = *value++; - } - } - - //munmap after use - int result = munmap(mappedAddr, handle->size); - if (result == -1) { - FML_DLOG(FATAL)<<"munmap failed"; - } - -} - -void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) -{ - FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap enter"; - if(pixelMap == nullptr) { - FML_DLOG(FATAL)<<"pixelMap in null"; - return; - } - if (state_ == AttachmentState::detached) { - FML_DLOG(FATAL)<<"DispatchPixelMap AttachmentState err"; - return; - } - if(nativeImage == nullptr) { - glGenTextures(1, &texture_name_); - nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); - FML_DLOG(INFO)<<"texture_name_:"<(texture_name_); - FML_DLOG(INFO)<<"nativeImage addr:"<(texture_name_)); - state_ = AttachmentState::attached; - } - FML_DLOG(INFO)<<"Attach after"; - OhosPixelMapInfos pixelMapInfo; - OH_PixelMap_GetImageInfo(pixelMap, &pixelMapInfo); - OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); - int code = SET_BUFFER_GEOMETRY; - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, pixelMapInfo.width, pixelMapInfo.height); - OHNativeWindowBuffer *buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - //get virAddr of bufferHandl by mmap sys interface - void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - FML_DLOG(FATAL)<<"mmap failed"; - return; - } - void *pixelAddr = nullptr; - OH_PixelMap_AccessPixels(pixelMap, &pixelAddr); - uint8_t *value = static_cast(pixelAddr); - uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < pixelMapInfo.width; x++) { - for (uint32_t y = 0; y < pixelMapInfo.height; y++) { - *pixel++ = *value++; - } - } - OH_PixelMap_UnAccessPixels(pixelMap); - //munmap after use - int result = munmap(mappedAddr, handle->size); - if (result == -1) { - FML_DLOG(FATAL)<<"munmap failed"; - } - FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap finish"; - -} - } // 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 85e37633d7..aa08880048 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,21 +15,17 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" -#include -#include -#include -#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id); + explicit OHOSExternalTextureGL(int id); ~OHOSExternalTextureGL() override; @@ -46,10 +42,6 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; - void DispatchImage(ImageNative* image); - - void DispatchPixelMap(NativePixelMap* pixelMap); - private: void Attach(int textureName); @@ -61,8 +53,6 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - // ImageNative* image_; - AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -71,8 +61,6 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; - OH_NativeImage *nativeImage; - FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index fd25e8a268..3fc6b6b1a6 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,41 +386,4 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } -void PlatformViewOHOS::RegisterExternalTextureByImage( - int64_t texture_id, - ImageNative* image) { - if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - auto iter = external_texture_gl_.find(texture_id); - if(iter != external_texture_gl_.end()) { - iter->second->DispatchImage(image); - } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); - external_texture_gl_[texture_id] = ohos_external_gl; - RegisterTexture(ohos_external_gl); - ohos_external_gl->DispatchImage(image); - } - } -} - -void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) -{ - external_texture_gl_.erase(texture_id); - UnregisterTexture(texture_id); -} - -void PlatformViewOHOS::RegisterExternalTextureByPixelMap(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->DispatchPixelMap(pixelMap); - } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); - external_texture_gl_[texture_id] = ohos_external_gl; - RegisterTexture(ohos_external_gl); - ohos_external_gl->DispatchPixelMap(pixelMap); - } - } -} - } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index bee41ca1dc..a1b863ed34 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,9 +31,6 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" -#include -#include "ohos_external_texture_gl.h" -#include namespace flutter { @@ -87,13 +84,6 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); - void RegisterExternalTextureByImage( - int64_t texture_id, - ImageNative* image); - - void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); - - void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -127,7 +117,6 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; - std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 43f1ab9e75b6ae67ab8c0b6e57111486378a5269 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Mon, 8 Jan 2024 16:35:16 +0800 Subject: [PATCH 07/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86Engin?= =?UTF-8?q?e=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yihuiyang --- shell/platform/ohos/BUILD.gn | 2 + shell/platform/ohos/library_loader.cpp | 12 ++ .../ohos/napi/platform_view_ohos_napi.cpp | 61 ++++++++ .../ohos/napi/platform_view_ohos_napi.h | 12 ++ .../ohos/ohos_external_texture_gl.cpp | 148 +++++++++++++++++- .../platform/ohos/ohos_external_texture_gl.h | 16 +- shell/platform/ohos/platform_view_ohos.cpp | 37 +++++ shell/platform/ohos/platform_view_ohos.h | 11 ++ 8 files changed, 291 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 8d18085468..3d631d79e0 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,6 +220,8 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] + ldflags += ["-limage_ndk.z"] + ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 7f88815b7b..214dc62cf7 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,6 +101,18 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), + DECLARE_NAPI_FUNCTION( + "nativeInitNativeImage", + flutter::PlatformViewOHOSNapi::nativeInitNativeImage), + DECLARE_NAPI_FUNCTION( + "nativeUnregisterTexture", + flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), + DECLARE_NAPI_FUNCTION( + "nativeMarkTextureFrameAvailable", + flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), + DECLARE_NAPI_FUNCTION( + "nativeRegisterPixelMap", + flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 3da5999832..a3101ad5c7 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,6 +26,9 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" +#include +#include +#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1418,6 +1421,64 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeInitNativeImage( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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)); + ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); + // std::unique_ptr uImage; + OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTextureByImage(textureId, imageNative); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeUnregisterTexture"; + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( + napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, + napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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()->RegisterExternalTextureByPixelMap(textureId, nativePixelMap); + return nullptr; +} + int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index d32a6fe996..7919577527 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,6 +143,18 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 + static napi_value nativeInitNativeImage(napi_env env, + napi_callback_info info); + + static napi_value nativeUnregisterTexture(napi_env env, + napi_callback_info info); + + static napi_value nativeMarkTextureFrameAvailable(napi_env env, + napi_callback_info info); + + static napi_value nativeRegisterPixelMap(napi_env env, + napi_callback_info info); + // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index f2ffccbaa8..6486763cb9 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,7 +14,6 @@ */ #include "ohos_external_texture_gl.h" -#include #include @@ -25,13 +24,19 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" +#include +#include + namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int id) - : Texture(id), transform(SkMatrix::I()) {} +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) + : Texture(id),transform(SkMatrix::I()) { + nativeImage = nullptr; +} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { + glDeleteTextures(1, &texture_name_); } } @@ -39,10 +44,12 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { return; } if (state_ == AttachmentState::uninitialized) { + glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -50,7 +57,8 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, + GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -87,6 +95,8 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); + glDeleteTextures(1, &texture_name_); + OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -100,22 +110,148 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - // do nothing + OH_NativeImage_AttachContext(nativeImage, textureName); } void OHOSExternalTextureGL::Update() { + OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - // do nothing + OH_NativeImage_DetachContext(nativeImage); } void OHOSExternalTextureGL::UpdateTransform() { + FML_DLOG(INFO)<<"OHOSExternalTextureGL::UpdateTransform"; + float m[16] = { 0.0f }; + OH_NativeImage_GetTransformMatrix(nativeImage, m); + //transform ohos 4x4 matrix to skia 3x3 matrix + SkScalar matrix3[] = { + m[0], m[4], m[12], // + m[1], m[5], m[13], // + m[3], m[7], m[15], // + }; + transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } + +void OHOSExternalTextureGL::DispatchImage(ImageNative* image) +{ + if(image == nullptr) { + return; + } + + if (state_ == AttachmentState::detached) { + return; + } + if(nativeImage == nullptr) { + glGenTextures(1, &texture_name_); + nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); + } + if (state_ == AttachmentState::uninitialized) { + // glGenTextures(1, &texture_name_); + Attach(static_cast(texture_name_)); + state_ = AttachmentState::attached; + } + OhosImageComponent componentNative; + if (IMAGE_RESULT_SUCCESS != + OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { + FML_DLOG(FATAL)<<"get native component failed"; + return; + } + OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); + int code = SET_BUFFER_GEOMETRY; + uint32_t width = componentNative.rowStride; + uint32_t height = componentNative.size / componentNative.rowStride; + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); + //get NativeWindowBuffer from NativeWindow + OHNativeWindowBuffer *buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + //get virAddr of bufferHandl by mmap sys interface + void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"mmap failed"; + return; + } + + uint8_t *value = componentNative.byteBuffer; + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + *pixel++ = *value++; + } + } + + //munmap after use + int result = munmap(mappedAddr, handle->size); + if (result == -1) { + FML_DLOG(FATAL)<<"munmap failed"; + } + +} + +void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) +{ + FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap enter"; + if(pixelMap == nullptr) { + FML_DLOG(FATAL)<<"pixelMap in null"; + return; + } + if (state_ == AttachmentState::detached) { + FML_DLOG(FATAL)<<"DispatchPixelMap AttachmentState err"; + return; + } + if(nativeImage == nullptr) { + glGenTextures(1, &texture_name_); + nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); + FML_DLOG(INFO)<<"texture_name_:"<(texture_name_); + FML_DLOG(INFO)<<"nativeImage addr:"<(texture_name_)); + state_ = AttachmentState::attached; + } + FML_DLOG(INFO)<<"Attach after"; + OhosPixelMapInfos pixelMapInfo; + OH_PixelMap_GetImageInfo(pixelMap, &pixelMapInfo); + OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); + int code = SET_BUFFER_GEOMETRY; + OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, pixelMapInfo.width, pixelMapInfo.height); + OHNativeWindowBuffer *buffer = nullptr; + int fenceFd; + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + //get virAddr of bufferHandl by mmap sys interface + void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"mmap failed"; + return; + } + void *pixelAddr = nullptr; + OH_PixelMap_AccessPixels(pixelMap, &pixelAddr); + uint8_t *value = static_cast(pixelAddr); + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < pixelMapInfo.width; x++) { + for (uint32_t y = 0; y < pixelMapInfo.height; y++) { + *pixel++ = *value++; + } + } + OH_PixelMap_UnAccessPixels(pixelMap); + //munmap after use + int result = munmap(mappedAddr, handle->size); + if (result == -1) { + FML_DLOG(FATAL)<<"munmap failed"; + } + FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap finish"; + +} + } // 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 aa08880048..85e37633d7 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,17 +15,21 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" +#include +#include +#include +#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int id); + explicit OHOSExternalTextureGL(int64_t id); ~OHOSExternalTextureGL() override; @@ -42,6 +46,10 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; + void DispatchImage(ImageNative* image); + + void DispatchPixelMap(NativePixelMap* pixelMap); + private: void Attach(int textureName); @@ -53,6 +61,8 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; + // ImageNative* image_; + AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -61,6 +71,8 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; + OH_NativeImage *nativeImage; + FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 3fc6b6b1a6..fd25e8a268 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,4 +386,41 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } +void PlatformViewOHOS::RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image) { + if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + auto iter = external_texture_gl_.find(texture_id); + if(iter != external_texture_gl_.end()) { + iter->second->DispatchImage(image); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchImage(image); + } + } +} + +void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) +{ + external_texture_gl_.erase(texture_id); + UnregisterTexture(texture_id); +} + +void PlatformViewOHOS::RegisterExternalTextureByPixelMap(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->DispatchPixelMap(pixelMap); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchPixelMap(pixelMap); + } + } +} + } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index a1b863ed34..bee41ca1dc 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,6 +31,9 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" +#include +#include "ohos_external_texture_gl.h" +#include namespace flutter { @@ -84,6 +87,13 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); + void RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image); + + void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); + + void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -117,6 +127,7 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; + std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 0f21d649442a538946e5b39722b84eb09161f06a Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Fri, 12 Jan 2024 17:35:28 +0800 Subject: [PATCH 08/69] =?UTF-8?q?Revert=20"=E5=A4=96=E6=8E=A5=E7=BA=B9?= =?UTF-8?q?=E7=90=86Engine=E5=AE=9E=E7=8E=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 43f1ab9e75b6ae67ab8c0b6e57111486378a5269. --- shell/platform/ohos/BUILD.gn | 2 - shell/platform/ohos/library_loader.cpp | 12 -- .../ohos/napi/platform_view_ohos_napi.cpp | 61 -------- .../ohos/napi/platform_view_ohos_napi.h | 12 -- .../ohos/ohos_external_texture_gl.cpp | 148 +----------------- .../platform/ohos/ohos_external_texture_gl.h | 16 +- shell/platform/ohos/platform_view_ohos.cpp | 37 ----- shell/platform/ohos/platform_view_ohos.h | 11 -- 8 files changed, 8 insertions(+), 291 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 3d631d79e0..8d18085468 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,8 +220,6 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] - ldflags += ["-limage_ndk.z"] - ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 214dc62cf7..7f88815b7b 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,18 +101,6 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), - DECLARE_NAPI_FUNCTION( - "nativeInitNativeImage", - flutter::PlatformViewOHOSNapi::nativeInitNativeImage), - DECLARE_NAPI_FUNCTION( - "nativeUnregisterTexture", - flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), - DECLARE_NAPI_FUNCTION( - "nativeMarkTextureFrameAvailable", - flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), - DECLARE_NAPI_FUNCTION( - "nativeRegisterPixelMap", - flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index a3101ad5c7..3da5999832 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,9 +26,6 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" -#include -#include -#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1421,64 +1418,6 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } -napi_value PlatformViewOHOSNapi::nativeInitNativeImage( - napi_env env, napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder, 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)); - ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); - // std::unique_ptr uImage; - OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTextureByImage(textureId, imageNative); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( - napi_env env, napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeUnregisterTexture"; - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( - napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - int64_t shell_holder, 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)); - OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); - return nullptr; -} - -napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, - napi_callback_info info) -{ - FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; - size_t argc = 3; - napi_value args[3] = {nullptr}; - int64_t shell_holder, 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()->RegisterExternalTextureByPixelMap(textureId, nativePixelMap); - return nullptr; -} - int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 7919577527..d32a6fe996 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,18 +143,6 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 - static napi_value nativeInitNativeImage(napi_env env, - napi_callback_info info); - - static napi_value nativeUnregisterTexture(napi_env env, - napi_callback_info info); - - static napi_value nativeMarkTextureFrameAvailable(napi_env env, - napi_callback_info info); - - static napi_value nativeRegisterPixelMap(napi_env env, - napi_callback_info info); - // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 6486763cb9..f2ffccbaa8 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,6 +14,7 @@ */ #include "ohos_external_texture_gl.h" +#include #include @@ -24,19 +25,13 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" -#include -#include - namespace flutter { -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) - : Texture(id),transform(SkMatrix::I()) { - nativeImage = nullptr; -} +OHOSExternalTextureGL::OHOSExternalTextureGL(int id) + : Texture(id), transform(SkMatrix::I()) {} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { - glDeleteTextures(1, &texture_name_); } } @@ -44,12 +39,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { return; } if (state_ == AttachmentState::uninitialized) { - glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -57,8 +50,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, - GL_RGBA8_OES}; + GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, @@ -95,8 +87,6 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); - glDeleteTextures(1, &texture_name_); - OH_NativeImage_Destroy(&nativeImage); } state_ = AttachmentState::detached; } @@ -110,148 +100,22 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - OH_NativeImage_AttachContext(nativeImage, textureName); + // do nothing } void OHOSExternalTextureGL::Update() { - OH_NativeImage_UpdateSurfaceImage(nativeImage); UpdateTransform(); } void OHOSExternalTextureGL::Detach() { - OH_NativeImage_DetachContext(nativeImage); + // do nothing } void OHOSExternalTextureGL::UpdateTransform() { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::UpdateTransform"; - float m[16] = { 0.0f }; - OH_NativeImage_GetTransformMatrix(nativeImage, m); - //transform ohos 4x4 matrix to skia 3x3 matrix - SkScalar matrix3[] = { - m[0], m[4], m[12], // - m[1], m[5], m[13], // - m[3], m[7], m[15], // - }; - transform.set9(matrix3); SkMatrix inverted; if (!transform.invert(&inverted)) { FML_LOG(FATAL) << "Invalid SurfaceTexture transformation matrix"; } transform = inverted; } - -void OHOSExternalTextureGL::DispatchImage(ImageNative* image) -{ - if(image == nullptr) { - return; - } - - if (state_ == AttachmentState::detached) { - return; - } - if(nativeImage == nullptr) { - glGenTextures(1, &texture_name_); - nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); - } - if (state_ == AttachmentState::uninitialized) { - // glGenTextures(1, &texture_name_); - Attach(static_cast(texture_name_)); - state_ = AttachmentState::attached; - } - OhosImageComponent componentNative; - if (IMAGE_RESULT_SUCCESS != - OH_Image_GetComponent(image, OHOS_IMAGE_COMPONENT_FORMAT_JPEG, &componentNative)) { - FML_DLOG(FATAL)<<"get native component failed"; - return; - } - OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); - int code = SET_BUFFER_GEOMETRY; - uint32_t width = componentNative.rowStride; - uint32_t height = componentNative.size / componentNative.rowStride; - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); - //get NativeWindowBuffer from NativeWindow - OHNativeWindowBuffer *buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - //get virAddr of bufferHandl by mmap sys interface - void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - FML_DLOG(FATAL)<<"mmap failed"; - return; - } - - uint8_t *value = componentNative.byteBuffer; - uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < width; x++) { - for (uint32_t y = 0; y < height; y++) { - *pixel++ = *value++; - } - } - - //munmap after use - int result = munmap(mappedAddr, handle->size); - if (result == -1) { - FML_DLOG(FATAL)<<"munmap failed"; - } - -} - -void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) -{ - FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap enter"; - if(pixelMap == nullptr) { - FML_DLOG(FATAL)<<"pixelMap in null"; - return; - } - if (state_ == AttachmentState::detached) { - FML_DLOG(FATAL)<<"DispatchPixelMap AttachmentState err"; - return; - } - if(nativeImage == nullptr) { - glGenTextures(1, &texture_name_); - nativeImage = OH_NativeImage_Create(texture_name_, GL_TEXTURE_2D); - FML_DLOG(INFO)<<"texture_name_:"<(texture_name_); - FML_DLOG(INFO)<<"nativeImage addr:"<(texture_name_)); - state_ = AttachmentState::attached; - } - FML_DLOG(INFO)<<"Attach after"; - OhosPixelMapInfos pixelMapInfo; - OH_PixelMap_GetImageInfo(pixelMap, &pixelMapInfo); - OHNativeWindow *nativeWindow = OH_NativeImage_AcquireNativeWindow(nativeImage); - int code = SET_BUFFER_GEOMETRY; - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, pixelMapInfo.width, pixelMapInfo.height); - OHNativeWindowBuffer *buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - //get virAddr of bufferHandl by mmap sys interface - void *mappedAddr = mmap(handle->virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); - if (mappedAddr == MAP_FAILED) { - FML_DLOG(FATAL)<<"mmap failed"; - return; - } - void *pixelAddr = nullptr; - OH_PixelMap_AccessPixels(pixelMap, &pixelAddr); - uint8_t *value = static_cast(pixelAddr); - uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < pixelMapInfo.width; x++) { - for (uint32_t y = 0; y < pixelMapInfo.height; y++) { - *pixel++ = *value++; - } - } - OH_PixelMap_UnAccessPixels(pixelMap); - //munmap after use - int result = munmap(mappedAddr, handle->size); - if (result == -1) { - FML_DLOG(FATAL)<<"munmap failed"; - } - FML_DLOG(INFO)<<"OHOSExternalTextureGL::DispatchPixelMap finish"; - -} - } // 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 85e37633d7..aa08880048 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,21 +15,17 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" -#include -#include -#include -#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id); + explicit OHOSExternalTextureGL(int id); ~OHOSExternalTextureGL() override; @@ -46,10 +42,6 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; - void DispatchImage(ImageNative* image); - - void DispatchPixelMap(NativePixelMap* pixelMap); - private: void Attach(int textureName); @@ -61,8 +53,6 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - // ImageNative* image_; - AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -71,8 +61,6 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; - OH_NativeImage *nativeImage; - FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index fd25e8a268..3fc6b6b1a6 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,41 +386,4 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } -void PlatformViewOHOS::RegisterExternalTextureByImage( - int64_t texture_id, - ImageNative* image) { - if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - auto iter = external_texture_gl_.find(texture_id); - if(iter != external_texture_gl_.end()) { - iter->second->DispatchImage(image); - } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); - external_texture_gl_[texture_id] = ohos_external_gl; - RegisterTexture(ohos_external_gl); - ohos_external_gl->DispatchImage(image); - } - } -} - -void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) -{ - external_texture_gl_.erase(texture_id); - UnregisterTexture(texture_id); -} - -void PlatformViewOHOS::RegisterExternalTextureByPixelMap(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->DispatchPixelMap(pixelMap); - } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); - external_texture_gl_[texture_id] = ohos_external_gl; - RegisterTexture(ohos_external_gl); - ohos_external_gl->DispatchPixelMap(pixelMap); - } - } -} - } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index bee41ca1dc..a1b863ed34 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,9 +31,6 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" -#include -#include "ohos_external_texture_gl.h" -#include namespace flutter { @@ -87,13 +84,6 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); - void RegisterExternalTextureByImage( - int64_t texture_id, - ImageNative* image); - - void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); - - void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -127,7 +117,6 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; - std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 047ba8e5cf9b04fd98c6e21b8c1e5164548fa11c Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Fri, 12 Jan 2024 17:38:10 +0800 Subject: [PATCH 09/69] =?UTF-8?q?1-12=20=E5=A4=96=E6=8E=A5=E7=BA=B9?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yihuiyang --- shell/platform/ohos/BUILD.gn | 3 + shell/platform/ohos/library_loader.cpp | 12 + .../ohos/napi/platform_view_ohos_napi.cpp | 61 +++++ .../ohos/napi/platform_view_ohos_napi.h | 12 + .../ohos/ohos_external_texture_gl.cpp | 250 +++++++++++++++++- .../platform/ohos/ohos_external_texture_gl.h | 44 ++- shell/platform/ohos/platform_view_ohos.cpp | 38 +++ shell/platform/ohos/platform_view_ohos.h | 11 + 8 files changed, 421 insertions(+), 10 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 8d18085468..11452fc6ca 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -220,6 +220,9 @@ shared_library("flutter") { ldflags += ["-lrawfile.z"] ldflags += ["-lEGL"] ldflags += ["-lGLESv3"] + # ldflags += ["-lGLESv2"] + ldflags += ["-limage_ndk.z"] + ldflags += ["-lnative_image"] ldflags += ["-lc++_shared"] ldflags += ["-lm"] diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 7f88815b7b..214dc62cf7 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,6 +101,18 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), + DECLARE_NAPI_FUNCTION( + "nativeInitNativeImage", + flutter::PlatformViewOHOSNapi::nativeInitNativeImage), + DECLARE_NAPI_FUNCTION( + "nativeUnregisterTexture", + flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), + DECLARE_NAPI_FUNCTION( + "nativeMarkTextureFrameAvailable", + flutter::PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable), + DECLARE_NAPI_FUNCTION( + "nativeRegisterPixelMap", + flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 3da5999832..a3101ad5c7 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,6 +26,9 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" +#include +#include +#include #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { @@ -1418,6 +1421,64 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeInitNativeImage( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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)); + ImageNative *imageNative = OH_Image_InitImageNative(env, args[2]); + // std::unique_ptr uImage; + OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTextureByImage(textureId, imageNative); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( + napi_env env, napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeUnregisterTexture"; + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->UnRegisterExternalTexture(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( + napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t shell_holder, 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)); + OHOS_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(textureId); + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, + napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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()->RegisterExternalTextureByPixelMap(textureId, nativePixelMap); + return nullptr; +} + int64_t PlatformViewOHOSNapi::GetShellHolder() { return PlatformViewOHOSNapi::shell_holder_value; } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index d32a6fe996..7919577527 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -143,6 +143,18 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); // 应用下发系统语言设置 + static napi_value nativeInitNativeImage(napi_env env, + napi_callback_info info); + + static napi_value nativeUnregisterTexture(napi_env env, + napi_callback_info info); + + static napi_value nativeMarkTextureFrameAvailable(napi_env env, + napi_callback_info info); + + static napi_value nativeRegisterPixelMap(napi_env env, + napi_callback_info info); + // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index f2ffccbaa8..fd825e2634 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -14,7 +14,6 @@ */ #include "ohos_external_texture_gl.h" -#include #include @@ -25,13 +24,34 @@ #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" +#include +#include + +#define EGL_PLATFORM_OHOS_KHR 0x34E0 + namespace flutter { +using GetPlatformDisplayExt = PFNEGLGETPLATFORMDISPLAYEXTPROC; +constexpr char CHARACTER_WHITESPACE = ' '; +constexpr const char *CHARACTER_STRING_WHITESPACE = " "; +constexpr const char *EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland"; +constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; +constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; +constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int id) - : Texture(id), transform(SkMatrix::I()) {} +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) + : Texture(id),transform(SkMatrix::I()) { + nativeImage_ = nullptr; + nativeWindow_ = nullptr; + eglContext_ = EGL_NO_CONTEXT; + eglDisplay_ = EGL_NO_DISPLAY; + buffer_ = nullptr; + pixelMap_ = nullptr; + lastImage_ = nullptr; +} OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { + glDeleteTextures(1, &texture_name_); } } @@ -39,10 +59,12 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { return; } if (state_ == AttachmentState::uninitialized) { + glGenTextures(1, &texture_name_); Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } @@ -50,12 +72,14 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - GrGLTextureInfo textureInfo = {0, texture_name_, GL_RGBA8_OES}; - GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); + GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, + GL_RGBA8_OES}; + GrBackendTexture backendTexture(pixelMapInfo.width, pixelMapInfo.height, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); if (image) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 1"; SkAutoCanvasRestore autoRestore(context.canvas, true); // The incoming texture is vertically flipped, so we flip it @@ -65,6 +89,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, context.canvas->scale(bounds.width(), -bounds.height()); if (!transform.isIdentity()) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 2"; sk_sp shader = image->makeShader( SkTileMode::kRepeat, SkTileMode::kRepeat, sampling, transform); @@ -75,47 +100,256 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, paintWithShader.setShader(shader); context.canvas->drawRect(SkRect::MakeWH(1, 1), paintWithShader); } else { + FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 3"; context.canvas->drawImage(image, 0, 0, sampling, context.sk_paint); } } } void OHOSExternalTextureGL::OnGrContextCreated() { + FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextCreated"; state_ = AttachmentState::uninitialized; } void OHOSExternalTextureGL::OnGrContextDestroyed() { + FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextDestroyed"; if (state_ == AttachmentState::attached) { Detach(); + glDeleteTextures(1, &texture_name_); + OH_NativeImage_Destroy(&nativeImage_); } state_ = AttachmentState::detached; } void OHOSExternalTextureGL::MarkNewFrameAvailable() { + FML_DLOG(INFO)<<" OHOSExternalTextureGL::MarkNewFrameAvailable"; new_frame_ready_ = true; } void OHOSExternalTextureGL::OnTextureUnregistered() { + FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnTextureUnregistered"; // do nothing } void OHOSExternalTextureGL::Attach(int textureName) { - // do nothing + if(eglContext_ == EGL_NO_CONTEXT) { + FML_DLOG(INFO)<<"OHOSExternalTextureGL eglContext_ no context, need init"; + InitEGLEnv(); + } + if(nativeImage_ == nullptr) { + // glGenTextures(1, &texture_name_); + nativeImage_ = OH_NativeImage_Create(textureName, GL_TEXTURE_2D); + FML_DLOG(INFO)<<"OHOSExternalTextureGL texture_name_:"<(textureName); + FML_DLOG(INFO)<<"OHOSExternalTextureGL nativeImage addr:"<virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); + if (mappedAddr == MAP_FAILED) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL mmap failed"; + return; + } + void *pixelAddr = nullptr; + int32_t ret = OH_PixelMap_AccessPixels(pixelMap_, &pixelAddr); + if(ret != IMAGE_RESULT_SUCCESS) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_PixelMap_AccessPixels err:"<< ret; + return; + } + FML_DLOG(INFO)<<"OHOSExternalTextureGL pixelAddr:"<(pixelAddr); + uint32_t *pixel = static_cast(mappedAddr); + for (uint32_t x = 0; x < pixelMapInfo.width; x++) { + for (uint32_t y = 0; y < pixelMapInfo.height; y++) { + *pixel++ = *value++; + } + } + OH_PixelMap_UnAccessPixels(pixelMap_); + //munmap after use + ret = munmap(mappedAddr, handle->size); + if (ret == -1) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL munmap failed"; + return; + } + Region region{nullptr, 0}; + ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer_, fenceFd, region); + if(ret != 0) { + FML_DLOG(FATAL)<<"OH_NativeWindow_NativeWindowFlushBuffer err code:"<< ret; + } + +} + +EGLDisplay OHOSExternalTextureGL::GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list) +{ + GetPlatformDisplayExt eglGetPlatformDisplayExt = NULL; + + if (!eglGetPlatformDisplayExt) { + const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (extensions && + (CheckEglExtension(extensions, EGL_EXT_PLATFORM_WAYLAND) || + CheckEglExtension(extensions, EGL_KHR_PLATFORM_WAYLAND))) { + eglGetPlatformDisplayExt = (GetPlatformDisplayExt)eglGetProcAddress(EGL_GET_PLATFORM_DISPLAY_EXT); + } + } + + if (eglGetPlatformDisplayExt) { + return eglGetPlatformDisplayExt(platform, native_display, attrib_list); + } + + return eglGetDisplay((EGLNativeDisplayType)native_display); +} + +void OHOSExternalTextureGL::InitEGLEnv() +{ + // 获取当前的显示设备 + eglDisplay_ = + GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL); + if (eglDisplay_ == EGL_NO_DISPLAY) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to create EGLDisplay gl errno : " + << eglGetError(); + } + EGLint major, minor; + // 初始化EGLDisplay + if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to initialize EGLDisplay"; + } + + // 绑定图形绘制的API为OpenGLES + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to bind OpenGL ES API"; + } + unsigned int ret; + EGLint count; + EGLint config_attribs[] = {EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, + 8, + EGL_GREEN_SIZE, + 8, + EGL_BLUE_SIZE, + 8, + EGL_ALPHA_SIZE, + 8, + EGL_RENDERABLE_TYPE, + EGL_OPENGL_ES3_BIT, + EGL_NONE}; + // 获取一个有效的系统配置信息 + ret = eglChooseConfig(eglDisplay_, config_attribs, &config_, 1, &count); + if (!(ret && static_cast(count) >= 1)) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to eglChooseConfig"; + } + + const EGLint context_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE}; + + // 创建上下文 + eglContext_ = + eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs); + if (eglContext_ == EGL_NO_CONTEXT) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to create egl context, error:" + << eglGetError(); + } + + // 关联上下文 + eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_); +} + +bool OHOSExternalTextureGL::CheckEglExtension(const char *extensions, const char *extension) +{ + size_t extlen = strlen(extension); + const char *end = extensions + strlen(extensions); + while (extensions < end) { + size_t n = 0; + if (*extensions == CHARACTER_WHITESPACE) { + extensions++; + continue; + } + n = strcspn(extensions, CHARACTER_STRING_WHITESPACE); + if (n == extlen && strncmp(extension, extensions, n) == 0) { + return true; + } + extensions += n; + } + return false; +} + +void OHOSExternalTextureGL::DispatchPixelMap(NativePixelMap* pixelMap) +{ + if(pixelMap != nullptr) { + pixelMap_ = 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 aa08880048..3dd7f0d765 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -15,17 +15,25 @@ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H #define OHOS_EXTERNAL_TEXTURE_GL_H -#include + +#include +#include +#include #include "flutter/common/graphics/texture.h" #include "napi/platform_view_ohos_napi.h" +#include +#include +#include +#include +#include // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int id); + explicit OHOSExternalTextureGL(int64_t id); ~OHOSExternalTextureGL() override; @@ -42,6 +50,10 @@ class OHOSExternalTextureGL : public flutter::Texture { void OnTextureUnregistered() override; + void DispatchImage(ImageNative* image); + + void DispatchPixelMap(NativePixelMap* pixelMap); + private: void Attach(int textureName); @@ -51,8 +63,18 @@ class OHOSExternalTextureGL : public flutter::Texture { void UpdateTransform(); + EGLDisplay GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list); + + void InitEGLEnv(); + + bool CheckEglExtension(const char *extensions, const char *extension); + + void ProducePixelMapToNativeImage(); + enum class AttachmentState { uninitialized, attached, detached }; + // ImageNative* image_; + AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; @@ -61,6 +83,24 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; + OH_NativeImage *nativeImage_; + + OHNativeWindow *nativeWindow_; + + OHNativeWindowBuffer *buffer_; + + NativePixelMap* pixelMap_; + + ImageNative* lastImage_; + + OhosPixelMapInfos pixelMapInfo; + + int fenceFd = -1; + + EGLContext eglContext_; + EGLDisplay eglDisplay_; + EGLConfig config_; + FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 3fc6b6b1a6..c6e6d5dba5 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -386,4 +386,42 @@ void PlatformViewOHOS::FireFirstFrameCallback() { napi_facade_->FlutterViewOnFirstFrame(); } +void PlatformViewOHOS::RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image) { + if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + auto iter = external_texture_gl_.find(texture_id); + if(iter != external_texture_gl_.end()) { + iter->second->DispatchImage(image); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchImage(image); + } + } +} + +void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) +{ + external_texture_gl_.erase(texture_id); + UnregisterTexture(texture_id); +} + +void PlatformViewOHOS::RegisterExternalTextureByPixelMap(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->DispatchPixelMap(pixelMap); + } else { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + external_texture_gl_[texture_id] = ohos_external_gl; + RegisterTexture(ohos_external_gl); + ohos_external_gl->DispatchPixelMap(pixelMap); + } + MarkTextureFrameAvailable(texture_id); + } +} + } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index a1b863ed34..bee41ca1dc 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,6 +31,9 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" +#include +#include "ohos_external_texture_gl.h" +#include namespace flutter { @@ -84,6 +87,13 @@ class PlatformViewOHOS final : public PlatformView { int action, void* actionData, int actionDataLenth); + void RegisterExternalTextureByImage( + int64_t texture_id, + ImageNative* image); + + void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); + + void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| void LoadDartDeferredLibrary( @@ -117,6 +127,7 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; + std::map> external_texture_gl_; // |PlatformView| void UpdateSemantics( -- Gitee From 0a671f0cce58774ce004d23f6ce2da346edfd411 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Fri, 26 Jan 2024 12:03:28 +0800 Subject: [PATCH 10/69] add registertexture napi Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/library_loader.cpp | 3 +++ .../platform/ohos/napi/platform_view_ohos_napi.cpp | 14 ++++++++++++++ shell/platform/ohos/napi/platform_view_ohos_napi.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 214dc62cf7..7bd6aa23a1 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -104,6 +104,9 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeInitNativeImage", flutter::PlatformViewOHOSNapi::nativeInitNativeImage), + DECLARE_NAPI_FUNCTION( + "nativeRegisterTexture", + flutter::PlatformViewOHOSNapi::nativeRegisterTexture), DECLARE_NAPI_FUNCTION( "nativeUnregisterTexture", flutter::PlatformViewOHOSNapi::nativeUnregisterTexture), diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index a3101ad5c7..46c652a33d 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1437,6 +1437,20 @@ napi_value PlatformViewOHOSNapi::nativeInitNativeImage( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeRegisterTexture(napi_env env, + napi_callback_info info) +{ + FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterTexture"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder, 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)); + int64_t surfaceId = OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTexture(textureId); + return surfaceId; +} + napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( napi_env env, napi_callback_info info) { diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 7919577527..1db75b5ad7 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -155,6 +155,9 @@ class PlatformViewOHOSNapi { static napi_value nativeRegisterPixelMap(napi_env env, napi_callback_info info); + static napi_value nativeRegisterTexture(napi_env env, + napi_callback_info info); + // Surface相关,XComponent调用 static void SurfaceCreated(int64_t shell_holder, void* window); static void SurfaceChanged(int64_t shell_holder, -- Gitee From ca1e0171abe02a3043b3018e43680791a8fe0ace Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 26 Jan 2024 16:51:31 +0800 Subject: [PATCH 11/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=AE=E6=94=B9?= 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 | 6 +++-- shell/platform/ohos/platform_view_ohos.cpp | 24 +++++++++++++++++++ shell/platform/ohos/platform_view_ohos.h | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index fd825e2634..2574c5446f 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -64,8 +64,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { + InitEGLEnv(); glGenTextures(1, &texture_name_); - Attach(static_cast(texture_name_)); + // Attach(static_cast(texture_name_)); + OH_NativeImage_AttachContext(nativeImage_, texture_name_); state_ = AttachmentState::attached; } if (!freeze && new_frame_ready_) { @@ -151,7 +153,7 @@ void OHOSExternalTextureGL::Attach(int textureName) { } void OHOSExternalTextureGL::Update() { - ProducePixelMapToNativeImage(); + //ProducePixelMapToNativeImage(); int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_UpdateSurfaceImage err code:"<< ret; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index c6e6d5dba5..227b02cc79 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -402,6 +402,30 @@ void PlatformViewOHOS::RegisterExternalTextureByImage( } } +int64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { + int surface_id = 0; + if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); + if (nativeImage_ == null) { + FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; + return surface_id; + } + int ret = OH_NativeImage_SetOnFrameAvailableListener(nativeImage_, OHOSExternalTextureGL::MarkNewFrameAvailable); + if (ret != 0) { + FML_DLOG(ERROR) << "Error with OH_NativeImage_SetOnFrameAvailableListener"; + return surface_id; + } + int ret = OH_NativeImage_GetSurfaceId(nativeImage_, &surface_id); + if (ret != 0) { + FML_DLOG(ERROR) << "Error with OH_NativeImage_GetSurfaceId"; + return surface_id; + } + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + RegisterTexture(ohos_external_gl); + } + return surface_id; +} + void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) { external_texture_gl_.erase(texture_id); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index bee41ca1dc..cc1cb6e98d 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -91,6 +91,8 @@ class PlatformViewOHOS final : public PlatformView { int64_t texture_id, ImageNative* image); + int64_t RegisterExternalTexture(int64_t texture_id); + void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); void UnRegisterExternalTexture(int64_t texture_id); -- Gitee From bd8a7fafaf97f2c75e61182468565c08c1c5713c Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 26 Jan 2024 19:46:26 +0800 Subject: [PATCH 12/69] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../ohos/napi/platform_view_ohos_napi.cpp | 8 ++++-- .../platform/ohos/ohos_external_texture_gl.h | 4 +-- shell/platform/ohos/platform_view_ohos.cpp | 28 ++++++++++++++----- shell/platform/ohos/platform_view_ohos.h | 6 +++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 46c652a33d..e31992ca7c 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1441,14 +1441,16 @@ napi_value PlatformViewOHOSNapi::nativeRegisterTexture(napi_env env, napi_callback_info info) { FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterTexture"; - size_t argc = 3; - napi_value args[3] = {nullptr}; + size_t argc = 2; + napi_value args[2] = {nullptr}; int64_t shell_holder, 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)); int64_t surfaceId = OHOS_SHELL_HOLDER->GetPlatformView()->RegisterExternalTexture(textureId); - return surfaceId; + napi_value res; + napi_create_int64(env, surfaceId, &res); + return res; } napi_value PlatformViewOHOSNapi::nativeUnregisterTexture( diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 3dd7f0d765..54a9c56808 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -37,6 +37,8 @@ class OHOSExternalTextureGL : public flutter::Texture { ~OHOSExternalTextureGL() override; + OH_NativeImage *nativeImage_; + void Paint(PaintContext& context, const SkRect& bounds, bool freeze, @@ -83,8 +85,6 @@ class OHOSExternalTextureGL : public flutter::Texture { SkMatrix transform; - OH_NativeImage *nativeImage_; - OHNativeWindow *nativeWindow_; OHNativeWindowBuffer *buffer_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 227b02cc79..6f61bf959f 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -25,6 +25,9 @@ #include "napi_common.h" #include "ohos_context_gl_impeller.h" #include "ohos_surface_gl_impeller.h" +#include "ohos_external_texture_gl.h" + +#include namespace flutter { @@ -402,30 +405,41 @@ void PlatformViewOHOS::RegisterExternalTextureByImage( } } -int64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { - int surface_id = 0; +uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { + uint64_t surface_id = 0; + int ret = -1; if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); - if (nativeImage_ == null) { + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + ohos_external_gl->nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); + if (ohos_external_gl->nativeImage_ == nullptr) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; return surface_id; } - int ret = OH_NativeImage_SetOnFrameAvailableListener(nativeImage_, OHOSExternalTextureGL::MarkNewFrameAvailable); + nativeImageFrameAvailableListener_.context = this; + nativeImageFrameAvailableListener_.onFrameAvailable = &PlatformViewOHOS::OnNativeImageFrameAvailable; + ret = OH_NativeImage_SetOnFrameAvailableListener(ohos_external_gl->nativeImage_, nativeImageFrameAvailableListener_); if (ret != 0) { FML_DLOG(ERROR) << "Error with OH_NativeImage_SetOnFrameAvailableListener"; return surface_id; } - int ret = OH_NativeImage_GetSurfaceId(nativeImage_, &surface_id); + ret = OH_NativeImage_GetSurfaceId(ohos_external_gl->nativeImage_, &surface_id); if (ret != 0) { FML_DLOG(ERROR) << "Error with OH_NativeImage_GetSurfaceId"; return surface_id; } - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); RegisterTexture(ohos_external_gl); } return surface_id; } +void PlatformViewOHOS::OnNativeImageFrameAvailable(void *data) { + auto renderThread = reinterpret_cast(data); + if (renderThread == nullptr) { + return; + } + renderThread->MarkNewFrameAvailable(); +} + void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) { external_texture_gl_.erase(texture_id); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index cc1cb6e98d..572f8640ac 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -91,7 +91,7 @@ class PlatformViewOHOS final : public PlatformView { int64_t texture_id, ImageNative* image); - int64_t RegisterExternalTexture(int64_t texture_id); + uint64_t RegisterExternalTexture(int64_t texture_id); void RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap); @@ -177,6 +177,10 @@ class PlatformViewOHOS final : public PlatformView { void FireFirstFrameCallback(); FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewOHOS); + + OH_OnFrameAvailableListener nativeImageFrameAvailableListener_{}; + + static void OnNativeImageFrameAvailable(void *data); }; } // namespace flutter #endif -- Gitee From ca3d03baa891bcb4f591b862734c237b506c4fbd Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Sat, 27 Jan 2024 15:00:40 +0800 Subject: [PATCH 13/69] add api Signed-off-by: 18719058668 <718092089@qq.com> --- .../src/main/cpp/types/libflutter/index.d.ets | 4 +- .../main/ets/embedding/engine/FlutterNapi.ets | 5 +++ .../engine/loader/FlutterApplicationInfo.ets | 2 +- .../engine/renderer/FlutterRenderer.ets | 44 ++++++++++++++----- .../src/main/ets/view/TextureRegistry.ets | 5 ++- 5 files changed, 47 insertions(+), 13 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 67ede582ab..4ef5e68f11 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 @@ -92,4 +92,6 @@ export const nativeInitNativeImage: (nativeShellHolderId: number, textureId: num export const nativeUnregisterTexture: (nativeShellHolderId: number, textureId: number) => void; -export const nativeRegisterPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; \ No newline at end of file +export const nativeRegisterPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; + +export const nativeRegisterTexture: (nativeShellHolderId: number, textureId: number) => number; \ No newline at end of file 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 68228017bf..a4439baec9 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 @@ -368,6 +368,11 @@ export default class FlutterNapi { Log.d(TAG, "called registerPixelMap "); flutter.nativeRegisterPixelMap(this.nativeShellHolderId!, textureId, pixelMap); } + + registerTexture(textureId: number): number { + Log.d(TAG, "called unregisterTexture "); + return flutter.nativeRegisterTexture(this.nativeShellHolderId!, textureId); + } } export interface AccessibilityDelegate { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets index 272615d612..bdb9509d4d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets @@ -49,7 +49,7 @@ export default class FlutterApplicationInfo { this.domainNetworkPolicy = domainNetworkPolicy == null ? "" : domainNetworkPolicy; this.nativeLibraryDir = nativeLibraryDir; this.automaticallyRegisterPlugins = automaticallyRegisterPlugins; - this.isDebugMode = false; + this.isDebugMode = true; this.isProfile = false; } } \ No newline at end of file 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 00755a33a9..47a38838d5 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 @@ -4,7 +4,9 @@ import { SurfaceTextureEntry, TextureRegistry } from '../../../view/TextureRegis import { FlutterAbility } from '../../ohos/FlutterAbility'; import FlutterNapi from '../FlutterNapi'; import { SurfaceTextureWrapper } from './SurfaceTextureWrapper'; +import Log from '../../../util/Log'; +const TAG = "FlutterRenderer" export class FlutterRenderer implements TextureRegistry { private nextTextureId: number = 0; private flutterNapi: FlutterNapi; @@ -17,10 +19,20 @@ export class FlutterRenderer implements TextureRegistry { return this.registerSurfaceTexture(receiver); } + registerTexture(): SurfaceTextureEntry { + Log.i(TAG, "registerTexture") + this.nextTextureId = this.nextTextureId + 1; + let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId); + let surfaceId = this.flutterNapi.registerTexture(this.nextTextureId); + surfaceTextureRegistryEntry.setSurfaceId(surfaceId); + return surfaceTextureRegistryEntry; + } + registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry { this.nextTextureId = this.nextTextureId + 1; - let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId, receiver); - this.registerTexture(surfaceTextureRegistryEntry.id(), surfaceTextureRegistryEntry.textureWrapper()); + let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId); + surfaceTextureRegistryEntry.setImageReceiver(receiver); + this.registerImage(surfaceTextureRegistryEntry.getTextureId(), surfaceTextureRegistryEntry.textureWrapper()); return surfaceTextureRegistryEntry; } @@ -46,7 +58,7 @@ export class FlutterRenderer implements TextureRegistry { } return receiver; } - private registerTexture(textureId: number, surfaceTextureWrapper: SurfaceTextureWrapper): void { + private registerImage(textureId: number, surfaceTextureWrapper: SurfaceTextureWrapper): void { let receiver = surfaceTextureWrapper.getImageReceiver(); receiver.on('imageArrival', () => { receiver.readNextImage((err: BusinessError, nextImage: image.Image) => { @@ -68,25 +80,37 @@ export class FlutterRenderer implements TextureRegistry { } export class SurfaceTextureRegistryEntry implements SurfaceTextureEntry { - private textureId: number; - private surfaceTextureWrapper: SurfaceTextureWrapper; + private textureId: number = 0; + private surfaceId: number = 0; + private surfaceTextureWrapper: SurfaceTextureWrapper | null = null; private released: boolean = false; - constructor(id: number, receiver: image.ImageReceiver) { + constructor(id: number) { this.textureId = id; - this.surfaceTextureWrapper = new SurfaceTextureWrapper(receiver); } getImageReceiver(): image.ImageReceiver { - return this.surfaceTextureWrapper.getImageReceiver(); + return this.surfaceTextureWrapper!.getImageReceiver(); + } + + setImageReceiver(receiver: image.ImageReceiver): void { + this.surfaceTextureWrapper = new SurfaceTextureWrapper(receiver); } - id(): number { + getTextureId(): number { return this.textureId; } + getSurfaceId(): number { + return this.surfaceId; + } + + setSurfaceId(surfaceId: number): void { + this.surfaceId = surfaceId; + } + textureWrapper(): SurfaceTextureWrapper { - return this.surfaceTextureWrapper; + return this.surfaceTextureWrapper!; } release() { throw new Error('Method not implemented.'); 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 28d95be297..18c9d24445 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 @@ -17,6 +17,7 @@ import image from '@ohos.multimedia.image'; export interface TextureRegistry { createSurfaceTexture(): SurfaceTextureEntry; + registerTexture(): SurfaceTextureEntry; registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; registerPixelMap(pixelMap: PixelMap): number; unregisterTexture(textureId: number): void; @@ -24,7 +25,9 @@ export interface TextureRegistry { } export interface SurfaceTextureEntry { - id(): number; + getTextureId(): number; + + getSurfaceId(): number; getImageReceiver(): image.ImageReceiver; -- Gitee From 7b09d52158e79fac4c68835b2d84d3b071e320b2 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 27 Jan 2024 15:49:06 +0800 Subject: [PATCH 14/69] =?UTF-8?q?=E6=9B=B4=E6=96=B0flutter=5Fembedding?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/flutter_embedding/.gitignore | 1 + shell/platform/ohos/flutter_embedding/build-profile.json5 | 4 ++-- .../ohos/flutter_embedding/hvigor/hvigor-config.json5 | 5 ++--- .../platform/ohos/flutter_embedding/hvigor/hvigor-wrapper.js | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/.gitignore b/shell/platform/ohos/flutter_embedding/.gitignore index 4510e76666..969cec852a 100644 --- a/shell/platform/ohos/flutter_embedding/.gitignore +++ b/shell/platform/ohos/flutter_embedding/.gitignore @@ -8,3 +8,4 @@ /.clang-format /.clang-tidy **/.test +flutter/BuildProfile.ets diff --git a/shell/platform/ohos/flutter_embedding/build-profile.json5 b/shell/platform/ohos/flutter_embedding/build-profile.json5 index 4c7fb9d2b2..dc99061b4d 100755 --- a/shell/platform/ohos/flutter_embedding/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/build-profile.json5 @@ -20,8 +20,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": "4.0.0(10)", - "compatibleSdkVersion": "4.0.0(10)", + "compileSdkVersion": "4.1.0(11)", + "compatibleSdkVersion": "4.1.0(11)", "runtimeOS": "HarmonyOS", } ] diff --git a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 index 7885cddc3c..e7e28a6727 100755 --- a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 +++ b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 @@ -14,9 +14,8 @@ */ { - "hvigorVersion": "file:../dependencies/hvigor-3.0.9-s.tgz", + "hvigorVersion": "4.0.2", "dependencies": { - "@ohos/hvigor-ohos-plugin": "file:../dependencies/hvigor-ohos-plugin-3.0.9-s.tgz", - "rollup": "file:../dependencies/rollup.tgz", + "@ohos/hvigor-ohos-plugin": "4.0.2", } } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-wrapper.js b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-wrapper.js index 994f22987b..26073b8c2c 100755 --- a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-wrapper.js +++ b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-wrapper.js @@ -1,2 +1 @@ -"use strict";var e=require("fs"),t=require("path"),n=require("os"),r=require("crypto"),u=require("child_process"),o=require("constants"),i=require("stream"),s=require("util"),c=require("assert"),a=require("tty"),l=require("zlib"),f=require("net");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var D=d(e),p=d(t),E=d(n),m=d(r),h=d(u),y=d(o),C=d(i),F=d(s),g=d(c),A=d(a),v=d(l),S=d(f),w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},O={},b={},_={},B=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(_,"__esModule",{value:!0}),_.isMac=_.isLinux=_.isWindows=void 0;const P=B(E.default),k="Windows_NT",x="Linux",N="Darwin";_.isWindows=function(){return P.default.type()===k},_.isLinux=function(){return P.default.type()===x},_.isMac=function(){return P.default.type()===N};var I={},T=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),R=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),M=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&T(t,e,n);return R(t,e),t};Object.defineProperty(I,"__esModule",{value:!0}),I.hash=void 0;const L=M(m.default);I.hash=function(e,t="md5"){return L.createHash(t).update(e,"utf-8").digest("hex")},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.HVIGOR_BOOT_JS_FILE_PATH=e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=e.HVIGOR_PROJECT_DEPENDENCIES_HOME=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_NAME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const u=r(p.default),o=r(E.default),i=_,s=I;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,i.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,i.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=u.resolve(o.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=u.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=u.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=u.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=u.resolve(e.HVIGOR_USER_HOME,"project_caches"),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_NAME=u.basename((0,s.hash)(e.HVIGOR_PROJECT_ROOT_DIR)),e.HVIGOR_PROJECT_WRAPPER_HOME=u.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.HVIGOR_PROJECT_DEPENDENCIES_HOME=u.resolve(e.HVIGOR_PROJECT_CACHES_HOME,e.HVIGOR_PROJECT_NAME,"workspace"),e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,e.DEFAULT_PACKAGE_JSON),e.HVIGOR_BOOT_JS_FILE_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js")}(b);var j={},$={};Object.defineProperty($,"__esModule",{value:!0}),$.logInfoPrintConsole=$.logErrorAndExit=void 0,$.logErrorAndExit=function(e){e instanceof Error?console.error(e.message):console.error(e),process.exit(-1)},$.logInfoPrintConsole=function(e){console.log(e)};var H=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),J=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),G=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&H(t,e,n);return J(t,e),t},V=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0}),j.isFileExists=j.offlinePluginConversion=j.executeCommand=j.getNpmPath=j.hasNpmPackInPaths=void 0;const U=h.default,W=G(p.default),z=b,K=$,q=V(D.default);j.hasNpmPackInPaths=function(e,t){try{return require.resolve(e,{paths:[...t]}),!0}catch(e){return!1}},j.getNpmPath=function(){const e=process.execPath;return W.join(W.dirname(e),z.NPM_TOOL)},j.executeCommand=function(e,t,n){0!==(0,U.spawnSync)(e,t,n).status&&(0,K.logErrorAndExit)(`Error: ${e} ${t} execute failed.See above for details.`)},j.offlinePluginConversion=function(e,t){return t.startsWith("file:")||t.endsWith(".tgz")?W.resolve(e,z.HVIGOR,t.replace("file:","")):t},j.isFileExists=function(e){return q.default.existsSync(e)&&q.default.statSync(e).isFile()},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r},u=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.executeInstallPnpm=e.isPnpmAvailable=e.environmentHandler=e.checkNpmConifg=e.PNPM_VERSION=void 0;const o=r(D.default),i=b,s=j,c=r(p.default),a=$,l=h.default,f=u(E.default);e.PNPM_VERSION="7.30.0",e.checkNpmConifg=function(){const e=c.resolve(i.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),t=c.resolve(f.default.homedir(),".npmrc");if((0,s.isFileExists)(e)||(0,s.isFileExists)(t))return;const n=(0,s.getNpmPath)(),r=(0,l.spawnSync)(n,["config","get","prefix"],{cwd:i.HVIGOR_PROJECT_ROOT_DIR});if(0!==r.status||!r.stdout)return void(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const u=c.resolve(`${r.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,s.isFileExists)(u)||(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},e.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},e.isPnpmAvailable=function(){return!!o.existsSync(i.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,s.hasNpmPackInPaths)("pnpm",[i.HVIGOR_WRAPPER_TOOLS_HOME])},e.executeInstallPnpm=function(){(0,a.logInfoPrintConsole)(`Installing pnpm@${e.PNPM_VERSION}...`);const t=(0,s.getNpmPath)();!function(){const t=c.resolve(i.HVIGOR_WRAPPER_TOOLS_HOME,i.DEFAULT_PACKAGE_JSON);try{o.existsSync(i.HVIGOR_WRAPPER_TOOLS_HOME)||o.mkdirSync(i.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const n={dependencies:{}};n.dependencies[i.PNPM]=e.PNPM_VERSION,o.writeFileSync(t,JSON.stringify(n))}catch(e){(0,a.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${t} failed.`)}}(),(0,s.executeCommand)(t,["install","pnpm"],{cwd:i.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,a.logInfoPrintConsole)("Pnpm install success.")}}(O);var Y={},X={},Z={},Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.Unicode=void 0;class ee{}Q.Unicode=ee,ee.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ee.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,ee.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(Z,"__esModule",{value:!0}),Z.JudgeUtil=void 0;const te=Q;Z.JudgeUtil=class{static isIgnoreChar(e){return"string"==typeof e&&("\t"===e||"\v"===e||"\f"===e||" "===e||" "===e||"\ufeff"===e||"\n"===e||"\r"===e||"\u2028"===e||"\u2029"===e)}static isSpaceSeparator(e){return"string"==typeof e&&te.Unicode.Space_Separator.test(e)}static isIdStartChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||te.Unicode.ID_Start.test(e))}static isIdContinueChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||te.Unicode.ID_Continue.test(e))}static isDigitWithoutZero(e){return/[1-9]/.test(e)}static isDigit(e){return"string"==typeof e&&/[0-9]/.test(e)}static isHexDigit(e){return"string"==typeof e&&/[0-9A-Fa-f]/.test(e)}};var ne={},re={fromCallback:function(e){return Object.defineProperty((function(...t){if("function"!=typeof t[t.length-1])return new Promise(((n,r)=>{e.call(this,...t,((e,t)=>null!=e?r(e):n(t)))}));e.apply(this,t)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(...t){const n=t[t.length-1];if("function"!=typeof n)return e.apply(this,t);e.apply(this,t.slice(0,-1)).then((e=>n(null,e)),n)}),"name",{value:e.name})}},ue=y.default,oe=process.cwd,ie=null,se=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=oe.call(process)),ie};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var ce=process.chdir;process.chdir=function(e){ie=null,ce.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ce)}var ae=function(e){ue.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(t,n,r){e.open(t,ue.O_WRONLY|ue.O_SYMLINK,n,(function(t,u){t?r&&r(t):e.fchmod(u,n,(function(t){e.close(u,(function(e){r&&r(t||e)}))}))}))},e.lchmodSync=function(t,n){var r,u=e.openSync(t,ue.O_WRONLY|ue.O_SYMLINK,n),o=!0;try{r=e.fchmodSync(u,n),o=!1}finally{if(o)try{e.closeSync(u)}catch(e){}else e.closeSync(u)}return r}}(e);e.lutimes||function(e){ue.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(t,n,r,u){e.open(t,ue.O_SYMLINK,(function(t,o){t?u&&u(t):e.futimes(o,n,r,(function(t){e.close(o,(function(e){u&&u(t||e)}))}))}))},e.lutimesSync=function(t,n,r){var u,o=e.openSync(t,ue.O_SYMLINK),i=!0;try{u=e.futimesSync(o,n,r),i=!1}finally{if(i)try{e.closeSync(o)}catch(e){}else e.closeSync(o)}return u}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=r(e.chown),e.fchown=r(e.fchown),e.lchown=r(e.lchown),e.chmod=t(e.chmod),e.fchmod=t(e.fchmod),e.lchmod=t(e.lchmod),e.chownSync=u(e.chownSync),e.fchownSync=u(e.fchownSync),e.lchownSync=u(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=o(e.stat),e.fstat=o(e.fstat),e.lstat=o(e.lstat),e.statSync=i(e.statSync),e.fstatSync=i(e.fstatSync),e.lstatSync=i(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===se&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,u){var o=Date.now(),i=0;t(n,r,(function s(c){if(c&&("EACCES"===c.code||"EPERM"===c.code||"EBUSY"===c.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,s):u(c)}))}),i),void(i<100&&(i+=10));u&&u(c)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function t(t){return t?function(n,r,u){return t.call(e,n,r,(function(e){s(e)&&(e=null),u&&u.apply(this,arguments)}))}:t}function n(t){return t?function(n,r){try{return t.call(e,n,r)}catch(e){if(!s(e))throw e}}:t}function r(t){return t?function(n,r,u,o){return t.call(e,n,r,u,(function(e){s(e)&&(e=null),o&&o.apply(this,arguments)}))}:t}function u(t){return t?function(n,r,u){try{return t.call(e,n,r,u)}catch(e){if(!s(e))throw e}}:t}function o(t){return t?function(n,r,u){function o(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),u&&u.apply(this,arguments)}return"function"==typeof r&&(u=r,r=null),r?t.call(e,n,r,o):t.call(e,n,o)}:t}function i(t){return t?function(n,r){var u=r?t.call(e,n,r):t.call(e,n);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}:t}function s(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,u,o,i,s){var c;if(s&&"function"==typeof s){var a=0;c=function(l,f,d){if(l&&"EAGAIN"===l.code&&a<10)return a++,t.call(e,n,r,u,o,i,c);s.apply(this,arguments)}}return t.call(e,n,r,u,o,i,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(c=e.readSync,function(t,n,r,u,o){for(var i=0;;)try{return c.call(e,t,n,r,u,o)}catch(e){if("EAGAIN"===e.code&&i<10){i++;continue}throw e}});var c};var le=C.default.Stream,fe=function(e){return{ReadStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this);var u=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var o=Object.keys(r),i=0,s=o.length;ithis.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick((function(){u._read()}));e.open(this.path,this.flags,this.mode,(function(e,t){if(e)return u.emit("error",e),void(u.readable=!1);u.fd=t,u.emit("open",t),u._read()}))},WriteStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var u=Object.keys(r),o=0,i=u.length;o= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var de=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var t={__proto__:De(e)};else t=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t},De=Object.getPrototypeOf||function(e){return e.__proto__};var pe,Ee,me=D.default,he=ae,ye=fe,Ce=de,Fe=F.default;function ge(e,t){Object.defineProperty(e,pe,{get:function(){return t}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(pe=Symbol.for("graceful-fs.queue"),Ee=Symbol.for("graceful-fs.previous")):(pe="___graceful-fs.queue",Ee="___graceful-fs.previous");var Ae=function(){};if(Fe.debuglog?Ae=Fe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ae=function(){var e=Fe.format.apply(Fe,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!me[pe]){var ve=w[pe]||[];ge(me,ve),me.close=function(e){function t(t,n){return e.call(me,t,(function(e){e||_e(),"function"==typeof n&&n.apply(this,arguments)}))}return Object.defineProperty(t,Ee,{value:e}),t}(me.close),me.closeSync=function(e){function t(t){e.apply(me,arguments),_e()}return Object.defineProperty(t,Ee,{value:e}),t}(me.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){Ae(me[pe]),g.default.equal(me[pe].length,0)}))}w[pe]||ge(w,me[pe]);var Se,we=Oe(Ce(me));function Oe(e){he(e),e.gracefulify=Oe,e.createReadStream=function(t,n){return new e.ReadStream(t,n)},e.createWriteStream=function(t,n){return new e.WriteStream(t,n)};var t=e.readFile;e.readFile=function(e,n,r){"function"==typeof n&&(r=n,n=null);return function e(n,r,u,o){return t(n,r,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof u&&u.apply(this,arguments):be([e,[n,r,u],t,o||Date.now(),Date.now()])}))}(e,n,r)};var n=e.writeFile;e.writeFile=function(e,t,r,u){"function"==typeof r&&(u=r,r=null);return function e(t,r,u,o,i){return n(t,r,u,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,r,u,o],n,i||Date.now(),Date.now()])}))}(e,t,r,u)};var r=e.appendFile;r&&(e.appendFile=function(e,t,n,u){"function"==typeof n&&(u=n,n=null);return function e(t,n,u,o,i){return r(t,n,u,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,u,o],r,i||Date.now(),Date.now()])}))}(e,t,n,u)});var u=e.copyFile;u&&(e.copyFile=function(e,t,n,r){"function"==typeof n&&(r=n,n=0);return function e(t,n,r,o,i){return u(t,n,r,(function(u){!u||"EMFILE"!==u.code&&"ENFILE"!==u.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,r,o],u,i||Date.now(),Date.now()])}))}(e,t,n,r)});var o=e.readdir;e.readdir=function(e,t,n){"function"==typeof t&&(n=t,t=null);var r=i.test(process.version)?function(e,t,n,r){return o(e,u(e,t,n,r))}:function(e,t,n,r){return o(e,t,u(e,t,n,r))};return r(e,t,n);function u(e,t,n,u){return function(o,i){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?(i&&i.sort&&i.sort(),"function"==typeof n&&n.call(this,o,i)):be([r,[e,t,n],o,u||Date.now(),Date.now()])}}};var i=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var s=ye(e);d=s.ReadStream,D=s.WriteStream}var c=e.ReadStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n),e.read())}))});var a=e.WriteStream;a&&(D.prototype=Object.create(a.prototype),D.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n))}))}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return D},set:function(e){D=e},enumerable:!0,configurable:!0});var l=d;Object.defineProperty(e,"FileReadStream",{get:function(){return l},set:function(e){l=e},enumerable:!0,configurable:!0});var f=D;function d(e,t){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(e,t){return this instanceof D?(a.apply(this,arguments),this):D.apply(Object.create(D.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=e.open;function E(e,t,n,r){return"function"==typeof n&&(r=n,n=null),function e(t,n,r,u,o){return p(t,n,r,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof u&&u.apply(this,arguments):be([e,[t,n,r,u],i,o||Date.now(),Date.now()])}))}(e,t,n,r)}return e.open=E,e}function be(e){Ae("ENQUEUE",e[0].name,e[1]),me[pe].push(e),Be()}function _e(){for(var e=Date.now(),t=0;t2&&(me[pe][t][3]=e,me[pe][t][4]=e);Be()}function Be(){if(clearTimeout(Se),Se=void 0,0!==me[pe].length){var e=me[pe].shift(),t=e[0],n=e[1],r=e[2],u=e[3],o=e[4];if(void 0===u)Ae("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-u>=6e4){Ae("TIMEOUT",t.name,n);var i=n.pop();"function"==typeof i&&i.call(null,r)}else{var s=Date.now()-o,c=Math.max(o-u,1);s>=Math.min(1.2*c,100)?(Ae("RETRY",t.name,n),t.apply(null,n.concat([u]))):me[pe].push(e)}void 0===Se&&(Se=setTimeout(Be,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!me.__patched&&(we=Oe(me),me.__patched=!0),function(e){const t=re.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.assign(e,n),r.forEach((r=>{e[r]=t(n[r])})),e.realpath.native=t(n.realpath.native),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.writev&&(e.writev=function(e,t,...r){return"function"==typeof r[r.length-1]?n.writev(e,t,...r):new Promise(((u,o)=>{n.writev(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffers:n})}))}))})}(ne);var Pe={},ke={};const xe=p.default;ke.checkPath=function(e){if("win32"===process.platform){if(/[<>:"|?*]/.test(e.replace(xe.parse(e).root,""))){const t=new Error(`Path contains invalid characters: ${e}`);throw t.code="EINVAL",t}}};const Ne=ne,{checkPath:Ie}=ke,Te=e=>"number"==typeof e?e:{mode:511,...e}.mode;Pe.makeDir=async(e,t)=>(Ie(e),Ne.mkdir(e,{mode:Te(t),recursive:!0})),Pe.makeDirSync=(e,t)=>(Ie(e),Ne.mkdirSync(e,{mode:Te(t),recursive:!0}));const Re=re.fromPromise,{makeDir:Me,makeDirSync:Le}=Pe,je=Re(Me);var $e={mkdirs:je,mkdirsSync:Le,mkdirp:je,mkdirpSync:Le,ensureDir:je,ensureDirSync:Le};const He=re.fromPromise,Je=ne;var Ge={pathExists:He((function(e){return Je.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:Je.existsSync};const Ve=we;var Ue=function(e,t,n,r){Ve.open(e,"r+",((e,u)=>{if(e)return r(e);Ve.futimes(u,t,n,(e=>{Ve.close(u,(t=>{r&&r(e||t)}))}))}))},We=function(e,t,n){const r=Ve.openSync(e,"r+");return Ve.futimesSync(r,t,n),Ve.closeSync(r)};const ze=ne,Ke=p.default,qe=F.default;function Ye(e,t,n){const r=n.dereference?e=>ze.stat(e,{bigint:!0}):e=>ze.lstat(e,{bigint:!0});return Promise.all([r(e),r(t).catch((e=>{if("ENOENT"===e.code)return null;throw e}))]).then((([e,t])=>({srcStat:e,destStat:t})))}function Xe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ze(e,t){const n=Ke.resolve(e).split(Ke.sep).filter((e=>e)),r=Ke.resolve(t).split(Ke.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function Qe(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var et={checkPaths:function(e,t,n,r,u){qe.callbackify(Ye)(e,t,r,((r,o)=>{if(r)return u(r);const{srcStat:i,destStat:s}=o;if(s){if(Xe(i,s)){const r=Ke.basename(e),o=Ke.basename(t);return"move"===n&&r!==o&&r.toLowerCase()===o.toLowerCase()?u(null,{srcStat:i,destStat:s,isChangingCase:!0}):u(new Error("Source and destination must not be the same."))}if(i.isDirectory()&&!s.isDirectory())return u(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!i.isDirectory()&&s.isDirectory())return u(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return i.isDirectory()&&Ze(e,t)?u(new Error(Qe(e,t,n))):u(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n,r){const{srcStat:u,destStat:o}=function(e,t,n){let r;const u=n.dereference?e=>ze.statSync(e,{bigint:!0}):e=>ze.lstatSync(e,{bigint:!0}),o=u(e);try{r=u(t)}catch(e){if("ENOENT"===e.code)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:r}}(e,t,r);if(o){if(Xe(u,o)){const r=Ke.basename(e),i=Ke.basename(t);if("move"===n&&r!==i&&r.toLowerCase()===i.toLowerCase())return{srcStat:u,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(u.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!u.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(u.isDirectory()&&Ze(e,t))throw new Error(Qe(e,t,n));return{srcStat:u,destStat:o}},checkParentPaths:function e(t,n,r,u,o){const i=Ke.resolve(Ke.dirname(t)),s=Ke.resolve(Ke.dirname(r));if(s===i||s===Ke.parse(s).root)return o();ze.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):Xe(n,c)?o(new Error(Qe(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=Ke.resolve(Ke.dirname(t)),i=Ke.resolve(Ke.dirname(r));if(i===o||i===Ke.parse(i).root)return;let s;try{s=ze.statSync(i,{bigint:!0})}catch(e){if("ENOENT"===e.code)return;throw e}if(Xe(n,s))throw new Error(Qe(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ze,areIdentical:Xe};const tt=we,nt=p.default,rt=$e.mkdirs,ut=Ge.pathExists,ot=Ue,it=et;function st(e,t,n,r,u){const o=nt.dirname(n);ut(o,((i,s)=>i?u(i):s?at(e,t,n,r,u):void rt(o,(o=>o?u(o):at(e,t,n,r,u)))))}function ct(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function at(e,t,n,r,u){(r.dereference?tt.stat:tt.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){return t?Dt(n,r,u,o):function(e,t,n,r,u){tt.mkdir(n,(o=>{if(o)return u(o);Dt(t,n,r,(t=>t?u(t):dt(n,e,u)))}))}(e.mode,n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();tt.unlink(n,(o=>o?u(o):lt(e,t,n,r,u)))}(e,n,r,u,o):lt(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){tt.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=nt.resolve(process.cwd(),o)),e?void tt.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?tt.symlink(o,n,u):u(t):(r.dereference&&(i=nt.resolve(process.cwd(),i)),it.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&it.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){tt.unlink(t,(r=>r?n(r):tt.symlink(e,t,n)))}(o,n,u)))):tt.symlink(o,n,u))))}(e,t,n,r,u):i.isSocket()?u(new Error(`Cannot copy a socket file: ${t}`)):i.isFIFO()?u(new Error(`Cannot copy a FIFO pipe: ${t}`)):u(new Error(`Unknown file: ${t}`))))}function lt(e,t,n,r,u){tt.copyFile(t,n,(o=>o?u(o):r.preserveTimestamps?function(e,t,n,r){if(function(e){return 0==(128&e)}(e))return function(e,t,n){return dt(e,128|t,n)}(n,e,(u=>u?r(u):ft(e,t,n,r)));return ft(e,t,n,r)}(e.mode,t,n,u):dt(n,e.mode,u)))}function ft(e,t,n,r){!function(e,t,n){tt.stat(e,((e,r)=>e?n(e):ot(t,r.atime,r.mtime,n)))}(t,n,(t=>t?r(t):dt(n,e,r)))}function dt(e,t,n){return tt.chmod(e,t,n)}function Dt(e,t,n,r){tt.readdir(e,((u,o)=>u?r(u):pt(o,e,t,n,r)))}function pt(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=nt.join(n,t),s=nt.join(r,t);it.checkPaths(i,s,"copy",u,((t,c)=>{if(t)return o(t);const{destStat:a}=c;!function(e,t,n,r,u){r.filter?ct(at,e,t,n,r,u):at(e,t,n,r,u)}(a,i,s,u,(t=>t?o(t):pt(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Et=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),it.checkPaths(e,t,"copy",n,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;it.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?ct(st,s,e,t,n,r):st(s,e,t,n,r)))}))};const mt=we,ht=p.default,yt=$e.mkdirsSync,Ct=We,Ft=et;function gt(e,t,n,r){const u=(r.dereference?mt.statSync:mt.lstatSync)(t);if(u.isDirectory())return function(e,t,n,r,u){return t?St(n,r,u):function(e,t,n,r){return mt.mkdirSync(n),St(t,n,r),vt(n,e)}(e.mode,n,r,u)}(u,e,t,n,r);if(u.isFile()||u.isCharacterDevice()||u.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return mt.unlinkSync(n),At(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):At(e,n,r,u)}(u,e,t,n,r);if(u.isSymbolicLink())return function(e,t,n,r){let u=mt.readlinkSync(t);r.dereference&&(u=ht.resolve(process.cwd(),u));if(e){let e;try{e=mt.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return mt.symlinkSync(u,n);throw e}if(r.dereference&&(e=ht.resolve(process.cwd(),e)),Ft.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(mt.statSync(n).isDirectory()&&Ft.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return mt.unlinkSync(t),mt.symlinkSync(e,t)}(u,n)}return mt.symlinkSync(u,n)}(e,t,n,r);if(u.isSocket())throw new Error(`Cannot copy a socket file: ${t}`);if(u.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${t}`);throw new Error(`Unknown file: ${t}`)}function At(e,t,n,r){return mt.copyFileSync(t,n),r.preserveTimestamps&&function(e,t,n){(function(e){return 0==(128&e)})(e)&&function(e,t){vt(e,128|t)}(n,e);(function(e,t){const n=mt.statSync(e);Ct(t,n.atime,n.mtime)})(t,n)}(e.mode,t,n),vt(n,e.mode)}function vt(e,t){return mt.chmodSync(e,t)}function St(e,t,n){mt.readdirSync(e).forEach((r=>function(e,t,n,r){const u=ht.join(t,e),o=ht.join(n,e),{destStat:i}=Ft.checkPathsSync(u,o,"copy",r);return function(e,t,n,r){if(!r.filter||r.filter(t,n))return gt(e,t,n,r)}(i,u,o,r)}(r,e,t,n)))}var wt=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=Ft.checkPathsSync(e,t,"copy",n);return Ft.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ht.dirname(n);mt.existsSync(u)||yt(u);return gt(e,t,n,r)}(u,e,t,n)};var Ot={copy:(0,re.fromCallback)(Et),copySync:wt};const bt=we,_t=p.default,Bt=g.default,Pt="win32"===process.platform;function kt(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||bt[t],e[t+="Sync"]=e[t]||bt[t]})),e.maxBusyTries=e.maxBusyTries||3}function xt(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt.strictEqual(typeof n,"function","rimraf: callback function required"),Bt(t,"rimraf: invalid options argument provided"),Bt.strictEqual(typeof t,"object","rimraf: options should be object"),kt(t),Nt(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rNt(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Nt(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&Pt?It(e,t,r,n):u&&u.isDirectory()?Rt(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return Pt?It(e,t,r,n):Rt(e,t,r,n);if("EISDIR"===r.code)return Rt(e,t,r,n)}return n(r)}))))}function It(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Rt(e,t,n,r):t.unlink(e,r)}))}))}function Tt(e,t,n){let r;Bt(e),Bt(t);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?Lt(e,t,n):t.unlinkSync(e)}function Rt(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{xt(_t.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Mt(e,t){let n;kt(t=t||{}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt(t,"rimraf: missing options"),Bt.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&Pt&&Tt(e,t,n)}try{n&&n.isDirectory()?Lt(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return Pt?Tt(e,t,n):Lt(e,t,n);if("EISDIR"!==n.code)throw n;Lt(e,t,n)}}function Lt(e,t,n){Bt(e),Bt(t);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Bt(e),Bt(t),t.readdirSync(e).forEach((n=>Mt(_t.join(e,n),t))),!Pt){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch{}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var jt=xt;xt.sync=Mt;const $t=we,Ht=re.fromCallback,Jt=jt;var Gt={remove:Ht((function(e,t){if($t.rm)return $t.rm(e,{recursive:!0,force:!0},t);Jt(e,t)})),removeSync:function(e){if($t.rmSync)return $t.rmSync(e,{recursive:!0,force:!0});Jt.sync(e)}};const Vt=re.fromPromise,Ut=ne,Wt=p.default,zt=$e,Kt=Gt,qt=Vt((async function(e){let t;try{t=await Ut.readdir(e)}catch{return zt.mkdirs(e)}return Promise.all(t.map((t=>Kt.remove(Wt.join(e,t)))))}));function Yt(e){let t;try{t=Ut.readdirSync(e)}catch{return zt.mkdirsSync(e)}t.forEach((t=>{t=Wt.join(e,t),Kt.removeSync(t)}))}var Xt={emptyDirSync:Yt,emptydirSync:Yt,emptyDir:qt,emptydir:qt};const Zt=re.fromCallback,Qt=p.default,en=we,tn=$e;var nn={createFile:Zt((function(e,t){function n(){en.writeFile(e,"",(e=>{if(e)return t(e);t()}))}en.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Qt.dirname(e);en.stat(o,((e,r)=>{if(e)return"ENOENT"===e.code?tn.mkdirs(o,(e=>{if(e)return t(e);n()})):t(e);r.isDirectory()?n():en.readdir(o,(e=>{if(e)return t(e)}))}))}))})),createFileSync:function(e){let t;try{t=en.statSync(e)}catch{}if(t&&t.isFile())return;const n=Qt.dirname(e);try{en.statSync(n).isDirectory()||en.readdirSync(n)}catch(e){if(!e||"ENOENT"!==e.code)throw e;tn.mkdirsSync(n)}en.writeFileSync(e,"")}};const rn=re.fromCallback,un=p.default,on=we,sn=$e,cn=Ge.pathExists,{areIdentical:an}=et;var ln={createLink:rn((function(e,t,n){function r(e,t){on.link(e,t,(e=>{if(e)return n(e);n(null)}))}on.lstat(t,((u,o)=>{on.lstat(e,((u,i)=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);if(o&&an(i,o))return n(null);const s=un.dirname(t);cn(s,((u,o)=>u?n(u):o?r(e,t):void sn.mkdirs(s,(u=>{if(u)return n(u);r(e,t)}))))}))}))})),createLinkSync:function(e,t){let n;try{n=on.lstatSync(t)}catch{}try{const t=on.lstatSync(e);if(n&&an(t,n))return}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const r=un.dirname(t);return on.existsSync(r)||sn.mkdirsSync(r),on.linkSync(e,t)}};const fn=p.default,dn=we,Dn=Ge.pathExists;var pn={symlinkPaths:function(e,t,n){if(fn.isAbsolute(e))return dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=fn.dirname(t),u=fn.join(r,e);return Dn(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:fn.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(fn.isAbsolute(e)){if(n=dn.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=fn.dirname(t),u=fn.join(r,e);if(n=dn.existsSync(u),n)return{toCwd:u,toDst:e};if(n=dn.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:fn.relative(r,e)}}}};const En=we;var mn={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);En.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=En.lstatSync(e)}catch{return"file"}return n&&n.isDirectory()?"dir":"file"}};const hn=re.fromCallback,yn=p.default,Cn=ne,Fn=$e.mkdirs,gn=$e.mkdirsSync,An=pn.symlinkPaths,vn=pn.symlinkPathsSync,Sn=mn.symlinkType,wn=mn.symlinkTypeSync,On=Ge.pathExists,{areIdentical:bn}=et;function _n(e,t,n,r){An(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,Sn(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=yn.dirname(t);On(o,((n,i)=>n?r(n):i?Cn.symlink(e,t,u,r):void Fn(o,(n=>{if(n)return r(n);Cn.symlink(e,t,u,r)}))))}))}))}var Bn={createSymlink:hn((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Cn.lstat(t,((u,o)=>{!u&&o.isSymbolicLink()?Promise.all([Cn.stat(e),Cn.stat(t)]).then((([u,o])=>{if(bn(u,o))return r(null);_n(e,t,n,r)})):_n(e,t,n,r)}))})),createSymlinkSync:function(e,t,n){let r;try{r=Cn.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const n=Cn.statSync(e),r=Cn.statSync(t);if(bn(n,r))return}const u=vn(e,t);e=u.toDst,n=wn(u.toCwd,n);const o=yn.dirname(t);return Cn.existsSync(o)||gn(o),Cn.symlinkSync(e,t,n)}};const{createFile:Pn,createFileSync:kn}=nn,{createLink:xn,createLinkSync:Nn}=ln,{createSymlink:In,createSymlinkSync:Tn}=Bn;var Rn={createFile:Pn,createFileSync:kn,ensureFile:Pn,ensureFileSync:kn,createLink:xn,createLinkSync:Nn,ensureLink:xn,ensureLinkSync:Nn,createSymlink:In,createSymlinkSync:Tn,ensureSymlink:In,ensureSymlinkSync:Tn};var Mn={stringify:function(e,{EOL:t="\n",finalEOL:n=!0,replacer:r=null,spaces:u}={}){const o=n?t:"";return JSON.stringify(e,r,u).replace(/\n/g,t)+o},stripBom:function(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}};let Ln;try{Ln=we}catch(e){Ln=D.default}const jn=re,{stringify:$n,stripBom:Hn}=Mn;const Jn=jn.fromPromise((async function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;let u,o=await jn.fromCallback(n.readFile)(e,t);o=Hn(o);try{u=JSON.parse(o,t?t.reviver:null)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}return u}));const Gn=jn.fromPromise((async function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);await jn.fromCallback(r.writeFile)(e,u,n)}));const Vn={readFile:Jn,readFileSync:function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;try{let r=n.readFileSync(e,t);return r=Hn(r),JSON.parse(r,t.reviver)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}},writeFile:Gn,writeFileSync:function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);return r.writeFileSync(e,u,n)}};var Un={readJson:Vn.readFile,readJsonSync:Vn.readFileSync,writeJson:Vn.writeFile,writeJsonSync:Vn.writeFileSync};const Wn=re.fromCallback,zn=we,Kn=p.default,qn=$e,Yn=Ge.pathExists;var Xn={outputFile:Wn((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Kn.dirname(e);Yn(u,((o,i)=>o?r(o):i?zn.writeFile(e,t,n,r):void qn.mkdirs(u,(u=>{if(u)return r(u);zn.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Kn.dirname(e);if(zn.existsSync(n))return zn.writeFileSync(e,...t);qn.mkdirsSync(n),zn.writeFileSync(e,...t)}};const{stringify:Zn}=Mn,{outputFile:Qn}=Xn;var er=async function(e,t,n={}){const r=Zn(t,n);await Qn(e,r,n)};const{stringify:tr}=Mn,{outputFileSync:nr}=Xn;var rr=function(e,t,n){const r=tr(t,n);nr(e,r,n)};const ur=re.fromPromise,or=Un;or.outputJson=ur(er),or.outputJsonSync=rr,or.outputJSON=or.outputJson,or.outputJSONSync=or.outputJsonSync,or.writeJSON=or.writeJson,or.writeJSONSync=or.writeJsonSync,or.readJSON=or.readJson,or.readJSONSync=or.readJsonSync;var ir=or;const sr=we,cr=p.default,ar=Ot.copy,lr=Gt.remove,fr=$e.mkdirp,dr=Ge.pathExists,Dr=et;function pr(e,t,n,r,u){return r?Er(e,t,n,u):n?lr(t,(r=>r?u(r):Er(e,t,n,u))):void dr(t,((r,o)=>r?u(r):o?u(new Error("dest already exists.")):Er(e,t,n,u)))}function Er(e,t,n,r){sr.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};ar(e,t,u,(t=>t?r(t):lr(e,r)))}(e,t,n,r):r()))}var mr=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;Dr.checkPaths(e,t,"move",n,((n,o)=>{if(n)return r(n);const{srcStat:i,isChangingCase:s=!1}=o;Dr.checkParentPaths(e,i,t,"move",(n=>n?r(n):function(e){const t=cr.dirname(e);return cr.parse(t).root===t}(t)?pr(e,t,u,s,r):void fr(cr.dirname(t),(n=>n?r(n):pr(e,t,u,s,r)))))}))};const hr=we,yr=p.default,Cr=Ot.copySync,Fr=Gt.removeSync,gr=$e.mkdirpSync,Ar=et;function vr(e,t,n){try{hr.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Cr(e,t,r),Fr(e)}(e,t,n)}}var Sr=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u,isChangingCase:o=!1}=Ar.checkPathsSync(e,t,"move",n);return Ar.checkParentPathsSync(e,u,t,"move"),function(e){const t=yr.dirname(e);return yr.parse(t).root===t}(t)||gr(yr.dirname(t)),function(e,t,n,r){if(r)return vr(e,t,n);if(n)return Fr(t),vr(e,t,n);if(hr.existsSync(t))throw new Error("dest already exists.");return vr(e,t,n)}(e,t,r,o)};var wr,Or,br,_r,Br,Pr={move:(0,re.fromCallback)(mr),moveSync:Sr},kr={...ne,...Ot,...Xt,...Rn,...ir,...$e,...Pr,...Xn,...Ge,...Gt},xr={},Nr={exports:{}},Ir={exports:{}};function Tr(){if(Or)return wr;Or=1;var e=1e3,t=60*e,n=60*t,r=24*n,u=7*r,o=365.25*r;function i(e,t,n,r){var u=t>=1.5*n;return Math.round(e/n)+" "+r+(u?"s":"")}return wr=function(s,c){c=c||{};var a=typeof s;if("string"===a&&s.length>0)return function(i){if((i=String(i)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===a&&isFinite(s))return c.long?function(u){var o=Math.abs(u);if(o>=r)return i(u,o,r,"day");if(o>=n)return i(u,o,n,"hour");if(o>=t)return i(u,o,t,"minute");if(o>=e)return i(u,o,e,"second");return u+" ms"}(s):function(u){var o=Math.abs(u);if(o>=r)return Math.round(u/r)+"d";if(o>=n)return Math.round(u/n)+"h";if(o>=t)return Math.round(u/t)+"m";if(o>=e)return Math.round(u/e)+"s";return u+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function Rr(){if(_r)return br;return _r=1,br=function(e){function t(e){let r,u,o,i=null;function s(...e){if(!s.enabled)return;const n=s,u=Number(new Date),o=u-(r||u);n.diff=o,n.prev=r,n.curr=u,r=u,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,u)=>{if("%%"===r)return"%";i++;const o=t.formatters[u];if("function"==typeof o){const t=e[i];r=o.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(u!==t.namespaces&&(u=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),u=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return-1!==r&&(-1===u||r{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if($r)return jr;$r=1;const e=E.default,t=A.default,n=Vr(),{env:r}=process;let u;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function i(t,o){if(0===u)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(t&&!o&&void 0===u)return 0;const i=u||0;if("dumb"===r.TERM)return i;if("win32"===process.platform){const t=e.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:i;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}return n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(u="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),jr={supportsColor:function(e){return o(i(e,e&&e.isTTY))},stdout:o(i(!0,t.isatty(1))),stderr:o(i(!0,t.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e}),{}),e.exports=Rr()(t);const{formatters:u}=e.exports;u.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},u.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(Gr,Gr.exports)),Gr.exports}Jr=Nr,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?Jr.exports=(Br||(Br=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,u=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(u=r))})),t.splice(u,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Rr()(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ir,Ir.exports)),Ir.exports):Jr.exports=Ur();var Wr=function(e){return(e=e||{}).circles?function(e){var t=[],n=[];return e.proto?function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o}:function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u)if(!1!==Object.hasOwnProperty.call(u,i)){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o};function r(e,r){for(var u=Object.keys(e),o=new Array(u.length),i=0;i!e,Qr=e=>e&&"object"==typeof e&&!Array.isArray(e),eu=(e,t,n)=>{(Array.isArray(t)?t:[t]).forEach((t=>{if(t)throw new Error(`Problem with log4js configuration: (${Kr.inspect(e,{depth:5})}) - ${n}`)}))};var tu={configure:e=>{qr("New configuration to be validated: ",e),eu(e,Zr(Qr(e)),"must be an object."),qr(`Calling pre-processing listeners (${Yr.length})`),Yr.forEach((t=>t(e))),qr("Configuration pre-processing finished."),qr(`Calling configuration listeners (${Xr.length})`),Xr.forEach((t=>t(e))),qr("Configuration finished.")},addListener:e=>{Xr.push(e),qr(`Added listener, now ${Xr.length} listeners`)},addPreProcessingListener:e=>{Yr.push(e),qr(`Added pre-processing listener, now ${Yr.length} listeners`)},throwExceptionIf:eu,anObject:Qr,anInteger:e=>e&&"number"==typeof e&&Number.isInteger(e),validIdentifier:e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),not:Zr},nu={exports:{}};!function(e){function t(e,t){for(var n=e.toString();n.length-1?s:c,l=n(u.getHours()),f=n(u.getMinutes()),d=n(u.getSeconds()),D=t(u.getMilliseconds(),3),p=function(e){var t=Math.abs(e),n=String(Math.floor(t/60)),r=String(t%60);return n=("0"+n).slice(-2),r=("0"+r).slice(-2),0===e?"Z":(e<0?"+":"-")+n+":"+r}(u.getTimezoneOffset());return r.replace(/dd/g,o).replace(/MM/g,i).replace(/y{1,4}/g,a).replace(/hh/g,l).replace(/mm/g,f).replace(/ss/g,d).replace(/SSS/g,D).replace(/O/g,p)}function u(e,t,n,r){e["set"+(r?"":"UTC")+t](n)}e.exports=r,e.exports.asString=r,e.exports.parse=function(t,n,r){if(!t)throw new Error("pattern must be supplied");return function(t,n,r){var o=t.indexOf("O")<0,i=!1,s=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(e,t){u(e,"FullYear",t,o)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Month",t-1,o),e.getMonth()!==t-1&&(i=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(e,t){i&&u(e,"Month",e.getMonth()-1,o),u(e,"Date",t,o)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Hours",t,o)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(e,t){u(e,"Minutes",t,o)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(e,t){u(e,"Seconds",t,o)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(e,t){u(e,"Milliseconds",t,o)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(e,t){t="Z"===t?0:t.replace(":","");var n=Math.abs(t),r=(t>0?-1:1)*(n%100+60*Math.floor(n/100));e.setUTCMinutes(e.getUTCMinutes()+r)}}],c=s.reduce((function(e,t){return t.pattern.test(e.regexp)?(t.index=e.regexp.match(t.pattern).index,e.regexp=e.regexp.replace(t.pattern,"("+t.regexp+")")):t.index=-1,e}),{regexp:t,index:[]}),a=s.filter((function(e){return e.index>-1}));a.sort((function(e,t){return e.index-t.index}));var l=new RegExp(c.regexp).exec(n);if(l){var f=r||e.exports.now();return a.forEach((function(e,t){e.fn(f,l[t+1])})),f}throw new Error("String '"+n+"' could not be parsed as '"+t+"'")}(t,n,r)},e.exports.now=function(){return new Date},e.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS",e.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO",e.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS",e.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"}(nu);const ru=nu.exports,uu=E.default,ou=F.default,iu=p.default,su={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function cu(e){return e?`[${su[e][0]}m`:""}function au(e){return e?`[${su[e][1]}m`:""}function lu(e,t){return n=ou.format("[%s] [%s] %s - ",ru.asString(e.startTime),e.level.toString(),e.categoryName),cu(r=t)+n+au(r);var n,r}function fu(e){return lu(e)+ou.format(...e.data)}function du(e){return lu(e,e.level.colour)+ou.format(...e.data)}function Du(e){return ou.format(...e.data)}function pu(e){return e.data[0]}function Eu(e,t){const n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;function r(e){return e&&e.pid?e.pid.toString():process.pid.toString()}e=e||"%r %p %c - %m%n";const u={c:function(e,t){let n=e.categoryName;if(t){const e=parseInt(t,10),r=n.split(".");ee&&(n=r.slice(-e).join(iu.sep))}return n},l:function(e){return e.lineNumber?`${e.lineNumber}`:""},o:function(e){return e.columnNumber?`${e.columnNumber}`:""},s:function(e){return e.callStack||""}};function o(e,t,n){return u[e](t,n)}function i(e,t,n){let r=e;return r=function(e,t){let n;return e?(n=parseInt(e.substr(1),10),n>0?t.slice(0,n):t.slice(n)):t}(t,r),r=function(e,t){let n;if(e)if("-"===e.charAt(0))for(n=parseInt(e.substr(1),10);t.lengthDu,basic:()=>fu,colored:()=>du,coloured:()=>du,pattern:e=>Eu(e&&e.pattern,e&&e.tokens),dummy:()=>pu};var hu={basicLayout:fu,messagePassThroughLayout:Du,patternLayout:Eu,colouredLayout:du,coloredLayout:du,dummyLayout:pu,addLayout(e,t){mu[e]=t},layout:(e,t)=>mu[e]&&mu[e](t)};const yu=tu,Cu=["white","grey","black","blue","cyan","green","magenta","red","yellow"];class Fu{constructor(e,t,n){this.level=e,this.levelStr=t,this.colour=n}toString(){return this.levelStr}static getLevel(e,t){return e?e instanceof Fu?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),Fu[e.toString().toUpperCase()]||t):t}static addLevels(e){if(e){Object.keys(e).forEach((t=>{const n=t.toUpperCase();Fu[n]=new Fu(e[t].value,n,e[t].colour);const r=Fu.levels.findIndex((e=>e.levelStr===n));r>-1?Fu.levels[r]=Fu[n]:Fu.levels.push(Fu[n])})),Fu.levels.sort(((e,t)=>e.level-t.level))}}isLessThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level>=e.level}isEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level===e.level}}Fu.levels=[],Fu.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}}),yu.addListener((e=>{const t=e.levels;if(t){yu.throwExceptionIf(e,yu.not(yu.anObject(t)),"levels must be an object");Object.keys(t).forEach((n=>{yu.throwExceptionIf(e,yu.not(yu.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),yu.throwExceptionIf(e,yu.not(yu.anObject(t[n])),`level "${n}" must be an object`),yu.throwExceptionIf(e,yu.not(t[n].value),`level "${n}" must have a 'value' property`),yu.throwExceptionIf(e,yu.not(yu.anInteger(t[n].value)),`level "${n}".value must have an integer value`),yu.throwExceptionIf(e,yu.not(t[n].colour),`level "${n}" must have a 'colour' property`),yu.throwExceptionIf(e,yu.not(Cu.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Cu.join(", ")}`)}))}})),yu.addListener((e=>{Fu.addLevels(e.levels)}));var gu=Fu,Au={exports:{}},vu={};/*! (c) 2020 Andrea Giammarchi */ -const{parse:Su,stringify:wu}=JSON,{keys:Ou}=Object,bu=String,_u="string",Bu={},Pu="object",ku=(e,t)=>t,xu=e=>e instanceof bu?bu(e):e,Nu=(e,t)=>typeof t===_u?new bu(t):t,Iu=(e,t,n,r)=>{const u=[];for(let o=Ou(n),{length:i}=o,s=0;s{const r=bu(t.push(n)-1);return e.set(n,r),r},Ru=(e,t)=>{const n=Su(e,Nu).map(xu),r=n[0],u=t||ku,o=typeof r===Pu&&r?Iu(n,new Set,r,u):r;return u.call({"":o},"",o)};vu.parse=Ru;const Mu=(e,t,n)=>{const r=t&&typeof t===Pu?(e,n)=>""===e||-1Su(Mu(e));vu.fromJSON=e=>Ru(wu(e));const Lu=vu,ju=gu;class $u{constructor(e,t,n,r,u){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=t,this.context=Object.assign({},r),this.pid=process.pid,u&&(this.functionName=u.functionName,this.fileName=u.fileName,this.lineNumber=u.lineNumber,this.columnNumber=u.columnNumber,this.callStack=u.callStack)}serialise(){const e=this.data.map((e=>(e&&e.message&&e.stack&&(e=Object.assign({message:e.message,stack:e.stack},e)),e)));return this.data=e,Lu.stringify(this)}static deserialise(e){let t;try{const n=Lu.parse(e);n.data=n.data.map((e=>{if(e&&e.message&&e.stack){const t=new Error(e);Object.keys(e).forEach((n=>{t[n]=e[n]})),e=t}return e})),t=new $u(n.categoryName,ju.getLevel(n.level.levelStr),n.data,n.context),t.startTime=new Date(n.startTime),t.pid=n.pid,t.cluster=n.cluster}catch(n){t=new $u("log4js",ju.ERROR,["Unable to parse log:",e,"because: ",n])}return t}}var Hu=$u;const Ju=Nr.exports("log4js:clustering"),Gu=Hu,Vu=tu;let Uu=!1,Wu=null;try{Wu=require("cluster")}catch(e){Ju("cluster module not present"),Uu=!0}const zu=[];let Ku=!1,qu="NODE_APP_INSTANCE";const Yu=()=>Ku&&"0"===process.env[qu],Xu=()=>Uu||Wu.isMaster||Yu(),Zu=e=>{zu.forEach((t=>t(e)))},Qu=(e,t)=>{if(Ju("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&"log4js:message"===t.topic){Ju("received message: ",t.data);const e=Gu.deserialise(t.data);Zu(e)}};Uu||Vu.addListener((e=>{zu.length=0,({pm2:Ku,disableClustering:Uu,pm2InstanceVar:qu="NODE_APP_INSTANCE"}=e),Ju(`clustering disabled ? ${Uu}`),Ju(`cluster.isMaster ? ${Wu&&Wu.isMaster}`),Ju(`pm2 enabled ? ${Ku}`),Ju(`pm2InstanceVar = ${qu}`),Ju(`process.env[${qu}] = ${process.env[qu]}`),Ku&&process.removeListener("message",Qu),Wu&&Wu.removeListener&&Wu.removeListener("message",Qu),Uu||e.disableClustering?Ju("Not listening for cluster messages, because clustering disabled."):Yu()?(Ju("listening for PM2 broadcast messages"),process.on("message",Qu)):Wu.isMaster?(Ju("listening for cluster messages"),Wu.on("message",Qu)):Ju("not listening for messages, because we are not a master process")}));var eo={onlyOnMaster:(e,t)=>Xu()?e():t,isMaster:Xu,send:e=>{Xu()?Zu(e):(Ku||(e.cluster={workerId:Wu.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{zu.push(e)}},to={};function no(e){if("number"==typeof e&&Number.isInteger(e))return e;const t={K:1024,M:1048576,G:1073741824},n=Object.keys(t),r=e.substr(e.length-1).toLocaleUpperCase(),u=e.substring(0,e.length-1).trim();if(n.indexOf(r)<0||!Number.isInteger(Number(u)))throw Error(`maxLogSize: "${e}" is invalid`);return u*t[r]}function ro(e){return function(e,t){const n=Object.assign({},t);return Object.keys(e).forEach((r=>{n[r]&&(n[r]=e[r](t[r]))})),n}({maxLogSize:no},e)}const uo={file:ro,fileSync:ro};to.modifyConfig=e=>uo[e.type]?uo[e.type](e):e;var oo={};const io=console.log.bind(console);oo.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{io(e(n,t))}}(n,e.timezoneOffset)};var so={};so.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stdout.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var co={};co.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stderr.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var ao={};ao.configure=function(e,t,n,r){const u=n(e.appender);return function(e,t,n,r){const u=r.getLevel(e),o=r.getLevel(t,r.FATAL);return e=>{const t=e.level;t.isGreaterThanOrEqualTo(u)&&t.isLessThanOrEqualTo(o)&&n(e)}}(e.level,e.maxLevel,u,r)};var lo={};const fo=Nr.exports("log4js:categoryFilter");lo.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return"string"==typeof e&&(e=[e]),n=>{fo(`Checking ${n.categoryName} against ${e}`),-1===e.indexOf(n.categoryName)&&(fo("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Do={};const po=Nr.exports("log4js:noLogFilter");Do.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return n=>{po(`Checking data: ${n.data} against filters: ${e}`),"string"==typeof e&&(e=[e]),e=e.filter((e=>null!=e&&""!==e));const r=new RegExp(e.join("|"),"i");(0===e.length||n.data.findIndex((e=>r.test(e)))<0)&&(po("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Eo={},mo={exports:{}},ho={},yo={fromCallback:function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise(((t,n)=>{arguments[arguments.length]=(e,r)=>{if(e)return n(e);t(r)},arguments.length++,e.apply(this,arguments)}));e.apply(this,arguments)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then((e=>t(null,e)),t)}),"name",{value:e.name})}};!function(e){const t=yo.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.keys(n).forEach((t=>{"promises"!==t&&(e[t]=n[t])})),r.forEach((r=>{e[r]=t(n[r])})),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.realpath.native&&(e.realpath.native=t(n.realpath.native))}(ho);const Co=p.default;function Fo(e){return(e=Co.normalize(Co.resolve(e)).split(Co.sep)).length>0?e[0]:null}const go=/[<>:"|?*]/;var Ao=function(e){const t=Fo(e);return e=e.replace(t,""),go.test(e)};const vo=we,So=p.default,wo=Ao,Oo=parseInt("0777",8);var bo=function e(t,n,r,u){if("function"==typeof n?(r=n,n={}):n&&"object"==typeof n||(n={mode:n}),"win32"===process.platform&&wo(t)){const e=new Error(t+" contains invalid WIN32 path characters.");return e.code="EINVAL",r(e)}let o=n.mode;const i=n.fs||vo;void 0===o&&(o=Oo&~process.umask()),u||(u=null),r=r||function(){},t=So.resolve(t),i.mkdir(t,o,(o=>{if(!o)return r(null,u=u||t);if("ENOENT"===o.code){if(So.dirname(t)===t)return r(o);e(So.dirname(t),n,((u,o)=>{u?r(u,o):e(t,n,r,o)}))}else i.stat(t,((e,t)=>{e||!t.isDirectory()?r(o,u):r(null,u)}))}))};const _o=we,Bo=p.default,Po=Ao,ko=parseInt("0777",8);var xo=function e(t,n,r){n&&"object"==typeof n||(n={mode:n});let u=n.mode;const o=n.fs||_o;if("win32"===process.platform&&Po(t)){const e=new Error(t+" contains invalid WIN32 path characters.");throw e.code="EINVAL",e}void 0===u&&(u=ko&~process.umask()),r||(r=null),t=Bo.resolve(t);try{o.mkdirSync(t,u),r=r||t}catch(u){if("ENOENT"===u.code){if(Bo.dirname(t)===t)throw u;r=e(Bo.dirname(t),n,r),e(t,n,r)}else{let e;try{e=o.statSync(t)}catch(e){throw u}if(!e.isDirectory())throw u}}return r};const No=(0,yo.fromCallback)(bo);var Io={mkdirs:No,mkdirsSync:xo,mkdirp:No,mkdirpSync:xo,ensureDir:No,ensureDirSync:xo};const To=we;E.default,p.default;var Ro=function(e,t,n,r){To.open(e,"r+",((e,u)=>{if(e)return r(e);To.futimes(u,t,n,(e=>{To.close(u,(t=>{r&&r(e||t)}))}))}))},Mo=function(e,t,n){const r=To.openSync(e,"r+");return To.futimesSync(r,t,n),To.closeSync(r)};const Lo=we,jo=p.default,$o=10,Ho=5,Jo=0,Go=process.versions.node.split("."),Vo=Number.parseInt(Go[0],10),Uo=Number.parseInt(Go[1],10),Wo=Number.parseInt(Go[2],10);function zo(){if(Vo>$o)return!0;if(Vo===$o){if(Uo>Ho)return!0;if(Uo===Ho&&Wo>=Jo)return!0}return!1}function Ko(e,t){const n=jo.resolve(e).split(jo.sep).filter((e=>e)),r=jo.resolve(t).split(jo.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function qo(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var Yo,Xo,Zo={checkPaths:function(e,t,n,r){!function(e,t,n){zo()?Lo.stat(e,{bigint:!0},((e,r)=>{if(e)return n(e);Lo.stat(t,{bigint:!0},((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))})):Lo.stat(e,((e,r)=>{if(e)return n(e);Lo.stat(t,((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))}))}(e,t,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;return s&&s.ino&&s.dev&&s.ino===i.ino&&s.dev===i.dev?r(new Error("Source and destination must not be the same.")):i.isDirectory()&&Ko(e,t)?r(new Error(qo(e,t,n))):r(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n){const{srcStat:r,destStat:u}=function(e,t){let n,r;n=zo()?Lo.statSync(e,{bigint:!0}):Lo.statSync(e);try{r=zo()?Lo.statSync(t,{bigint:!0}):Lo.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:n,destStat:null};throw e}return{srcStat:n,destStat:r}}(e,t);if(u&&u.ino&&u.dev&&u.ino===r.ino&&u.dev===r.dev)throw new Error("Source and destination must not be the same.");if(r.isDirectory()&&Ko(e,t))throw new Error(qo(e,t,n));return{srcStat:r,destStat:u}},checkParentPaths:function e(t,n,r,u,o){const i=jo.resolve(jo.dirname(t)),s=jo.resolve(jo.dirname(r));if(s===i||s===jo.parse(s).root)return o();zo()?Lo.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o))):Lo.stat(s,((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=jo.resolve(jo.dirname(t)),i=jo.resolve(jo.dirname(r));if(i===o||i===jo.parse(i).root)return;let s;try{s=zo()?Lo.statSync(i,{bigint:!0}):Lo.statSync(i)}catch(e){if("ENOENT"===e.code)return;throw e}if(s.ino&&s.dev&&s.ino===n.ino&&s.dev===n.dev)throw new Error(qo(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ko};const Qo=we,ei=p.default,ti=Io.mkdirsSync,ni=Mo,ri=Zo;function ui(e,t,n,r){if(!r.filter||r.filter(t,n))return function(e,t,n,r){const u=r.dereference?Qo.statSync:Qo.lstatSync,o=u(t);if(o.isDirectory())return function(e,t,n,r,u){if(!t)return function(e,t,n,r){return Qo.mkdirSync(n),ii(t,n,r),Qo.chmodSync(n,e.mode)}(e,n,r,u);if(t&&!t.isDirectory())throw new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`);return ii(n,r,u)}(o,e,t,n,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return Qo.unlinkSync(n),oi(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):oi(e,n,r,u)}(o,e,t,n,r);if(o.isSymbolicLink())return function(e,t,n,r){let u=Qo.readlinkSync(t);r.dereference&&(u=ei.resolve(process.cwd(),u));if(e){let e;try{e=Qo.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return Qo.symlinkSync(u,n);throw e}if(r.dereference&&(e=ei.resolve(process.cwd(),e)),ri.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(Qo.statSync(n).isDirectory()&&ri.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return Qo.unlinkSync(t),Qo.symlinkSync(e,t)}(u,n)}return Qo.symlinkSync(u,n)}(e,t,n,r)}(e,t,n,r)}function oi(e,t,n,r){return"function"==typeof Qo.copyFileSync?(Qo.copyFileSync(t,n),Qo.chmodSync(n,e.mode),r.preserveTimestamps?ni(n,e.atime,e.mtime):void 0):function(e,t,n,r){const u=65536,o=(Xo?Yo:(Xo=1,Yo=function(e){if("function"==typeof Buffer.allocUnsafe)try{return Buffer.allocUnsafe(e)}catch(t){return new Buffer(e)}return new Buffer(e)}))(u),i=Qo.openSync(t,"r"),s=Qo.openSync(n,"w",e.mode);let c=0;for(;cfunction(e,t,n,r){const u=ei.join(t,e),o=ei.join(n,e),{destStat:i}=ri.checkPathsSync(u,o,"copy");return ui(i,u,o,r)}(r,e,t,n)))}var si=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=ri.checkPathsSync(e,t,"copy");return ri.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ei.dirname(n);Qo.existsSync(u)||ti(u);return ui(e,t,n,r)}(u,e,t,n)},ci={copySync:si};const ai=yo.fromPromise,li=ho;var fi={pathExists:ai((function(e){return li.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:li.existsSync};const di=we,Di=p.default,pi=Io.mkdirs,Ei=fi.pathExists,mi=Ro,hi=Zo;function yi(e,t,n,r,u){const o=Di.dirname(n);Ei(o,((i,s)=>i?u(i):s?Fi(e,t,n,r,u):void pi(o,(o=>o?u(o):Fi(e,t,n,r,u)))))}function Ci(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function Fi(e,t,n,r,u){return r.filter?Ci(gi,e,t,n,r,u):gi(e,t,n,r,u)}function gi(e,t,n,r,u){(r.dereference?di.stat:di.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){if(!t)return function(e,t,n,r,u){di.mkdir(n,(o=>{if(o)return u(o);Si(t,n,r,(t=>t?u(t):di.chmod(n,e.mode,u)))}))}(e,n,r,u,o);if(t&&!t.isDirectory())return o(new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`));return Si(n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();di.unlink(n,(o=>o?u(o):Ai(e,t,n,r,u)))}(e,n,r,u,o):Ai(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){di.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=Di.resolve(process.cwd(),o)),e?void di.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?di.symlink(o,n,u):u(t):(r.dereference&&(i=Di.resolve(process.cwd(),i)),hi.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&hi.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){di.unlink(t,(r=>r?n(r):di.symlink(e,t,n)))}(o,n,u)))):di.symlink(o,n,u))))}(e,t,n,r,u):void 0))}function Ai(e,t,n,r,u){return"function"==typeof di.copyFile?di.copyFile(t,n,(t=>t?u(t):vi(e,n,r,u))):function(e,t,n,r,u){const o=di.createReadStream(t);o.on("error",(e=>u(e))).once("open",(()=>{const t=di.createWriteStream(n,{mode:e.mode});t.on("error",(e=>u(e))).on("open",(()=>o.pipe(t))).once("close",(()=>vi(e,n,r,u)))}))}(e,t,n,r,u)}function vi(e,t,n,r){di.chmod(t,e.mode,(u=>u?r(u):n.preserveTimestamps?mi(t,e.atime,e.mtime,r):r()))}function Si(e,t,n,r){di.readdir(e,((u,o)=>u?r(u):wi(o,e,t,n,r)))}function wi(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=Di.join(n,t),s=Di.join(r,t);hi.checkPaths(i,s,"copy",((t,c)=>{if(t)return o(t);const{destStat:a}=c;Fi(a,i,s,u,(t=>t?o(t):wi(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Oi=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),hi.checkPaths(e,t,"copy",((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;hi.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?Ci(yi,s,e,t,n,r):yi(s,e,t,n,r)))}))};var bi={copy:(0,yo.fromCallback)(Oi)};const _i=we,Bi=p.default,Pi=g.default,ki="win32"===process.platform;function xi(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||_i[t],e[t+="Sync"]=e[t]||_i[t]})),e.maxBusyTries=e.maxBusyTries||3}function Ni(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi.strictEqual(typeof n,"function","rimraf: callback function required"),Pi(t,"rimraf: invalid options argument provided"),Pi.strictEqual(typeof t,"object","rimraf: options should be object"),xi(t),Ii(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rIi(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Ii(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&ki?Ti(e,t,r,n):u&&u.isDirectory()?Mi(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return ki?Ti(e,t,r,n):Mi(e,t,r,n);if("EISDIR"===r.code)return Mi(e,t,r,n)}return n(r)}))))}function Ti(e,t,n,r){Pi(e),Pi(t),Pi("function"==typeof r),n&&Pi(n instanceof Error),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Mi(e,t,n,r):t.unlink(e,r)}))}))}function Ri(e,t,n){let r;Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?ji(e,t,n):t.unlinkSync(e)}function Mi(e,t,n,r){Pi(e),Pi(t),n&&Pi(n instanceof Error),Pi("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{Ni(Bi.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Li(e,t){let n;xi(t=t||{}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi(t,"rimraf: missing options"),Pi.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&ki&&Ri(e,t,n)}try{n&&n.isDirectory()?ji(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return ki?Ri(e,t,n):ji(e,t,n);if("EISDIR"!==n.code)throw n;ji(e,t,n)}}function ji(e,t,n){Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Pi(e),Pi(t),t.readdirSync(e).forEach((n=>Li(Bi.join(e,n),t))),!ki){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch(e){}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var $i=Ni;Ni.sync=Li;const Hi=$i;var Ji={remove:(0,yo.fromCallback)(Hi),removeSync:Hi.sync};const Gi=yo.fromCallback,Vi=we,Ui=p.default,Wi=Io,zi=Ji,Ki=Gi((function(e,t){t=t||function(){},Vi.readdir(e,((n,r)=>{if(n)return Wi.mkdirs(e,t);r=r.map((t=>Ui.join(e,t))),function e(){const n=r.pop();if(!n)return t();zi.remove(n,(n=>{if(n)return t(n);e()}))}()}))}));function qi(e){let t;try{t=Vi.readdirSync(e)}catch(t){return Wi.mkdirsSync(e)}t.forEach((t=>{t=Ui.join(e,t),zi.removeSync(t)}))}var Yi={emptyDirSync:qi,emptydirSync:qi,emptyDir:Ki,emptydir:Ki};const Xi=yo.fromCallback,Zi=p.default,Qi=we,es=Io,ts=fi.pathExists;var ns={createFile:Xi((function(e,t){function n(){Qi.writeFile(e,"",(e=>{if(e)return t(e);t()}))}Qi.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Zi.dirname(e);ts(o,((e,r)=>e?t(e):r?n():void es.mkdirs(o,(e=>{if(e)return t(e);n()}))))}))})),createFileSync:function(e){let t;try{t=Qi.statSync(e)}catch(e){}if(t&&t.isFile())return;const n=Zi.dirname(e);Qi.existsSync(n)||es.mkdirsSync(n),Qi.writeFileSync(e,"")}};const rs=yo.fromCallback,us=p.default,os=we,is=Io,ss=fi.pathExists;var cs={createLink:rs((function(e,t,n){function r(e,t){os.link(e,t,(e=>{if(e)return n(e);n(null)}))}ss(t,((u,o)=>u?n(u):o?n(null):void os.lstat(e,(u=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);const o=us.dirname(t);ss(o,((u,i)=>u?n(u):i?r(e,t):void is.mkdirs(o,(u=>{if(u)return n(u);r(e,t)}))))}))))})),createLinkSync:function(e,t){if(os.existsSync(t))return;try{os.lstatSync(e)}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const n=us.dirname(t);return os.existsSync(n)||is.mkdirsSync(n),os.linkSync(e,t)}};const as=p.default,ls=we,fs=fi.pathExists;var ds={symlinkPaths:function(e,t,n){if(as.isAbsolute(e))return ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=as.dirname(t),u=as.join(r,e);return fs(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:as.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(as.isAbsolute(e)){if(n=ls.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=as.dirname(t),u=as.join(r,e);if(n=ls.existsSync(u),n)return{toCwd:u,toDst:e};if(n=ls.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:as.relative(r,e)}}}};const Ds=we;var ps={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);Ds.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=Ds.lstatSync(e)}catch(e){return"file"}return n&&n.isDirectory()?"dir":"file"}};const Es=yo.fromCallback,ms=p.default,hs=we,ys=Io.mkdirs,Cs=Io.mkdirsSync,Fs=ds.symlinkPaths,gs=ds.symlinkPathsSync,As=ps.symlinkType,vs=ps.symlinkTypeSync,Ss=fi.pathExists;var ws={createSymlink:Es((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Ss(t,((u,o)=>u?r(u):o?r(null):void Fs(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,As(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=ms.dirname(t);Ss(o,((n,i)=>n?r(n):i?hs.symlink(e,t,u,r):void ys(o,(n=>{if(n)return r(n);hs.symlink(e,t,u,r)}))))}))}))))})),createSymlinkSync:function(e,t,n){if(hs.existsSync(t))return;const r=gs(e,t);e=r.toDst,n=vs(r.toCwd,n);const u=ms.dirname(t);return hs.existsSync(u)||Cs(u),hs.symlinkSync(e,t,n)}};var Os,bs={createFile:ns.createFile,createFileSync:ns.createFileSync,ensureFile:ns.createFile,ensureFileSync:ns.createFileSync,createLink:cs.createLink,createLinkSync:cs.createLinkSync,ensureLink:cs.createLink,ensureLinkSync:cs.createLinkSync,createSymlink:ws.createSymlink,createSymlinkSync:ws.createSymlinkSync,ensureSymlink:ws.createSymlink,ensureSymlinkSync:ws.createSymlinkSync};try{Os=we}catch(e){Os=D.default}function _s(e,t){var n,r="\n";return"object"==typeof t&&null!==t&&(t.spaces&&(n=t.spaces),t.EOL&&(r=t.EOL)),JSON.stringify(e,t?t.replacer:null,n).replace(/\n/g,r)+r}function Bs(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\uFEFF/,"")}var Ps={readFile:function(e,t,n){null==n&&(n=t,t={}),"string"==typeof t&&(t={encoding:t});var r=(t=t||{}).fs||Os,u=!0;"throws"in t&&(u=t.throws),r.readFile(e,t,(function(r,o){if(r)return n(r);var i;o=Bs(o);try{i=JSON.parse(o,t?t.reviver:null)}catch(t){return u?(t.message=e+": "+t.message,n(t)):n(null,null)}n(null,i)}))},readFileSync:function(e,t){"string"==typeof(t=t||{})&&(t={encoding:t});var n=t.fs||Os,r=!0;"throws"in t&&(r=t.throws);try{var u=n.readFileSync(e,t);return u=Bs(u),JSON.parse(u,t.reviver)}catch(t){if(r)throw t.message=e+": "+t.message,t;return null}},writeFile:function(e,t,n,r){null==r&&(r=n,n={});var u=(n=n||{}).fs||Os,o="";try{o=_s(t,n)}catch(e){return void(r&&r(e,null))}u.writeFile(e,o,n,r)},writeFileSync:function(e,t,n){var r=(n=n||{}).fs||Os,u=_s(t,n);return r.writeFileSync(e,u,n)}},ks=Ps;const xs=yo.fromCallback,Ns=ks;var Is={readJson:xs(Ns.readFile),readJsonSync:Ns.readFileSync,writeJson:xs(Ns.writeFile),writeJsonSync:Ns.writeFileSync};const Ts=p.default,Rs=Io,Ms=fi.pathExists,Ls=Is;var js=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=Ts.dirname(e);Ms(u,((o,i)=>o?r(o):i?Ls.writeJson(e,t,n,r):void Rs.mkdirs(u,(u=>{if(u)return r(u);Ls.writeJson(e,t,n,r)}))))};const $s=we,Hs=p.default,Js=Io,Gs=Is;var Vs=function(e,t,n){const r=Hs.dirname(e);$s.existsSync(r)||Js.mkdirsSync(r),Gs.writeJsonSync(e,t,n)};const Us=yo.fromCallback,Ws=Is;Ws.outputJson=Us(js),Ws.outputJsonSync=Vs,Ws.outputJSON=Ws.outputJson,Ws.outputJSONSync=Ws.outputJsonSync,Ws.writeJSON=Ws.writeJson,Ws.writeJSONSync=Ws.writeJsonSync,Ws.readJSON=Ws.readJson,Ws.readJSONSync=Ws.readJsonSync;var zs=Ws;const Ks=we,qs=p.default,Ys=ci.copySync,Xs=Ji.removeSync,Zs=Io.mkdirpSync,Qs=Zo;function ec(e,t,n){try{Ks.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Ys(e,t,r),Xs(e)}(e,t,n)}}var tc=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u}=Qs.checkPathsSync(e,t,"move");return Qs.checkParentPathsSync(e,u,t,"move"),Zs(qs.dirname(t)),function(e,t,n){if(n)return Xs(t),ec(e,t,n);if(Ks.existsSync(t))throw new Error("dest already exists.");return ec(e,t,n)}(e,t,r)},nc={moveSync:tc};const rc=we,uc=p.default,oc=bi.copy,ic=Ji.remove,sc=Io.mkdirp,cc=fi.pathExists,ac=Zo;function lc(e,t,n,r){rc.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};oc(e,t,u,(t=>t?r(t):ic(e,r)))}(e,t,n,r):r()))}var fc=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;ac.checkPaths(e,t,"move",((n,o)=>{if(n)return r(n);const{srcStat:i}=o;ac.checkParentPaths(e,i,t,"move",(n=>{if(n)return r(n);sc(uc.dirname(t),(n=>n?r(n):function(e,t,n,r){if(n)return ic(t,(u=>u?r(u):lc(e,t,n,r)));cc(t,((u,o)=>u?r(u):o?r(new Error("dest already exists.")):lc(e,t,n,r)))}(e,t,u,r)))}))}))};var dc={move:(0,yo.fromCallback)(fc)};const Dc=yo.fromCallback,pc=we,Ec=p.default,mc=Io,hc=fi.pathExists;var yc={outputFile:Dc((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Ec.dirname(e);hc(u,((o,i)=>o?r(o):i?pc.writeFile(e,t,n,r):void mc.mkdirs(u,(u=>{if(u)return r(u);pc.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Ec.dirname(e);if(pc.existsSync(n))return pc.writeFileSync(e,...t);mc.mkdirsSync(n),pc.writeFileSync(e,...t)}};!function(e){e.exports=Object.assign({},ho,ci,bi,Yi,bs,zs,Io,nc,dc,yc,fi,Ji);const t=D.default;Object.getOwnPropertyDescriptor(t,"promises")&&Object.defineProperty(e.exports,"promises",{get:()=>t.promises})}(mo);const Cc=Nr.exports("streamroller:fileNameFormatter"),Fc=p.default;const gc=Nr.exports("streamroller:fileNameParser"),Ac=nu.exports;const vc=Nr.exports("streamroller:moveAndMaybeCompressFile"),Sc=mo.exports,wc=v.default;var Oc=async(e,t,n)=>{if(n=function(e){const t={mode:parseInt("0600",8),compress:!1},n=Object.assign({},t,e);return vc(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(n)}`),n}(n),e!==t){if(await Sc.pathExists(e))if(vc(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${n.compress?"with":"without"} compress`),n.compress)await new Promise(((r,u)=>{let o=!1;const i=Sc.createWriteStream(t,{mode:n.mode,flags:"wx"}).on("open",(()=>{o=!0;const t=Sc.createReadStream(e).on("open",(()=>{t.pipe(wc.createGzip()).pipe(i)})).on("error",(t=>{vc(`moveAndMaybeCompressFile: error reading ${e}`,t),i.destroy(t)}))})).on("finish",(()=>{vc(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),Sc.unlink(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,t),Sc.truncate(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error truncating ${e}`,t),u(t)}))}))})).on("error",(e=>{o?(vc(`moveAndMaybeCompressFile: error writing ${t}, deleting`,e),Sc.unlink(t).then((()=>{u(e)})).catch((e=>{vc(`moveAndMaybeCompressFile: error deleting ${t}`,e),u(e)}))):(vc(`moveAndMaybeCompressFile: error creating ${t}`,e),u(e))}))})).catch((()=>{}));else{vc(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await Sc.move(e,t,{overwrite:!0})}catch(n){if(vc(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),"ENOENT"!==n.code){vc("moveAndMaybeCompressFile: trying copy+truncate instead");try{await Sc.copy(e,t,{overwrite:!0}),await Sc.truncate(e)}catch(e){vc("moveAndMaybeCompressFile: error copy+truncate",e)}}}}}else vc("moveAndMaybeCompressFile: source and target are the same, not doing anything")};const bc=Nr.exports("streamroller:RollingFileWriteStream"),_c=mo.exports,Bc=p.default,Pc=E.default,kc=()=>new Date,xc=nu.exports,{Writable:Nc}=C.default,Ic=({file:e,keepFileExt:t,needsIndex:n,alwaysIncludeDate:r,compress:u,fileNameSep:o})=>{let i=o||".";const s=Fc.join(e.dir,e.name),c=t=>t+e.ext,a=(e,t,r)=>!n&&r||!t?e:e+i+t,l=(e,t,n)=>(t>0||r)&&n?e+i+n:e,f=(e,t)=>t&&u?e+".gz":e,d=t?[l,a,c,f]:[c,l,a,f];return({date:e,index:t})=>(Cc(`_formatFileName: date=${e}, index=${t}`),d.reduce(((n,r)=>r(n,t,e)),s))},Tc=({file:e,keepFileExt:t,pattern:n,fileNameSep:r})=>{let u=r||".";const o="__NOT_MATCHING__";let i=[(e,t)=>e.endsWith(".gz")?(gc("it is gzipped"),t.isCompressed=!0,e.slice(0,-1*".gz".length)):e,t?t=>t.startsWith(e.name)&&t.endsWith(e.ext)?(gc("it starts and ends with the right things"),t.slice(e.name.length+1,-1*e.ext.length)):o:t=>t.startsWith(e.base)?(gc("it starts with the right things"),t.slice(e.base.length+1)):o,n?(e,t)=>{const r=e.split(u);let o=r[r.length-1];gc("items: ",r,", indexStr: ",o);let i=e;void 0!==o&&o.match(/^\d+$/)?(i=e.slice(0,-1*(o.length+1)),gc(`dateStr is ${i}`),n&&!i&&(i=o,o="0")):o="0";try{const r=Ac.parse(n,i,new Date(0,0));return Ac.asString(n,r)!==i?e:(t.index=parseInt(o,10),t.date=i,t.timestamp=r.getTime(),"")}catch(t){return gc(`Problem parsing ${i} as ${n}, error was: `,t),e}}:(e,t)=>e.match(/^\d+$/)?(gc("it has an index"),t.index=parseInt(e,10),""):e];return e=>{let t={filename:e,index:0,isCompressed:!1};return i.reduce(((e,n)=>n(e,t)),e)?null:t}},Rc=Oc;var Mc=class extends Nc{constructor(e,t){if(bc(`constructor: creating RollingFileWriteStream. path=${e}`),"string"!=typeof e||0===e.length)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Bc.sep))throw new Error(`Filename is a directory: ${e}`);0===e.indexOf(`~${Bc.sep}`)&&(e=e.replace("~",Pc.homedir())),super(t),this.options=this._parseOption(t),this.fileObject=Bc.parse(e),""===this.fileObject.dir&&(this.fileObject=Bc.parse(Bc.join(process.cwd(),e))),this.fileFormatter=Ic({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`)}else delete n.maxSize;if(n.numBackups||0===n.numBackups){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return bc(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,t,n){this._shouldRoll().then((()=>{bc(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,t,(t=>{this.state.currentSize+=e.length,n(t)}))}))}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(bc(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==xc(this.options.pattern,kc())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return bc("_roll: closing the current stream"),new Promise(((e,t)=>{this.currentFileStream.end("",this.options.encoding,(()=>{this._moveOldFiles().then(e).catch(t)}))}))}async _moveOldFiles(){const e=await this._getExistingFiles();for(let t=(this.state.currentDate?e.filter((e=>e.date===this.state.currentDate)):e).length;t>=0;t--){bc(`_moveOldFiles: i = ${t}`);const e=this.fileFormatter({date:this.state.currentDate,index:t}),n=this.fileFormatter({date:this.state.currentDate,index:t+1}),r={compress:this.options.compress&&0===t,mode:this.options.mode};await Rc(e,n,r)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?xc(this.options.pattern,kc()):null,bc(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise(((e,t)=>{this.currentFileStream.write("","utf8",(()=>{this._clean().then(e).catch(t)}))}))}async _getExistingFiles(){const e=await _c.readdir(this.fileObject.dir).catch((()=>[]));bc(`_getExistingFiles: files=${e}`);const t=e.map((e=>this.fileNameParser(e))).filter((e=>e)),n=e=>(e.timestamp?e.timestamp:kc().getTime())-e.index;return t.sort(((e,t)=>n(e)-n(t))),t}_renewWriteStream(){const e=this.fileFormatter({date:this.state.currentDate,index:0}),t=e=>{try{return _c.mkdirSync(e,{recursive:!0})}catch(n){if("ENOENT"===n.code)return t(Bc.dirname(e)),t(e);if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(_c.statSync(e).isDirectory())return e;throw n}catch(e){throw n}}};t(this.fileObject.dir);const n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode};var r,u;_c.appendFileSync(e,"",(r={...n},u="flags",r["flag"]=r[u],delete r[u],r)),this.currentFileStream=_c.createWriteStream(e,n),this.currentFileStream.on("error",(e=>{this.emit("error",e)}))}async _clean(){const e=await this._getExistingFiles();if(bc(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),bc("_clean: existing files are: ",e),this._tooManyFiles(e.length)){const n=e.slice(0,e.length-this.options.numToKeep).map((e=>Bc.format({dir:this.fileObject.dir,base:e.filename})));await(t=n,bc(`deleteFiles: files to delete: ${t}`),Promise.all(t.map((e=>_c.unlink(e).catch((t=>{bc(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${t}`)}))))))}var t}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};const Lc=Mc;var jc=class extends Lc{constructor(e,t,n,r){r||(r={}),t&&(r.maxSize=t),r.numBackups||0===r.numBackups||(n||0===n||(n=1),r.numBackups=n),super(e,r),this.backups=r.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};const $c=Mc;var Hc={RollingFileWriteStream:Mc,RollingFileStream:jc,DateRollingFileStream:class extends $c{constructor(e,t,n){t&&"object"==typeof t&&(n=t,t=null),n||(n={}),t||(t="yyyy-MM-dd"),n.pattern=t,n.numBackups||0===n.numBackups?n.daysToKeep=n.numBackups:(n.daysToKeep||0===n.daysToKeep?process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"):n.daysToKeep=1,n.numBackups=n.daysToKeep),super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}}};const Jc=Nr.exports("log4js:file"),Gc=p.default,Vc=Hc,Uc=E.default.EOL;let Wc=!1;const zc=new Set;function Kc(){zc.forEach((e=>{e.sighupHandler()}))}function qc(e,t,n,r){const u=new Vc.RollingFileStream(e,t,n,r);return u.on("error",(t=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",e,t)})),u.on("drain",(()=>{process.emit("log4js:pause",!1)})),u}Eo.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,function(e,t,n,r,u,o){e=Gc.normalize(e),Jc("Creating file appender (",e,", ",n,", ",r=r||0===r?r:5,", ",u,", ",o,")");let i=qc(e,n,r,u);const s=function(e){if(i.writable){if(!0===u.removeColor){const t=/\x1b[[0-9;]*m/g;e.data=e.data.map((e=>"string"==typeof e?e.replace(t,""):e))}i.write(t(e,o)+Uc,"utf8")||process.emit("log4js:pause",!0)}};return s.reopen=function(){i.end((()=>{i=qc(e,n,r,u)}))},s.sighupHandler=function(){Jc("SIGHUP handler called."),s.reopen()},s.shutdown=function(e){zc.delete(s),0===zc.size&&Wc&&(process.removeListener("SIGHUP",Kc),Wc=!1),i.end("","utf-8",e)},zc.add(s),Wc||(process.on("SIGHUP",Kc),Wc=!0),s}(e.filename,n,e.maxLogSize,e.backups,e,e.timezoneOffset)};var Yc={};const Xc=Hc,Zc=E.default.EOL;function Qc(e,t,n,r,u){r.maxSize=r.maxLogSize;const o=function(e,t,n){const r=new Xc.DateRollingFileStream(e,t,n);return r.on("error",(t=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,t)})),r.on("drain",(()=>{process.emit("log4js:pause",!1)})),r}(e,t,r),i=function(e){o.writable&&(o.write(n(e,u)+Zc,"utf8")||process.emit("log4js:pause",!0))};return i.shutdown=function(e){o.end("","utf-8",e)},i}Yc.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,Qc(e.filename,e.pattern,n,e,e.timezoneOffset)};var ea={};const ta=Nr.exports("log4js:fileSync"),na=p.default,ra=D.default,ua=E.default.EOL||"\n";function oa(e,t){if(ra.existsSync(e))return;const n=ra.openSync(e,t.flags,t.mode);ra.closeSync(n)}class ia{constructor(e,t,n,r){ta("In RollingFileStream"),function(){if(!e||!t||t<=0)throw new Error("You must specify a filename and file size")}(),this.filename=e,this.size=t,this.backups=n,this.options=r,this.currentSize=0,this.currentSize=function(e){let t=0;try{t=ra.statSync(e).size}catch(t){oa(e,r)}return t}(this.filename)}shouldRoll(){return ta("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){const t=this,n=new RegExp(`^${na.basename(e)}`);function r(e){return n.test(e)}function u(t){return parseInt(t.substring(`${na.basename(e)}.`.length),10)||0}function o(e,t){return u(e)>u(t)?1:u(e) ${e}.${r+1}`),ra.renameSync(na.join(na.dirname(e),n),`${e}.${r+1}`)}}ta("Rolling, rolling, rolling"),ta("Renaming the old files"),ra.readdirSync(na.dirname(e)).filter(r).sort(o).reverse().forEach(i)}write(e,t){const n=this;ta("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),ta("writing the chunk to the file"),n.currentSize+=e.length,ra.appendFileSync(n.filename,e)}}ea.configure=function(e,t){let n=t.basicLayout;e.layout&&(n=t.layout(e.layout.type,e.layout));const r={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return function(e,t,n,r,u,o){ta("fileSync appender created");const i=function(e,t,n){let r;var u;return t?r=new ia(e,t,n,o):(oa(u=e,o),r={write(e){ra.appendFileSync(u,e)}}),r}(e=na.normalize(e),n,r=r||0===r?r:5);return e=>{i.write(t(e,u)+ua)}}(e.filename,n,e.maxLogSize,e.backups,e.timezoneOffset,r)};var sa={};const ca=Nr.exports("log4js:tcp"),aa=S.default;sa.configure=function(e,t){ca(`configure with config = ${e}`);let n=function(e){return e.serialise()};return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){let n=!1;const r=[];let u,o=3,i="__LOG4JS__";function s(e){ca("Writing log event to socket"),n=u.write(`${t(e)}${i}`,"utf8")}function c(){let e;for(ca("emptying buffer");e=r.shift();)s(e)}function a(e){n?s(e):(ca("buffering log event because it cannot write at the moment"),r.push(e))}return function t(){ca(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),i=`${e.endMsg||"__LOG4JS__"}`,u=aa.createConnection(e.port||5e3,e.host||"localhost"),u.on("connect",(()=>{ca("socket connected"),c(),n=!0})),u.on("drain",(()=>{ca("drain event received, emptying buffer"),n=!0,c()})),u.on("timeout",u.end.bind(u)),u.on("error",(e=>{ca("connection error",e),n=!1,c()})),u.on("close",t)}(),a.shutdown=function(e){ca("shutdown called"),r.length&&o?(ca("buffer has items, waiting 100ms to empty"),o-=1,setTimeout((()=>{a.shutdown(e)}),100)):(u.removeAllListeners("close"),u.end(e))},a}(e,n)};const la=p.default,fa=Nr.exports("log4js:appenders"),da=tu,Da=eo,pa=gu,Ea=hu,ma=to,ha=new Map;ha.set("console",oo),ha.set("stdout",so),ha.set("stderr",co),ha.set("logLevelFilter",ao),ha.set("categoryFilter",lo),ha.set("noLogFilter",Do),ha.set("file",Eo),ha.set("dateFile",Yc),ha.set("fileSync",ea),ha.set("tcp",sa);const ya=new Map,Ca=(e,t)=>{fa("Loading module from ",e);try{return require(e)}catch(n){return void da.throwExceptionIf(t,"MODULE_NOT_FOUND"!==n.code,`appender "${e}" could not be loaded (error was: ${n})`)}},Fa=new Set,ga=(e,t)=>{if(ya.has(e))return ya.get(e);if(!t.appenders[e])return!1;if(Fa.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);Fa.add(e),fa(`Creating appender ${e}`);const n=Aa(e,t);return Fa.delete(e),ya.set(e,n),n},Aa=(e,t)=>{const n=t.appenders[e],r=n.type.configure?n.type:((e,t)=>ha.get(e)||Ca(`./${e}`,t)||Ca(e,t)||require.main&&Ca(la.join(la.dirname(require.main.filename),e),t)||Ca(la.join(process.cwd(),e),t))(n.type,t);return da.throwExceptionIf(t,da.not(r),`appender "${e}" is not valid (type "${n.type}" could not be found)`),r.appender&&fa(`DEPRECATION: Appender ${n.type} exports an appender function.`),r.shutdown&&fa(`DEPRECATION: Appender ${n.type} exports a shutdown function.`),fa(`${e}: clustering.isMaster ? ${Da.isMaster()}`),fa(`${e}: appenderModule is ${F.default.inspect(r)}`),Da.onlyOnMaster((()=>(fa(`calling appenderModule.configure for ${e} / ${n.type}`),r.configure(ma.modifyConfig(n),Ea,(e=>ga(e,t)),pa))),(()=>{}))},va=e=>{ya.clear(),Fa.clear();const t=[];Object.values(e.categories).forEach((e=>{t.push(...e.appenders)})),Object.keys(e.appenders).forEach((n=>{(t.includes(n)||"tcp-server"===e.appenders[n].type)&&ga(n,e)}))},Sa=()=>{va({appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"trace"}}})};Sa(),da.addListener((e=>{da.throwExceptionIf(e,da.not(da.anObject(e.appenders)),'must have a property "appenders" of type object.');const t=Object.keys(e.appenders);da.throwExceptionIf(e,da.not(t.length),"must define at least one appender."),t.forEach((t=>{da.throwExceptionIf(e,da.not(e.appenders[t].type),`appender "${t}" is not valid (must be an object with property "type")`)}))})),da.addListener(va),Au.exports=ya,Au.exports.init=Sa;var wa={exports:{}};!function(e){const t=Nr.exports("log4js:categories"),n=tu,r=gu,u=Au.exports,o=new Map;function i(e,t,n){if(!1===t.inherit)return;const r=n.lastIndexOf(".");if(r<0)return;const u=n.substring(0,r);let o=e.categories[u];o||(o={inherit:!0,appenders:[]}),i(e,o,u),!e.categories[u]&&o.appenders&&o.appenders.length&&o.level&&(e.categories[u]=o),t.appenders=t.appenders||[],t.level=t.level||o.level,o.appenders.forEach((e=>{t.appenders.includes(e)||t.appenders.push(e)})),t.parent=o}function s(e){if(!e.categories)return;Object.keys(e.categories).forEach((t=>{const n=e.categories[t];i(e,n,t)}))}n.addPreProcessingListener((e=>s(e))),n.addListener((e=>{n.throwExceptionIf(e,n.not(n.anObject(e.categories)),'must have a property "categories" of type object.');const t=Object.keys(e.categories);n.throwExceptionIf(e,n.not(t.length),"must define at least one category."),t.forEach((t=>{const o=e.categories[t];n.throwExceptionIf(e,[n.not(o.appenders),n.not(o.level)],`category "${t}" is not valid (must be an object with properties "appenders" and "level")`),n.throwExceptionIf(e,n.not(Array.isArray(o.appenders)),`category "${t}" is not valid (appenders must be an array of appender names)`),n.throwExceptionIf(e,n.not(o.appenders.length),`category "${t}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(o,"enableCallStack")&&n.throwExceptionIf(e,"boolean"!=typeof o.enableCallStack,`category "${t}" is not valid (enableCallStack must be boolean type)`),o.appenders.forEach((r=>{n.throwExceptionIf(e,n.not(u.get(r)),`category "${t}" is not valid (appender "${r}" is not defined)`)})),n.throwExceptionIf(e,n.not(r.getLevel(o.level)),`category "${t}" is not valid (level "${o.level}" not recognised; valid levels are ${r.levels.join(", ")})`)})),n.throwExceptionIf(e,n.not(e.categories.default),'must define a "default" category.')}));const c=e=>{o.clear();Object.keys(e.categories).forEach((n=>{const i=e.categories[n],s=[];i.appenders.forEach((e=>{s.push(u.get(e)),t(`Creating category ${n}`),o.set(n,{appenders:s,level:r.getLevel(i.level),enableCallStack:i.enableCallStack||!1})}))}))},a=()=>{c({categories:{default:{appenders:["out"],level:"OFF"}}})};a(),n.addListener(c);const l=e=>(t(`configForCategory: searching for config for ${e}`),o.has(e)?(t(`configForCategory: ${e} exists in config, returning it`),o.get(e)):e.indexOf(".")>0?(t(`configForCategory: ${e} has hierarchy, searching for parents`),l(e.substring(0,e.lastIndexOf(".")))):(t("configForCategory: returning config for default category"),l("default")));e.exports=o,e.exports=Object.assign(e.exports,{appendersForCategory:e=>l(e).appenders,getLevelForCategory:e=>l(e).level,setLevelForCategory:(e,n)=>{let r=o.get(e);if(t(`setLevelForCategory: found ${r} for ${e}`),!r){const n=l(e);t(`setLevelForCategory: no config found for category, found ${n} for parents of ${e}`),r={appenders:n.appenders}}r.level=n,o.set(e,r)},getEnableCallStackForCategory:e=>!0===l(e).enableCallStack,setEnableCallStackForCategory:(e,t)=>{l(e).enableCallStack=t},init:a})}(wa);const Oa=Nr.exports("log4js:logger"),ba=Hu,_a=gu,Ba=eo,Pa=wa.exports,ka=tu,xa=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function Na(e,t=4){const n=e.stack.split("\n").slice(t),r=xa.exec(n[0]);return r&&6===r.length?{functionName:r[1],fileName:r[2],lineNumber:parseInt(r[3],10),columnNumber:parseInt(r[4],10),callStack:n.join("\n")}:null}class Ia{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=Na,Oa(`Logger created (${this.category}, ${this.level})`)}get level(){return _a.getLevel(Pa.getLevelForCategory(this.category),_a.TRACE)}set level(e){Pa.setLevelForCategory(this.category,_a.getLevel(e,this.level))}get useCallStack(){return Pa.getEnableCallStackForCategory(this.category)}set useCallStack(e){Pa.setEnableCallStackForCategory(this.category,!0===e)}log(e,...t){let n=_a.getLevel(e);n||(this._log(_a.WARN,"log4js:logger.log: invalid value for log-level as first parameter given: ",e),n=_a.INFO),this.isLevelEnabled(n)&&this._log(n,t)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,t){Oa(`sending log data (${e}) to appenders`);const n=new ba(this.category,e,t,this.context,this.useCallStack&&this.parseCallStack(new Error));Ba.send(n)}addContext(e,t){this.context[e]=t}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}}function Ta(e){const t=_a.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,(e=>e[1].toUpperCase())),r=n[0].toUpperCase()+n.slice(1);Ia.prototype[`is${r}Enabled`]=function(){return this.isLevelEnabled(t)},Ia.prototype[n]=function(...e){this.log(t,...e)}}_a.levels.forEach(Ta),ka.addListener((()=>{_a.levels.forEach(Ta)}));var Ra=Ia;const Ma=gu;function La(e){return e.originalUrl||e.url}function ja(e,t){for(let n=0;ne.source?e.source:e));t=new RegExp(n.join("|"))}return t}(t.nolog);return(e,i,s)=>{if(e._logging)return s();if(o&&o.test(e.originalUrl))return s();if(n.isLevelEnabled(r)||"auto"===t.level){const o=new Date,{writeHead:s}=i;e._logging=!0,i.writeHead=(e,t)=>{i.writeHead=s,i.writeHead(e,t),i.__statusCode=e,i.__headers=t||{}},i.on("finish",(()=>{i.responseTime=new Date-o,i.statusCode&&"auto"===t.level&&(r=Ma.INFO,i.statusCode>=300&&(r=Ma.WARN),i.statusCode>=400&&(r=Ma.ERROR)),r=function(e,t,n){let r=t;if(n){const t=n.find((t=>{let n=!1;return n=t.from&&t.to?e>=t.from&&e<=t.to:-1!==t.codes.indexOf(e),n}));t&&(r=Ma.getLevel(t.level,r))}return r}(i.statusCode,r,t.statusRules);const s=function(e,t,n){const r=[];return r.push({token:":url",replacement:La(e)}),r.push({token:":protocol",replacement:e.protocol}),r.push({token:":hostname",replacement:e.hostname}),r.push({token:":method",replacement:e.method}),r.push({token:":status",replacement:t.__statusCode||t.statusCode}),r.push({token:":response-time",replacement:t.responseTime}),r.push({token:":date",replacement:(new Date).toUTCString()}),r.push({token:":referrer",replacement:e.headers.referer||e.headers.referrer||""}),r.push({token:":http-version",replacement:`${e.httpVersionMajor}.${e.httpVersionMinor}`}),r.push({token:":remote-addr",replacement:e.headers["x-forwarded-for"]||e.ip||e._remoteAddress||e.socket&&(e.socket.remoteAddress||e.socket.socket&&e.socket.socket.remoteAddress)}),r.push({token:":user-agent",replacement:e.headers["user-agent"]}),r.push({token:":content-length",replacement:t.getHeader("content-length")||t.__headers&&t.__headers["Content-Length"]||"-"}),r.push({token:/:req\[([^\]]+)]/g,replacement:(t,n)=>e.headers[n.toLowerCase()]}),r.push({token:/:res\[([^\]]+)]/g,replacement:(e,n)=>t.getHeader(n.toLowerCase())||t.__headers&&t.__headers[n]}),(e=>{const t=e.concat();for(let e=0;eja(e,s)));t&&n.log(r,t)}else n.log(r,ja(u,s));t.context&&n.removeContext("res")}))}return s()}},nl=Va;let rl=!1;function ul(e){if(!rl)return;Ua("Received log event ",e);Za.appendersForCategory(e.categoryName).forEach((t=>{t(e)}))}function ol(e){rl&&il();let t=e;return"string"==typeof t&&(t=function(e){Ua(`Loading configuration from ${e}`);try{return JSON.parse(Wa.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}(e)),Ua(`Configuration is ${t}`),Ka.configure(za(t)),el.onMessage(ul),rl=!0,sl}function il(e){Ua("Shutdown called. Disabling all log writing."),rl=!1;const t=Array.from(Xa.values());Xa.init(),Za.init();const n=t.reduceRight(((e,t)=>t.shutdown?e+1:e),0);if(0===n)return Ua("No appenders with shutdown functions found."),void 0!==e&&e();let r,u=0;function o(t){r=r||t,u+=1,Ua(`Appender shutdowns complete: ${u} / ${n}`),u>=n&&(Ua("All shutdown functions completed."),e&&e(r))}return Ua(`Found ${n} appenders with shutdown functions.`),t.filter((e=>e.shutdown)).forEach((e=>e.shutdown(o))),null}const sl={getLogger:function(e){return rl||ol(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new Qa(e||"default")},configure:ol,shutdown:il,connectLogger:tl,levels:Ya,addLayout:qa.addLayout,recording:function(){return nl}};var cl=sl,al={};Object.defineProperty(al,"__esModule",{value:!0}),al.levelMap=al.getLevel=al.setCategoriesLevel=al.getConfiguration=al.setConfiguration=void 0;const ll=cl;let fl={appenders:{debug:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %p %c %[%m%]"}},info:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %[%m%]"}},"no-pattern-info":{type:"stdout",layout:{type:"pattern",pattern:"%m"}},wrong:{type:"stderr",layout:{type:"pattern",pattern:"[%d] > hvigor %[%p: %m%]"}},"just-debug":{type:"logLevelFilter",appender:"debug",level:"debug",maxLevel:"debug"},"just-info":{type:"logLevelFilter",appender:"info",level:"info",maxLevel:"info"},"just-wrong":{type:"logLevelFilter",appender:"wrong",level:"warn",maxLevel:"error"}},categories:{default:{appenders:["just-debug","just-info","just-wrong"],level:"debug"},"no-pattern-info":{appenders:["no-pattern-info"],level:"info"}}};al.setConfiguration=e=>{fl=e};al.getConfiguration=()=>fl;let dl=ll.levels.DEBUG;al.setCategoriesLevel=(e,t)=>{dl=e;const n=fl.categories;for(const r in n)(null==t?void 0:t.includes(r))||Object.prototype.hasOwnProperty.call(n,r)&&(n[r].level=e.levelStr)};al.getLevel=()=>dl,al.levelMap=new Map([["ALL",ll.levels.ALL],["MARK",ll.levels.MARK],["TRACE",ll.levels.TRACE],["DEBUG",ll.levels.DEBUG],["INFO",ll.levels.INFO],["WARN",ll.levels.WARN],["ERROR",ll.levels.ERROR],["FATAL",ll.levels.FATAL],["OFF",ll.levels.OFF]]);var Dl=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),pl=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),El=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Dl(t,e,n);return pl(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0}),xr.evaluateLogLevel=xr.HvigorLogger=void 0;const ml=El(cl),hl=cl,yl=El(F.default),Cl=al;class Fl{constructor(e){ml.configure((0,Cl.getConfiguration)()),this._logger=ml.getLogger(e),this._logger.level=(0,Cl.getLevel)()}static getLogger(e){return new Fl(e)}log(e,...t){this._logger.log(e,...t)}debug(e,...t){this._logger.debug(e,...t)}info(e,...t){this._logger.info(e,...t)}warn(e,...t){void 0!==e&&""!==e&&this._logger.warn(e,...t)}error(e,...t){this._logger.error(e,...t)}_printTaskExecuteInfo(e,t){this.info(`Finished :${e}... after ${t}`)}_printFailedTaskInfo(e){this.error(`Failed :${e}... `)}_printDisabledTaskInfo(e){this.info(`Disabled :${e}... `)}_printUpToDateTaskInfo(e){this.info(`UP-TO-DATE :${e}... `)}errorMessageExit(e,...t){throw new Error(yl.format(e,...t))}errorExit(e,t,...n){t&&this._logger.error(t,n),this._logger.error(e.stack)}setLevel(e,t){(0,Cl.setCategoriesLevel)(e,t),ml.shutdown(),ml.configure((0,Cl.getConfiguration)())}getLevel(){return this._logger.level}configure(e){const t=(0,Cl.getConfiguration)(),n={appenders:{...t.appenders,...e.appenders},categories:{...t.categories,...e.categories}};(0,Cl.setConfiguration)(n),ml.shutdown(),ml.configure(n)}}xr.HvigorLogger=Fl,xr.evaluateLogLevel=function(e,t){t.debug?e.setLevel(hl.levels.DEBUG):t.warn?e.setLevel(hl.levels.WARN):t.error?e.setLevel(hl.levels.ERROR):e.setLevel(hl.levels.INFO)};var gl=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.parseJsonText=X.parseJsonFile=void 0;const Al=Z,vl=gl(kr),Sl=gl(p.default),wl=gl(E.default),Ol=xr.HvigorLogger.getLogger("parse-json-util");var bl;!function(e){e[e.Char=0]="Char",e[e.EOF=1]="EOF",e[e.Identifier=2]="Identifier"}(bl||(bl={}));let _l,Bl,Pl,kl,xl,Nl,Il="start",Tl=[],Rl=0,Ml=1,Ll=0,jl=!1,$l="default",Hl="'",Jl=1;function Gl(e,t=!1){Bl=String(e),Il="start",Tl=[],Rl=0,Ml=1,Ll=0,kl=void 0,jl=t;do{_l=Vl(),Xl[Il]()}while("eof"!==_l.type);return kl}function Vl(){for($l="default",xl="",Hl="'",Jl=1;;){Nl=Ul();const e=zl[$l]();if(e)return e}}function Ul(){if(Bl[Rl])return String.fromCodePoint(Bl.codePointAt(Rl))}function Wl(){const e=Ul();return"\n"===e?(Ml++,Ll=0):e?Ll+=e.length:Ll++,e&&(Rl+=e.length),e}X.parseJsonFile=function(e,t=!1,n="utf-8"){const r=vl.default.readFileSync(Sl.default.resolve(e),{encoding:n});try{return Gl(r,t)}catch(t){if(t instanceof SyntaxError){const n=t.message.split("at");2===n.length&&Ol.errorMessageExit(`${n[0].trim()}${wl.default.EOL}\t at ${e}:${n[1].trim()}`)}Ol.errorMessageExit(`${e} is not in valid JSON/JSON5 format.`)}},X.parseJsonText=Gl;const zl={default(){switch(Nl){case"/":return Wl(),void($l="comment");case void 0:return Wl(),Kl("eof")}if(!Al.JudgeUtil.isIgnoreChar(Nl)&&!Al.JudgeUtil.isSpaceSeparator(Nl))return zl[Il]();Wl()},start(){$l="value"},beforePropertyName(){switch(Nl){case"$":case"_":return xl=Wl(),void($l="identifierName");case"\\":return Wl(),void($l="identifierNameStartEscape");case"}":return Kl("punctuator",Wl());case'"':case"'":return Hl=Nl,Wl(),void($l="string")}if(Al.JudgeUtil.isIdStartChar(Nl))return xl+=Wl(),void($l="identifierName");throw tf(bl.Char,Wl())},afterPropertyName(){if(":"===Nl)return Kl("punctuator",Wl());throw tf(bl.Char,Wl())},beforePropertyValue(){$l="value"},afterPropertyValue(){switch(Nl){case",":case"}":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},beforeArrayValue(){if("]"===Nl)return Kl("punctuator",Wl());$l="value"},afterArrayValue(){switch(Nl){case",":case"]":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},end(){throw tf(bl.Char,Wl())},comment(){switch(Nl){case"*":return Wl(),void($l="multiLineComment");case"/":return Wl(),void($l="singleLineComment")}throw tf(bl.Char,Wl())},multiLineComment(){switch(Nl){case"*":return Wl(),void($l="multiLineCommentAsterisk");case void 0:throw tf(bl.Char,Wl())}Wl()},multiLineCommentAsterisk(){switch(Nl){case"*":return void Wl();case"/":return Wl(),void($l="default");case void 0:throw tf(bl.Char,Wl())}Wl(),$l="multiLineComment"},singleLineComment(){switch(Nl){case"\n":case"\r":case"\u2028":case"\u2029":return Wl(),void($l="default");case void 0:return Wl(),Kl("eof")}Wl()},value(){switch(Nl){case"{":case"[":return Kl("punctuator",Wl());case"n":return Wl(),ql("ull"),Kl("null",null);case"t":return Wl(),ql("rue"),Kl("boolean",!0);case"f":return Wl(),ql("alse"),Kl("boolean",!1);case"-":case"+":return"-"===Wl()&&(Jl=-1),void($l="numerical");case".":case"0":case"I":case"N":return void($l="numerical");case'"':case"'":return Hl=Nl,Wl(),xl="",void($l="string")}if(void 0===Nl||!Al.JudgeUtil.isDigitWithoutZero(Nl))throw tf(bl.Char,Wl());$l="numerical"},numerical(){switch(Nl){case".":return xl=Wl(),void($l="decimalPointLeading");case"0":return xl=Wl(),void($l="zero");case"I":return Wl(),ql("nfinity"),Kl("numeric",Jl*(1/0));case"N":return Wl(),ql("aN"),Kl("numeric",NaN)}if(void 0!==Nl&&Al.JudgeUtil.isDigitWithoutZero(Nl))return xl=Wl(),void($l="decimalInteger");throw tf(bl.Char,Wl())},zero(){switch(Nl){case".":case"e":case"E":return void($l="decimal");case"x":case"X":return xl+=Wl(),void($l="hexadecimal")}return Kl("numeric",0)},decimalInteger(){switch(Nl){case".":case"e":case"E":return void($l="decimal")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimal(){switch(Nl){case".":xl+=Wl(),$l="decimalFraction";break;case"e":case"E":xl+=Wl(),$l="decimalExponent"}},decimalPointLeading(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalFraction");throw tf(bl.Char,Wl())},decimalFraction(){switch(Nl){case"e":case"E":return xl+=Wl(),void($l="decimalExponent")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimalExponent(){switch(Nl){case"+":case"-":return xl+=Wl(),void($l="decimalExponentSign")}if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentSign(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentInteger(){if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},hexadecimal(){if(Al.JudgeUtil.isHexDigit(Nl))return xl+=Wl(),void($l="hexadecimalInteger");throw tf(bl.Char,Wl())},hexadecimalInteger(){if(!Al.JudgeUtil.isHexDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},identifierNameStartEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":break;default:if(!Al.JudgeUtil.isIdStartChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},identifierName(){switch(Nl){case"$":case"_":case"‌":case"‍":return void(xl+=Wl());case"\\":return Wl(),void($l="identifierNameEscape")}if(!Al.JudgeUtil.isIdContinueChar(Nl))return Kl("identifier",xl);xl+=Wl()},identifierNameEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!Al.JudgeUtil.isIdContinueChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},string(){switch(Nl){case"\\":return Wl(),void(xl+=function(){const e=Ul(),t=function(){switch(Ul()){case"b":return Wl(),"\b";case"f":return Wl(),"\f";case"n":return Wl(),"\n";case"r":return Wl(),"\r";case"t":return Wl(),"\t";case"v":return Wl(),"\v"}return}();if(t)return t;switch(e){case"0":if(Wl(),Al.JudgeUtil.isDigit(Ul()))throw tf(bl.Char,Wl());return"\0";case"x":return Wl(),function(){let e="",t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());if(e+=Wl(),t=Ul(),!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());return e+=Wl(),String.fromCodePoint(parseInt(e,16))}();case"u":return Wl(),Yl();case"\n":case"\u2028":case"\u2029":return Wl(),"";case"\r":return Wl(),"\n"===Ul()&&Wl(),""}if(void 0===e||Al.JudgeUtil.isDigitWithoutZero(e))throw tf(bl.Char,Wl());return Wl()}());case'"':case"'":if(Nl===Hl){const e=Kl("string",xl);return Wl(),e}return void(xl+=Wl());case"\n":case"\r":case void 0:throw tf(bl.Char,Wl());case"\u2028":case"\u2029":!function(e){Ol.warn(`JSON5: '${ef(e)}' in strings is not valid ECMAScript; consider escaping.`)}(Nl)}xl+=Wl()}};function Kl(e,t){return{type:e,value:t,line:Ml,column:Ll}}function ql(e){for(const t of e){if(Ul()!==t)throw tf(bl.Char,Wl());Wl()}}function Yl(){let e="",t=4;for(;t-- >0;){const t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());e+=Wl()}return String.fromCodePoint(parseInt(e,16))}const Xl={start(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},beforePropertyName(){switch(_l.type){case"identifier":case"string":return Pl=_l.value,void(Il="afterPropertyName");case"punctuator":return void Ql();case"eof":throw tf(bl.EOF)}},afterPropertyName(){if("eof"===_l.type)throw tf(bl.EOF);Il="beforePropertyValue"},beforePropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},afterPropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforePropertyName");case"}":Ql()}},beforeArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);"punctuator"!==_l.type||"]"!==_l.value?Zl():Ql()},afterArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforeArrayValue");case"]":Ql()}},end(){}};function Zl(){const e=function(){let e;switch(_l.type){case"punctuator":switch(_l.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=_l.value}return e}();if(jl&&"object"==typeof e&&(e._line=Ml,e._column=Ll),void 0===kl)kl=e;else{const t=Tl[Tl.length-1];Array.isArray(t)?jl&&"object"!=typeof e?t.push({value:e,_line:Ml,_column:Ll}):t.push(e):t[Pl]=jl&&"object"!=typeof e?{value:e,_line:Ml,_column:Ll}:e}!function(e){if(e&&"object"==typeof e)Tl.push(e),Il=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}}(e)}function Ql(){Tl.pop();const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}function ef(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){const t=e.charCodeAt(0).toString(16);return`\\x${`00${t}`.substring(t.length)}`}return e}function tf(e,t){let n="";switch(e){case bl.Char:n=void 0===t?`JSON5: invalid end of input at ${Ml}:${Ll}`:`JSON5: invalid character '${ef(t)}' at ${Ml}:${Ll}`;break;case bl.EOF:n=`JSON5: invalid end of input at ${Ml}:${Ll}`;break;case bl.Identifier:Ll-=5,n=`JSON5: invalid identifier character at ${Ml}:${Ll}`}const r=new nf(n);return r.lineNumber=Ml,r.columnNumber=Ll,r}class nf extends SyntaxError{}var rf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),uf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&rf(t,e,n);return uf(t,e),t};Object.defineProperty(Y,"__esModule",{value:!0});var sf=Y.cleanWorkSpace=Ff=Y.executeInstallHvigor=yf=Y.isHvigorInstalled=mf=Y.isAllDependenciesInstalled=void 0;const cf=of(D.default),af=of(p.default),lf=b,ff=j,df=$,Df=X;let pf,Ef;var mf=Y.isAllDependenciesInstalled=function(){function e(e){const t=null==e?void 0:e.dependencies;return void 0===t?0:Object.getOwnPropertyNames(t).length}if(pf=gf(),Ef=Af(),e(pf)+1!==e(Ef))return!1;for(const e in null==pf?void 0:pf.dependencies)if(!(0,ff.hasNpmPackInPaths)(e,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])||!hf(e,pf,Ef))return!1;return!0};function hf(e,t,n){return void 0!==n.dependencies&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,t.dependencies[e])===n.dependencies[e]}var yf=Y.isHvigorInstalled=function(){return pf=gf(),Ef=Af(),(0,ff.hasNpmPackInPaths)(lf.HVIGOR_ENGINE_PACKAGE_NAME,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion)===Ef.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]};const Cf={cwd:lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,stdio:["inherit","inherit","inherit"]};var Ff=Y.executeInstallHvigor=function(){(0,df.logInfoPrintConsole)("Hvigor installing...");const e={dependencies:{}};e.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]=(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion);try{cf.mkdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,{recursive:!0});const t=af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,lf.DEFAULT_PACKAGE_JSON);cf.writeFileSync(t,JSON.stringify(e))}catch(e){(0,df.logErrorAndExit)(e)}!function(){const e=["config","set","store-dir",lf.HVIGOR_PNPM_STORE_PATH];(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,e,Cf)}(),(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,["install"],Cf)};function gf(){const e=af.resolve(lf.HVIGOR_PROJECT_WRAPPER_HOME,lf.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);return cf.existsSync(e)||(0,df.logErrorAndExit)(`Error: Hvigor config file ${e} does not exist.`),(0,Df.parseJsonFile)(e)}function Af(){return cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH)?(0,Df.parseJsonFile)(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH):{dependencies:{}}}sf=Y.cleanWorkSpace=function(){if((0,df.logInfoPrintConsole)("Hvigor cleaning..."),!cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME))return;const e=cf.readdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME);if(e&&0!==e.length){cf.existsSync(lf.HVIGOR_BOOT_JS_FILE_PATH)&&(0,ff.executeCommand)(process.argv[0],[lf.HVIGOR_BOOT_JS_FILE_PATH,"--stop-daemon"],{});try{e.forEach((e=>{cf.rmSync(af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,e),{recursive:!0})}))}catch(e){(0,df.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${lf.HVIGOR_PROJECT_DEPENDENCIES_HOME}.`)}}};var vf={},Sf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),wf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Sf(t,e,n);return wf(t,e),t};Object.defineProperty(vf,"__esModule",{value:!0});var bf=vf.executeBuild=void 0;const _f=b,Bf=Of(D.default),Pf=Of(p.default),kf=$;bf=vf.executeBuild=function(){const e=Pf.resolve(_f.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const t=Bf.realpathSync(e);require(t)}catch(t){(0,kf.logErrorAndExit)(`Error: ENOENT: no such file ${e},delete ${_f.HVIGOR_PROJECT_DEPENDENCIES_HOME} and retry.`)}},function(){if(O.checkNpmConifg(),O.environmentHandler(),O.isPnpmAvailable()||O.executeInstallPnpm(),yf()&&mf())bf();else{sf();try{Ff()}catch(e){return void sf()}bf()}}(); \ No newline at end of file +"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},E=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const F=E(D),A="Windows_NT",o="Darwin";function a(){return F.default.type()===A}function c(){return F.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===F.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.ENABLE_SIGN_TASK_KEY=e.HVIGOR_CACHE_DIR_KEY=e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const E=i(D),F=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=F.resolve(E.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=F.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=F.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=F.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=F.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=F.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace",e.HVIGOR_CACHE_DIR_KEY="hvigor.cacheDir",e.ENABLE_SIGN_TASK_KEY="enableSignTask"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const O=f(e),p=f(u),h=l;_=s.executeBuild=function(u){const D=p.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=O.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class I{}R.Unicode=I,I.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,I.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,I.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const y=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&y.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||y.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||"‌"===u||"‍"===u||y.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const S=N(e),b=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,G,V,j,J,U="start",L=[],W=0,$=1,K=0,k=!1,z="default",q="'",Z=1;function Y(u,D=!1){T=String(u),U="start",L=[],W=0,$=1,K=0,V=void 0,k=D;do{M=X(),nu[U]()}while("eof"!==M.type);return V}function X(){for(z="default",j="",q="'",Z=1;;){J=Q();const u=Du[z]();if(u)return u}}function Q(){if(T[W])return String.fromCodePoint(T.codePointAt(W))}function uu(){const u=Q();return"\n"===u?($++,K=0):u?K+=u.length:K++,u&&(W+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=S.default.readFileSync(w.default.resolve(u),{encoding:e});try{return Y(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${b.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=Y;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[U]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Fu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Fu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Fu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Fu(x.Char,uu())},end(){throw Fu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Fu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Fu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Fu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Fu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Fu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Fu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Fu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Fu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Fu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Fu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Fu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"‌":case"‍":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Fu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Fu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Q(),D=function(){switch(Q()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Q()))throw Fu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Q();if(!H.JudgeUtil.isHexDigit(D))throw Fu(x.Char,uu());if(u+=uu(),D=Q(),!H.JudgeUtil.isHexDigit(D))throw Fu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Q()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Fu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Fu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Eu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:K}}function tu(u){for(const D of u){if(Q()!==D)throw Fu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Q();if(!H.JudgeUtil.isHexDigit(D))throw Fu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Fu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return G=M.value,void(U="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Fu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Fu(x.EOF);U="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Fu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Fu(x.EOF);switch(M.value){case",":return void(U="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Fu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Fu(x.EOF);switch(M.value){case",":return void(U="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(k&&"object"==typeof u&&(u._line=$,u._column=K),void 0===V)V=u;else{const D=L[L.length-1];Array.isArray(D)?k&&"object"!=typeof u?D.push({value:u,_line:$,_column:K}):D.push(u):D[G]=k&&"object"!=typeof u?{value:u,_line:$,_column:K}:u}!function(u){if(u&&"object"==typeof u)L.push(u),U=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=L[L.length-1];U=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){L.pop();const u=L[L.length-1];U=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Eu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Fu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${K}`:`JSON5: invalid character '${Eu(D)}' at ${$}:${K}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${K}`;break;case x.Identifier:K-=5,e=`JSON5: invalid identifier character at ${$}:${K}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=K,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,Ou=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,Ou.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var pu=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&pu(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),Iu=Pu(u),yu=i,Nu=v,Su=g,bu=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===Iu.normalize(e.dependencies[u])}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=Iu.resolve(yu.HVIGOR_PROJECT_WRAPPER_HOME,yu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,bu.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,Su.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){const D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${yu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Nu.hash)(D)}(u):(0,Nu.hash)(process.cwd());return Iu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=Iu.resolve(Mu,yu.WORK_SPACE,yu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,Su.parseJsonFile)(u):{dependencies:{}}}(),function(){const u=Iu.resolve(yu.HVIGOR_USER_HOME,yu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);if(mu.existsSync(u))(0,Su.parseJsonFile)(u)}(),!(0,wu.hasNpmPackInPaths)(yu.HVIGOR_ENGINE_PACKAGE_NAME,[Iu.join(Mu,yu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[yu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[Iu.join(Mu,yu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}())try{!function(){(0,bu.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[yu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=Iu.join(Mu,yu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=Iu.resolve(D,yu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,bu.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",yu.HVIGOR_PNPM_STORE_PATH],D={cwd:Iu.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:Iu.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,bu.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){!function(){const u=Iu.join(Mu,yu.WORK_SPACE);if((0,bu.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=Iu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(Iu.resolve(u,D),{recursive:!0})}))}catch(D){(0,bu.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}()}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),E=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),F=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return E(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=F(e),c=A(D),s=F(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}(); \ No newline at end of file -- Gitee From 8c078fb248eeab75f6de366ab164769b473bfe02 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 27 Jan 2024 15:53:47 +0800 Subject: [PATCH 15/69] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 584d718af6bbd75cf8b478a7450f232bb1d7c978 Merge: 26d3c46624 f1fcec0410 Author: openharmony_ci <120357966@qq.com> Date: Fri Jan 26 11:11:39 2024 +0000 !142 解决XComponent type设置错误引起的flutterpage切换时出现黑屏和flutterpage半屏透明无效的问题 Merge pull request !142 from wwyang/dev commit f1fcec04102e24d44f08f4a9084637b9be04ea94 Author: wwyang <137208408@qq.com> Date: Fri Jan 26 17:29:51 2024 +0800 解决XComponent type设置错误引起的flutterpage切换时出现黑屏和flutterpage半屏透明无效的问题 Signed-off-by: wwyang <137208408@qq.com> commit 26d3c466242ff2becf0a69b89323c3768481ee4d Merge: 850800ee3b 49921622eb Author: openharmony_ci <120357966@qq.com> Date: Thu Jan 25 06:37:40 2024 +0000 !140 修复编译./ohos -t release时lint失败 Merge pull request !140 from 肖湘/fix_lint_in_release commit 49921622ebe4be0f44dbc3585d976cc41168c0a0 Author: xiaoxiang Date: Wed Jan 24 12:59:51 2024 +0800 lint Signed-off-by: xiaoxiang commit 850800ee3b1b77e2d34c11aa679d29d9b20af17b Merge: cc4ecd19c6 746e975980 Author: openharmony_ci <120357966@qq.com> Date: Tue Jan 23 10:09:00 2024 +0000 !139 DetachFlutterEnginei时 window_ = nullptr 会导致重新AttachFlutterEngine时无法恢复点击 Merge pull request !139 from 肖湘/not_set_window_null_ptr commit 746e9759805deea8229f1fc76201b80573b1a94b Author: xiaoxiang Date: Tue Jan 23 16:39:50 2024 +0800 index.d.ets暴露接口 Signed-off-by: xiaoxiang commit ab1485441047a3226d41d7ab38059342cbde7213 Author: xiaoxiang Date: Tue Jan 23 16:04:40 2024 +0800 确认aboutToAppear的逻辑只会进一次 Signed-off-by: xiaoxiang commit f183262964b0c4e636e1d36e25e680bc990e26f1 Author: xiaoxiang Date: Mon Jan 22 16:05:22 2024 +0800 DetachFlutterEngine时不将window设置为nullptr Signed-off-by: xiaoxiang commit cc4ecd19c63e89d48e5de3bc67697e6408ee55ca Merge: ffd4ac8888 b316301991 Author: openharmony_ci <120357966@qq.com> Date: Mon Jan 15 14:32:17 2024 +0000 !134 移除键盘隐藏时的回调(会触发TextField的onSubmitted属性) Merge pull request !134 from wwyang/dev commit b316301991a804abab0862f51531749733de1ff2 Author: wwyang <137208408@qq.com> Date: Mon Jan 15 22:05:16 2024 +0800 移除键盘隐藏时的回调(会触发TextField的onSubmitted属性) Signed-off-by: wwyang <137208408@qq.com> commit ffd4ac888860c2950e32ebf942f84bdfd7b8f0a9 Merge: f77ea6b203 573a407fb3 Author: openharmony_ci <120357966@qq.com> Date: Mon Jan 15 02:22:41 2024 +0000 !130 修复 TextField 组件通过软键盘隐藏按钮隐藏软键盘后,单击输入框无法再次弹出软键盘问题 Merge pull request !130 from nobody/dev commit 573a407fb32e965587a3d1578cd8351de68f57a3 Author: huangkai Date: Mon Jan 15 09:40:30 2024 +0800 修复 TextField 组件通过软键盘隐藏按钮隐藏软键盘后,单击输入框无法再次弹出软键盘问题 Signed-off-by: huangkai commit f77ea6b2034dd793a9c577e9fbc747cfaed1c488 Merge: 03fdfdccb7 dc80bd8276 Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 13 12:53:04 2024 +0000 !133 修复setApplicationSwitcherDescription设置无效问题 Merge pull request !133 from huangxiaoyao/dev commit dc80bd82766bf8ae6877cc0883ecb3dcaf0b5206 Author: hxy-111 <976125628@qq.com> Date: Sat Jan 13 20:21:02 2024 +0800 修复setApplicationSwitcherDescription设置无效问题 Signed-off-by: hxy-111 <976125628@qq.com> commit dc7afe078a04720eee405673200a6c117cc6dc8a Author: hxy-111 <976125628@qq.com> Date: Sat Jan 13 20:10:48 2024 +0800 修复setApplicationSwitcherDescription设置无效问题 Signed-off-by: hxy-111 <976125628@qq.com> commit 03fdfdccb75409f23fed97c3425e7c5e4776dd0c Merge: 8494fb755e 8876d93ea1 Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 13 11:46:48 2024 +0000 !131 修复点击修改鼠标样式的按钮,样式不发生改变;以及适配官网新增的鼠标样式 Merge pull request !131 from liuyuehu/dev commit 8494fb755e9de1776fc551521eb8d96db85d812d Merge: 881b6ce721 17aa6d4a34 Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 13 11:44:15 2024 +0000 !129 解决TextInputAction为unspecified时候,TextField的onSubmitted属 性无法触发的问题 Merge pull request !129 from wwyang/dev commit 8876d93ea1501b44fa14a51170ecee31b4f3208f Author: liuyuehu <3455278857@qq.com> Date: Sat Jan 13 19:21:37 2024 +0800 mouseCursorPlugin放到FlutterView里面初始化 Signed-off-by: liuyuehu <3455278857@qq.com> commit 881b6ce7214cda267899f2e0321293a0110baba3 Merge: 988f08cf15 52a6ab92fd Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 13 10:54:04 2024 +0000 !127 修改flutter资源重复复制 Merge pull request !127 from zjzhu/dev commit 17aa6d4a349ed349413488b561a65c6a1f159d98 Author: wwyang <137208408@qq.com> Date: Sat Jan 13 18:44:31 2024 +0800 添加TextInputChannel.newline Signed-off-by: wwyang <137208408@qq.com> commit 988f08cf152ee685ed0ad9a4ba20d960b6e496df Merge: 0ea341ad56 4dc47de000 Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 13 10:17:30 2024 +0000 !128 更新ohos.py文件,修改生成zip文件的逻辑 Merge pull request !128 from hazy/feature-ohos-py commit 4dc47de000d2198c9167e5a2622636f70c306a03 Author: hezhengyi Date: Sat Jan 13 17:46:22 2024 +0800 修改引用路径 Signed-off-by: hezhengyi commit 4455b0e5849b997a9a2363eb658e67504e436129 Author: liuyuehu <3455278857@qq.com> Date: Sat Jan 13 12:09:35 2024 +0800 适配官网新增的鼠标样式 Signed-off-by: liuyuehu <3455278857@qq.com> commit d1814415efdf7c6fd45f1b2a53ddc4ca1e78c812 Author: liuyuehu <3455278857@qq.com> Date: Sat Jan 13 12:08:47 2024 +0800 修复点击修改鼠标样式的按钮,样式不发生改变 Signed-off-by: liuyuehu <3455278857@qq.com> commit 048b579b45eaffa5cf64c2a30c27ba1b966f9f9e Author: hezhengyi Date: Sat Jan 13 09:41:08 2024 +0800 默认构建参数改为 config compile Signed-off-by: hezhengyi commit 072c9277869d0ddc93ff32187d6240612204d94f Author: hezhengyi Date: Fri Jan 12 19:50:27 2024 +0800 修改流水线编译的问题 Signed-off-by: hezhengyi commit 51de38c7f8826b4bbcf1e05508c2f5b20471c63c Author: wwyang <137208408@qq.com> Date: Fri Jan 12 11:50:21 2024 +0800 解决TextInputAction为unspecified时候,TextField的onSubmitted属 性无法触发的问题 Signed-off-by: wwyang <137208408@qq.com> commit 69fdf877665950465b1a8cb5d5434c27b2a7ed02 Author: hezhengyi Date: Fri Jan 12 10:51:59 2024 +0800 优先使用当前路径下的depot_tools Signed-off-by: hezhengyi commit 15d2e9ca8a249731867aa82ab3358b9f7bd3243d Author: hezhengyi Date: Fri Jan 12 10:18:53 2024 +0800 在ndk目录,根据系统类型搜索对应的native Signed-off-by: hezhengyi commit e4addbbdbf11a2b1d5b3ab786257876702fa7552 Author: hezhengyi Date: Tue Jan 9 16:09:57 2024 +0800 更新ohos.py,生成zip文件时使用正则表达式进行过滤 Signed-off-by: hezhengyi commit 52a6ab92fd0f01706b95cfc8ea2bccdffac469ce Author: zhuzhengjun Date: Thu Jan 11 11:35:15 2024 +0800 修改flutter资源加载重复 Signed-off-by: zhuzhengjun commit 0ea341ad566ed5bb39562e56e91495ae56bc66fc Merge: 4f7768e77e 34b1576a01 Author: openharmony_ci <120357966@qq.com> Date: Thu Jan 11 00:23:42 2024 +0000 !125 暴露IncomingResultHandler和IncomingMethodCallHandler Merge pull request !125 from 肖湘/export_IncomingMethodCallHandler_IncomingResultHandler commit 4f7768e77e4c92de815e2a83ff043f95ef5d1956 Merge: 92420b6926 2c43acbf38 Author: openharmony_ci <120357966@qq.com> Date: Wed Jan 10 14:33:14 2024 +0000 !124 修改spawn异常 Merge pull request !124 from zjzhu/dev commit 34b1576a0151c380f3473295ff538d84d0602307 Author: 肖湘 Date: Wed Jan 10 09:56:55 2024 +0000 暴露IncomingResultHandler和IncomingMethodCallHandler Signed-off-by: 肖湘 commit 2c43acbf3894d238b5f3dbadaf4202e80551327d Author: zhuzhengjun Date: Wed Jan 10 17:50:37 2024 +0800 修改spawn异常 Signed-off-by: zhuzhengjun commit 4df528ce0cb6ab066899870359fa72df9e174fc4 Author: zhuzhengjun Date: Wed Jan 10 17:42:39 2024 +0800 修改代码编译报错 Signed-off-by: zhuzhengjun commit 92420b6926cc044f978b9b4ad1cf91268a229c12 Merge: b63105929e e1883cbf7e Author: openharmony_ci <120357966@qq.com> Date: Wed Jan 10 08:59:34 2024 +0000 !123 修改图片加载错误阻塞IO线程 Merge pull request !123 from zjzhu/dev commit e1883cbf7e6cd14485735d2a8018ad9f63a339e7 Author: zhuzhengjun Date: Wed Jan 10 15:49:27 2024 +0800 修改图片加载错误阻塞IO线程 Signed-off-by: zhuzhengjun commit 3e9fa820c48e5772a4e236af3885e694a4332776 Author: zhuzhengjun Date: Wed Jan 10 15:32:03 2024 +0800 修改图片加载错误阻塞IO线程 Signed-off-by: zhuzhengjun commit b63105929e2ed409b322cc2a2598d5d623031b2a Merge: 9e59ae874b 8c80df939f Author: openharmony_ci <120357966@qq.com> Date: Tue Jan 9 15:01:28 2024 +0000 !122 修改ByteBuffer处理效率 Merge pull request !122 from zjzhu/dev commit 8c80df939f92a9b554269315c0a0835436459015 Author: zhuzhengjun Date: Tue Jan 9 17:33:55 2024 +0800 修改ByteBuffer处理效率 Signed-off-by: zhuzhengjun commit 9e59ae874b2d57a5bf46935fc5ad187dd1c89060 Merge: 5d22c16ff8 58a085811d Author: openharmony_ci <120357966@qq.com> Date: Mon Jan 8 07:32:35 2024 +0000 !121 IssueNo: #I8UEY3 修改OAT.xml中copyright声明的path的路径通配符,约束到只匹配ohos文件夹新增文件 Merge pull request !121 from get_moon/dev_mr_0108 commit 58a085811d22ddcfe139d54bf8d90350d40b81be Author: xuchang Date: Mon Jan 8 14:46:10 2024 +0800 IssueNo: #I8UEY3 修改OAT.xml中copyright声明的path的路径通配符,约束到只匹配ohos文件夹新增文件 Sig: OpenHarmony-SIG/flutter-engine Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: xuchang commit 5d22c16ff86e981a89ccaf86d776d1243a834ea3 Merge: dd10b3f99c 89e0661a91 Author: openharmony_ci <120357966@qq.com> Date: Mon Jan 8 03:49:02 2024 +0000 !120 修改页面退出没有调用detach Merge pull request !120 from zjzhu/dev commit 89e0661a91f829828e165cb7dcd056598a86a98b Author: zhuzhengjun Date: Mon Jan 8 11:23:40 2024 +0800 添加platformPlugin回收 Signed-off-by: zhuzhengjun commit b3cdc462dd7e10b367137413eebfe55fd3f581e0 Author: zhuzhengjun Date: Mon Jan 8 11:08:25 2024 +0800 修改页面退出没有调用detach Signed-off-by: zhuzhengjun commit dd10b3f99c10de41cec43488175cb510917f1f79 Merge: 065bfca439 2053771ba7 Author: openharmony_ci <120357966@qq.com> Date: Sat Jan 6 10:56:07 2024 +0000 !119 适配api11 Merge pull request !119 from gxzmf/master commit 2053771ba7c2620ac94178618ec5b87c4510708c Author: zmf <279822581@qq.com> Date: Sat Jan 6 17:20:25 2024 +0800 适配api11 Signed-off-by: zmf <279822581@qq.com> commit 065bfca4395c1bdf9e4141118803096efa750be8 Merge: 0af9afba68 1b77aa7be4 Author: openharmony_ci <120357966@qq.com> Date: Fri Jan 5 11:13:40 2024 +0000 !117 支持TextInputChannel的onConnectionClosed方法 Merge pull request !117 from cj-and/dev_lcj_0104 commit 0af9afba6809a88cc2678cd79222058c3f16d246 Merge: aaafa379f4 58bf2aa5b3 Author: openharmony_ci <120357966@qq.com> Date: Fri Jan 5 11:03:22 2024 +0000 !116 支持FlutterEntry和FlutterView Merge pull request !116 from zjzhu/dev commit aaafa379f4f45ed0c0b30a62b3ca9735ca0b5354 Merge: fc2f4ea3d5 78c10e0d2c Author: openharmony_ci <120357966@qq.com> Date: Fri Jan 5 03:37:34 2024 +0000 !118 修改README.OpenSource Merge pull request !118 from get_moon/dev_mr_0104 commit 58bf2aa5b3a5933cbdafbbfcfb79b785c909282c Merge: 258ac0d901 c43e26372a Author: zjzhu Date: Fri Jan 5 03:30:01 2024 +0000 !1 FlutterEngine多实例相关改动 Merge pull request !1 from hazy/feature-multi-flutter commit c43e26372ad96351a4bbb443eeb60f454c423a5e Author: hezhengyi Date: Fri Dec 29 10:07:18 2023 +0800 flutter多实例支持 Signed-off-by: hezhengyi commit 258ac0d901d9ecff8d9233e46d67607c52bdce1d Author: zhuzhengjun Date: Thu Jan 4 17:25:11 2024 -0800 FlutterEntry提交FlutterEngineConfigurator监听回调 Signed-off-by: zhuzhengjun commit 78c10e0d2c4418f5c069b84a8afde74148f80928 Author: xuchang Date: Thu Jan 4 20:03:18 2024 +0800 修改README.OpenSource Sig: OpenHarmony-SIG/flutter-engine Feature or Bugfix: Feature Binary Source: No Signed-off-by: xuchang commit cfe91b1435b287799fd89b025d21645881f030b6 Author: zhuzhengjun Date: Thu Jan 4 02:20:48 2024 -0800 修改资源回收 Signed-off-by: zhuzhengjun commit 1b77aa7be41733dd5b30289692f4ae6e592df5c1 Author: cjand <1747143535@qq.com> Date: Thu Jan 4 17:11:07 2024 +0800 onConnectionClosed方法 commit 2fc6c186d708787d9747d3ebedd07488d83b9644 Author: cjand <1747143535@qq.com> Date: Thu Jan 4 14:13:10 2024 +0800 onConnectionClosed方法 commit 448836830b66a4edc1ae1de9e5d0f35ad5222af7 Author: zhuzhengjun Date: Wed Jan 3 03:09:45 2024 -0800 修改On小写开头 Signed-off-by: zhuzhengjun commit 75a5c2b24f39e2c7134835cc1cb39dd43b78fdf5 Author: zhuzhengjun Date: Wed Jan 3 02:46:19 2024 -0800 修改On小写开头 Signed-off-by: zhuzhengjun commit 7aba8a70eeaf8bd3e378e4f01cd7154cea3ff50c Author: zhuzhengjun Date: Wed Jan 3 00:49:34 2024 -0800 重构Flutter支持FlutterEntry,FlutterView Signed-off-by: zhuzhengjun commit fc2f4ea3d543d62e06d0abb039b01dde734b0419 Merge: bad36241dc 3872bf3ee8 Author: openharmony_ci <120357966@qq.com> Date: Wed Jan 3 07:44:49 2024 +0000 !115 IssueNo: #I8T6TN 补充flutter engine初始化从want读取参数的逻辑 Merge pull request !115 from get_moon/dev_mr_0103 commit 3872bf3ee8c1f4cf7c42f37cfb1ca3809fb3eef6 Author: xuchang Date: Wed Jan 3 11:49:10 2024 +0800 IssueNo: #I8T6TN 补充flutter engine初始化从want读取参数的逻辑 Sig: OpenHarmony-SIG/flutter-engine Feature or Bugfix: Feature Binary Source: No Signed-off-by: xuchang commit bad36241dc97829355d7f073c8d4eb0c4c5381ad Merge: 160e9cc3fe 0592c193d8 Author: openharmony_ci <120357966@qq.com> Date: Fri Dec 29 10:22:38 2023 +0000 !112 提交产物构建链接 Merge pull request !112 from gxzmf/master commit 160e9cc3fe4aa6e064214acbddd99f87637f1203 Merge: 6c7fa32c5f fd734e8224 Author: openharmony_ci <120357966@qq.com> Date: Fri Dec 29 09:39:25 2023 +0000 !113 FlutterAbility增加onNewWant Merge pull request !113 from liuyuehu/dev commit 6c7fa32c5f10d81e567d3409880d3412ef5edfae Merge: b7b9b60884 9007033bb0 Author: openharmony_ci <120357966@qq.com> Date: Fri Dec 29 08:15:58 2023 +0000 !114 完善故障恢复机制 Merge pull request !114 from EwingZhou/dev commit 9007033bb0d6b439f4e2d60929cf3c0fd2cf2768 Author: zhoujiaying Date: Fri Dec 29 14:43:47 2023 +0800 完善故障恢复机制 Signed-off-by: zhoujiaying commit fd734e82243180897de50d241c5cdd7b732e92ee Author: liuyuehu <3455278857@qq.com> Date: Fri Dec 29 14:20:24 2023 +0800 FlutterAbility增加onNewWant Signed-off-by: liuyuehu <3455278857@qq.com> commit 0592c193d8987cf2dda184dd209989de86724ed0 Author: zmf <279822581@qq.com> Date: Fri Dec 29 12:01:04 2023 +0800 提交构建链接 Signed-off-by: zmf <279822581@qq.com> commit b7b9b6088415122ed81b2681dbd4bad7beb9388f Merge: a341781233 32616e5813 Author: openharmony_ci <120357966@qq.com> Date: Fri Dec 29 03:08:15 2023 +0000 !108 修复release模式输入光标不移动 Merge pull request !108 from yhyang24/icudtl commit a341781233a1022b2e7120727d64f735bc15efa9 Merge: 4f75d72287 f947148609 Author: openharmony_ci <120357966@qq.com> Date: Thu Dec 28 12:44:42 2023 +0000 !109 FlutterAbility支持指定页面路径 Merge pull request !109 from hazy/feature-page-index commit 4f75d722870a83a90d1269442ef2156deba6b6f5 Merge: a07c7d6619 73ab98223a Author: openharmony_ci <120357966@qq.com> Date: Thu Dec 28 12:39:46 2023 +0000 !111 FlutterAbilityDelegate优化方法名与onDetach() Merge pull request !111 from 詹淋淋/dev commit 73ab98223ad69359728b7a13bd641e3c2db15ee3 Author: zhan-linlin <17301907374@163.com> Date: Thu Dec 28 18:55:23 2023 +0800 IssueNo: 优化方法名与onDetach() Sig: OpenHarmony-SIG/flutter-engine Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: zhan-linlin <17301907374@163.com> commit a07c7d661907c14b5a772a0851f4587694e43078 Merge: e7abee323b d970ea7c50 Author: openharmony_ci <120357966@qq.com> Date: Thu Dec 28 10:20:07 2023 +0000 !106 不再使用多余拷贝的sysroot和libcxx头文件 Merge pull request !106 from gxzmf/master commit d970ea7c505105fc743ba391149af144783fb2a7 Author: zmf <279822581@qq.com> Date: Thu Dec 28 15:39:20 2023 +0800 不再使用多余拷贝的sysroot和libcxx头文件 Signed-off-by: zmf <279822581@qq.com> commit 32616e5813422f9bc0ac5fab4084971e78599441 Author: yihuiyang Date: Thu Dec 28 17:27:48 2023 +0800 解决release模式输入光标不移动 Signed-off-by: yihuiyang commit f9471486097ea485d86d859a6e6282afe36b83f9 Author: hezhengyi Date: Thu Dec 28 16:32:08 2023 +0800 FlutterAbility支持指定页面路径 Signed-off-by: hezhengyi commit d314cfc0ab09574f34fd14b7d296ecc433f79143 Author: zhan-linlin <17301907374@163.com> Date: Thu Dec 28 15:29:03 2023 +0800 IssueNo: 优化方法名与onDetach() Sig: OpenHarmony-SIG/flutter-engine Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: zhan-linlin <17301907374@163.com> commit e7abee323b72fca28d8e33a10156a9606b98de4d Merge: 7dc206049b f442935341 Author: openharmony_ci <120357966@qq.com> Date: Wed Dec 27 01:30:34 2023 +0000 !103 获取系统深色模式 Merge pull request !103 from Wangxiaoping/dev Signed-off-by: hezhengyi --- OAT.xml | 22 +- README.OpenSource | 2 +- README.md | 4 + attachment/repos/bootstrap/ohos.py | 120 ++- attachment/repos/build.patch | 870 ++++++++++++++++++ attachment/scripts/config.json | 35 +- attachment/scripts/config_pre.json | 9 +- attachment/scripts/ohos_setup.py | 7 +- attachment/scripts/ohos_setup_pre.py | 2 +- fml/platform/ohos/message_loop_ohos.cc | 3 +- .../flutter_embedding/build-profile.json5 | 2 +- .../ohos/flutter_embedding/flutter/index.ets | 177 +++- .../src/main/cpp/types/libflutter/index.d.ets | 15 +- .../cpp/types/libflutter/index_actual.d.ets | 3 +- .../flutter/src/main/ets/FlutterInjector.ets | 6 +- .../main/ets/app/FlutterPluginRegistry.ets | 6 +- .../main/ets/component/XComponentStruct.ets | 2 +- .../ets/embedding/engine/FlutterEngine.ets | 3 + .../embedding/engine/FlutterEngineGroup.ets | 6 +- .../main/ets/embedding/engine/FlutterNapi.ets | 22 +- .../ets/embedding/engine/FlutterShellArgs.ets | 53 +- .../embedding/engine/loader/FlutterLoader.ets | 93 +- .../engine/systemchannels/KeyEventChannel.ets | 27 +- .../engine/systemchannels/PlatformChannel.ets | 7 + .../systemchannels/RestorationChannel.ets | 58 +- .../systemchannels/TextInputChannel.ets | 6 +- .../ets/embedding/ohos/FlutterAbility.ets | 251 ++--- ...ets => FlutterAbilityAndEntryDelegate.ets} | 126 ++- .../ohos/FlutterComopnentDelegate.ets | 153 --- .../ohos/FlutterEngineConfigurator.ets | 6 +- .../main/ets/embedding/ohos/FlutterEntry.ets | 240 +++++ .../ets/embedding/ohos/FlutterManager.ets | 89 ++ .../main/ets/embedding/ohos/FlutterPage.ets | 56 +- .../ets/embedding/ohos/KeyboardManager.ets | 32 + .../src/main/ets/plugin/PlatformPlugin.ets | 10 +- .../ets/plugin/common/BinaryMessenger.ets | 6 +- .../main/ets/plugin/common/EventChannel.ets | 14 +- .../main/ets/plugin/common/MethodChannel.ets | 4 +- .../plugin/editing/ListenableEditingState.ets | 3 +- .../ets/plugin/editing/TextInputPlugin.ets | 13 + .../ets/plugin/mouse/MouseCursorPlugin.ets | 72 +- .../platform/PlatformViewsController.ets | 27 +- .../plugin/platform/RootDvModelManager.ets | 2 + .../flutter/src/main/ets/util/ByteBuffer.ets | 17 +- .../src/main/ets/view/FlutterNativeView.ets | 137 --- .../src/main/ets/view/FlutterRunArguments.ets | 6 + .../flutter/src/main/ets/view/FlutterView.ets | 193 ++++ shell/platform/ohos/library_loader.cpp | 6 + .../ohos/napi/platform_view_ohos_napi.cpp | 95 +- .../ohos/napi/platform_view_ohos_napi.h | 9 +- shell/platform/ohos/ohos_image_generator.cpp | 3 +- shell/platform/ohos/ohos_shell_holder.cpp | 6 + shell/platform/ohos/ohos_shell_holder.h | 1 + shell/platform/ohos/ohos_surface_gl_skia.cpp | 14 +- .../platform/ohos/ohos_xcomponent_adapter.cpp | 120 ++- shell/platform/ohos/ohos_xcomponent_adapter.h | 14 +- shell/platform/ohos/platform_view_ohos.cpp | 1 + 57 files changed, 2473 insertions(+), 813 deletions(-) create mode 100644 attachment/repos/build.patch rename shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/{FlutterAbilityDelegate.ets => FlutterAbilityAndEntryDelegate.ets} (83%) delete mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterComopnentDelegate.ets create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets delete mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterNativeView.ets diff --git a/OAT.xml b/OAT.xml index eaadc3d1be..2e84930ccc 100644 --- a/OAT.xml +++ b/OAT.xml @@ -69,7 +69,15 @@ used to filter file path. filefilter="copyrightPolicyFilter" group="defaultGroup" name="Hunan OpenValley Digital Industry Development Co., Ltd." - path=".*" + path=".*/ohos/.*" + rule="may" + type="copyright" /> + @@ -90,17 +98,7 @@ used to filter file path. desc="app resource files" /> - - - - - - - - - - - + diff --git a/README.OpenSource b/README.OpenSource index 4302db9e1a..d0011eeaca 100644 --- a/README.OpenSource +++ b/README.OpenSource @@ -5,7 +5,7 @@ "License File": "LICENSE", "Version Number": "3.7.12", "Owner": "aibin@openvalley.net", - "Upstream URL": "https://flutter.dev/", + "Upstream URL": "https://github.com/flutter/engine/", "Description": "The Flutter Engine is a portable runtime for hosting Flutter applications. It implements Flutter's core libraries, including animation and graphics, file and network I/O, accessibility support, plugin architecture, and a Dart runtime and compile toolchain. Most developers will interact with Flutter via the Flutter Framework, which provides a modern, reactive framework, and a rich set of platform, layout and foundation widgets." } ] \ No newline at end of file diff --git a/README.md b/README.md index e3b16e8ba6..5cb27d599c 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,10 @@ export OHOS_SDK_HOME= 6. 更新代码:在engine目录,执行`./ohos -b master` +## Engine构建产物 + + [构建产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) + ## FAQ 1. 运行项目工程报Member notfound:'isOhos'的错误:请确保src/third_party/dart目录下应用了所有的dart patch(补丁位于src/flutter/attachment/repos目录,可使用git apply应用patch)应用patch后重新编译engine diff --git a/attachment/repos/bootstrap/ohos.py b/attachment/repos/bootstrap/ohos.py index 7687acbeb8..7a1c796b4e 100644 --- a/attachment/repos/bootstrap/ohos.py +++ b/attachment/repos/bootstrap/ohos.py @@ -26,12 +26,12 @@ import sys import zipfile from datetime import datetime -SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip") +SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2") SUPPORT_BUILD_TYPES = ("debug", "profile", "release") DIR_ROOT = os.path.abspath(os.path.join(sys.argv[0], os.pardir)) OS_NAME = platform.system().lower() -PATH_SEP = ";" if OS_NAME.startswith("win") else ":" - +IS_WINDOWS = OS_NAME.startswith("win") +PATH_SEP = ";" if IS_WINDOWS else ":" logging.basicConfig( format="%(levelname)s:%(asctime)s: %(message)s", datefmt="%Y-%d-%m %H:%M:%S", @@ -48,7 +48,7 @@ def safeGetPath(filePath, isDirectory=True): return os.path.abspath(filePath) -TIME_STR = datetime.now().strftime("%H%M") +TIME_STR = datetime.now().strftime("%Y%m%d-%H%M") DIR_OUTPUTS = safeGetPath( "%s/outputs/%s" % (DIR_ROOT, datetime.now().strftime("%Y%m%d")) ) @@ -104,8 +104,28 @@ def engineClean(buildInfo): shutil.rmtree(target, ignore_errors=True) +def findFile(path, search, results): + if not os.path.exists(path): + return + for item in os.listdir(path): + cur_path = os.path.join(path, item) + if os.path.isdir(cur_path): + if cur_path.endswith(search): + results.append(os.path.abspath(cur_path)) + findFile(cur_path, search, results) + + +def findNativeInCurrentDir(): + os_dir = "mac" if OS_NAME == "darwin" else OS_NAME + dirs = [] + findFile(os.path.join("ndk", os_dir), "native", dirs) + return dirs[0] if len(dirs) != 0 else "" + + def getNdkHome(): OHOS_NDK_HOME = os.getenv("OHOS_NDK_HOME") + if not OHOS_NDK_HOME: + OHOS_NDK_HOME = findNativeInCurrentDir() if not OHOS_NDK_HOME: OHOS_SDK_HOME = os.getenv("OHOS_SDK_HOME") if not OHOS_SDK_HOME: @@ -151,20 +171,24 @@ def engineConfig(buildInfo, extraParam=""): os.environ["PATH"] = ( "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "cmake", "bin"), PATH_SEP) + "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "llvm", "bin"), PATH_SEP) + + "%s%s" % (os.path.abspath("depot_tools"), PATH_SEP) + lastPath ) unixCommand = "" - if (platform.system() != "Windows"): - unixCommand = ("--target-sysroot %s " % os.path.join(OHOS_NDK_HOME, "sysroot") - + "--target-toolchain %s " % os.path.join(OHOS_NDK_HOME, "llvm") - + "--target-triple %s " % buildInfo.targetTriple) + if not IS_WINDOWS: + unixCommand = ( + "--target-sysroot %s " % os.path.join(OHOS_NDK_HOME, "sysroot") + + "--target-toolchain %s " % os.path.join(OHOS_NDK_HOME, "llvm") + + "--target-triple %s " % buildInfo.targetTriple + ) OPT = "--unoptimized --no-lto " if buildInfo.buildType == "debug" else "" runCommand( "%s " % os.path.join("src", "flutter", "tools", "gn") - + "--ohos " + unixCommand + + "--ohos " + "--ohos-cpu %s " % buildInfo.targetArch + "--runtime-mode %s " % buildInfo.buildType + OPT + + unixCommand + "--no-goma " + "--no-prebuilt-dart-sdk " + "--embedder-for-target " @@ -227,22 +251,30 @@ def harBuild(buildInfo): ) -def isPathValid(filepath, filename, includeDir, excludeDir): - for dir in includeDir: - if dir in filepath: +def isPathValid(filepath, filename, includes, excludes): + fileOrigin = filepath + os.path.sep + filename + for regex in includes: + if re.search(regex, fileOrigin): return True - if includeDir != []: + if includes != []: return False - for dir in excludeDir: - if dir in filepath: + for regex in excludes: + if re.search(regex, fileOrigin): return False return True -def zipFileDir(fileIn, fileName, prefixInZip="", includeDir=[], excludeDir=[]): +def zipFileDir( + fileIn, + fileName, + prefixInZip="", + includes=[], + excludes=[], + useZip2=False, +): logging.info( - "fileIn= %s, fileName= %s, prefixInZip= %s, includeDir= %s, excludeDir= %s" - % (fileIn, fileName, prefixInZip, includeDir, excludeDir) + "fileIn= %s, fileName= %s, prefixInZip= %s, includes= %s, excludes= %s" + % (fileIn, fileName, prefixInZip, includes, excludes) ) fileOut1 = os.path.abspath("%s/%s.zip" % (DIR_OUTPUTS, fileName)) fileOut2 = os.path.abspath("%s/%s-unstripped.zip" % (DIR_OUTPUTS, fileName)) @@ -252,29 +284,42 @@ def zipFileDir(fileIn, fileName, prefixInZip="", includeDir=[], excludeDir=[]): fpath = path.replace(fileIn, "")[1:] pPath = prefixInZip + os.sep + fpath for filename in filenames: - if isPathValid(fpath, filename, includeDir, excludeDir): - zip1.write( - os.path.join(path, filename), os.path.join(pPath, filename) - ) - else: - zip2.write( - os.path.join(path, filename), os.path.join(pPath, filename) - ) + path1 = os.path.join(path, filename) + path2 = os.path.join(pPath, filename) + if isPathValid(fpath, filename, includes, excludes): + zip1.write(path1, path2) + elif useZip2: + zip2.write(path1, path2) + + if not useZip2: + os.remove(fileOut2) -def zipFiles(buildInfo): +def zipFiles(buildInfo, useZip2=False): logging.info("zipFiles buildInfo=%s" % buildInfo) + sdkInt = int(getNdkHome()[-9:-7]) outputName = getOutput(buildInfo) fileIn = os.path.abspath("%s/src/out/%s" % (DIR_ROOT, outputName)) - fileName = "%s-%s-%s-%s" % ( - outputName, - TIME_STR, + fileName = "ohos_api%s_%s-%s-%s-%s" % ( + sdkInt, + buildInfo.buildType, OS_NAME, platform.machine(), + TIME_STR, ) prefixInZip = os.path.join("src", "out", outputName) - dirArray = ["obj", "exe.unstripped", "so.unstripped"] - zipFileDir(fileIn, fileName, prefixInZip, excludeDir=dirArray) + if IS_WINDOWS: + excludes = [ + ".*\.ilk", + ".*\.pdb", + ] + else: + excludes = [ + "obj", + "exe.unstripped", + "so.unstripped", + ] + zipFileDir(fileIn, fileName, prefixInZip, excludes=excludes, useZip2=useZip2) def addParseParam(parser): @@ -328,7 +373,7 @@ def checkEnvironment(): def buildByNameAndType(args): - buildNames = args.name if args.branch or args.name else ["config", "compile", "har"] + buildNames = args.name if args.branch or args.name else ["config", "compile"] buildTypes = args.type for buildType in SUPPORT_BUILD_TYPES: if not buildType in buildTypes: @@ -347,19 +392,22 @@ def buildByNameAndType(args): engineCompile(buildInfo) elif "zip" == buildName: zipFiles(buildInfo) + elif "zip2" == buildName: + zipFiles(buildInfo, True) else: logging.warning("Other name=%s" % buildName) -def main(): +def ohos_main(): parser = argparse.ArgumentParser() addParseParam(parser) args = parser.parse_args() checkEnvironment() updateCode(args) buildByNameAndType(args) - logging.info("main() finish.") + logging.info("ohos_main() finish.") return 0 -exit(main()) +if __name__ == "__main__": + exit(ohos_main()) diff --git a/attachment/repos/build.patch b/attachment/repos/build.patch new file mode 100644 index 0000000000..c3df91e35f --- /dev/null +++ b/attachment/repos/build.patch @@ -0,0 +1,870 @@ +diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn +index 4e62965..ea49a53 100644 +--- a/build/config/BUILD.gn ++++ b/build/config/BUILD.gn +@@ -146,6 +146,8 @@ config("default_libs") { + "dl", + "m", + ] ++ } else if (is_ohos) { ++ libs = [ "dl","hilog_ndk.z" ] + } else if (is_linux) { + libs = [ "dl" ] + } +diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn +index b8d0f47..d789796 100644 +--- a/build/config/BUILDCONFIG.gn ++++ b/build/config/BUILDCONFIG.gn +@@ -34,6 +34,7 @@ + # When writing build files, to do something only for the host: + # if (current_toolchain == host_toolchain) { ... + ++ + if (target_os == "") { + target_os = host_os + } +@@ -190,6 +191,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = false ++ is_ohos = false + is_mac = false + is_posix = false + is_win = true +@@ -198,6 +200,7 @@ if (current_os == "win") { + is_android = false + is_chromeos = false + is_fuchsia = false ++ is_ohos = false + is_fuchsia_host = false + is_ios = false + is_linux = false +@@ -212,6 +215,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = false ++ is_ohos = false + is_mac = false + is_posix = true + is_win = false +@@ -223,6 +227,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = true ++ is_ohos = false + is_mac = false + is_posix = true + is_win = false +@@ -237,6 +242,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = false ++ is_ohos = false + is_mac = false + is_posix = true + is_win = false +@@ -248,6 +254,19 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = true + is_linux = false ++ is_ohos = false ++ is_mac = false ++ is_posix = true ++ is_win = false ++ is_wasm = false ++} else if (current_os == "ohos") { ++ is_android = false ++ is_chromeos = false ++ is_fuchsia = false ++ is_fuchsia_host = false ++ is_ios = false ++ is_linux = false ++ is_ohos = true + is_mac = false + is_posix = true + is_win = false +@@ -259,6 +278,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = true ++ is_ohos = false + is_mac = false + is_posix = true + is_win = false +@@ -270,6 +290,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = false ++ is_ohos = false + is_mac = false + is_posix = true + is_win = false +@@ -281,6 +302,7 @@ if (current_os == "win") { + is_fuchsia_host = false + is_ios = false + is_linux = false ++ is_ohos = false + is_mac = false + is_posix = false + is_win = false +@@ -313,7 +335,7 @@ if (!is_clang && using_sanitizer) { + is_clang = true + } + +-use_flutter_cxx = is_clang && (is_linux || is_android || is_mac || is_ios) ++use_flutter_cxx = is_clang && (is_linux || is_android || is_mac || is_ios || is_ohos ) + + if (is_msan && !is_linux) { + assert(false, "Memory sanitizer is only available on Linux.") +@@ -365,7 +387,9 @@ if (is_posix) { + ] + } + +-if (is_linux) { ++if(is_ohos || (is_linux && host_os == "mac")){ ++ _native_compiler_configs += [ "//build/config/ohos:sdk" ] ++ }else if (is_linux) { + _native_compiler_configs += [ "//build/config/linux:sdk" ] + } else if (is_mac) { + _native_compiler_configs += [ "//build/config/mac:sdk" ] +@@ -510,8 +534,18 @@ shlib_toolchain = false + if (custom_toolchain != "") { + assert(custom_sysroot != "") + assert(custom_target_triple != "") +- host_toolchain = "//build/toolchain/linux:clang_$host_cpu" + set_default_toolchain("//build/toolchain/custom") ++ if (host_os == "linux") { ++ if (is_clang) { ++ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" ++ } else { ++ host_toolchain = "//build/toolchain/linux:$host_cpu" ++ } ++ } else if (host_os == "mac") { ++ host_toolchain = "//build/toolchain/mac:clang_$host_cpu" ++ } else { ++ assert(false, "Unknown host for ohos cross compile") ++ } + } else if (is_win) { + if (is_clang) { + host_toolchain = "//build/toolchain/win:clang_$host_cpu" +@@ -544,6 +578,21 @@ if (custom_toolchain != "") { + } else { + set_default_toolchain("//build/toolchain/android:$current_cpu") + } ++} else if (is_ohos) { ++ if (host_os == "linux") { ++ if (is_clang) { ++ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" ++ set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") ++ } else { ++ host_toolchain = "//build/toolchain/linux:$host_cpu" ++ set_default_toolchain("//build/toolchain/linux:$current_cpu") ++ } ++ } else if (host_os == "mac") { ++ host_toolchain = "//build/toolchain/mac:clang_$host_cpu" ++ set_default_toolchain("//build/toolchain/ohos:clang_$current_cpu") ++ } else { ++ assert(false, "Unknown host for ohos cross compile") ++ } + } else if (is_linux) { + if (is_clang) { + host_toolchain = "//build/toolchain/linux:clang_$host_cpu" +diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn +index ba20010..24a7d4e 100644 +--- a/build/config/compiler/BUILD.gn ++++ b/build/config/compiler/BUILD.gn +@@ -191,11 +191,18 @@ config("compiler") { + # CPU architecture. We may or may not be doing a cross compile now, so for + # simplicity we always explicitly set the architecture. + if (current_cpu == "x64") { +- cflags += [ +- "-m64", +- "-march=x86-64", +- ] ++ if ( is_ohos ){ ++ cflags += [ ++ "-m64", ++ ] ++ }else { ++ cflags += [ ++ "-m64", ++ "-march=x86-64", ++ ] ++ } + ldflags += [ "-m64" ] ++ + } else if (current_cpu == "x86") { + cflags += [ "-m32" ] + ldflags += [ "-m32" ] +@@ -315,7 +322,7 @@ config("compiler") { + + # Linux/Android common flags setup. + # --------------------------------- +- if (is_linux || is_android) { ++ if (is_linux || is_android || is_ohos ) { + cflags += [ + "-fPIC", + "-pipe", # Use pipes for communicating between sub-processes. Faster. +@@ -334,7 +341,16 @@ config("compiler") { + + # Linux-specific compiler flags setup. + # ------------------------------------ +- if (is_linux) { ++ if (is_ohos ) { ++ cflags += [ "-pthread" ] ++ ldflags += [ "-pthread" ] ++ ++ if (current_cpu == "arm64") { ++ cflags += [ "--target=aarch64-linux-ohos" ] ++ ldflags += [ "--target=aarch64-linux-ohos" ] ++ cflags += [ "-DBORINGSSL_CLANG_SUPPORTS_DOT_ARCH" ] ++ } ++ }else if (is_linux ) { + cflags += [ "-pthread" ] + ldflags += [ "-pthread" ] + +@@ -521,8 +537,8 @@ config("runtime_library") { + ldflags += [ "-nostdlib++" ] + } + include_dirs = [ +- "//third_party/libcxx/include", + "//third_party/libcxxabi/include", ++ "$custom_toolchain/include/c++/v1", + ] + } + +diff --git a/build/config/ohos/BUILD.gn b/build/config/ohos/BUILD.gn +new file mode 100644 +index 0000000..1d29b40 +--- /dev/null ++++ b/build/config/ohos/BUILD.gn +@@ -0,0 +1,29 @@ ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++import("//build/config/ohos/pkg_config.gni") ++import("//build/config/features.gni") ++import("//build/config/sysroot.gni") ++import("//build/config/ui.gni") ++ ++config("sdk") { ++ if (sysroot != "") { ++ cflags = [ "--sysroot=" + sysroot ] ++ ldflags = [ "--sysroot=" + sysroot ] ++ ++ # Need to get some linker flags out of the sysroot. ++ ldflags += [ exec_script("sysroot_ld_path.py", ++ [ ++ rebase_path("//build/ohos/sysroot_ld_path.sh", ++ root_build_dir), ++ sysroot, ++ ], ++ "value") ] ++ } ++} ++ ++config("fontconfig") { ++ libs = [ ] ++} ++ +diff --git a/build/config/ohos/pkg-config.py b/build/config/ohos/pkg-config.py +new file mode 100644 +index 0000000..b4a6aff +--- /dev/null ++++ b/build/config/ohos/pkg-config.py +@@ -0,0 +1,249 @@ ++#!/usr/bin/env python3 ++# ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++ ++ ++import json ++import os ++import subprocess ++import sys ++import re ++from optparse import OptionParser ++ ++# This script runs pkg-config, optionally filtering out some results, and ++# returns the result. ++# ++# The result will be [ , , , , ] ++# where each member is itself a list of strings. ++# ++# You can filter out matches using "-v " where all results from ++# pkgconfig matching the given regular expression will be ignored. You can ++# specify more than one regular expression my specifying "-v" more than once. ++# ++# You can specify a sysroot using "-s " where sysroot is the absolute ++# system path to the sysroot used for compiling. This script will attempt to ++# generate correct paths for the sysroot. ++# ++# When using a sysroot, you must also specify the architecture via ++# "-a " where arch is either "x86" or "x64". ++# ++# CrOS systemroots place pkgconfig files at /usr/share/pkgconfig ++# and one of /usr/lib/pkgconfig or /usr/lib64/pkgconfig ++# depending on whether the systemroot is for a 32 or 64 bit architecture. They ++# specify the 'lib' or 'lib64' of the pkgconfig path by defining the ++# 'system_libdir' variable in the args.gn file. pkg_config.gni communicates this ++# variable to this script with the "--system_libdir " flag. If no ++# flag is provided, then pkgconfig files are assumed to come from ++# /usr/lib/pkgconfig. ++# ++# Additionally, you can specify the option --atleast-version. This will skip ++# the normal outputting of a dictionary and instead print true or false, ++# depending on the return value of pkg-config for the given package. ++ ++ ++def SetConfigPath(options): ++ """Set the PKG_CONFIG_LIBDIR environment variable. ++ ++ This takes into account any sysroot and architecture specification from the ++ options on the given command line. ++ """ ++ ++ sysroot = options.sysroot ++ assert sysroot ++ ++ # Compute the library path name based on the architecture. ++ arch = options.arch ++ if sysroot and not arch: ++ print("You must specify an architecture via -a if using a sysroot.") ++ sys.exit(1) ++ ++ libdir = sysroot + '/usr/' + options.system_libdir + '/pkgconfig' ++ libdir += ':' + sysroot + '/usr/share/pkgconfig' ++ os.environ['PKG_CONFIG_LIBDIR'] = libdir ++ return libdir ++ ++ ++def GetPkgConfigPrefixToStrip(options, args): ++ """Returns the prefix from pkg-config where packages are installed. ++ ++ This returned prefix is the one that should be stripped from the beginning of ++ directory names to take into account sysroots. ++ """ ++ # Some sysroots, like the Chromium OS ones, may generate paths that are not ++ # relative to the sysroot. For example, ++ # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all ++ # paths relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) ++ # instead of relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). ++ # To support this correctly, it's necessary to extract the prefix to strip ++ # from pkg-config's |prefix| variable. ++ prefix = subprocess.check_output([options.pkg_config, ++ "--variable=prefix"] + args, env=os.environ).decode('utf-8') ++ if prefix[-4] == '/usr': ++ return prefix[4:] ++ return prefix ++ ++ ++def MatchesAnyRegexp(flag, list_of_regexps): ++ """Returns true if the first argument matches any regular expression in the ++ given list.""" ++ for regexp in list_of_regexps: ++ if regexp.search(flag) != None: ++ return True ++ return False ++ ++ ++def RewritePath(path, strip_prefix, sysroot): ++ """Rewrites a path by stripping the prefix and prepending the sysroot.""" ++ if os.path.isabs(path) and not path.startswith(sysroot): ++ if path.startswith(strip_prefix): ++ path = path[len(strip_prefix):] ++ path = path.lstrip('/') ++ return os.path.join(sysroot, path) ++ else: ++ return path ++ ++ ++def main(): ++ # If this is run on non-Linux platforms, just return nothing and indicate ++ # success. This allows us to "kind of emulate" a Linux build from other ++ # platforms. ++ if "linux" not in sys.platform: ++ print("[[],[],[],[],[]]") ++ return 0 ++ ++ parser = OptionParser() ++ parser.add_option('-d', '--debug', action='store_true') ++ parser.add_option('-p', action='store', dest='pkg_config', type='string', ++ default='pkg-config') ++ parser.add_option('-v', action='append', dest='strip_out', type='string') ++ parser.add_option('-s', action='store', dest='sysroot', type='string') ++ parser.add_option('-a', action='store', dest='arch', type='string') ++ parser.add_option('--system_libdir', action='store', dest='system_libdir', ++ type='string', default='lib') ++ parser.add_option('--atleast-version', action='store', ++ dest='atleast_version', type='string') ++ parser.add_option('--libdir', action='store_true', dest='libdir') ++ parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir') ++ parser.add_option('--version-as-components', action='store_true', ++ dest='version_as_components') ++ (options, args) = parser.parse_args() ++ ++ # Make a list of regular expressions to strip out. ++ strip_out = [] ++ if options.strip_out != None: ++ for regexp in options.strip_out: ++ strip_out.append(re.compile(regexp)) ++ ++ if options.sysroot: ++ libdir = SetConfigPath(options) ++ if options.debug: ++ sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir) ++ prefix = GetPkgConfigPrefixToStrip(options, args) ++ else: ++ prefix = '' ++ ++ if options.atleast_version: ++ # When asking for the return value, just run pkg-config and print the return ++ # value, no need to do other work. ++ if not subprocess.call([options.pkg_config, ++ "--atleast-version=" + options.atleast_version] + ++ args): ++ print("true") ++ else: ++ print("false") ++ return 0 ++ ++ if options.version_as_components: ++ cmd = [options.pkg_config, "--modversion"] + args ++ try: ++ version_string = subprocess.check_output(cmd).decode('utf-8') ++ except: ++ sys.stderr.write('Error from pkg-config.\n') ++ return 1 ++ print(json.dumps(list(map(int, version_string.strip().split("."))))) ++ return 0 ++ ++ ++ if options.libdir: ++ cmd = [options.pkg_config, "--variable=libdir"] + args ++ if options.debug: ++ sys.stderr.write('Running: %s\n' % cmd) ++ try: ++ libdir = subprocess.check_output(cmd).decode('utf-8') ++ except: ++ print("Error from pkg-config.") ++ return 1 ++ sys.stdout.write(libdir.strip()) ++ return 0 ++ ++ if options.dridriverdir: ++ cmd = [options.pkg_config, "--variable=dridriverdir"] + args ++ if options.debug: ++ sys.stderr.write('Running: %s\n' % cmd) ++ try: ++ dridriverdir = subprocess.check_output(cmd).decode('utf-8') ++ except: ++ print("Error from pkg-config.") ++ return 1 ++ sys.stdout.write(dridriverdir.strip()) ++ return ++ ++ cmd = [options.pkg_config, "--cflags", "--libs"] + args ++ if options.debug: ++ sys.stderr.write('Running: %s\n' % ' '.join(cmd)) ++ ++ try: ++ flag_string = subprocess.check_output(cmd).decode('utf-8') ++ except: ++ sys.stderr.write('Could not run pkg-config.\n') ++ return 1 ++ ++ # For now just split on spaces to get the args out. This will break if ++ # pkgconfig returns quoted things with spaces in them, but that doesn't seem ++ # to happen in practice. ++ all_flags = flag_string.strip().split(' ') ++ ++ ++ sysroot = options.sysroot ++ if not sysroot: ++ sysroot = '' ++ ++ includes = [] ++ cflags = [] ++ libs = [] ++ lib_dirs = [] ++ ++ for flag in all_flags[:]: ++ if len(flag) == 0 or MatchesAnyRegexp(flag, strip_out): ++ continue; ++ ++ if flag[:2] == '-l': ++ libs.append(RewritePath(flag[2:], prefix, sysroot)) ++ elif flag[:2] == '-L': ++ lib_dirs.append(RewritePath(flag[2:], prefix, sysroot)) ++ elif flag[:2] == '-I': ++ includes.append(RewritePath(flag[2:], prefix, sysroot)) ++ elif flag[:3] == '-Wl': ++ # Don't allow libraries to control ld flags. These should be specified ++ # only in build files. ++ pass ++ elif flag == '-pthread': ++ # Many libs specify "-pthread" which we don't need since we always include ++ # this anyway. Removing it here prevents a bunch of duplicate inclusions ++ # on the command line. ++ pass ++ else: ++ cflags.append(flag) ++ ++ # Output a GN array, the first one is the cflags, the second are the libs. The ++ # JSON formatter prints GN compatible lists when everything is a list of ++ # strings. ++ print(json.dumps([includes, cflags, libs, lib_dirs])) ++ return 0 ++ ++ ++if __name__ == '__main__': ++ sys.exit(main()) +diff --git a/build/config/ohos/pkg_config.gni b/build/config/ohos/pkg_config.gni +new file mode 100644 +index 0000000..f970ac1 +--- /dev/null ++++ b/build/config/ohos/pkg_config.gni +@@ -0,0 +1,131 @@ ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++import("//build/config/sysroot.gni") ++ ++# Defines a config specifying the result of running pkg-config for the given ++# packages. Put the package names you want to query in the "packages" variable ++# inside the template invocation. ++# ++# You can also add defines via the "defines" variable. This can be useful to ++# add this to the config to pass defines that the library expects to get by ++# users of its headers. ++# ++# Example: ++# pkg_config("mything") { ++# packages = [ "mything1", "mything2" ] ++# defines = [ "ENABLE_AWESOME" ] ++# } ++# ++# You can also use "extra args" to filter out results (see pkg-config.py): ++# extra_args = [ "-v, "foo" ] ++# To ignore libs and ldflags (only cflags/defines will be set, which is useful ++# when doing manual dynamic linking), set: ++# ignore_libs = true ++ ++declare_args() { ++ # A pkg-config wrapper to call instead of trying to find and call the right ++ # pkg-config directly. Wrappers like this are common in cross-compilation ++ # environments. ++ # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on ++ # the sysroot mechanism to find the right .pc files. ++ pkg_config = "" ++ ++ # A optional pkg-config wrapper to use for tools built on the host. ++ host_pkg_config = "" ++ ++ # CrOS systemroots place pkgconfig files at /usr/share/pkgconfig ++ # and one of /usr/lib/pkgconfig or /usr/lib64/pkgconfig ++ # depending on whether the systemroot is for a 32 or 64 bit architecture. ++ # ++ # When build under GYP, CrOS board builds specify the 'system_libdir' variable ++ # as part of the GYP_DEFINES provided by the CrOS emerge build or simple ++ # chrome build scheme. This variable permits controlling this for GN builds ++ # in similar fashion by setting the `system_libdir` variable in the build's ++ # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture. ++ system_libdir = "lib" ++} ++ ++pkg_config_script = "//build/config/ohos/pkg-config.py" ++ ++# Define the args we pass to the pkg-config script for other build files that ++# need to invoke it manually. ++pkg_config_args = [] ++ ++if (sysroot != "") { ++ # Pass the sysroot if we're using one (it requires the CPU arch also). ++ pkg_config_args += [ ++ "-s", ++ rebase_path(sysroot), ++ "-a", ++ current_cpu, ++ ] ++} ++ ++if (pkg_config != "") { ++ pkg_config_args += [ ++ "-p", ++ pkg_config, ++ ] ++} ++ ++# Only use the custom libdir when building with the target sysroot. ++if (target_sysroot != "" && sysroot == target_sysroot) { ++ pkg_config_args += [ ++ "--system_libdir", ++ system_libdir, ++ ] ++} ++ ++if (host_pkg_config != "") { ++ host_pkg_config_args = [ ++ "-p", ++ host_pkg_config, ++ ] ++} else { ++ host_pkg_config_args = pkg_config_args ++} ++ ++template("pkg_config") { ++ assert(defined(invoker.packages), ++ "Variable |packages| must be defined to be a list in pkg_config.") ++ config(target_name) { ++ if (host_toolchain == current_toolchain) { ++ args = host_pkg_config_args + invoker.packages ++ } else { ++ args = pkg_config_args + invoker.packages ++ } ++ if (defined(invoker.extra_args)) { ++ args += invoker.extra_args ++ } ++ ++ pkgresult = exec_script(pkg_config_script, args, "value") ++ cflags = pkgresult[1] ++ ++ foreach(include, pkgresult[0]) { ++ if (sysroot != "") { ++ # We want the system include paths to use -isystem instead of -I to ++ # suppress warnings in those headers. ++ include_relativized = rebase_path(include, root_build_dir) ++ cflags += [ "-isystem$include_relativized" ] ++ } else { ++ cflags += [ "-I$include" ] ++ } ++ } ++ ++ if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { ++ libs = pkgresult[2] ++ lib_dirs = pkgresult[3] ++ } ++ ++ forward_variables_from(invoker, ++ [ ++ "defines", ++ "visibility", ++ ]) ++ } ++} ++ ++OHOS_NDK_ROOT = target_sysroot ++OHOS_NDK_LIB = "$OHOS_NDK_ROOT/usr/aarch64-linux-ohos" +diff --git a/build/config/ohos/sysroot_ld_path.py b/build/config/ohos/sysroot_ld_path.py +new file mode 100644 +index 0000000..2cde6e2 +--- /dev/null ++++ b/build/config/ohos/sysroot_ld_path.py +@@ -0,0 +1,21 @@ ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++# This file takes two arguments, the relative location of the shell script that ++# does the checking, and the name of the sysroot. ++ ++# TODO(brettw) the build/linux/sysroot_ld_path.sh script should be rewritten in ++# Python in this file. ++ ++import subprocess ++import sys ++ ++if len(sys.argv) != 3: ++ print("Need two arguments") ++ sys.exit(1) ++ ++result = subprocess.check_output([sys.argv[1], sys.argv[2]], ++ universal_newlines=True).strip() ++ ++print('"%s"' % result) +diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni +index 7987e51..cd7b060 100644 +--- a/build/config/sysroot.gni ++++ b/build/config/sysroot.gni +@@ -22,8 +22,10 @@ if (current_toolchain == default_toolchain && target_sysroot != "") { + } else if (is_android) { + import("//build/config/android/config.gni") + sysroot = rebase_path("$llvm_android_toolchain_root/sysroot") ++} else if (is_ohos) { ++ sysroot = target_sysroot + } else if (is_linux && !is_chromeos) { +- if (use_default_linux_sysroot && !is_fuchsia) { ++ if (use_default_linux_sysroot) { + if (current_cpu == "x64") { + sysroot = rebase_path("//build/linux/debian_sid_amd64-sysroot") + } else { +diff --git a/build/ohos/sysroot_ld_path.sh b/build/ohos/sysroot_ld_path.sh +new file mode 100755 +index 0000000..4b8bf73 +--- /dev/null ++++ b/build/ohos/sysroot_ld_path.sh +@@ -0,0 +1,100 @@ ++#!/bin/sh ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++# Reads etc/ld.so.conf and/or etc/ld.so.conf.d/*.conf and returns the ++# appropriate linker flags. ++# ++# sysroot_ld_path.sh /abspath/to/sysroot ++# ++ ++log_error_and_exit() { ++ echo $0: $@ ++ exit 1 ++} ++ ++process_entry() { ++ if [ -z "$1" ] || [ -z "$2" ]; then ++ log_error_and_exit "bad arguments to process_entry()" ++ fi ++ local root="$1" ++ local localpath="$2" ++ ++ echo $localpath | grep -qs '^/' ++ if [ $? -ne 0 ]; then ++ log_error_and_exit $localpath does not start with / ++ fi ++ local entry="$root$localpath" ++ echo -L$entry ++ echo -Wl,-rpath-link=$entry ++} ++ ++process_ld_so_conf() { ++ if [ -z "$1" ] || [ -z "$2" ]; then ++ log_error_and_exit "bad arguments to process_ld_so_conf()" ++ fi ++ local root="$1" ++ local ld_so_conf="$2" ++ ++ # ld.so.conf may include relative include paths. pushd is a bashism. ++ local saved_pwd=$(pwd) ++ cd $(dirname "$ld_so_conf") ++ ++ cat "$ld_so_conf" | \ ++ while read ENTRY; do ++ echo "$ENTRY" | grep -qs ^include ++ if [ $? -eq 0 ]; then ++ local included_files=$(echo "$ENTRY" | sed 's/^include //') ++ echo "$included_files" | grep -qs ^/ ++ if [ $? -eq 0 ]; then ++ if ls $root$included_files >/dev/null 2>&1 ; then ++ for inc_file in $root$included_files; do ++ process_ld_so_conf "$root" "$inc_file" ++ done ++ fi ++ else ++ if ls $(pwd)/$included_files >/dev/null 2>&1 ; then ++ for inc_file in $(pwd)/$included_files; do ++ process_ld_so_conf "$root" "$inc_file" ++ done ++ fi ++ fi ++ continue ++ fi ++ ++ echo "$ENTRY" | grep -qs ^/ ++ if [ $? -eq 0 ]; then ++ process_entry "$root" "$ENTRY" ++ fi ++ done ++ ++ # popd is a bashism ++ cd "$saved_pwd" ++} ++ ++# Main ++ ++if [ $# -ne 1 ]; then ++ echo Usage $0 /abspath/to/sysroot ++ exit 1 ++fi ++ ++echo $1 | grep -qs ' ' ++if [ $? -eq 0 ]; then ++ log_error_and_exit $1 contains whitespace. ++fi ++ ++LD_SO_CONF="$1/etc/ld.so.conf" ++LD_SO_CONF_D="$1/etc/ld.so.conf.d" ++ ++if [ -e "$LD_SO_CONF" ]; then ++ process_ld_so_conf "$1" "$LD_SO_CONF" | xargs echo ++elif [ -e "$LD_SO_CONF_D" ]; then ++ find "$LD_SO_CONF_D" -maxdepth 1 -name '*.conf' -print -quit > /dev/null ++ if [ $? -eq 0 ]; then ++ for entry in $LD_SO_CONF_D/*.conf; do ++ process_ld_so_conf "$1" "$entry" ++ done | xargs echo ++ fi ++fi +diff --git a/build/secondary/third_party/glfw/BUILD.gn b/build/secondary/third_party/glfw/BUILD.gn +index cad6cbc..c17950b 100644 +--- a/build/secondary/third_party/glfw/BUILD.gn ++++ b/build/secondary/third_party/glfw/BUILD.gn +@@ -47,6 +47,34 @@ source_set("glfw") { + ] + + defines = [ "_GLFW_WIN32" ] ++ } else if (is_ohos) { ++ sources += [ ++ "$_checkout_dir/src/glx_context.c", ++ "$_checkout_dir/src/glx_context.h", ++ "$_checkout_dir/src/posix_time.c", ++ "$_checkout_dir/src/posix_time.h", ++ "$_checkout_dir/src/posix_thread.c", ++ "$_checkout_dir/src/posix_thread.h", ++ "$_checkout_dir/src/x11_init.c", ++ "$_checkout_dir/src/x11_monitor.c", ++ "$_checkout_dir/src/x11_platform.h", ++ "$_checkout_dir/src/x11_window.c", ++ "$_checkout_dir/src/xkb_unicode.c", ++ "$_checkout_dir/src/xkb_unicode.h", ++ ] ++ ++ defines = [ ++ "_GLFW_X11", ++ "_GLFW_HAS_XF86VM", ++ ] ++ ++ libs = [ ++ "X11", ++ "Xcursor", ++ "Xinerama", ++ "Xrandr", ++ "Xxf86vm", ++ ] + } else if (is_linux) { + sources += [ + "$_checkout_dir/src/glx_context.c", +diff --git a/build/toolchain/custom/BUILD.gn b/build/toolchain/custom/BUILD.gn +index 65b1623..a89742a 100644 +--- a/build/toolchain/custom/BUILD.gn ++++ b/build/toolchain/custom/BUILD.gn +@@ -12,11 +12,11 @@ toolchain("custom") { + # these values in our scope. + cc = "${toolchain_bin}/clang" + cxx = "${toolchain_bin}/clang++" +- ar = "${toolchain_bin}/${custom_target_triple}-ar" ++ ar = "${toolchain_bin}/llvm-ar" + ld = "${toolchain_bin}/clang++" +- readelf = "${toolchain_bin}/${custom_target_triple}-readelf" +- nm = "${toolchain_bin}/${custom_target_triple}-nm" +- strip = "${toolchain_bin}/${custom_target_triple}-strip" ++ readelf = "${toolchain_bin}/llvm-readelf" ++ nm = "${toolchain_bin}/llvm-nm" ++ strip = "${toolchain_bin}/llvm-strip" + + target_triple_flags = "--target=${custom_target_triple}" + sysroot_flags = "--sysroot ${custom_sysroot}" diff --git a/attachment/scripts/config.json b/attachment/scripts/config.json index 3bca2b5b1d..a1bef3cb13 100644 --- a/attachment/scripts/config.json +++ b/attachment/scripts/config.json @@ -41,42 +41,11 @@ "file_path": "../../flutter/attachment/repos/angle.patch" }, { - "name": "libcxx", - "target": "./src/third_party/libcxx", - "type": "patch", - "file_path": "../../flutter/attachment/repos/libcxx.bin" - }, - { - "name": "build0", - "target": "./src/build", - "type": "patch", - "file_path": "../flutter/attachment/repos/build0.bin" - }, - { - "name": "build1", + "name": "build", "target": "./src/build", "type": "patch", - "file_path": "../flutter/attachment/repos/build1.bin" + "file_path": "../flutter/attachment/repos/build.patch" }, - { - "name": "build2", - "target": "./src/build", - "type": "patch", - "file_path": "../flutter/attachment/repos/build2.bin" - }, - { - "name": "build3", - "target": "./src/build", - "type": "patch", - "file_path": "../flutter/attachment/repos/build3.bin" - }, - { - "name": "build4", - "target": "./src/build", - "type": "patch", - "file_path": "../flutter/attachment/repos/build4.bin" - } - , { "name": "zlib", "target": "./src/third_party/zlib", diff --git a/attachment/scripts/config_pre.json b/attachment/scripts/config_pre.json index 2f42833073..ff6eb88366 100644 --- a/attachment/scripts/config_pre.json +++ b/attachment/scripts/config_pre.json @@ -41,12 +41,11 @@ "file_path": "../../flutter/attachment/repos/angle.patch" }, { - "name": "libcxx", - "target": "./src/third_party/libcxx", + "name": "build", + "target": "./src/build", "type": "patch", - "file_path": "../../flutter/attachment/repos/libcxx.bin" - } - , + "file_path": "../flutter/attachment/repos/build.patch" + }, { "name": "zlib", "target": "./src/third_party/zlib", diff --git a/attachment/scripts/ohos_setup.py b/attachment/scripts/ohos_setup.py index b6e1b53101..4bb80b246b 100644 --- a/attachment/scripts/ohos_setup.py +++ b/attachment/scripts/ohos_setup.py @@ -85,15 +85,16 @@ def doTask(task, log=False): pass -def parse_config(config_file="{}/scripts/config.json".format(ROOT)): +def parse_config(config_file="{}/scripts/config.json".format(ROOT), useStash=True): log = False if (len(sys.argv) > 1): if(sys.argv[1] == '-v'): log = True with open(config_file) as json_file: data = json.load(json_file) - for task in data: - stashChanges(task, log) + if useStash: + for task in data: + stashChanges(task, log) for task in data: doTask(task, log) diff --git a/attachment/scripts/ohos_setup_pre.py b/attachment/scripts/ohos_setup_pre.py index f1239d5f6a..9d13a27fac 100644 --- a/attachment/scripts/ohos_setup_pre.py +++ b/attachment/scripts/ohos_setup_pre.py @@ -15,4 +15,4 @@ import ohos_setup # 在预编译脚本中使用的配置 -ohos_setup.parse_config("{}/scripts/config_pre.json".format(ohos_setup.ROOT)) +ohos_setup.parse_config("{}/scripts/config_pre.json".format(ohos_setup.ROOT), useStash=False) diff --git a/fml/platform/ohos/message_loop_ohos.cc b/fml/platform/ohos/message_loop_ohos.cc index c91a061a63..ed2d44d2a6 100644 --- a/fml/platform/ohos/message_loop_ohos.cc +++ b/fml/platform/ohos/message_loop_ohos.cc @@ -66,7 +66,8 @@ void MessageLoopOhos::Run() { // |fml::MessageLoopImpl| void MessageLoopOhos::Terminate() { running_ = false; - WakeUp(fml::TimePoint::Now()); + // WakeUp(fml::TimePoint::Now()); + uv_poll_stop(&poll_handle_); } // |fml::MessageLoopImpl| diff --git a/shell/platform/ohos/flutter_embedding/build-profile.json5 b/shell/platform/ohos/flutter_embedding/build-profile.json5 index dc99061b4d..ae4533ee39 100755 --- a/shell/platform/ohos/flutter_embedding/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/build-profile.json5 @@ -32,4 +32,4 @@ "srcPath": "./flutter" } ] -} \ No newline at end of file +} diff --git a/shell/platform/ohos/flutter_embedding/flutter/index.ets b/shell/platform/ohos/flutter_embedding/flutter/index.ets index 3c96b70703..c146ae457d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/index.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/index.ets @@ -13,6 +13,179 @@ * limitations under the License. */ -export { FlutterAbility } from './src/main/ets/embedding/ohos/FlutterAbility' +import FlutterInjector from './src/main/ets/FlutterInjector'; +import FlutterPluginRegistry from './src/main/ets/app/FlutterPluginRegistry'; +import FlutterComponent from './src/main/ets/component/FlutterComponent'; +import FlutterEngine from './src/main/ets/embedding/engine/FlutterEngine'; +import FlutterEngineCache from './src/main/ets/embedding/engine/FlutterEngineCache'; +import FlutterEngineConnectionRegistry from './src/main/ets/embedding/engine/FlutterEngineConnectionRegistry'; +import FlutterEngineGroup from './src/main/ets/embedding/engine/FlutterEngineGroup'; +import FlutterEngineGroupCache from './src/main/ets/embedding/engine/FlutterEngineGroupCache'; +import FlutterNapi from './src/main/ets/embedding/engine/FlutterNapi'; +import { FlutterOverlaySurface } from './src/main/ets/embedding/engine/FlutterOverlaySurface'; +import FlutterShellArgs from './src/main/ets/embedding/engine/FlutterShellArgs'; +import DartExecutor from './src/main/ets/embedding/engine/dart/DartExecutor'; +import { DartMessenger } from './src/main/ets/embedding/engine/dart/DartMessenger'; +import { PlatformMessageHandler } from './src/main/ets/embedding/engine/dart/PlatformMessageHandler'; +import ApplicationInfoLoader from './src/main/ets/embedding/engine/loader/ApplicationInfoLoader'; +import FlutterApplicationInfo from './src/main/ets/embedding/engine/loader/FlutterApplicationInfo'; +import FlutterLoader from './src/main/ets/embedding/engine/loader/FlutterLoader'; +import { FlutterMutatorView } from './src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView'; +import { FlutterMutatorsStack } from './src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack'; +import { FlutterPlugin } from './src/main/ets/embedding/engine/plugins/FlutterPlugin'; +import AbilityAware from './src/main/ets/embedding/engine/plugins/ability/AbilityAware'; +import AbilityControlSurface from './src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface'; +import { AbilityPluginBinding } from './src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding'; +import GeneratedPluginRegister from './src/main/ets/embedding/engine/plugins/util/GeneratedPluginRegister'; +import { FlutterUiDisplayListener } from './src/main/ets/embedding/engine/renderer/FlutterUiDisplayListener'; +import AccessibilityChannel from './src/main/ets/embedding/engine/systemchannels/AccessibilityChannel'; +import KeyEventChannel from './src/main/ets/embedding/engine/systemchannels/KeyEventChannel'; +import LifecycleChannel from './src/main/ets/embedding/engine/systemchannels/LifecycleChannel'; +import LocalizationChannel from './src/main/ets/embedding/engine/systemchannels/LocalizationChannel'; +import MouseCursorChannel from './src/main/ets/embedding/engine/systemchannels/MouseCursorChannel'; +import NavigationChannel from './src/main/ets/embedding/engine/systemchannels/NavigationChannel'; +import PlatformChannel from './src/main/ets/embedding/engine/systemchannels/PlatformChannel'; +import PlatformViewsChannel from './src/main/ets/embedding/engine/systemchannels/PlatformViewsChannel'; +import RestorationChannel from './src/main/ets/embedding/engine/systemchannels/RestorationChannel'; +import SettingsChannel from './src/main/ets/embedding/engine/systemchannels/SettingsChannel'; +import SystemChannel from './src/main/ets/embedding/engine/systemchannels/SystemChannel'; +import TestChannel from './src/main/ets/embedding/engine/systemchannels/TestChannel'; +import TextInputChannel from './src/main/ets/embedding/engine/systemchannels/TextInputChannel'; +import ExclusiveAppComponent from './src/main/ets/embedding/ohos/ExclusiveAppComponent'; +import { FlutterAbility } from './src/main/ets/embedding/ohos/FlutterAbility'; +import { FlutterAbilityAndEntryDelegate } from './src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate'; +import FlutterAbilityLaunchConfigs from './src/main/ets/embedding/ohos/FlutterAbilityLaunchConfigs'; +import FlutterEngineConfigurator from './src/main/ets/embedding/ohos/FlutterEngineConfigurator'; +import FlutterEngineProvider from './src/main/ets/embedding/ohos/FlutterEngineProvider'; +import FlutterEntry from './src/main/ets/embedding/ohos/FlutterEntry'; +import FlutterManager from './src/main/ets/embedding/ohos/FlutterManager'; +import { FlutterPage } from './src/main/ets/embedding/ohos/FlutterPage'; +import KeyboardManager from './src/main/ets/embedding/ohos/KeyboardManager'; +import OhosTouchProcessor from './src/main/ets/embedding/ohos/OhosTouchProcessor'; +import Settings from './src/main/ets/embedding/ohos/Settings'; +import { TouchEventTracker } from './src/main/ets/embedding/ohos/TouchEventTracker'; +import WindowInfoRepositoryCallbackAdapterWrapper + from './src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper'; +import PlatformPlugin from './src/main/ets/plugin/PlatformPlugin'; +import BasicMessageChannel from './src/main/ets/plugin/common/BasicMessageChannel'; +import BinaryCodec from './src/main/ets/plugin/common/BinaryCodec'; +import { BinaryMessenger } from './src/main/ets/plugin/common/BinaryMessenger'; +import EventChannel from './src/main/ets/plugin/common/EventChannel'; +import FlutterException from './src/main/ets/plugin/common/FlutterException'; +import JSONMessageCodec from './src/main/ets/plugin/common/JSONMessageCodec'; +import JSONMethodCodec from './src/main/ets/plugin/common/JSONMethodCodec'; +import MessageCodec from './src/main/ets/plugin/common/MessageCodec'; +import MethodCall from './src/main/ets/plugin/common/MethodCall'; +import MethodChannel from './src/main/ets/plugin/common/MethodChannel'; +import MethodCodec from './src/main/ets/plugin/common/MethodCodec'; +import StandardMessageCodec from './src/main/ets/plugin/common/StandardMessageCodec'; +import StandardMethodCodec from './src/main/ets/plugin/common/StandardMethodCodec'; +import StringCodec from './src/main/ets/plugin/common/StringCodec'; +import { ListenableEditingState } from './src/main/ets/plugin/editing/ListenableEditingState'; +import { TextEditingDelta } from './src/main/ets/plugin/editing/TextEditingDelta'; +import TextInputPlugin from './src/main/ets/plugin/editing/TextInputPlugin'; +import LocalizationPlugin from './src/main/ets/plugin/localization/LocalizationPlugin'; +import MouseCursorPlugin from './src/main/ets/plugin/mouse/MouseCursorPlugin'; +import { AccessibilityEventsDelegate } from './src/main/ets/plugin/platform/AccessibilityEventsDelegate'; +import { PlatformOverlayView } from './src/main/ets/plugin/platform/PlatformOverlayView'; +import PlatformView from './src/main/ets/plugin/platform/PlatformView'; +import PlatformViewFactory from './src/main/ets/plugin/platform/PlatformViewFactory'; +import PlatformViewRegistry from './src/main/ets/plugin/platform/PlatformViewRegistry'; +import PlatformViewRegistryImpl from './src/main/ets/plugin/platform/PlatformViewRegistryImpl'; +import { PlatformViewWrapper } from './src/main/ets/plugin/platform/PlatformViewWrapper'; +import { PlatformViewsAccessibilityDelegate } from './src/main/ets/plugin/platform/PlatformViewsAccessibilityDelegate'; +import PlatformViewsController from './src/main/ets/plugin/platform/PlatformViewsController'; +import AccessibilityBridge from './src/main/ets/view/AccessibilityBridge'; +import { FlutterCallbackInformation } from './src/main/ets/view/FlutterCallbackInformation'; +import FlutterRunArguments from './src/main/ets/view/FlutterRunArguments'; +import { FlutterView } from './src/main/ets/view/FlutterView'; +import { TextureRegistry } from './src/main/ets/view/TextureRegistry'; -export { FlutterPage } from './src/main/ets/embedding/ohos/FlutterPage' +export { + FlutterInjector, + FlutterPluginRegistry, + FlutterComponent, + FlutterEngine, + FlutterEngineCache, + FlutterEngineConnectionRegistry, + FlutterEngineGroup, + FlutterEngineGroupCache, + FlutterNapi, + FlutterOverlaySurface, + FlutterShellArgs, + DartExecutor, + DartMessenger, + PlatformMessageHandler, + ApplicationInfoLoader, + FlutterApplicationInfo, + FlutterLoader, + FlutterMutatorView, + FlutterMutatorsStack, + FlutterPlugin, + AbilityAware, + AbilityControlSurface, + AbilityPluginBinding, + GeneratedPluginRegister, + FlutterUiDisplayListener, + AccessibilityChannel, + KeyEventChannel, + LifecycleChannel, + LocalizationChannel, + MouseCursorChannel, + NavigationChannel, + PlatformChannel, + PlatformViewsChannel, + RestorationChannel, + SettingsChannel, + SystemChannel, + TestChannel, + TextInputChannel, + ExclusiveAppComponent, + FlutterAbility, + FlutterAbilityAndEntryDelegate, + FlutterAbilityLaunchConfigs, + FlutterEngineConfigurator, + FlutterEngineProvider, + FlutterEntry, + FlutterManager, + FlutterPage, + KeyboardManager, + OhosTouchProcessor, + Settings, + TouchEventTracker, + WindowInfoRepositoryCallbackAdapterWrapper, + PlatformPlugin, + BasicMessageChannel, + BinaryCodec, + BinaryMessenger, + EventChannel, + FlutterException, + JSONMessageCodec, + JSONMethodCodec, + MessageCodec, + MethodCall, + MethodChannel, + MethodCodec, + StandardMessageCodec, + StandardMethodCodec, + StringCodec, + ListenableEditingState, + TextEditingDelta, + TextInputPlugin, + LocalizationPlugin, + MouseCursorPlugin, + AccessibilityEventsDelegate, + PlatformOverlayView, + PlatformView, + PlatformViewFactory, + PlatformViewRegistry, + PlatformViewRegistryImpl, + PlatformViewWrapper, + PlatformViewsAccessibilityDelegate, + PlatformViewsController, + AccessibilityBridge, + FlutterCallbackInformation, + FlutterRunArguments, + FlutterView, + TextureRegistry, +} 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 4ef5e68f11..6cb09bd9f0 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 @@ -52,7 +52,8 @@ export const nativeSpawn: ( entrypointFunctionName: string, pathToEntrypointFunction: string, initialRoute: string, - entrypointArgs: Array + entrypointArgs: Array, + napi: FlutterNapi ) => number; export const nativeRunBundleAndSnapshotFromLibrary: ( @@ -88,6 +89,18 @@ export const nativeImageDecodeCallback: (width: number, height: number, imageGen export const nativeGetSystemLanguages: (nativeShellHolderId: number, languages: Array) => void; +export const nativeXComponentAttachFlutterEngine: (xcomponentId: number, nativeShellHolderId: number) => void; + +export const nativeXComponentDetachFlutterEngine: (xcomponentId: number, nativeShellHolderId: number) => void; + +/** + * Detaches flutterNapi和engine之间的关联 + * 这个方法执行前提是flutterNapi已经和engine关联 + */ +export const nativeDestroy: ( + nativeShellHolderId: number +) => void; + export const nativeInitNativeImage: (nativeShellHolderId: number, textureId: number, aImage: image.Image) => void; export const nativeUnregisterTexture: (nativeShellHolderId: number, textureId: number) => void; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index_actual.d.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index_actual.d.ets index afab18030d..d3f5c0a65d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index_actual.d.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index_actual.d.ets @@ -73,7 +73,8 @@ export const nativeSpawn: ( entrypointFunctionName: string, pathToEntrypointFunction: string, initialRoute: string, - entrypointArgs: Array + entrypointArgs: Array, + napi: FlutterNapi ) => number; /** diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets index 4e6f2f8b0e..f7ac83e3a0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets @@ -23,7 +23,6 @@ export default class FlutterInjector { private static instance: FlutterInjector; private flutterLoader: FlutterLoader; - private flutterNapi: FlutterNapi; static getInstance(): FlutterInjector { if (FlutterInjector.instance == null) { @@ -35,8 +34,7 @@ export default class FlutterInjector { * 初始化 */ private constructor() { - this.flutterNapi = new FlutterNapi(); - this.flutterLoader = new FlutterLoader(this.flutterNapi); + this.flutterLoader = new FlutterLoader(this.getFlutterNapi()); } getFlutterLoader(): FlutterLoader { @@ -44,6 +42,6 @@ export default class FlutterInjector { } getFlutterNapi(): FlutterNapi { - return this.flutterNapi; + return new FlutterNapi(); } } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets index 2a2a44964d..4eabe6ad35 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets @@ -18,11 +18,13 @@ import PlatformViewController from '../plugin/platform/PlatformViewsController' export default class FlutterPluginRegistry { private mPlatformViewsController: PlatformViewController; - private mFlutterView: FlutterView; - private mContext: common.Context; + private mFlutterView: FlutterView | null; + private mContext: common.Context | null; constructor() { this.mPlatformViewsController = new PlatformViewController(); + this.mFlutterView = null; + this.mContext = null; } attach(flutterView: FlutterView, context: common.Context): void { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets index e9d66ef987..d8198a8b32 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets @@ -21,7 +21,7 @@ struct XComponentStruct { dvModelParams: DVModelParameters = new DVModelParameters(); build() { - XComponent({ id: (this.dvModelParams as Record)["xComponentId"], type: 'texture', libraryname: 'flutter'}) + XComponent({ id: (this.dvModelParams as Record)["xComponentId"], type: XComponentType.TEXTURE, libraryname: 'flutter'}) .onLoad((context) => { this.context = context; }) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index 3254625d1e..390d7d024b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -263,6 +263,9 @@ export default class FlutterEngine implements EngineLifecycleListener{ this.flutterNapi.removeEngineLifecycleListener(this); this.pluginRegistry?.detachFromAbility(); this.platformViewsController?.onDetachedFromNapi(); + this.pluginRegistry?.destroy(); + this.dartExecutor.onDetachedFromNAPI(); + this.flutterNapi.detachFromNativeAndReleaseResources(); } getRestorationChannel(): RestorationChannel | null { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets index 817cbd3faf..d0b61daf80 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets @@ -22,6 +22,9 @@ import PlatformViewsController from '../../plugin/platform/PlatformViewsControll import ArrayList from '@ohos.util.ArrayList' import { FlutterPlugin } from './plugins/FlutterPlugin' import List from '@ohos.util.List'; +import Log from '../../util/Log'; + +const TAG = "FlutterEngineGroup" export default class FlutterEngineGroup { private activeEngines: ArrayList = new ArrayList(); @@ -33,7 +36,7 @@ export default class FlutterEngineGroup { async checkLoader(context: common.Context, args: Array) { let loader: FlutterLoader = FlutterInjector.getInstance().getFlutterLoader(); if (!loader.initialized) { - await loader.startInitialization(context.getApplicationContext()); + await loader.startInitialization(context); loader.ensureInitializationComplete(args); } } @@ -57,6 +60,7 @@ export default class FlutterEngineGroup { platformViewsController = new PlatformViewsController(); } + Log.i(TAG, "shellHolder, this.activeEngines.length=" + this.activeEngines.length) if (this.activeEngines.length == 0) { engine = this.createEngine(context, platformViewsController); await engine.init(context, null, // String[]. The Dart VM has already started, this arguments will have no effect. 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 a4439baec9..271ec23e6e 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 @@ -219,8 +219,8 @@ export default class FlutterNapi { } spawn(entrypointFunctionName: string, pathToEntrypointFunction: string, initialRoute: string, entrypointArgs: Array): FlutterNapi { - let shellHolderId: number = flutter.nativeSpawn(this.nativeShellHolderId, entrypointFunctionName, pathToEntrypointFunction, initialRoute, entrypointArgs) let flutterNapi = new FlutterNapi() + let shellHolderId: number = flutter.nativeSpawn(this.nativeShellHolderId, entrypointFunctionName, pathToEntrypointFunction, initialRoute, entrypointArgs, flutterNapi) flutterNapi.nativeShellHolderId = shellHolderId return flutterNapi; } @@ -354,6 +354,26 @@ export default class FlutterNapi { flutter.nativeGetSystemLanguages(this.nativeShellHolderId!, systemLanguages); } + /** + * xcomponet绑定flutterEngine + * @param xcomponentId + */ + xComponentAttachFlutterEngine(xcomponentId: number) { + flutter.nativeXComponentAttachFlutterEngine(xcomponentId, this.nativeShellHolderId!); + } + + /** + * xcomponet解除绑定flutterEngine + * @param xcomponentId + */ + xComponentDetachFlutterEngine(xcomponentId: number) { + flutter.nativeXComponentDetachFlutterEngine(xcomponentId, this.nativeShellHolderId!); + } + + detachFromNativeAndReleaseResources() { + flutter.nativeDestroy(this.nativeShellHolderId!!); + } + initNativeImage(textureId: number, aImage: image.Image) { Log.d(TAG, "called initNativeImage "); flutter.nativeInitNativeImage(this.nativeShellHolderId!, textureId, aImage); diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets index 7a3cd75a49..604c490010 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets @@ -56,17 +56,62 @@ export default class FlutterShellArgs { static ARG_KEY_OBSERVATORY_PORT = "observatory-port"; static ARG_OBSERVATORY_PORT = "--observatory-port="; static ARG_KEY_DART_FLAGS = "dart-flags"; - static ARG_DART_FLAGS = "--dart-flags"; + static ARG_DART_FLAGS = "--dart-flags="; static ARG_KEY_MSAA_SAMPLES = "msaa-samples"; - static ARG_MSAA_SAMPLES = "--msaa-samples"; + static ARG_MSAA_SAMPLES = "--msaa-samples="; /** * 从意图中解析参数,创建shellArgs * @returns */ static fromWant(want: Want): FlutterShellArgs { - //tdo 解析want - return new FlutterShellArgs(); + let flutterShellArgs: FlutterShellArgs = new FlutterShellArgs(); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_TRACE_STARTUP, FlutterShellArgs.ARG_TRACE_STARTUP, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_START_PAUSED, FlutterShellArgs.ARG_START_PAUSED, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_DISABLE_SERVICE_AUTH_CODES, FlutterShellArgs.ARG_DISABLE_SERVICE_AUTH_CODES, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_ENDLESS_TRACE_BUFFER, FlutterShellArgs.ARG_ENDLESS_TRACE_BUFFER, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_USE_TEST_FONTS, FlutterShellArgs.ARG_USE_TEST_FONTS, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_ENABLE_DART_PROFILING, FlutterShellArgs.ARG_ENABLE_DART_PROFILING, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING, FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_SKIA_DETERMINISTIC_RENDERING, FlutterShellArgs.ARG_SKIA_DETERMINISTIC_RENDERING, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_TRACE_SKIA, FlutterShellArgs.ARG_TRACE_SKIA, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_TRACE_SYSTRACE, FlutterShellArgs.ARG_TRACE_SYSTRACE, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_ENABLE_IMPELLER, FlutterShellArgs.ARG_ENABLE_IMPELLER, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_DUMP_SHADER_SKP_ON_SHADER_COMPILATION, FlutterShellArgs.ARG_DUMP_SHADER_SKP_ON_SHADER_COMPILATION, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_CACHE_SKSL, FlutterShellArgs.ARG_CACHE_SKSL, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_PURGE_PERSISTENT_CACHE, FlutterShellArgs.ARG_PURGE_PERSISTENT_CACHE, want, flutterShellArgs); + FlutterShellArgs.checkArg(FlutterShellArgs.ARG_KEY_VERBOSE_LOGGING, FlutterShellArgs.ARG_VERBOSE_LOGGING, want, flutterShellArgs); + + let skia_allow_list: Object = want.parameters![FlutterShellArgs.ARG_KEY_TRACE_SKIA_ALLOWLIST]; + if (skia_allow_list != undefined) { + flutterShellArgs.add(FlutterShellArgs.ARG_TRACE_SKIA_ALLOWLIST + (skia_allow_list as string)); + } + + let observatory_port: Object = want.parameters![FlutterShellArgs.ARG_KEY_OBSERVATORY_PORT]; + if (observatory_port != undefined && (observatory_port as number > 0)) { + flutterShellArgs.add(FlutterShellArgs.ARG_OBSERVATORY_PORT + (observatory_port as number)); + } + + let msaa: Object = want.parameters![FlutterShellArgs.ARG_KEY_MSAA_SAMPLES]; + if (msaa != undefined && (msaa as number > 1)) { + flutterShellArgs.add(FlutterShellArgs.ARG_MSAA_SAMPLES + (msaa as number)); + } + + let dart_flags: Object = want.parameters![FlutterShellArgs.ARG_KEY_DART_FLAGS]; + if (dart_flags != undefined) { + flutterShellArgs.add(FlutterShellArgs.ARG_DART_FLAGS + (msaa as string)); + } + return flutterShellArgs; + } + + static checkArg(argKey: string, argFlag: string, want: Want, flutterShellArgs: FlutterShellArgs) { + if (want.parameters == undefined) { + return; + } + let value: Object = want.parameters![argKey]; + if (value != undefined && value as Boolean) { + flutterShellArgs.add(argFlag); + } } //参数 diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets index 2f874e60a9..89e7cf3264 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets @@ -51,6 +51,8 @@ const AOT_VMSERVICE_SHARED_LIBRARY_NAME = "aot-vmservice-shared-library-name"; //文件路径分隔符 const FILE_SEPARATOR = "/"; +const TIMESTAMP_PREFIX = "res_timestamp-"; + /** * 定位在hap包中的flutter资源,并且加载flutter native library. */ @@ -83,11 +85,10 @@ export default class FlutterLoader { this.initStartTimestampMillis = Date.now(); this.context = context; this.flutterApplicationInfo = ApplicationInfoLoader.load(context); - Log.d(TAG, "context.filesDir=" + context.filesDir) - Log.d(TAG, "context.cacheDir=" + context.cacheDir) - Log.d(TAG, "context.bundleCodeDir=" + context.bundleCodeDir) if (this.flutterApplicationInfo!.isDebugMode) { await this.copyResource(context) + } else { + await this.copyICU(context) } this.initResult = new InitResult( `${context.filesDir}/`, @@ -97,38 +98,36 @@ export default class FlutterLoader { Log.d(TAG, "flutterLoader end init") } - private async isNeedCopyResource(): Promise { - let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; - try { - if (this.context != null) { - let bundleInfo = await bundleManager.getBundleInfoForSelf(bundleFlags); - let key = bundleInfo.name + '.bundleInfoPreferences' - let preferences: data_preferences.Preferences = await data_preferences.getPreferences(this.context, key); - let storeInstallTime = await preferences.get("installTime", 0); - let storeUpdateTime = await preferences.get("updateTime", 0); - if (storeInstallTime != bundleInfo.installTime || storeUpdateTime != bundleInfo.updateTime) { - await preferences.put("installTime", bundleInfo.installTime); - await preferences.put("updateTime", bundleInfo.updateTime); - await preferences.flush(); - return true; - } + private async copyICU(context: common.Context) { + let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir + const timestamp = await this.checkTimestamp(filePath); + if (timestamp == null) { + Log.d(TAG, "no need copyICU") + return; + } + if (this.context != null) { + Log.d(TAG, "start copyICU") + if (fs.accessSync(filePath)) { + fs.rmdirSync(filePath); } - - return false; - } catch (err) { - let message = (err as BusinessError).message; - Log.i(TAG, 'Judge is need copy resource : %{public}s', message); - return true; + fs.mkdirSync(filePath) + let icudtlBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + "/icudtl.dat") + let icudtlFile = fs.openSync(filePath + FILE_SEPARATOR + "/icudtl.dat", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) + fs.writeSync(icudtlFile.fd, icudtlBuffer.buffer) + if (timestamp != null) { + fs.openSync(filePath + FILE_SEPARATOR + timestamp, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE) + } + Log.d(TAG, "copyICU end") } } private async copyResource(context: common.Context) { - let copyFlag = await this.isNeedCopyResource(); - if (!copyFlag) { + let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir + const timestamp = await this.checkTimestamp(filePath); + if (timestamp == null) { + Log.d(TAG, "no need copyResource") return; } - - let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir if (this.context != null) { Log.d(TAG, "start copyResource") if (fs.accessSync(filePath + FILE_SEPARATOR + DEFAULT_KERNEL_BLOB)) { @@ -153,6 +152,10 @@ export default class FlutterLoader { let isolateBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + this.flutterApplicationInfo!.isolateSnapshotData) let isolateFile = fs.openSync(filePath + FILE_SEPARATOR + this.flutterApplicationInfo!.isolateSnapshotData, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) fs.writeSync(isolateFile.fd, isolateBuffer.buffer) + + if (timestamp != null) { + fs.openSync(filePath + FILE_SEPARATOR + timestamp, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE) + } Log.d(TAG, "copyResource end") } else { Log.d(TAG, "no copyResource") @@ -197,6 +200,8 @@ export default class FlutterLoader { + this.flutterApplicationInfo!.nativeLibraryDir + FILE_SEPARATOR + this.flutterApplicationInfo!.aotSharedLibraryName); + const snapshotAssetPath = this.initResult!.dataDirPath + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir; + shellArgs.push("--icu-data-file-path=" + snapshotAssetPath + "/icudtl.dat") if (this.flutterApplicationInfo!.isProfile) { shellArgs.push("--" + AOT_VMSERVICE_SHARED_LIBRARY_NAME + "=" + VMSERVICE_SNAPSHOT_LIBRARY); } @@ -239,6 +244,36 @@ export default class FlutterLoader { fullAssetPathFrom(filePath: string): string { return this.flutterApplicationInfo == null ? "" : this.flutterApplicationInfo!.flutterAssetsDir + "/" + filePath; } + + private async checkTimestamp(dataDir: string) : Promise { + let bundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT); + const expectedTimestamp = TIMESTAMP_PREFIX + bundleInfo.versionCode + "-" + bundleInfo.updateTime; + const existingTimestamps = this.getExistingTimestamps(dataDir); + if (existingTimestamps == null) { + Log.i(TAG, "No extracted resources found"); + return expectedTimestamp; + } + + if (existingTimestamps.length == 1) { + Log.i(TAG, "Found extracted resources " + existingTimestamps[0]); + } + + if (existingTimestamps.length != 1 || !(expectedTimestamp == existingTimestamps[0])) { + Log.i(TAG, "Resource version mismatch " + expectedTimestamp); + return expectedTimestamp; + } + + return null; + } + + private getExistingTimestamps(dataDir: string): string[] { + return fs.accessSync(dataDir) ? fs.listFileSync(dataDir, { + filter: { + displayName: [`${TIMESTAMP_PREFIX}*`] + } + }) : new Array(); + } + } class InitResult { @@ -253,4 +288,4 @@ class InitResult { this.engineCachesPath = engineCachesPath; this.dataDirPath = dataDirPath; } -} +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets index 8ac0e08bf3..0e28c4cc97 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets @@ -15,15 +15,13 @@ import BasicMessageChannel from '../../../plugin/common/BasicMessageChannel'; import { BinaryMessenger } from '../../../plugin/common/BinaryMessenger'; -import { Reply } from '../../../plugin/common/BasicMessageChannel'; -import { Action, Key, KeyEvent } from '@ohos.multimodalInput.keyEvent'; import Log from '../../../util/Log'; import JSONMessageCodec from '../../../plugin/common/JSONMessageCodec'; export default class KeyEventChannel { private static TAG = "KeyEventChannel"; private static CHANNEL_NAME = "flutter/keyevent"; - private channel : BasicMessageChannel>; + private channel: BasicMessageChannel>; constructor(binaryMessenger: BinaryMessenger) { this.channel = new BasicMessageChannel>(binaryMessenger, KeyEventChannel.CHANNEL_NAME, JSONMessageCodec.INSTANCE); @@ -33,7 +31,7 @@ export default class KeyEventChannel { isKeyUp: boolean, responseHandler: EventResponseHandler): void { this.channel.send(this.encodeKeyEvent(keyEvent, isKeyUp), - (message:Map) => { + (message: Map) => { let isEventHandled = false; try { if (message != null) { @@ -47,29 +45,26 @@ export default class KeyEventChannel { ); } - encodeKeyEvent(keyEvent: FlutterKeyEvent, isKeyUp: boolean): Map { - let message: Map = new Map(); - message.set("type", isKeyUp ? "keyup" : "keydown"); + private encodeKeyEvent(keyEvent: FlutterKeyEvent, isKeyUp: boolean): Map { + let message: Map = new Map(); + message.set("type", isKeyUp ? "keyup" : "keydown"); message.set("keymap", "ohos"); - message.set("codePoint", keyEvent.event.unicodeChar); - message.set("keyCode", keyEvent.event.key.code); - message.set("deviceId", keyEvent.event.key.deviceId); - message.set("character", keyEvent.event.key.code.toString()); + message.set("keyCode", keyEvent.event.keyCode); + message.set("deviceId", keyEvent.event.deviceId); + message.set("character", keyEvent.event.keyText); message.set("repeatCount", 1); return message; } - - } -export interface EventResponseHandler { - onFrameworkResponse(isEventHandled: boolean): void; +export interface EventResponseHandler { + onFrameworkResponse: (isEventHandled: boolean) => void; } export class FlutterKeyEvent { event: KeyEvent; - constructor( ohosKeyEvent: KeyEvent) { + constructor(ohosKeyEvent: KeyEvent) { this.event = ohosKeyEvent; } } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets index e7155e04e6..4b90f2f63c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets @@ -325,6 +325,13 @@ class PlatformMethodCallback implements MethodCallHandler { break; case "SystemChrome.setApplicationSwitcherDescription": Log.d(PlatformMethodCallback.TAG, "setApplicationSwitcherDescription: " + JSON.stringify(args)); + try { + this.platform.platformMessageHandler.setApplicationSwitcherDescription(args); + result.success(null); + } catch (err) { + Log.e(PlatformMethodCallback.TAG, "setApplicationSwitcherDescription err:" + JSON.stringify(err)); + result.error("error", JSON.stringify(err), null); + } break; case "SystemChrome.setEnabledSystemUIOverlays": try { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets index 3992521523..23568f97b2 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets @@ -17,6 +17,7 @@ import MethodCall from '../../../plugin/common/MethodCall'; import MethodChannel, { MethodCallHandler, MethodResult } from '../../../plugin/common/MethodChannel'; import StandardMethodCodec from '../../../plugin/common/StandardMethodCodec'; import Log from '../../../util/Log'; +import StringUtils from '../../../util/StringUtils'; import DartExecutor from '../dart/DartExecutor'; /** @@ -38,6 +39,7 @@ import DartExecutor from '../dart/DartExecutor'; */ export default class RestorationChannel { private static TAG = "RestorationChannel"; + private static CHANNEL_NAME = "flutter/restoration"; /** @@ -55,25 +57,31 @@ export default class RestorationChannel { */ public waitForRestorationData: boolean = false; + public pendingFrameworkRestorationChannelRequest: MethodResult | null = null; + + public engineHasProvidedData: boolean = false; + + public frameworkHasRequestedData: boolean = false; + // Holds the most current restoration data which may have been provided by the engine // via "setRestorationData" or by the framework via the method channel. This is the data the // framework should be restored to in case the app is terminated. private restorationData: Uint8Array; + private channel: MethodChannel | null = null; - private pendingFrameworkRestorationChannelRequest: MethodResult | null = null; - private engineHasProvidedData: boolean = false; - private frameworkHasRequestedData: boolean = false; + private handler: MethodCallHandler; constructor(channelOrExecutor: MethodChannel | DartExecutor, waitForRestorationData: boolean) { if (channelOrExecutor instanceof MethodChannel) { this.channel = channelOrExecutor; } else { - this.channel = new MethodChannel(channelOrExecutor, RestorationChannel.CHANNEL_NAME, StandardMethodCodec.INSTANCE); + this.channel = + new MethodChannel(channelOrExecutor, RestorationChannel.CHANNEL_NAME, StandardMethodCodec.INSTANCE); } this.waitForRestorationData = waitForRestorationData; this.restorationData = new Uint8Array(1).fill(0); - this.handler = new RestorationChannelMethodCallHandler(this.restorationData); + this.handler = new RestorationChannelMethodCallHandler(this); this.channel.setMethodCallHandler(this.handler); } @@ -82,6 +90,10 @@ export default class RestorationChannel { return this.restorationData; } + setRestorationDataOnly(data: Uint8Array) { + this.restorationData = data; + } + /** Set the restoration data from which the framework will restore its state. */ setRestorationData(data: Uint8Array) { this.engineHasProvidedData = true; @@ -96,17 +108,20 @@ export default class RestorationChannel { // framework retrieved the restoration state before it was set via this method. // Experimentally, this can also be used to restore a previously used engine to another state, // e.g. when the engine is attached to a new activity. - this.channel?.invokeMethod("push", RestorationChannelMethodCallHandler.packageData(data), { - success: (result: ESObject) :void => { + this.channel?.invokeMethod( + "push", RestorationChannelMethodCallHandler.packageData(data), { + success: (result: ESObject): void => { this.restorationData = data; }, - error: (errorCode: string, errorMessage: string, errorDetails: ESObject) :void => { - Log.e(RestorationChannel.TAG, - "Error " + errorCode + " while sending restoration data to framework: " + errorMessage); + error: (errorCode: string, errorMessage: string, errorDetails: ESObject): void => { + Log.e( + RestorationChannel.TAG, + "Error " + errorCode + " while sending restoration data to framework: " + errorMessage + ); }, - notImplemented: () :void => { + notImplemented: (): void => { // do nothing } }) @@ -128,15 +143,10 @@ export default class RestorationChannel { } class RestorationChannelMethodCallHandler implements MethodCallHandler { - public waitForRestorationData: boolean = false; - private restorationData: Uint8Array; - private engineHasProvidedData: boolean = false; - private frameworkHasRequestedData: boolean = false; - private channel: MethodChannel | null = null; - private pendingFrameworkRestorationChannelRequest: MethodResult | null = null; + private channel: RestorationChannel; - constructor(restorationData: Uint8Array) { - this.restorationData = restorationData; + constructor(channel: RestorationChannel) { + this.channel = channel; } onMethodCall(call: MethodCall, result: MethodResult): void { @@ -144,20 +154,20 @@ class RestorationChannelMethodCallHandler implements MethodCallHandler { const args: ESObject = call.args; switch (method) { case "put": { - this.restorationData = args; + this.channel.setRestorationDataOnly(args); result.success(null); break; } case "get": { - this.frameworkHasRequestedData = true; - if (this.engineHasProvidedData || !this.waitForRestorationData) { - result.success(RestorationChannelMethodCallHandler.packageData(this.restorationData)); + this.channel.frameworkHasRequestedData = true; + if (this.channel.engineHasProvidedData || !this.channel.waitForRestorationData) { + result.success(RestorationChannelMethodCallHandler.packageData(this.channel.getRestorationData())); // Do not delete the restoration data on the engine side after sending it to the // framework. We may need to hand this data back to the operating system if the // framework never modifies the data (and thus doesn't send us any // data back). } else { - this.pendingFrameworkRestorationChannelRequest = result; + this.channel.pendingFrameworkRestorationChannelRequest = result; } break; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets index 801e8ecdd4..c02c3ad005 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets @@ -109,7 +109,7 @@ export default class TextInputChannel { unspecifiedAction(inputClientId: number): void { Log.d(TAG, "Sending 'unspecifiedAction' message."); - this.channel.invokeMethod("TextInputClient.performAction", [inputClientId, "TextInputAction.unspecifiedAction"]); + this.channel.invokeMethod("TextInputClient.performAction", [inputClientId, "TextInputAction.unspecified"]); } commitContent(inputClientId: number): void { @@ -117,6 +117,10 @@ export default class TextInputChannel { this.channel.invokeMethod("TextInputClient.performAction", [inputClientId, "TextInputAction.commitContent"]); } + onConnectionClosed(inputClientId: number): void { + Log.d(TAG, "Sending 'onConnectionClosed' message."); + } + performPrivateCommand(inputClientId: number, action: string, data: ESObject) { } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets index 22b808584e..a5869a3cbf 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets @@ -15,55 +15,30 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import window from '@ohos.window'; -import { FlutterAbilityDelegate, Host } from './FlutterAbilityDelegate'; +import { FlutterAbilityAndEntryDelegate, Host } from './FlutterAbilityAndEntryDelegate'; import Log from '../../util/Log'; import FlutterEngine from '../engine/FlutterEngine'; import FlutterShellArgs from '../engine/FlutterShellArgs'; import FlutterAbilityLaunchConfigs from './FlutterAbilityLaunchConfigs'; import common from '@ohos.app.ability.common'; import Want from '@ohos.app.ability.Want'; -import display from '@ohos.display'; import { FlutterPlugin } from '../engine/plugins/FlutterPlugin'; -import { AsyncCallback } from '@ohos.base'; import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import I18n from '@ohos.i18n' import { PlatformBrightness } from '../engine/systemchannels/SettingsChannel'; import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; -import { DVModelContainer } from '../../view/DynamicView/dynamicView'; -import { RootDvModeManager } from '../../plugin/platform/RootDvModelManager'; import { Configuration } from '@ohos.app.ability.Configuration'; -import { - BuilderParams, - DVModel, - DVModelChildren, - DVModelEvents, - DVModelParameters } from '../../view/DynamicView/dynamicView'; -import StringUtils from '../../util/StringUtils'; + import List from '@ohos.util.List'; import ExclusiveAppComponent from './ExclusiveAppComponent'; +import errorManager from '@ohos.app.ability.errorManager'; +import appRecovery from '@ohos.app.ability.appRecovery'; +import FlutterManager from './FlutterManager'; +import { FlutterView } from '../../view/FlutterView'; const TAG = "FlutterAbility"; const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'; -@Component -struct XComponentStruct { - private context:ESObject; - dvModelParams: DVModelParameters = new DVModelParameters(); - - build() { - XComponent({ id: (this.dvModelParams as Record)["xComponentId"], type: 'texture', libraryname: 'flutter'}) - .onLoad((context) => { - this.context = context; - }) - .onDestroy(() => { - }) - } -} - -@Builder function BuildXComponentStruct(buildParams: BuilderParams) { - XComponentStruct({dvModelParams: buildParams.params}); -} - /** * flutter ohos基础ability,请在让主ability继承自该类。 * 该类主要职责: @@ -71,11 +46,18 @@ struct XComponentStruct { * 2、生命周期传递; */ export class FlutterAbility extends UIAbility implements Host { - private delegate?: FlutterAbilityDelegate | null; - private windowStage?: window.WindowStage; - private mainWindow?: window.Window; - private viewportMetrics = new ViewportMetrics(); - private displayInfo?: display.Display; + private delegate?: FlutterAbilityAndEntryDelegate | null; + private flutterView: FlutterView | null = null; + private mainWindow?: window.Window | null; + private errorManagerId:number = 0; + + getFlutterView(): FlutterView | null { + return this.flutterView; + } + + pagePath(): string { + return "pages/Index" + } /** * onCreate @@ -86,11 +68,9 @@ export class FlutterAbility extends UIAbility implements Host { */ async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { Log.i(TAG, "bundleCodeDir=" + this.context.bundleCodeDir); + FlutterManager.getInstance().pushUIAbility(this) - this.displayInfo = display.getDefaultDisplaySync(); - this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels - - this.delegate = new FlutterAbilityDelegate(this); + this.delegate = new FlutterAbilityAndEntryDelegate(this); await this?.delegate?.onAttach(this.context); Log.i(TAG, 'onAttach end'); this?.delegate?.platformPlugin?.setUIAbilityContext(this.context); @@ -100,18 +80,44 @@ export class FlutterAbility extends UIAbility implements Host { this.delegate?.onCreate(); } + if (this.stillAttachedForEvent("onWindowStageCreate")) { + this?.delegate?.onWindowStageCreate(); + } + console.log('MyAbility onCreate'); this.context.eventHub.on(EVENT_BACK_PRESS, () => { this.delegate?.flutterEngine?.getNavigationChannel()?.popRoute(); }); + let observer:errorManager.ErrorObserver = { + onUnhandledException(errorMsg) { + console.log("onUnhandledException, errorMsg:", errorMsg); + appRecovery.saveAppState(); + appRecovery.restartApp(); + } + } + this.errorManagerId = errorManager.on('error', observer); } onDestroy() { + FlutterManager.getInstance().popUIAbility(this); this.context.eventHub.off(EVENT_BACK_PRESS); + errorManager.off('error', this.errorManagerId); + + if (this.flutterView != null) { + this.flutterView.onDestroy() + this.flutterView = null; + } + if (this.stillAttachedForEvent("onDestroy")) { - this?.delegate?.onDestroy(); + this?.delegate?.onDetach(); } + + this.release() + } + + onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult { + return this?.delegate?.onSaveState(reason, wantParam) ?? AbilityConstant.OnSaveResult.ALL_REJECT; } /** @@ -119,9 +125,10 @@ export class FlutterAbility extends UIAbility implements Host { * @param windowStage */ async onWindowStageCreate(windowStage: window.WindowStage) { - this.windowStage = windowStage + FlutterManager.getInstance().pushWindowStage(this, windowStage); + this.mainWindow = windowStage.getMainWindowSync(); try { - windowStage?.on('windowStageEvent', (data) => { + windowStage.on('windowStageEvent', (data) => { let stageEventType: window.WindowStageEventType = data; switch (stageEventType) { case window.WindowStageEventType.SHOWN: // 切到前台 @@ -142,90 +149,33 @@ export class FlutterAbility extends UIAbility implements Host { case window.WindowStageEventType.HIDDEN: // 切到后台 Log.i(TAG, 'windowStage background.'); break; - default: - break; } }); - this.mainWindow = windowStage?.getMainWindowSync() - this.mainWindow?.on('windowSizeChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - - this.mainWindow?.on('avoidAreaChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - - this.mainWindow?.on('keyboardHeightChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - - this.loadContent(); - this.mainWindow?.setWindowLayoutFullScreen(true); - } catch (exception) { - Log.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); - } - } - - loadContent() { - if (this.windowStage != null && this.stillAttachedForEvent("loadContent")) { - Log.i(TAG, 'loadContent'); - let params: DVModelParameters = new DVModelParameters(); - (params as Record)["xComponentId"] = - this.delegate?.getFlutterNapi()?.nativeShellHolderId?.toString(); - let xComponentModel: DVModel = - new DVModel("xComponent", params, new DVModelEvents(), new DVModelChildren(), BuildXComponentStruct); - RootDvModeManager.addDvModel(xComponentModel); - - this.windowStage?.loadContent('pages/Index', (err, data) => { + this.flutterView = this.delegate!!.createView(this.context) + Log.e(TAG, 'onWindowStageCreate:' + this.flutterView!!.getId()); + let storage: LocalStorage = new LocalStorage(); + storage.setOrCreate("viewId", this.flutterView!!.getId()) + windowStage.loadContent(this.pagePath(), storage, (err, data) => { if (err.code) { Log.e(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } - let mainWindow = this.windowStage?.getMainWindowSync(); - let _UIContext = mainWindow?.getUIContext(); - this.delegate?.setUIContext(_UIContext); - this.delegate?.sendSettings(); - - this.onWindowPropertiesUpdated(); Log.i(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); - if (this.stillAttachedForEvent("onWindowStageCreate")) { - this?.delegate?.onWindowStageCreate(); - } - this?.delegate?.getFlutterNapi()?.updateRefreshRate(this.displayInfo!.refreshRate) - this.onFlutterEngineReady() + this.mainWindow?.setWindowLayoutFullScreen(true); + } catch (exception) { + Log.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); } } - onFlutterEngineReady(): void { - - } - - private updateViewportMetrics() { - this?.delegate?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, - this.viewportMetrics.physicalWidth, - this.viewportMetrics.physicalHeight, - this.viewportMetrics.physicalViewPaddingTop, - this.viewportMetrics.physicalViewPaddingRight, - this.viewportMetrics.physicalViewPaddingBottom, - this.viewportMetrics.physicalViewPaddingLeft, - this.viewportMetrics.physicalViewInsetTop, - this.viewportMetrics.physicalViewInsetRight, - this.viewportMetrics.physicalViewInsetBottom, - this.viewportMetrics.physicalViewInsetLeft, - this.viewportMetrics.systemGestureInsetTop, - this.viewportMetrics.systemGestureInsetRight, - this.viewportMetrics.systemGestureInsetBottom, - this.viewportMetrics.systemGestureInsetLeft, - this.viewportMetrics.physicalTouchSlop, - new Array(0), - new Array(0), - new Array(0)) + onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void { + this?.delegate?.onNewWant(want,launchParams) } onWindowStageDestroy() { + FlutterManager.getInstance().popWindowStage(this); if (this.stillAttachedForEvent("onWindowStageDestroy")) { this?.delegate?.onWindowStageDestroy(); } @@ -267,7 +217,9 @@ export class FlutterAbility extends UIAbility implements Host { } configureFlutterEngine(flutterEngine: FlutterEngine) { - + let _UIContext = this.mainWindow?.getUIContext(); + this.delegate?.setUIContext(_UIContext); + this.delegate?.sendSettings(); } cleanUpFlutterEngine(flutterEngine: FlutterEngine) { @@ -295,7 +247,7 @@ export class FlutterAbility extends UIAbility implements Host { return false; } - shouldAttachEngineToActivity(): boolean { + shouldAttachEngineToAbility(): boolean { return true; } @@ -326,6 +278,10 @@ export class FlutterAbility extends UIAbility implements Host { } shouldDestroyEngineWithHost(): boolean { + if ((this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) || this.delegate!!.isFlutterEngineFromHost()) { + // Only destroy a cached engine if explicitly requested by app developer. + return false; + } return true; } @@ -353,7 +309,7 @@ export class FlutterAbility extends UIAbility implements Host { return this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as string } - getCachedEngineGroupId(): string { + getCachedEngineGroupId(): string | null { return this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID] as string } @@ -385,35 +341,6 @@ export class FlutterAbility extends UIAbility implements Host { } } - private onWindowPropertiesUpdated(){ - if (this.delegate == null || !this.delegate.isAttached) { - return; - } - let systemAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - let gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); - let keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); - const properties = this.mainWindow?.getWindowProperties(); - this.viewportMetrics.physicalWidth = properties!.windowRect.width; - this.viewportMetrics.physicalHeight = properties!.windowRect.height; - - this.viewportMetrics.physicalViewPaddingTop = systemAvoidArea!.topRect.height - this.viewportMetrics.physicalViewPaddingLeft = systemAvoidArea!.leftRect.width - this.viewportMetrics.physicalViewPaddingBottom = systemAvoidArea!.bottomRect.height - this.viewportMetrics.physicalViewPaddingRight = systemAvoidArea!.rightRect.width - - this.viewportMetrics.physicalViewInsetTop = keyboardAvoidArea!.topRect.height - this.viewportMetrics.physicalViewInsetLeft = keyboardAvoidArea!.leftRect.width - this.viewportMetrics.physicalViewInsetBottom = keyboardAvoidArea!.bottomRect.height - this.viewportMetrics.physicalViewInsetRight = keyboardAvoidArea!.rightRect.width - - this.viewportMetrics.systemGestureInsetTop = gestureAvoidArea!.topRect.height - this.viewportMetrics.systemGestureInsetLeft = gestureAvoidArea!.leftRect.width - this.viewportMetrics.systemGestureInsetBottom = gestureAvoidArea!.bottomRect.height - this.viewportMetrics.systemGestureInsetRight = gestureAvoidArea!.rightRect.width - - this.updateViewportMetrics() - } - onMemoryLevel(level: AbilityConstant.MemoryLevel): void { Log.i(TAG, 'onMemoryLevel: ' + level); if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) { @@ -429,45 +356,7 @@ export class FlutterAbility extends UIAbility implements Host { ? PlatformBrightness.LIGHT : PlatformBrightness.DARK); } - getWindowId(callback: AsyncCallback): void { - if (callback === null) { - return; - } - try { - window.getLastWindow(this.context, (error, win) => { - if (error.code) { - callback(error, -1); - return; - } - let windowId = win.getWindowProperties().id; - callback(error, windowId); - }); - } catch (err) { - Log.e(TAG, "get window id error!"); - callback(err, -1); - } - } - getFlutterEngine(): FlutterEngine | null { return this.delegate?.flutterEngine || null; } -} - -export class ViewportMetrics { - devicePixelRatio: number = 1.0; - physicalWidth: number = 0; - physicalHeight: number = 0; - physicalViewPaddingTop: number = 0; - physicalViewPaddingRight: number = 0; - physicalViewPaddingBottom: number = 0; - physicalViewPaddingLeft: number = 0; - physicalViewInsetTop: number = 0; - physicalViewInsetRight: number = 0; - physicalViewInsetBottom: number = 0; - physicalViewInsetLeft: number = 0; - systemGestureInsetTop: number = 0; - systemGestureInsetRight: number = 0; - systemGestureInsetBottom: number = 0; - systemGestureInsetLeft: number = 0; - physicalTouchSlop = -1; } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets similarity index 83% rename from shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityDelegate.ets rename to shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets index cbe0e80830..056d8c0b5c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets @@ -32,12 +32,13 @@ import { FlutterPlugin } from '../engine/plugins/FlutterPlugin'; import FlutterEngineCache from '../engine/FlutterEngineCache'; import FlutterEngineGroupCache from '../engine/FlutterEngineGroupCache'; import FlutterEngineGroup, { Options } from '../engine/FlutterEngineGroup'; -import MouseCursorPlugin, { MouseCursorViewDelegate } from '../../plugin/mouse/MouseCursorPlugin'; import Settings from './Settings'; import FlutterNapi from '../engine/FlutterNapi'; import List from '@ohos.util.List'; import GeneratedPluginRegister from '../engine/plugins/util/GeneratedPluginRegister'; import { UIContext } from '@ohos.arkui.UIContext'; +import { FlutterView } from '../../view/FlutterView'; +import FlutterManager from './FlutterManager'; const TAG = "FlutterAbilityDelegate"; const PLUGINS_RESTORATION_BUNDLE_KEY = "plugins"; @@ -48,17 +49,18 @@ const FRAMEWORK_RESTORATION_BUNDLE_KEY = "framework"; * 1、初始化engine * 2、处理ability生命周期回调 */ -class FlutterAbilityDelegate implements ExclusiveAppComponent { +class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent { private host?: Host | null; flutterEngine?: FlutterEngine | null; platformPlugin?: PlatformPlugin; private context?: common.Context; private uiContext?: UIContext | undefined; private textInputPlugin?: TextInputPlugin; - private isFlutterEngineFromHost: boolean = false; + private isFlutterEngineFromHostOrCache: boolean = false; private engineGroup?: FlutterEngineGroup; private settings?: Settings; private isHost:boolean = false; + private flutterView?: FlutterView constructor(host?: Host) { this.host = host; @@ -78,14 +80,13 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { if (this.flutterEngine == null) { await this.setupFlutterEngine(); } - //shouldAttachEngineToActivity - if (this.host?.shouldAttachEngineToActivity()) { + //shouldAttachEngineToAbility + if (this.host?.shouldAttachEngineToAbility()) { // Notify any plugins that are currently attached to our FlutterEngine that they // are now attached to an Ability. Log.d(TAG, "Attaching FlutterEngine to the Ability that owns this delegate."); this.flutterEngine?.getAbilityControlSurface()?.attachToAbility(this); } - //providePlatformPlugin //configureFlutterEngine @@ -94,14 +95,16 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { if (plugins) { GeneratedPluginRegister.registerGeneratedPlugins(this.flutterEngine!, plugins); } - Log.d(TAG, "onAttach end start loadcontent") - this.host?.loadContent() if (this.flutterEngine) { this.textInputPlugin = new TextInputPlugin(this.flutterEngine.getTextInputChannel()!); this.platformPlugin = new PlatformPlugin(this.flutterEngine.getPlatformChannel()!, this.context); this.settings = new Settings(this.flutterEngine.getSettingsChannel()!); this.flutterEngine.getSystemLanguages(); } + if (this.flutterEngine && this.flutterView) { + this.flutterView.attachToFlutterEngine(this.flutterEngine!!); + } + this.host?.configureFlutterEngine(this.flutterEngine!!); } /** @@ -146,14 +149,34 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { * @param want */ onRestoreInstanceState(want: Want) { - let frameworkState = want.parameters != null - ? want.parameters[FRAMEWORK_RESTORATION_BUNDLE_KEY] as Uint8Array - : new Uint8Array(1).fill(0); + let frameworkState: Uint8Array = this.getRestorationData(want.parameters as Record); if (this.host?.shouldRestoreAndSaveState()) { this.flutterEngine?.getRestorationChannel()?.setRestorationData(frameworkState); } } + private getRestorationData(wantParam: Record): Uint8Array { + let result: Uint8Array = new Uint8Array(1).fill(0); + if (wantParam == null) { + return result; + } + if (wantParam[FRAMEWORK_RESTORATION_BUNDLE_KEY] == undefined) { + return result + } + if (typeof wantParam[FRAMEWORK_RESTORATION_BUNDLE_KEY] == 'object') { + let data: Record = wantParam[FRAMEWORK_RESTORATION_BUNDLE_KEY] as Record; + let byteArray: Array = new Array; + Object.keys(data).forEach( + key => { + byteArray.push(data[key]); + } + ); + result = Uint8Array.from(byteArray); + } + return result; + } + /** * 初始化flutterEngine */ @@ -163,7 +186,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { Log.d(TAG, "cachedEngineId=" + cachedEngineId); if (cachedEngineId && cachedEngineId.length > 0) { this.flutterEngine = FlutterEngineCache.getInstance().get(cachedEngineId); - this.isFlutterEngineFromHost = true; + this.isFlutterEngineFromHostOrCache = true; if (this.flutterEngine == null) { throw new Error( "The requested cached FlutterEngine did not exist in the FlutterEngineCache: '" @@ -178,7 +201,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { this.flutterEngine = this.host.provideFlutterEngine(this.context); } if (this.flutterEngine != null) { - this.isFlutterEngineFromHost = true; + this.isFlutterEngineFromHostOrCache = true; return; } @@ -199,7 +222,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { this.flutterEngine = await flutterEngineGroup.createAndRunEngineByOptions( this.addEntrypointOptions(new Options(this.context))); } - this.isFlutterEngineFromHost = false; + this.isFlutterEngineFromHostOrCache = false; return; } @@ -221,7 +244,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { .setAutomaticallyRegisterPlugins(false) .setWaitForRestorationData(this.host?.shouldRestoreAndSaveState() || false))); } - this.isFlutterEngineFromHost = false; + this.isFlutterEngineFromHostOrCache = false; } addEntrypointOptions(options: Options): Options { @@ -246,20 +269,55 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { .setDartEntrypointArgs(this.host?.getDartEntrypointArgs() ?? []); } + createView(context: Context): FlutterView { + this.flutterView = FlutterManager.getInstance().createFlutterView(context) + if (this.flutterEngine) { + this.flutterView.attachToFlutterEngine(this.flutterEngine!!); + } + return this.flutterView + } + /** * 释放所有持有对象 */ release() { this.host = null; this.flutterEngine = null; + this.textInputPlugin = undefined; + this.platformPlugin = undefined; } onDetach() { - if (this.host?.shouldAttachEngineToActivity()) { - // Notify plugins that they are no longer attached to an Activity. + if (this.host?.shouldAttachEngineToAbility()) { + // Notify plugins that they are no longer attached to an Ability. Log.d(TAG, "Detaching FlutterEngine from the Ability"); this.flutterEngine?.getAbilityControlSurface()?.detachFromAbility(); } + this.flutterView?.detachFromFlutterEngine(); + this.host?.cleanUpFlutterEngine(this.flutterEngine!!); + + if (this.host?.shouldDispatchAppLifecycleState() && this.flutterEngine != null) { + this.flutterEngine?.getLifecycleChannel()?.appIsDetached(); + } + + if (this.textInputPlugin) { + this.textInputPlugin?.detach(); + } + + if (this.platformPlugin) { + this.platformPlugin.destroy(); + } + + // Destroy our FlutterEngine if we're not set to retain it. + if (this.host?.shouldDestroyEngineWithHost()) { + this.flutterEngine?.destroy(); + if (this.host.getCachedEngineId() != null && this.host.getCachedEngineId().length > 0) { + FlutterEngineCache.getInstance().remove(this.host.getCachedEngineId()); + } + this.flutterEngine = null; + } + + this.isAttached = false; } onLowMemory(): void { @@ -278,14 +336,6 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { } } - onDestroy() { - this.ensureAlive(); - if (this.shouldDispatchAppLifecycleState()) { - this.flutterEngine?.getLifecycleChannel()?.appIsDetached(); - } - this.textInputPlugin?.detach(); - } - onWindowStageCreate() { this.ensureAlive(); this.doInitialFlutterViewRun(); @@ -350,17 +400,17 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { detachFromFlutterEngine() { if (this.host?.shouldDestroyEngineWithHost()) { // The host owns the engine and should never have its engine taken by another exclusive - // activity. + // ability. throw new Error( "The internal FlutterEngine created by " + this.host - + " has been attached to by another activity. To persist a FlutterEngine beyond the " + + " has been attached to by another Ability. To persist a FlutterEngine beyond the " + "ownership of this ablity, explicitly create a FlutterEngine"); } // Default, but customizable, behavior is for the host to call {@link #onDetach} // deterministically as to not mix more events during the lifecycle of the next exclusive - // activity. + // ability. this.host?.detachFromFlutterEngine(); } @@ -368,7 +418,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { const ability = this.host?.getAbility(); if (ability == null) { throw new Error( - "FlutterActivityAndFragmentDelegate's getAppComponent should only " + "FlutterAbilityAndFragmentDelegate's getAppComponent should only " + "be queried after onAttach, when the host's ability should always be non-null"); } return ability; @@ -384,7 +434,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { this.flutterEngine?.getNavigationChannel()?.pushRouteInformation(initialRoute); } } else { - Log.w(TAG, "onNewIntent() invoked before FlutterFragment was attached to an Activity."); + Log.w(TAG, "onNewIntent() invoked before FlutterFragment was attached to an Ability."); } } @@ -394,7 +444,7 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { if (this.host?.shouldRestoreAndSaveState()) { wantParam[FRAMEWORK_RESTORATION_BUNDLE_KEY] = this.flutterEngine!.getRestorationChannel()!.getRestorationData(); } - if (this.host?.shouldAttachEngineToActivity()) { + if (this.host?.shouldAttachEngineToAbility()) { const plugins:Record = {} const result = this.flutterEngine?.getAbilityControlSurface()?.onSaveState(reason, plugins); wantParam[PLUGINS_RESTORATION_BUNDLE_KEY] = plugins; @@ -423,27 +473,29 @@ class FlutterAbilityDelegate implements ExclusiveAppComponent { setUIContext(uiContext: UIContext | undefined): void { this.uiContext = uiContext; } + + isFlutterEngineFromHost(): boolean { + return this.isFlutterEngineFromHostOrCache; + } } /** * FlutterAbility句柄 */ -interface Host extends FlutterEngineProvider, FlutterEngineConfigurator, PlatformPluginDelegate, MouseCursorViewDelegate { +interface Host extends FlutterEngineProvider, FlutterEngineConfigurator, PlatformPluginDelegate { getAbility(): UIAbility; - loadContent():void; - shouldDispatchAppLifecycleState(): boolean; detachFromFlutterEngine(): void; - shouldAttachEngineToActivity(): boolean; + shouldAttachEngineToAbility(): boolean; getCachedEngineId(): string; - getCachedEngineGroupId(): string; + getCachedEngineGroupId(): string | null; /** * Returns true if the {@link io.flutter.embedding.engine.FlutterEngine} used in this delegate @@ -487,4 +539,4 @@ interface Host extends FlutterEngineProvider, FlutterEngineConfigurator, Platfor getExclusiveAppComponent(): ExclusiveAppComponent | null } -export { Host, FlutterAbilityDelegate } \ No newline at end of file +export { Host, FlutterAbilityAndEntryDelegate } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterComopnentDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterComopnentDelegate.ets deleted file mode 100644 index 7cec8a4a5d..0000000000 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterComopnentDelegate.ets +++ /dev/null @@ -1,153 +0,0 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import common from '@ohos.app.ability.common'; -import { FlutterAbilityDelegate } from './FlutterAbilityDelegate'; -import window from '@ohos.window'; -import { ViewportMetrics } from './FlutterAbility'; -import { - BuilderParams, - DVModel, - DVModelChildren, - DVModelEvents, - DVModelParameters -} from '../../view/DynamicView/dynamicView'; -import display from '@ohos.display'; -import { RootDvModeManager } from '../../plugin/platform/RootDvModelManager'; -import { FlutterPlugin } from '../engine/plugins/FlutterPlugin'; -import { BuildXComponentStruct } from '../../component/XComponentStruct'; - -export class FlutterComponentDelegate { - private context: common.UIAbilityContext - - private delegate?: FlutterAbilityDelegate | null; - - private mainWindow?: window.Window; - - private viewportMetrics = new ViewportMetrics(); - - constructor(context: common.UIAbilityContext) { - this.context = context; - this.delegate = new FlutterAbilityDelegate(); - } - - async init(): Promise { - let displayInfo = display.getDefaultDisplaySync(); - this.viewportMetrics.devicePixelRatio = displayInfo?.densityPixels; - await this?.delegate?.onAttach(this.context); - this?.delegate?.platformPlugin?.setUIAbilityContext(this.context); - this?.delegate?.sendSettings(); - let params: DVModelParameters = new DVModelParameters(); - (params as Record)["xComponentId"] = - this.delegate?.getFlutterNapi()?.nativeShellHolderId?.toString(); - let xComponentModel: DVModel = - new DVModel("xComponent", params, new DVModelEvents(), new DVModelChildren(), BuildXComponentStruct); - RootDvModeManager.addDvModel(xComponentModel); - this.mainWindow = await window.getLastWindow(this.context); - this.mainWindow?.on( - 'windowSizeChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - - this.mainWindow?.on( - 'avoidAreaChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - - this.mainWindow?.on( - 'keyboardHeightChange', (data) => { - this.onWindowPropertiesUpdated(); - }); - this.onWindowPropertiesUpdated(); - this?.delegate?.onWindowStageCreate(); - this?.delegate?.onWindowFocusChanged(true); - this?.delegate?.onForeground(); - } - - private onWindowPropertiesUpdated() { - if (this.delegate == null || !this.delegate.isAttached) { - return; - } - let systemAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - let gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); - let keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); - const properties = this.mainWindow?.getWindowProperties(); - if (properties!.windowRect.width < this.viewportMetrics.physicalWidth) { - this.viewportMetrics.physicalWidth = properties!.windowRect.width; - } - if (properties!.windowRect.height < this.viewportMetrics.physicalHeight) { - this.viewportMetrics.physicalHeight = properties!.windowRect.height; - } - - this.viewportMetrics.physicalViewPaddingTop = systemAvoidArea!.topRect.height - this.viewportMetrics.physicalViewPaddingLeft = systemAvoidArea!.leftRect.width - this.viewportMetrics.physicalViewPaddingBottom = systemAvoidArea!.bottomRect.height - this.viewportMetrics.physicalViewPaddingRight = systemAvoidArea!.rightRect.width - - this.viewportMetrics.physicalViewInsetTop = keyboardAvoidArea!.topRect.height - this.viewportMetrics.physicalViewInsetLeft = keyboardAvoidArea!.leftRect.width - this.viewportMetrics.physicalViewInsetBottom = keyboardAvoidArea!.bottomRect.height - this.viewportMetrics.physicalViewInsetRight = keyboardAvoidArea!.rightRect.width - - this.viewportMetrics.systemGestureInsetTop = gestureAvoidArea!.topRect.height - this.viewportMetrics.systemGestureInsetLeft = gestureAvoidArea!.leftRect.width - this.viewportMetrics.systemGestureInsetBottom = gestureAvoidArea!.bottomRect.height - this.viewportMetrics.systemGestureInsetRight = gestureAvoidArea!.rightRect.width - - this.updateViewportMetrics() - } - - private updateViewportMetrics() { - this?.delegate?.getFlutterNapi()?.setViewportMetrics( - this.viewportMetrics.devicePixelRatio, - this.viewportMetrics.physicalWidth, - this.viewportMetrics.physicalHeight, - this.viewportMetrics.physicalViewPaddingTop, - this.viewportMetrics.physicalViewPaddingRight, - this.viewportMetrics.physicalViewPaddingBottom, - this.viewportMetrics.physicalViewPaddingLeft, - this.viewportMetrics.physicalViewInsetTop, - this.viewportMetrics.physicalViewInsetRight, - this.viewportMetrics.physicalViewInsetBottom, - this.viewportMetrics.physicalViewInsetLeft, - this.viewportMetrics.systemGestureInsetTop, - this.viewportMetrics.systemGestureInsetRight, - this.viewportMetrics.systemGestureInsetBottom, - this.viewportMetrics.systemGestureInsetLeft, - this.viewportMetrics.physicalTouchSlop, - new Array(0), - new Array(0), - new Array(0) - ) - } - - addPlugin(plugin: FlutterPlugin): void { - this.delegate?.addPlugin(plugin) - } - - release(): void { - if (this?.delegate != null) { - this?.delegate?.onDestroy(); - this?.delegate?.release(); - this.delegate = null; - } - } - - updateView(width: number, height: number): void { - this.viewportMetrics.physicalWidth = width; - this.viewportMetrics.physicalHeight = height; - this.updateViewportMetrics(); - } -} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets index 168baf5a1c..75408f2baa 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets @@ -16,8 +16,8 @@ import FlutterEngine from '../engine/FlutterEngine'; export default interface FlutterEngineConfigurator { - - configureFlutterEngine(flutterEngine: FlutterEngine): void; - cleanUpFlutterEngine(flutterEngine: FlutterEngine): void; + configureFlutterEngine: (flutterEngine: FlutterEngine) => void; + + cleanUpFlutterEngine: (flutterEngine: FlutterEngine) => void; } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets new file mode 100644 index 0000000000..e66095a173 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets @@ -0,0 +1,240 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FlutterEngine from '../engine/FlutterEngine'; +import Want from '@ohos.app.ability.Want'; +import FlutterShellArgs from '../engine/FlutterShellArgs'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import ExclusiveAppComponent from './ExclusiveAppComponent'; +import { FlutterPlugin } from '../engine/plugins/FlutterPlugin'; +import List from '@ohos.util.List'; +import { FlutterAbilityAndEntryDelegate, Host } from './FlutterAbilityAndEntryDelegate'; +import FlutterAbilityLaunchConfigs from './FlutterAbilityLaunchConfigs'; +import Log from '../../util/Log'; +import { FlutterView } from '../../view/FlutterView'; +import FlutterManager from './FlutterManager'; +import window from '@ohos.window'; +import FlutterEngineConfigurator from './FlutterEngineConfigurator'; + +const TAG = "FlutterEntry"; + +export default class FlutterEntry implements Host { + private static ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY: string = "should_attach_engine_to_ability"; + + protected uiAbility: UIAbility | null = null + protected delegate: FlutterAbilityAndEntryDelegate | null = null + private flutterView: FlutterView | null = null + private context: Context; + private windowStage: window.WindowStage | null = null + private parameters: ESObject = {}; + private engineConfigurator: FlutterEngineConfigurator | null = null + private hasInit: boolean = false; + + constructor(context: Context, params: ESObject = {}) { + this.context = context; + this.uiAbility = FlutterManager.getInstance().getUIAbility(context); + this.parameters = params; + this.windowStage = FlutterManager.getInstance().getWindowStage(this.uiAbility); + this.hasInit = false; + } + + async aboutToAppear() { + Log.i(TAG, 'aboutToAppear'); + if (this.hasInit == false) { + this.delegate = new FlutterAbilityAndEntryDelegate(this); + this.flutterView = this.delegate?.createView(this.context); + await this?.delegate?.onAttach(this.context); + Log.i(TAG, 'onAttach end'); + this?.delegate?.platformPlugin?.setUIAbilityContext(this.uiAbility!!.context); + this.delegate?.onCreate(); + this.delegate?.onWindowStageCreate() + this.windowStage?.on('windowStageEvent', this.windowStageEventCallback); + this.hasInit = true; + } + } + + private windowStageEventCallback = (data: window.WindowStageEventType) => { + let stageEventType: window.WindowStageEventType = data; + switch (stageEventType) { + case window.WindowStageEventType.SHOWN: // 切到前台 + Log.i(TAG, 'windowStage foreground.'); + break; + case window.WindowStageEventType.ACTIVE: // 获焦状态 + Log.i(TAG, 'windowStage active.'); + this?.delegate?.onWindowFocusChanged(true); + break; + case window.WindowStageEventType.INACTIVE: // 失焦状态 + Log.i(TAG, 'windowStage inactive.'); + this?.delegate?.onWindowFocusChanged(false); + break; + case window.WindowStageEventType.HIDDEN: // 切到后台 + Log.i(TAG, 'windowStage background.'); + break; + } + } + + setFlutterEngineConfigurator(configurator: FlutterEngineConfigurator) { + this.engineConfigurator = configurator; + } + + getFlutterView(): FlutterView { + return this.flutterView!! + } + + getFlutterEngine(): FlutterEngine | null { + return this.delegate?.flutterEngine! + } + + aboutToDisappear() { + Log.d(TAG, "FlutterEntry aboutToDisappear==="); + try { + this.windowStage?.off('windowStageEvent', this.windowStageEventCallback); + } catch (err) { + + } + if (this.flutterView != null) { + this.flutterView.onDestroy(); + this.flutterView = null; + } + if (this.delegate != null) { + this.delegate?.onDetach(); + this.delegate?.release() + } + } + + onPageShow() { //生命周期 + Log.d(TAG, "FlutterEntry onPageShow==="); + this?.delegate?.onForeground(); + } + + onPageHide() { //生命周期 + Log.d(TAG, "FlutterEntry onPageHide==="); + this?.delegate?.onBackground(); + } + + shouldDispatchAppLifecycleState(): boolean { + return true; + } + + detachFromFlutterEngine() { + if (this?.delegate != null) { + this?.delegate?.onDetach(); + } + } + + getAbility(): UIAbility { + return this.uiAbility!! + } + + loadContent() { + + } + + shouldAttachEngineToAbility(): boolean { + return this.parameters![FlutterEntry.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY] as boolean + } + + getCachedEngineId(): string { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as string + } + + getCachedEngineGroupId(): string | null { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID] as string + } + + shouldDestroyEngineWithHost(): boolean { + if ((this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) || this.delegate!!.isFlutterEngineFromHost()) { + // Only destroy a cached engine if explicitly requested by app developer. + return false; + } + return true; + } + + getFlutterShellArgs(): FlutterShellArgs { + return new FlutterShellArgs(); + } + + getDartEntrypointArgs(): string[] { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT_ARGS]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT_ARGS] as Array; + } + return new Array() + } + + getDartEntrypointLibraryUri(): string { + return ""; + } + + getAppBundlePath(): string { + return ""; + } + + getDartEntrypointFunctionName(): string { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT] as string; + } + return FlutterAbilityLaunchConfigs.DEFAULT_DART_ENTRYPOINT + } + + getInitialRoute(): string { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_INITIAL_ROUTE]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_INITIAL_ROUTE] as string + } + return ""; + } + + getWant(): Want { + return new Want(); + } + + shouldRestoreAndSaveState(): boolean { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] != undefined) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as boolean; + } + if (this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) { + // Prevent overwriting the existing state in a cached engine with restoration state. + return false; + } + return true; + } + + getPlugins(): List { + return new List() + } + + getExclusiveAppComponent(): ExclusiveAppComponent | null { + return this.delegate ? this.delegate : null + } + + provideFlutterEngine(context: Context): FlutterEngine | null { + return null; + } + + configureFlutterEngine(flutterEngine: FlutterEngine) { + if (this.engineConfigurator) { + this.engineConfigurator.configureFlutterEngine(flutterEngine) + } + } + + cleanUpFlutterEngine(flutterEngine: FlutterEngine) { + if (this.engineConfigurator) { + this.engineConfigurator.cleanUpFlutterEngine(flutterEngine) + } + } + + popSystemNavigator(): boolean { + return false; + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets new file mode 100644 index 0000000000..88362ab53a --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +import { FlutterView } from '../../view/FlutterView'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; + +export default class FlutterManager { + private static instance: FlutterManager; + + static getInstance(): FlutterManager { + if (FlutterManager.instance == null) { + FlutterManager.instance = new FlutterManager(); + } + return FlutterManager.instance; + } + + private flutterViewList = new Map(); + private flutterViewIndex = 1; + private uiAbilityList = new Array(); + private windowStageList = new Map(); + + pushUIAbility(uiAbility: UIAbility) { + this.uiAbilityList.push(uiAbility); + } + + popUIAbility(uiAbility: UIAbility) { + let index = this.uiAbilityList.findIndex((item: UIAbility) => item == uiAbility) + if (index > 0) { + this.uiAbilityList.splice(index, 1) + } + } + + pushWindowStage(uiAbility: UIAbility, windowStage: window.WindowStage) { + this.windowStageList.set(uiAbility, windowStage) + } + + popWindowStage(uiAbility: UIAbility) { + this.windowStageList.delete(uiAbility) + } + + getWindowStage(uiAbility: UIAbility): window.WindowStage { + return this.windowStageList.get(uiAbility)!! + } + + getUIAbility(context: Context): UIAbility { + return this.uiAbilityList.find((item: UIAbility) => item.context == context)!! + } + + hasFlutterView(viewId: string): boolean { + return this.flutterViewList.has(viewId); + } + + getFlutterView(viewId: string): FlutterView | null { + return this.flutterViewList.get(viewId) ?? null; + } + + private putFlutterView(viewId: string, flutterView?: FlutterView): void { + if (flutterView != null) { + this.flutterViewList.set(viewId, flutterView); + } else { + this.flutterViewList.delete(viewId); + } + } + + createFlutterView(context: Context): FlutterView { + let flutterView = new FlutterView((this.flutterViewIndex++).toString(), context); + this.putFlutterView(flutterView.getId(), flutterView); + return flutterView; + } + + clear(): void { + this.flutterViewList.clear(); + } + +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index 0569511193..53e7ef62d1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets @@ -14,30 +14,64 @@ */ import { PlatformViewWrapper } from '../../plugin/platform/PlatformViewWrapper'; import { RootDvModeManager } from '../../plugin/platform/RootDvModelManager'; -import { DVModel, +import Log from '../../util/Log'; +import { + DVModel, DVModelChildren, DVModelContainer, DVModelEvents, - DVModelParameters, DynamicView } from '../../view/DynamicView/dynamicView'; + DVModelParameters, + DynamicView +} from '../../view/DynamicView/dynamicView'; import { createDVModelFromJson } from '../../view/DynamicView/dynamicViewJson'; +import { FlutterView } from '../../view/FlutterView'; +import KeyEventChannel from '../engine/systemchannels/KeyEventChannel'; +import FlutterManager from './FlutterManager'; + +const TAG = "FlutterPage"; /** * 基础page组件,承载XComponent组件 */ @Component export struct FlutterPage { - @State message: string = 'Hello World'; + @State rootDvModel: DVModel | undefined = undefined + @Prop viewId: string = "" + private flutterView?: FlutterView | null - @State rootDvModel: DVModelContainer = RootDvModeManager.getRootDvMode(); + aboutToAppear() { + this.flutterView = FlutterManager.getInstance().getFlutterView(this.viewId); + this.rootDvModel = this.flutterView!!.getDVModel() + } build() { - DynamicView({ - model: this.rootDvModel.model as DVModel, - params: this.rootDvModel.model.params as DVModelParameters, - events: this.rootDvModel.model.events as DVModelEvents, - children: this.rootDvModel.model.children as DVModelChildren, - customBuilder: this.rootDvModel.model.builder as ($$: Record<"params",DVModelParameters >) => void - //customBuilder: this.rootDvModel.model.builder as ($$: { params: DVModelParameters }) => void + Stack() { + XComponent({ id: this.viewId, type: XComponentType.TEXTURE, libraryname: 'flutter' }) + .focusable(true) + .onLoad((context) => { + this.flutterView?.onSurfaceCreated() + Log.d(TAG, "XComponent onLoad "); + }) + .onDestroy(() => { + Log.d(TAG, "XComponent onDestroy "); + this.flutterView?.onSurfaceDestroyed() + }) + DynamicView({ + model: this.rootDvModel, + params: this.rootDvModel!!.params as DVModelParameters, + events: this.rootDvModel!!.events as DVModelEvents, + children: this.rootDvModel!!.children as DVModelChildren, + customBuilder: this.rootDvModel!!.builder as ($$: Record<"params", DVModelParameters>) => void + //customBuilder: this.rootDvModel.model.builder as ($$: { params: DVModelParameters }) => void + }) + } + .onAreaChange((oldValue: Area, newValue: Area) => { + Log.d(TAG, "onAreaChange "); + this.flutterView?.onAreaChange(newValue) + }) + .onKeyEvent((event: KeyEvent) => { + Log.d(TAG, "onKeyEvent " + event.type); + this.flutterView?.onKeyEvent(event) }) } } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets new file mode 100644 index 0000000000..ec4a02ff78 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import FlutterEngine from '../engine/FlutterEngine'; +import KeyEventChannel, { FlutterKeyEvent } from '../engine/systemchannels/KeyEventChannel'; + +export default class KeyboardManager { + private keyEventChannel: KeyEventChannel | null = null + + constructor(engine: FlutterEngine) { + this.keyEventChannel = new KeyEventChannel(engine.dartExecutor) + } + + handleKeyEvent(event: KeyEvent) { + this.keyEventChannel?.sendFlutterKeyEvent(new FlutterKeyEvent(event), event.type == KeyType.Up, { + onFrameworkResponse: (isEventHandled: boolean): void => { + + } + }) + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets index 14a84d6948..44b8ebe6d9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets @@ -139,7 +139,15 @@ class PlatformPluginCallback implements PlatformMessageHandler { } setApplicationSwitcherDescription(description: AppSwitcherDescription) { - // representation described in the given {@code description}. + Log.d(PlatformPluginCallback.TAG, "setApplicationSwitcherDescription: " + JSON.stringify(description)); + try { + let label: string = description?.label; + this.uiAbilityContext?.setMissionLabel(label).then(() => { + Log.d(PlatformPluginCallback.TAG, "Succeeded in seting mission label"); + }) + } catch (err) { + Log.d(PlatformPluginCallback.TAG, "Failed to set mission label: " + JSON.stringify(err)); + } } showSystemOverlays(overlays: SystemUiOverlay[]) { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets index e0b55276be..68925a8b1a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets @@ -49,7 +49,7 @@ export interface BinaryReply { * outgoing replies must place the reply bytes between position zero and current position. * Reply receivers can read from the buffer directly. */ - reply(reply: ArrayBuffer): void; + reply(reply: ArrayBuffer | null): void; } /** Handler for incoming binary messages from Flutter. */ @@ -96,7 +96,7 @@ export interface BinaryMessenger { * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message * bytes between position zero and current position, or null. */ - send(channel: String, message: ArrayBuffer): void; + send(channel: String, message: ArrayBuffer | null): void; /** * Sends a binary message to the Flutter application, optionally expecting a reply. @@ -127,7 +127,7 @@ export interface BinaryMessenger { * the handler. Specifying null means execute on the platform thread. */ //setMessageHandler(channel: String, handler: BinaryMessageHandler) - setMessageHandler(channel: String, handler: BinaryMessageHandler, taskQueue?: TaskQueue): void; + setMessageHandler(channel: String, handler: BinaryMessageHandler | null, taskQueue?: TaskQueue): void; // { // if (taskQueue != null) { // throw new Error("setMessageHandler called with nonnull taskQueue is not supported.") diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets index 166659a32e..cc792fbb52 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets @@ -40,7 +40,7 @@ export default class EventChannel { private messenger: BinaryMessenger; private name: string; private codec: MethodCodec; - private taskQueue: TaskQueue; + private taskQueue: TaskQueue | undefined; constructor(messenger: BinaryMessenger, name: string, codec?: MethodCodec, taskQueue?: TaskQueue) { this.messenger = messenger @@ -240,22 +240,22 @@ class EventSinkImplementation implements EventSink { } } -class AtomicReference { - private value: T; +class AtomicReference { + private value: T | null; - constructor(value: T) { + constructor(value: T | null) { this.value = value } - get(): T { + get(): T | null { return this.value; } - set(newValue: T): void { + set(newValue: T | null): void { this.value = newValue; } - getAndSet(newValue: T) { + getAndSet(newValue: T | null): T | null { const oldValue = this.value; this.value = newValue; return oldValue; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets index 31da9ff489..f42df11830 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets @@ -156,7 +156,7 @@ export interface MethodResult { notImplemented: () => void; } -class IncomingResultHandler implements BinaryReply { +export class IncomingResultHandler implements BinaryReply { private callback: MethodResult; private codec: MethodCodec; @@ -182,7 +182,7 @@ class IncomingResultHandler implements BinaryReply { } } -class IncomingMethodCallHandler implements BinaryMessageHandler { +export class IncomingMethodCallHandler implements BinaryMessageHandler { private handler: MethodCallHandler; private codec: MethodCodec; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets index 8b51a6671a..953f7cad09 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets @@ -252,6 +252,7 @@ export class ListenableEditingState { this.TextInputChannel.unspecifiedAction(this.client); break; case inputMethod.EnterKeyType.NONE: + this.TextInputChannel.newline(this.client); break; case inputMethod.EnterKeyType.GO: this.TextInputChannel.go(this.client); @@ -266,7 +267,7 @@ export class ListenableEditingState { this.TextInputChannel.next(this.client); break; case inputMethod.EnterKeyType.DONE: - this.TextInputChannel.done(this.client) + this.TextInputChannel.done(this.client); break; } } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets index 56fe4ed593..ca7f22a339 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets @@ -226,6 +226,19 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { return; } + try { + this.inputMethodController.on('sendKeyboardStatus', (state) => { + if(state == KeyboardStatus.HIDE) { + this.keyboardStatus = KeyboardStatus.HIDE; + this.plugin.textInputChannel.onConnectionClosed(this.inputTarget.id); + } + }) + } catch (err) { + Log.e(TextInputMethodHandlerImpl.TAG, "Failed to subscribe sendKeyboardStatus:" + JSON.stringify(err)); + this.cancelListenKeyBoardEvent(); + return; + } + try { this.inputMethodController.on('selectByRange', (range: inputMethod.Range) => { this.mEditable.handleSelectByRange(range); diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets index 0f8bf873c4..36c8d93cf7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets @@ -17,37 +17,35 @@ import MouseCursorChannel, { MouseCursorMethodHandler } from '../../embedding/en import pointer from '@ohos.multimodalInput.pointer'; import HashMap from '@ohos.util.HashMap'; import Log from '../../util/Log'; -import { AsyncCallback } from '@ohos.base'; const TAG: string = "MouseCursorPlugin"; export default class MouseCursorPlugin implements MouseCursorMethodHandler{ - private mView: MouseCursorViewDelegate; private mouseCursorChannel: MouseCursorChannel; private systemCursorConstants: HashMap | null = null; - constructor(mouseCursorView: MouseCursorViewDelegate, mouseCursorChannel: MouseCursorChannel) { - this.mView = mouseCursorView; + private windowId : number; + + constructor(windowId : number, mouseCursorChannel: MouseCursorChannel) { + this.windowId = windowId; this.mouseCursorChannel = mouseCursorChannel; this.mouseCursorChannel.setMethodHandler(this); } activateSystemCursor(kind: string): void { - this.mView.getWindowId((error, windowId) => { - if (windowId < 0) { - Log.w(TAG, "set point style failed windowId is invalid"); - return; - } - let pointStyle: pointer.PointerStyle = this.resolveSystemCursor(kind); - try { - pointer.setPointerStyle(windowId, pointStyle, (err: ESObject) => { - Log.i(TAG, "set point style success kind : " + kind); - }) - } catch (e) { - Log.e(TAG, "set point style failed : " + kind + " " + JSON.stringify(e)); - } - }); + if (this.windowId < 0) { + Log.w(TAG, "set point style failed windowId is invalid"); + return; + } + let pointStyle: pointer.PointerStyle = this.resolveSystemCursor(kind); + try { + pointer.setPointerStyle(this.windowId, pointStyle, (err: ESObject) => { + Log.i(TAG, "set point style success kind : " + kind); + }) + } catch (e) { + Log.e(TAG, "set point style failed : " + kind + " " + JSON.stringify(e)); + } } /** @@ -79,7 +77,7 @@ export default class MouseCursorPlugin implements MouseCursorMethodHandler{ this.systemCursorConstants.set("text", pointer.PointerStyle.TEXT_CURSOR); this.systemCursorConstants.set("resizeColum", pointer.PointerStyle.NORTH_SOUTH); this.systemCursorConstants.set("resizeDown", pointer.PointerStyle.SOUTH); - this.systemCursorConstants.set("resizeUpLeft", pointer.PointerStyle.NORTH_WEST); + this.systemCursorConstants.set("resizeDownLeft", pointer.PointerStyle.SOUTH_WEST); this.systemCursorConstants.set("resizeDownRight", pointer.PointerStyle.SOUTH_EAST); this.systemCursorConstants.set("resizeLeft", pointer.PointerStyle.WEST); this.systemCursorConstants.set("resizeLeftRight", pointer.PointerStyle.RESIZE_LEFT_RIGHT); @@ -89,12 +87,30 @@ export default class MouseCursorPlugin implements MouseCursorMethodHandler{ this.systemCursorConstants.set("resizeUpDown", pointer.PointerStyle.RESIZE_UP_DOWN); this.systemCursorConstants.set("resizeUpLeft", pointer.PointerStyle.NORTH_WEST); this.systemCursorConstants.set("resizeUpRight", pointer.PointerStyle.NORTH_EAST); - this.systemCursorConstants.set("resizeUpLeftDownRight", pointer.PointerStyle.MOVE); - this.systemCursorConstants.set("resizeUpRightDownLeft", pointer.PointerStyle.MOVE); + this.systemCursorConstants.set("resizeUpLeftDownRight", pointer.PointerStyle.NORTH_WEST_SOUTH_EAST); + this.systemCursorConstants.set("resizeUpRightDownLeft", pointer.PointerStyle.NORTH_EAST_SOUTH_WEST); this.systemCursorConstants.set("verticalText", pointer.PointerStyle.TEXT_CURSOR); this.systemCursorConstants.set("wait", pointer.PointerStyle.DEFAULT); this.systemCursorConstants.set("zoomIn", pointer.PointerStyle.ZOOM_IN); this.systemCursorConstants.set("zoomOut", pointer.PointerStyle.ZOOM_OUT); + this.systemCursorConstants.set("middleBtnEast", pointer.PointerStyle.MIDDLE_BTN_EAST); + this.systemCursorConstants.set("middleBtnWest", pointer.PointerStyle.MIDDLE_BTN_WEST); + this.systemCursorConstants.set("middleBtnSouth", pointer.PointerStyle.MIDDLE_BTN_SOUTH); + this.systemCursorConstants.set("middleBtnNorth", pointer.PointerStyle.MIDDLE_BTN_NORTH); + this.systemCursorConstants.set("middleBtnNorthSouth", pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH); + this.systemCursorConstants.set("middleBtnNorthEast", pointer.PointerStyle.MIDDLE_BTN_NORTH_EAST); + this.systemCursorConstants.set("middleBtnNorthWest", pointer.PointerStyle.MIDDLE_BTN_NORTH_WEST); + this.systemCursorConstants.set("middleBtnSouthEast", pointer.PointerStyle.MIDDLE_BTN_SOUTH_EAST); + this.systemCursorConstants.set("middleBtnSouthWest", pointer.PointerStyle.MIDDLE_BTN_SOUTH_WEST); + this.systemCursorConstants.set("middleBtnNorthSouthWestEast", pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST); + this.systemCursorConstants.set("horizontalTextCursor", pointer.PointerStyle.HORIZONTAL_TEXT_CURSOR); + this.systemCursorConstants.set("cursorCross", pointer.PointerStyle.CURSOR_CROSS); + this.systemCursorConstants.set("cursorCircle", pointer.PointerStyle.CURSOR_CIRCLE); + this.systemCursorConstants.set("loading", pointer.PointerStyle.LOADING); + this.systemCursorConstants.set("running", pointer.PointerStyle.RUNNING); + this.systemCursorConstants.set("colorSucker", pointer.PointerStyle.COLOR_SUCKER); + this.systemCursorConstants.set("screenshotChoose", pointer.PointerStyle.SCREENSHOT_CHOOSE); + this.systemCursorConstants.set("screenshotCursor", pointer.PointerStyle.SCREENSHOT_CURSOR); } let pointStyle:pointer.PointerStyle = this.systemCursorConstants.get(kind); if (pointStyle === null) { @@ -113,17 +129,3 @@ export default class MouseCursorPlugin implements MouseCursorMethodHandler{ } } -/** - * Delegate interface for requesting the system to display a pointer icon object. - * - *

Typically implemented by an component, such as a{@code FlutterView} - */ -export interface MouseCursorViewDelegate { - /** - * get window id to set mouse style - *

component need to implement this interface to get windowId - * - * @param callback windowId - * */ - getWindowId(callback: AsyncCallback): void; -} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets index 0d244a9d96..e802dc7092 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets @@ -35,7 +35,6 @@ import PlatformViewRegistryImpl from './PlatformViewRegistryImpl'; import DartExecutor from '../../embedding/engine/dart/DartExecutor'; import { AccessibilityEventsDelegate } from './AccessibilityEventsDelegate'; import AccessibilityBridge from '../../view/AccessibilityBridge'; -import { RootDvModeManager } from './RootDvModelManager'; import { FlutterMutatorView } from '../../embedding/engine/mutatorsstack/FlutterMutatorView'; import common from '@ohos.app.ability.common'; import Log from '../../util/Log' @@ -61,7 +60,6 @@ export default class PlatformViewsController implements PlatformViewsAccessibili private viewWrappers: Map; private currentFrameUsedOverlayLayerIds: HashSet; private currentFrameUsedPlatformViewIds: HashSet; - private rootDvModel: DVModelContainer | null = RootDvModeManager.getRootDvMode(); private platformViewParent: Map; constructor() { @@ -118,9 +116,11 @@ export default class PlatformViewsController implements PlatformViewsAccessibili let viewWrapper: PlatformViewWrapper | null = this.viewWrappers.get(viewId) || null; if (viewWrapper != null) { let children = viewWrapper.getDvModel().children; - let index = RootDvModeManager.getRootDvMode().model.children.indexOf(viewWrapper.getDvModel()); - children.splice(0, children.length); - RootDvModeManager.getRootDvMode().model.children.splice(index, 1); + if (this.flutterView) { + let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()); + children.splice(0, children.length); + this.flutterView.getDVModel().children.splice(index, 1); + } this.viewWrappers.delete(viewId); } @@ -351,7 +351,7 @@ export default class PlatformViewsController implements PlatformViewsAccessibili viewWrapper.setLayoutParams(param); viewWrapper.addDvModel(model); - RootDvModeManager.addDvModel(viewWrapper.getDvModel()!); + this.flutterView?.getDVModel().children.push(viewWrapper.getDvModel()!); this.viewWrappers.set(request.viewId, viewWrapper); Log.i(TAG, "Create platform view success"); @@ -378,28 +378,29 @@ export default class PlatformViewsController implements PlatformViewsAccessibili this.textureRegistry = null; } - public attachToView() { + public attachToView(newFlutterView : FlutterView) { + this.flutterView = newFlutterView; for (let wrapper of this.viewWrappers.values()) { - this.rootDvModel?.model.children.push(wrapper.getDvModel()!); + this.flutterView?.getDVModel().children.push(wrapper.getDvModel()!); } for (let mutator of this.platformViewParent.values()) { - this.rootDvModel?.model.children.push(mutator.getDvModel()!); + this.flutterView?.getDVModel().children.push(mutator.getDvModel()!); } for (let platformView of this.platformViews.values()) { - platformView.onFlutterViewAttached(this.rootDvModel!.model); + platformView.onFlutterViewAttached(this.flutterView?.getDVModel()); } } public detachFromView(): void { for (let index = 0; index < this.viewWrappers.size; index++) { - this.rootDvModel?.model.children.pop(); + this.flutterView?.getDVModel().children.pop(); } for (let index = 0; index < this.platformViewParent.size; index++) { - this.rootDvModel?.model.children.pop(); + this.flutterView?.getDVModel().children.pop(); } this.destroyOverlaySurfaces(); this.removeOverlaySurfaces(); - this.rootDvModel = null; + this.flutterView = null; for (let platformView of this.platformViews.values()) { platformView.onFlutterViewDetached(); diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets index 54ef775d0a..a4d3da8a23 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets @@ -18,6 +18,7 @@ import { DVModel, DVModelContainer, DVModelEvents, DVModelParameters } from '../../view/DynamicView/dynamicView'; +import Log from '../../util/Log'; export class RootDvModeManager { private static model: DVModel = new DVModel("Stack", new DVModelParameters(), new DVModelEvents(), new DVModelChildren(), null); @@ -30,5 +31,6 @@ export class RootDvModeManager { public static addDvModel(model: DVModel): void { RootDvModeManager.container.model.children.push(model); + Log.i("flutter RootDvModeManager", 'DVModel: %{public}s', JSON.stringify(RootDvModeManager.container.model.children) ?? ''); } } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets index 38d652b936..57193e339a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets @@ -86,11 +86,7 @@ export class ByteBuffer { } get buffer(): ArrayBuffer { - const dataBuffer = new DataView(new ArrayBuffer(this.mByteOffset)); - for (let i = 0; i < this.mByteOffset; i++) { - dataBuffer.setUint8(i, this.dataView!.getUint8(i)); - } - return dataBuffer.buffer + return this.dataView!.buffer.slice(0, this.mByteOffset) } /** @@ -120,11 +116,12 @@ export class ByteBuffer { */ checkWriteCapacity(slen: number): void { if (this.mByteOffset + slen > this.dataView!.byteLength) { - let checkBuffer = new DataView(new ArrayBuffer(this.dataView!.byteLength + slen + 512)); - for (let i = 0; i < this.mByteOffset; i++) { - checkBuffer.setUint8(i, this.dataView!.getUint8(i)); - } - this.dataView = checkBuffer; + let newBuffer = new ArrayBuffer(this.dataView!.byteLength + slen + 512); + let newDataView = new DataView(newBuffer); + let oldUint8Array = new Uint8Array(this.dataView!.buffer); + let newUint8Array = new Uint8Array(newBuffer); + newUint8Array.set(oldUint8Array); + this.dataView = newDataView; } } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterNativeView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterNativeView.ets deleted file mode 100644 index 9138ad7285..0000000000 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterNativeView.ets +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import common from '@ohos.app.ability.common'; -import DartExecutor from '../embedding/engine/dart/DartExecutor'; -import { EngineLifecycleListener } from '../embedding/engine/FlutterEngine'; -import FlutterNapi from '../embedding/engine/FlutterNapi'; -import Log from '../util/Log'; -import FlutterPluginRegistry from '../app/FlutterPluginRegistry'; -import FlutterRunArguments from './FlutterRunArguments'; -import { FlutterView } from './FlutterView'; - -const TAG: string = "FlutterNativeView"; - -export default class FlutterNativeView { - private mContext: common.Context; - private mPluginRegistry: FlutterPluginRegistry; - private mFlutterNapi: FlutterNapi; - private dartExecutor: DartExecutor; - private mFlutterView: FlutterView; - private applicationIsRunning: boolean; - - constructor(context: common.Context, isBackgroundView?: boolean) { - if (isBackgroundView) { - Log.i(TAG, "isBackgroundView is no longer supported and will be ignored"); - } - this.mContext = context; - this.mPluginRegistry = new FlutterPluginRegistry(); - this.mFlutterNapi = new FlutterNapi(); - //this.mFlutterNapi.addIsDisplayingFlutterUiListener(this.flutterUiDisplayListener); - this.dartExecutor = new DartExecutor(this.mFlutterNapi, this.mContext.resourceManager); - this.mFlutterNapi.addEngineLifecycleListener(new EngineLifecycleListenerImpl(this.mFlutterView, this.mPluginRegistry)); - this.attach(this.mFlutterNapi, this.dartExecutor); - this.assertAttached(this.mFlutterNapi); - } - - attach(flutterNapi: FlutterNapi, dartExecutor: DartExecutor): void { - flutterNapi.attachToNative(); - dartExecutor.onAttachedToNAPI(); - } - - assertAttached(flutterNapi: FlutterNapi): void { - if (!this.isAttached(flutterNapi)) { - throw new Error('Platform View is not attached'); - } - } - - isAttached(flutterNapi: FlutterNapi): boolean { - return flutterNapi.isAttached(); - } - - detachFromFlutterView(): void { - this.mPluginRegistry.detach(); - this.mFlutterView = null; - } - - destroy(): void { - this.mPluginRegistry.destroy(); - this.dartExecutor.onDetachedFromNAPI(); - this.mFlutterView = null; - //this.mFlutterNapi.removeIsDisplayingFlutterUiListener(this.flutterUiDisplayListener); - this.applicationIsRunning = false; - } - - getDartExecutor(): DartExecutor { - return this.dartExecutor; - } - - getPluginRegistry(): FlutterPluginRegistry { - return this.mPluginRegistry; - } - - attachViewAndAbility(flutterView: FlutterView, context: common.Context): void { - this.mFlutterView = flutterView; - this.mPluginRegistry.attach(flutterView, context); - } - - runFromBundle(args: FlutterRunArguments): void { - if (args.entrypoint == null) { - throw new Error("an entrypoint must be specific"); - } - this.assertAttached(this.mFlutterNapi); - if (this.applicationIsRunning) { - throw new Error("this flutter engine instance is already running an application"); - } - this.mFlutterNapi.runBundleAndSnapshotFromLibrary(args.bundlePath, args.entrypoint, args.libraryPath, this.mContext.resourceManager, null); - this.applicationIsRunning = true; - } - - isApplicationRunning(): boolean { - return this.applicationIsRunning; - } - - // getObservatoryUri(): string { - // return this.mFlutterNapi.getObservatoryUri(); - // } -} - -class EngineLifecycleListenerImpl implements EngineLifecycleListener { - private flutterView: FlutterView; - private pluginRegistry: FlutterPluginRegistry; - - onPreEngineRestart(): void { - if (this.flutterView != null) { - //this.flutterView.resetAccessibilityTree(); - } - - if (this.pluginRegistry == null) { - return; - } - - this.pluginRegistry.onPreEngineRestart(); - } - - onEngineWillDestroy(): void { - - } - - constructor(flutterView: FlutterView, pluginRegistry: FlutterPluginRegistry) { - this.flutterView = flutterView; - this.pluginRegistry = pluginRegistry; - } -} - - diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets index d17ec28d1f..c81e33f381 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets @@ -17,4 +17,10 @@ export default class FlutterRunArguments { public bundlePath: string; public entrypoint: string; public libraryPath: string; + + constructor(bundlePath: string, entrypoint: string, libraryPath: string) { + this.bundlePath = bundlePath; + this.entrypoint = entrypoint; + this.libraryPath = libraryPath; + } } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index cf38a74159..0e19662f6c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -12,7 +12,200 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import FlutterEngine from '../embedding/engine/FlutterEngine'; +import Log from '../util/Log'; +import { DVModel, DVModelChildren, DVModelEvents, DVModelParameters } from './DynamicView/dynamicView'; +import display from '@ohos.display'; +import FlutterManager from '../embedding/ohos/FlutterManager'; +import window from '@ohos.window'; +import KeyboardManager from '../embedding/ohos/KeyboardManager'; +import MouseCursorPlugin from '../plugin/mouse/MouseCursorPlugin'; + +const TAG = "FlutterView"; + +class ViewportMetrics { + devicePixelRatio: number = 1.0; + physicalWidth: number = 0; + physicalHeight: number = 0; + physicalViewPaddingTop: number = 0; + physicalViewPaddingRight: number = 0; + physicalViewPaddingBottom: number = 0; + physicalViewPaddingLeft: number = 0; + physicalViewInsetTop: number = 0; + physicalViewInsetRight: number = 0; + physicalViewInsetBottom: number = 0; + physicalViewInsetLeft: number = 0; + systemGestureInsetTop: number = 0; + systemGestureInsetRight: number = 0; + systemGestureInsetBottom: number = 0; + systemGestureInsetLeft: number = 0; + physicalTouchSlop = -1; +} export class FlutterView { + private flutterEngine: FlutterEngine | null = null + private id: string = "" + private dVModel: DVModel = new DVModel("Stack", new DVModelParameters(), new DVModelEvents(), new DVModelChildren(), null); + private isSurfaceAvailableForRendering: boolean = false + private viewportMetrics = new ViewportMetrics(); + private displayInfo?: display.Display; + private keyboardManager: KeyboardManager | null = null; + private mainWindow: window.Window + private mouseCursorPlugin?: MouseCursorPlugin; + + constructor(viewId: string, context: Context) { + this.id = viewId + this.displayInfo = display.getDefaultDisplaySync(); + this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels + this.mainWindow = FlutterManager.getInstance() + .getWindowStage(FlutterManager.getInstance().getUIAbility(context)) + .getMainWindowSync(); + + this.mainWindow?.on('windowSizeChange', this.windowSizeChangeCallback); + this.mainWindow?.on('avoidAreaChange', this.avoidAreaChangeCallback); + this.mainWindow?.on('keyboardHeightChange', this.keyboardHeightChangeCallback); + } + + private windowSizeChangeCallback= (data: window.Size) => { + Log.i(TAG, "windowSizeChangeCallback"); + this.onAreaChange(null); + } + private avoidAreaChangeCallback = (data: ESObject) => { + Log.i(TAG, "avoidAreaChangeCallback"); + this.onAreaChange(null); + } + private keyboardHeightChangeCallback = (data: number) => { + Log.i(TAG, "keyboardHeightChangeCallback"); + this.onAreaChange(null); + } + + getId(): string { + return this.id + } + + getDVModel() { + return this.dVModel + } + + onDestroy() { + try { + this.mainWindow?.off('windowSizeChange', this.windowSizeChangeCallback); + this.mainWindow?.off('avoidAreaChange', this.avoidAreaChangeCallback); + this.mainWindow?.off('keyboardHeightChange', this.keyboardHeightChangeCallback); + } catch (e) { + } + } + + attachToFlutterEngine(flutterEngine: FlutterEngine): void { + if (this.isAttachedToFlutterEngine()) { + if (flutterEngine == this.flutterEngine) { + Log.i(TAG, "Already attached to this engine. Doing nothing."); + return; + } + // Detach from a previous FlutterEngine so we can attach to this new one.f + Log.i( + TAG, + "Currently attached to a different engine. Detaching and then attaching" + + " to new engine."); + this.detachFromFlutterEngine(); + } + Log.i(TAG, "attachToFlutterEngine"); + this.flutterEngine = flutterEngine; + this.keyboardManager = new KeyboardManager(flutterEngine); + if (this.isSurfaceAvailableForRendering) { + this.flutterEngine.getFlutterNapi().xComponentAttachFlutterEngine(Number(this.id)) + } + this.flutterEngine?.getFlutterNapi()?.updateRefreshRate(this.displayInfo!.refreshRate) + flutterEngine.getPlatformViewsController()?.attachToView(this); + this.updateViewportMetrics() + let windowId = this.mainWindow?.getWindowProperties()?.id + this.mouseCursorPlugin = new MouseCursorPlugin(windowId, this.flutterEngine?.getMouseCursorChannel()!); + } + + detachFromFlutterEngine(): void { + Log.i(TAG, "detachFromFlutterEngine"); + if (!this.isAttachedToFlutterEngine()) { + Log.d(TAG, "FlutterView not attached to an engine. Not detaching."); + return; + } + if (this.isSurfaceAvailableForRendering) { + this.flutterEngine!!.getFlutterNapi().xComponentDetachFlutterEngine(Number(this.id)) + } + this.flutterEngine?.getPlatformViewsController()?.detachFromView(); + this.flutterEngine = null; + this.keyboardManager = null; + } + + onSurfaceCreated() { + this.isSurfaceAvailableForRendering = true; + if (this.isAttachedToFlutterEngine()) { + this.flutterEngine!!.getFlutterNapi().xComponentAttachFlutterEngine(Number(this.id)) + } + } + + onSurfaceDestroyed() { + this.isSurfaceAvailableForRendering = false; + if (this.isAttachedToFlutterEngine()) { + this.flutterEngine!!.getFlutterNapi().xComponentDetachFlutterEngine(Number(this.id)) + } + } + + onAreaChange(newArea: Area | null) { + let systemAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + let gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); + let keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); + + if (newArea != null) { + this.viewportMetrics.physicalWidth = vp2px(newArea.width as number); + this.viewportMetrics.physicalHeight = vp2px(newArea.height as number); + } + + this.viewportMetrics.physicalViewPaddingTop = systemAvoidArea!.topRect.height + this.viewportMetrics.physicalViewPaddingLeft = systemAvoidArea!.leftRect.width + this.viewportMetrics.physicalViewPaddingBottom = systemAvoidArea!.bottomRect.height + this.viewportMetrics.physicalViewPaddingRight = systemAvoidArea!.rightRect.width + + this.viewportMetrics.physicalViewInsetTop = keyboardAvoidArea!.topRect.height + this.viewportMetrics.physicalViewInsetLeft = keyboardAvoidArea!.leftRect.width + this.viewportMetrics.physicalViewInsetBottom = keyboardAvoidArea!.bottomRect.height + this.viewportMetrics.physicalViewInsetRight = keyboardAvoidArea!.rightRect.width + + this.viewportMetrics.systemGestureInsetTop = gestureAvoidArea!.topRect.height + this.viewportMetrics.systemGestureInsetLeft = gestureAvoidArea!.leftRect.width + this.viewportMetrics.systemGestureInsetBottom = gestureAvoidArea!.bottomRect.height + this.viewportMetrics.systemGestureInsetRight = gestureAvoidArea!.rightRect.width + this.updateViewportMetrics() + } + + private isAttachedToFlutterEngine(): boolean { + return this.flutterEngine != null + } + + private updateViewportMetrics() { + if (this.isAttachedToFlutterEngine()) { + this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, + this.viewportMetrics.physicalWidth, + this.viewportMetrics.physicalHeight, + this.viewportMetrics.physicalViewPaddingTop, + this.viewportMetrics.physicalViewPaddingRight, + this.viewportMetrics.physicalViewPaddingBottom, + this.viewportMetrics.physicalViewPaddingLeft, + this.viewportMetrics.physicalViewInsetTop, + this.viewportMetrics.physicalViewInsetRight, + this.viewportMetrics.physicalViewInsetBottom, + this.viewportMetrics.physicalViewInsetLeft, + this.viewportMetrics.systemGestureInsetTop, + this.viewportMetrics.systemGestureInsetRight, + this.viewportMetrics.systemGestureInsetBottom, + this.viewportMetrics.systemGestureInsetLeft, + this.viewportMetrics.physicalTouchSlop, + new Array(0), + new Array(0), + new Array(0)) + } + } + onKeyEvent(event: KeyEvent) { + this.keyboardManager?.handleKeyEvent(event) + } } \ No newline at end of file diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 7bd6aa23a1..506efd16ab 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -101,6 +101,12 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeGetSystemLanguages", flutter::PlatformViewOHOSNapi::nativeGetSystemLanguages), + DECLARE_NAPI_FUNCTION( + "nativeXComponentAttachFlutterEngine", + flutter::PlatformViewOHOSNapi::nativeXComponentAttachFlutterEngine), + DECLARE_NAPI_FUNCTION( + "nativeXComponentDetachFlutterEngine", + flutter::PlatformViewOHOSNapi::nativeXComponentDetachFlutterEngine), DECLARE_NAPI_FUNCTION( "nativeInitNativeImage", flutter::PlatformViewOHOSNapi::nativeInitNativeImage), diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index e31992ca7c..c740480d5f 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -26,6 +26,7 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "unicode/uchar.h" +#include "flutter/shell/platform/ohos/ohos_xcomponent_adapter.h" #include #include #include @@ -33,9 +34,7 @@ #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { -int64_t PlatformViewOHOSNapi::shell_holder_value; napi_env PlatformViewOHOSNapi::env_; -napi_ref PlatformViewOHOSNapi::ref_napi_obj_; std::vector PlatformViewOHOSNapi::system_languages; /** @@ -415,7 +414,7 @@ void PlatformViewOHOSNapi::DecodeImage(int64_t imageGeneratorAddress, FML_DLOG(INFO) << "start decodeImage"; platform_task_runner_->PostTask(fml::MakeCopyable( [imageGeneratorAddress_ = imageGeneratorAddress, - inputData_ = std::move(inputData), dataSize_ = dataSize]() mutable { + inputData_ = std::move(inputData), dataSize_ = dataSize, this]() mutable { napi_value callbackParam[2]; callbackParam[0] = @@ -449,10 +448,10 @@ napi_value PlatformViewOHOSNapi::nativeAttach(napi_env env, if (status != napi_ok) { FML_DLOG(ERROR) << "nativeAttach Failed to get napiObjec info"; } - napi_create_reference(env, argv[0], 1, &ref_napi_obj_); std::shared_ptr napi_facade = std::make_shared(env); + napi_create_reference(env, argv[0], 1, &(napi_facade->ref_napi_obj_)); uv_loop_t* platform_loop = nullptr; status = napi_get_uv_event_loop(env, &platform_loop); @@ -463,10 +462,10 @@ napi_value PlatformViewOHOSNapi::nativeAttach(napi_env env, auto shell_holder = std::make_unique( OhosMain::Get().GetSettings(), napi_facade, platform_loop); if (shell_holder->IsValid()) { - PlatformViewOHOSNapi::shell_holder_value = + int64_t shell_holder_value = reinterpret_cast(shell_holder.get()); FML_DLOG(INFO) << "PlatformViewOHOSNapi shell_holder:" - << PlatformViewOHOSNapi::shell_holder_value; + << shell_holder_value; napi_value id; napi_create_int64(env, reinterpret_cast(shell_holder.release()), &id); @@ -620,6 +619,8 @@ napi_value PlatformViewOHOSNapi::nativeSpawn(napi_env env, napi_callback_info in } std::shared_ptr napi_facade = std::make_shared(env); + napi_create_reference(env, args[5], 1, &(napi_facade->ref_napi_obj_)); + auto spawned_shell_holder = OHOS_SHELL_HOLDER->Spawn( napi_facade, entrypoint, libraryUrl, initial_route, entrypoint_args); @@ -1521,4 +1522,84 @@ void PlatformViewOHOSNapi::SetPlatformTaskRunner( platform_task_runner_ = platform_task_runner; } -} // namespace flutter +/** + * @brief xcomponent与flutter引擎绑定 + * @note + * @param nativeShellHolderId: number + * @param xcomponentId: number + * @return void + */ +napi_value PlatformViewOHOSNapi::nativeXComponentAttachFlutterEngine( + napi_env env, + napi_callback_info info){ + napi_status ret; + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t xcomponent_id; + int64_t shell_holder; + ret = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine napi_get_cb_info error:" + << ret; + return nullptr; + } + ret = napi_get_value_int64(env, args[0], &xcomponent_id); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine xcomponent_id napi_get_value_int64 error"; + return nullptr; + } + ret = napi_get_value_int64(env, args[1], &shell_holder); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine shell_holder napi_get_value_int64 error"; + return nullptr; + } + std::string xcomponent_id_str = std::to_string(xcomponent_id); + std::string shell_holder_str = std::to_string(shell_holder); + + LOGD("nativeXComponentAttachFlutterEngine xcomponent_id: %{public}ld , shell_holder: %{public}ld ", + xcomponent_id, shell_holder); + + XComponentAdapter::GetInstance()->AttachFlutterEngine(xcomponent_id_str, + shell_holder_str); + return nullptr; +} +/** + * @brief xcomponent解除flutter引擎绑定 + * @note + * @param nativeShellHolderId: number + * @param xcomponentId: number + * @return napi_value + */ +napi_value PlatformViewOHOSNapi::nativeXComponentDetachFlutterEngine( + napi_env env, + napi_callback_info info){ + napi_status ret; + size_t argc = 2; + napi_value args[2] = {nullptr}; + int64_t xcomponent_id; + int64_t shell_holder; + ret = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine napi_get_cb_info error:" + << ret; + return nullptr; + } + ret = napi_get_value_int64(env, args[0], &xcomponent_id); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine xcomponent_id napi_get_value_int64 error"; + return nullptr; + } + ret = napi_get_value_int64(env, args[1], &shell_holder); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeXComponentAttachFlutterEngine shell_holder napi_get_value_int64 error"; + return nullptr; + } + std::string xcomponent_id_str = std::to_string(xcomponent_id); + + LOGD("nativeXComponentDetachFlutterEngine xcomponent_id: %{public}ld", + xcomponent_id); + XComponentAdapter::GetInstance()->DetachFlutterEngine(xcomponent_id_str); + return nullptr; +} + +} // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 1db75b5ad7..8339308b00 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -165,11 +165,16 @@ class PlatformViewOHOSNapi { int32_t height); static void SurfaceDestroyed(int64_t shell_holder); static int64_t GetShellHolder(); + static napi_value nativeXComponentAttachFlutterEngine( + napi_env env, + napi_callback_info info); + static napi_value nativeXComponentDetachFlutterEngine( + napi_env env, + napi_callback_info info); private: static napi_env env_; - static napi_ref ref_napi_obj_; - static int64_t shell_holder_value; + napi_ref ref_napi_obj_; static std::vector system_languages; fml::RefPtr platform_task_runner_; }; diff --git a/shell/platform/ohos/ohos_image_generator.cpp b/shell/platform/ohos/ohos_image_generator.cpp index b44acf24a8..46211d3d75 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -157,12 +157,10 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); if (status != napi_ok) { LOGE("NativeImageDecodeCallback napi_get_cb_info error"); - return nullptr; } if (argc != 4) { FML_LOG(ERROR) << "argc is error"; - return nullptr; } // unwarp object @@ -197,6 +195,7 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( int ret = OHOS::Media::OH_AccessPixels(g_env, args[3], (void**)&pixel_lock); if (ret != 0) { FML_DLOG(ERROR) << "Failed to lock pixels, error=" << ret; + generator->native_callback_latch_.Signal(); return nullptr; } // pixel_lock, g_env_ =g_env , resultout diff --git a/shell/platform/ohos/ohos_shell_holder.cpp b/shell/platform/ohos/ohos_shell_holder.cpp index 26aa35c67a..cbc08c05a6 100644 --- a/shell/platform/ohos/ohos_shell_holder.cpp +++ b/shell/platform/ohos/ohos_shell_holder.cpp @@ -209,6 +209,12 @@ OHOSShellHolder::OHOSShellHolder( is_valid_ = shell_ != nullptr; } +OHOSShellHolder::~OHOSShellHolder() { + FML_LOG(INFO) << "MHN enter ~OHOSShellHolder()"; + shell_.reset(); + thread_host_.reset(); +} + bool OHOSShellHolder::IsValid() const { return is_valid_; } diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 6e94255f25..a1d83ab44d 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -42,6 +42,7 @@ class OHOSShellHolder { std::shared_ptr napi_facade, void* plateform_loop); + ~OHOSShellHolder(); bool IsValid() const; const flutter::Settings& GetSettings() const; diff --git a/shell/platform/ohos/ohos_surface_gl_skia.cpp b/shell/platform/ohos/ohos_surface_gl_skia.cpp index 36609d4b63..dcd4a06481 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.cpp +++ b/shell/platform/ohos/ohos_surface_gl_skia.cpp @@ -45,7 +45,10 @@ OhosSurfaceGLSkia::OhosSurfaceGLSkia( FML_LOG(INFO) << "OhosSurfaceGLSkia constructor end"; } -OhosSurfaceGLSkia::~OhosSurfaceGLSkia() = default; +OhosSurfaceGLSkia::~OhosSurfaceGLSkia() { + eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT); +} void OhosSurfaceGLSkia::TeardownOnScreenContext() { // When the onscreen surface is destroyed, the context and the surface @@ -107,10 +110,11 @@ bool OhosSurfaceGLSkia::ResourceContextMakeCurrent() { } bool OhosSurfaceGLSkia::ResourceContextClearCurrent() { - FML_DCHECK(IsValid()); - EGLBoolean result = eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, - EGL_NO_SURFACE, EGL_NO_CONTEXT); - return result == EGL_TRUE; + // FML_DCHECK(IsValid()); + // EGLBoolean result = eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, + // EGL_NO_SURFACE, EGL_NO_CONTEXT); + // return result == EGL_TRUE; + return true; } bool OhosSurfaceGLSkia::SetNativeWindow(fml::RefPtr window) { diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 29e820b67d..a657f6b949 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -70,10 +70,36 @@ void XComponentAdapter::SetNativeXComponent( std::string& id, OH_NativeXComponent* nativeXComponent) { auto iter = xcomponetMap_.find(id); - if(iter == xcomponetMap_.end()) { - XComponentBase* xcomponet = new XComponentBase(id, nativeXComponent); + if (iter == xcomponetMap_.end()) { + XComponentBase* xcomponet = new XComponentBase(id); xcomponetMap_[id] = xcomponet; } + + iter = xcomponetMap_.find(id); + if (iter != xcomponetMap_.end()) { + iter->second->SetNativeXComponent(nativeXComponent); + } +} + +void XComponentAdapter::AttachFlutterEngine(std::string& id, + std::string& shellholderId) { + auto iter = xcomponetMap_.find(id); + if (iter == xcomponetMap_.end()) { + XComponentBase* xcomponet = new XComponentBase(id); + xcomponetMap_[id] = xcomponet; + } + + auto findIter = xcomponetMap_.find(id); + if (findIter != xcomponetMap_.end()) { + findIter->second->AttachFlutterEngine(shellholderId); + } +} + +void XComponentAdapter::DetachFlutterEngine(std::string& id) { + auto iter = xcomponetMap_.find(id); + if (iter != xcomponetMap_.end()) { + iter->second->DetachFlutterEngine(); + } } #include @@ -213,26 +239,56 @@ void XComponentBase::BindXComponentCallback() { callback_.DispatchTouchEvent = DispatchTouchEventCB; } -XComponentBase::XComponentBase(std::string id,OH_NativeXComponent* xcomponet) { - nativeXComponent_ = xcomponet; - if (nativeXComponent_ != nullptr) { - id_ = id; - BindXComponentCallback(); - OH_NativeXComponent_RegisterCallback(nativeXComponent_, &callback_); +XComponentBase::XComponentBase(std::string id){ + id_ = id; + isEngineAttached_ = false; +} + +XComponentBase::~XComponentBase() {} + +void XComponentBase::AttachFlutterEngine(std::string shellholderId) { + LOGD( + "XComponentManger::AttachFlutterEngine xcomponentId:%{public}s, " + "shellholderId:%{public}s", + id_.c_str(), shellholderId.c_str()); + shellholderId_ = shellholderId; + isEngineAttached_ = true; + if (window_ != nullptr) { + PlatformViewOHOSNapi::SurfaceCreated(std::stoll(shellholderId_), window_); + } else { + LOGE("OnSurfaceCreated XComponentBase is not attached"); } } -XComponentBase::~XComponentBase() -{ +void XComponentBase::DetachFlutterEngine() { + LOGD( + "XComponentManger::DetachFlutterEngine xcomponentId:%{public}s, " + "shellholderId:%{public}s", + id_.c_str(), shellholderId_.c_str()); + if (window_ != nullptr) { + PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); + } else { + LOGE("DetachFlutterEngine XComponentBase is not attached"); + } + shellholderId_ = ""; + isEngineAttached_ = false; +} +void XComponentBase::SetNativeXComponent(OH_NativeXComponent* nativeXComponent){ + nativeXComponent_ = nativeXComponent; + if (nativeXComponent_ != nullptr) { + BindXComponentCallback(); + OH_NativeXComponent_RegisterCallback(nativeXComponent_, &callback_); + } } -void XComponentBase::OnSurfaceCreated(OH_NativeXComponent* component, void* window) -{ +void XComponentBase::OnSurfaceCreated(OH_NativeXComponent* component, + void* window) { LOGD( "XComponentManger::OnSurfaceCreated window = %{public}p component = " "%{public}p", window, component); + window_ = window; int32_t ret = OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_); if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { @@ -248,7 +304,11 @@ void XComponentBase::OnSurfaceCreated(OH_NativeXComponent* component, void* wind if (ret) { LOGD("SetNativeWindowOpt failed:%{public}d", ret); } - PlatformViewOHOSNapi::SurfaceCreated(std::stoll(id_), window); + if (isEngineAttached_) { + PlatformViewOHOSNapi::SurfaceCreated(std::stoll(shellholderId_), window); + } else { + LOGE("OnSurfaceCreated XComponentBase is not attached"); + } } void XComponentBase::OnSurfaceChanged(OH_NativeXComponent* component, void* window) @@ -260,23 +320,41 @@ void XComponentBase::OnSurfaceChanged(OH_NativeXComponent* component, void* wind LOGD("XComponent Current width:%{public}d,height:%{public}d", static_cast(width_), static_cast(height_)); } - PlatformViewOHOSNapi::SurfaceChanged(std::stoll(id_), width_, height_); + if (isEngineAttached_) { + PlatformViewOHOSNapi::SurfaceChanged(std::stoll(shellholderId_), width_, + height_); + } else { + LOGE("OnSurfaceChanged XComponentBase is not attached"); + } } -void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, void* window) -{ +void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, + void* window) { + window_ = nullptr; LOGD("XComponentManger::OnSurfaceDestroyed"); - PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(id_)); + if (isEngineAttached_) { + PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); + } else { + LOGE("OnSurfaceCreated OnSurfaceDestroyed is not attached"); + } } -void XComponentBase::OnDispatchTouchEvent(OH_NativeXComponent* component, void* window) -{ +void XComponentBase::OnDispatchTouchEvent(OH_NativeXComponent* component, + void* window) { LOGD("XComponentManger::DispatchTouchEvent"); int32_t ret = OH_NativeXComponent_GetTouchEvent(component, window, &touchEvent_); if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - ohosTouchProcessor_.HandleTouchEvent(std::stoll(id_), component, &touchEvent_); + if (isEngineAttached_) { + LOGD("XComponentManger::HandleTouchEvent"); + ohosTouchProcessor_.HandleTouchEvent(std::stoll(shellholderId_), + component, &touchEvent_); + } else { + LOGE( + "XComponentManger::DispatchTouchEvent XComponentBase is not " + "attached"); + } } } -} // namespace flutter +} // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.h b/shell/platform/ohos/ohos_xcomponent_adapter.h index 210483e392..4fd6ff4990 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.h +++ b/shell/platform/ohos/ohos_xcomponent_adapter.h @@ -29,9 +29,13 @@ private: void BindXComponentCallback(); public: - XComponentBase(std::string id_, OH_NativeXComponent* xcomponet); + XComponentBase(std::string id); ~XComponentBase(); + void AttachFlutterEngine(std::string shellholderId); + void DetachFlutterEngine(); + void SetNativeXComponent(OH_NativeXComponent* nativeXComponent); + // Callback, called by ACE XComponent void OnSurfaceCreated(OH_NativeXComponent* component, void* window); void OnSurfaceChanged(OH_NativeXComponent* component, void* window); @@ -41,7 +45,11 @@ public: OH_NativeXComponent_TouchEvent touchEvent_; OH_NativeXComponent_Callback callback_; std::string id_; + std::string shellholderId_; + bool isEngineAttached_; + bool isWindowAttached_; OH_NativeXComponent* nativeXComponent_; + void* window_; uint64_t width_; uint64_t height_; OhosTouchProcessor ohosTouchProcessor_; @@ -56,6 +64,8 @@ class XComponentAdapter { bool Export(napi_env env, napi_value exports); void SetNativeXComponent(std::string& id, OH_NativeXComponent* nativeXComponent); + void AttachFlutterEngine(std::string& id, std::string& shellholderId); + void DetachFlutterEngine(std::string& id); public: std::map xcomponetMap_; @@ -66,4 +76,4 @@ class XComponentAdapter { } // namespace flutter -#endif +#endif \ No newline at end of file diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 6f61bf959f..3bd660353f 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -172,6 +172,7 @@ void PlatformViewOHOS::NotifyChanged(const SkISize& size) { // |PlatformView| void PlatformViewOHOS::NotifyDestroyed() { LOGI("PlatformViewOHOS NotifyDestroyed enter"); + PlatformView::NotifyDestroyed(); if (ohos_surface_) { fml::AutoResetWaitableEvent latch; fml::TaskRunner::RunNowOrPostTask( -- Gitee From c9ceaecfd17d0b15bfb48c39adec99311b4eb8f9 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Mon, 29 Jan 2024 19:48:29 +0800 Subject: [PATCH 16/69] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91?= =?UTF-8?q?=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/napi/platform_view_ohos_napi.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index c740480d5f..5564b1c089 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -306,7 +306,7 @@ void PlatformViewOHOSNapi::FlutterViewHandlePlatformMessage( FML_DLOG(ERROR) << "napi_create_string_utf8 err " << status; return; } - + FML_DLOG(INFO) << "FlutterViewHandlePlatformMessage mapData= " << mapData; if (mapData) { delete mapData; } @@ -1496,10 +1496,6 @@ napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, return nullptr; } -int64_t PlatformViewOHOSNapi::GetShellHolder() { - return PlatformViewOHOSNapi::shell_holder_value; -} - void PlatformViewOHOSNapi::SurfaceCreated(int64_t shell_holder, void* window) { auto native_window = fml::MakeRefCounted( static_cast(window)); -- Gitee From ce7dee47bc6fd8a7a9f5e2f6c0f9e275bd9b2035 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 30 Jan 2024 20:23:47 +0800 Subject: [PATCH 17/69] add getflutterloader Signed-off-by: 18719058668 <718092089@qq.com> --- .../src/main/ets/embedding/engine/FlutterEngine.ets | 4 ++++ .../ets/embedding/engine/loader/FlutterLoader.ets | 4 ++++ .../ets/embedding/engine/renderer/FlutterRenderer.ets | 11 ++++++++--- .../src/main/ets/embedding/ohos/FlutterAbility.ets | 4 ++++ .../embedding/ohos/FlutterAbilityAndEntryDelegate.ets | 4 ++++ .../flutter/src/main/ets/view/TextureRegistry.ets | 3 ++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index 390d7d024b..597f61bd8b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -241,6 +241,10 @@ export default class FlutterEngine implements EngineLifecycleListener{ return this.settingsChannel; } + getFlutterLoader() { + return this.flutterLoader; + } + onPreEngineRestart(): void { } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets index 89e7cf3264..cefe06bd1a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets @@ -274,6 +274,10 @@ export default class FlutterLoader { }) : new Array(); } + isInitialized(): boolean { + return this.initialized; + } + } class InitResult { 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 47a38838d5..d41e8e0923 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 @@ -19,11 +19,16 @@ export class FlutterRenderer implements TextureRegistry { return this.registerSurfaceTexture(receiver); } - registerTexture(): SurfaceTextureEntry { - Log.i(TAG, "registerTexture") + getTextureId(): number { this.nextTextureId = this.nextTextureId + 1; + Log.i(TAG, "getTextureId: ", this.nextTextureId ) + return this.nextTextureId; + } + + registerTexture(textureId: number): SurfaceTextureEntry { + Log.i(TAG, "registerTexture") let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId); - let surfaceId = this.flutterNapi.registerTexture(this.nextTextureId); + let surfaceId = this.flutterNapi.registerTexture(textureId); surfaceTextureRegistryEntry.setSurfaceId(surfaceId); return surfaceTextureRegistryEntry; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets index a5869a3cbf..7c63ef9873 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets @@ -208,6 +208,10 @@ export class FlutterAbility extends UIAbility implements Host { return this; } + getFlutterAbilityAndEntryDelegate(): FlutterAbilityAndEntryDelegate | null{ + return this.delegate ?? null; + } + shouldDispatchAppLifecycleState(): boolean { return true; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets index 056d8c0b5c..939d28fd07 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets @@ -397,6 +397,10 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent return this.flutterEngine?.getFlutterNapi() ?? null } + getFlutterEngine(): FlutterEngine | null { + return this.flutterEngine ?? null; + } + detachFromFlutterEngine() { if (this.host?.shouldDestroyEngineWithHost()) { // The host owns the engine and should never have its engine taken by another exclusive 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 18c9d24445..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 @@ -17,7 +17,8 @@ import image from '@ohos.multimedia.image'; export interface TextureRegistry { createSurfaceTexture(): SurfaceTextureEntry; - registerTexture(): SurfaceTextureEntry; + getTextureId(): number; + registerTexture(textureId: number): SurfaceTextureEntry; registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; registerPixelMap(pixelMap: PixelMap): number; unregisterTexture(textureId: number): void; -- Gitee From e2ef67185e33e04106e610421080e29925af8770 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 30 Jan 2024 20:50:36 +0800 Subject: [PATCH 18/69] modify nativeSpawn Signed-off-by: 18719058668 <718092089@qq.com> --- .../flutter/src/main/cpp/types/libflutter/index.d.ets | 2 -- 1 file changed, 2 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 3f16c6c5cd..6cb09bd9f0 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 @@ -54,8 +54,6 @@ export const nativeSpawn: ( initialRoute: string, entrypointArgs: Array, napi: FlutterNapi - entrypointArgs: Array, - napi: FlutterNapi ) => number; export const nativeRunBundleAndSnapshotFromLibrary: ( -- Gitee From 25c4a79c00fe9922f8840d3c5837ba68b3bd5396 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Wed, 31 Jan 2024 18:09:46 +0800 Subject: [PATCH 19/69] =?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=9A=84=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../ets/embedding/engine/FlutterEngine.ets | 2 ++ .../embedding/engine/loader/FlutterLoader.ets | 2 +- .../engine/renderer/FlutterRenderer.ets | 2 +- shell/platform/ohos/library_loader.cpp | 2 ++ shell/platform/ohos/platform_view_ohos.cpp | 31 ++++++++++++++++--- shell/platform/ohos/platform_view_ohos.h | 13 ++++++++ 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index 597f61bd8b..b99be906f1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -144,6 +144,8 @@ export default class FlutterEngine implements EngineLifecycleListener{ if (automaticallyRegisterPlugins && plugins) { GeneratedPluginRegister.registerGeneratedPlugins(this, plugins); } + + Log.d(TAG, "Call init finished.") } private attachToNapi(): void { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets index cefe06bd1a..2317af9f61 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets @@ -170,7 +170,6 @@ export default class FlutterLoader { if (this.initialized) { return; } - Log.d(TAG, "ensureInitializationComplete") if (shellArgs == null) { shellArgs = new Array(); } @@ -231,6 +230,7 @@ export default class FlutterLoader { costTime ); this.initialized = true; + Log.d(TAG, "ensureInitializationComplete") } findAppBundlePath(): string { 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 d41e8e0923..f2f1f75c94 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 @@ -26,9 +26,9 @@ export class FlutterRenderer implements TextureRegistry { } registerTexture(textureId: number): SurfaceTextureEntry { - Log.i(TAG, "registerTexture") let surfaceTextureRegistryEntry = new SurfaceTextureRegistryEntry(this.nextTextureId); let surfaceId = this.flutterNapi.registerTexture(textureId); + Log.i(TAG, "registerTexture, surfaceId=" + surfaceId); surfaceTextureRegistryEntry.setSurfaceId(surfaceId); return surfaceTextureRegistryEntry; } diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 506efd16ab..f6c52a6aff 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -124,6 +124,8 @@ static napi_value Init(napi_env env, napi_value exports) { flutter::PlatformViewOHOSNapi::nativeRegisterPixelMap), }; + + FML_DLOG(INFO) << "Init NAPI size=" << sizeof(desc) / sizeof(desc[0]); napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); bool ret = flutter::XComponentAdapter::GetInstance()->Export(env, exports); if (!ret) { diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 3bd660353f..dee61402d1 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -416,7 +416,11 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; return surface_id; } - nativeImageFrameAvailableListener_.context = this; + // std::make_shared(this); + // std::shared_ptr* p = std::make_shared(this); + void* contextData = new OhosImageFrameData(this, texture_id); + // std::shared_ptr contextData = std::make_shared(std::make_shared(this), texture_id); + nativeImageFrameAvailableListener_.context = contextData; nativeImageFrameAvailableListener_.onFrameAvailable = &PlatformViewOHOS::OnNativeImageFrameAvailable; ret = OH_NativeImage_SetOnFrameAvailableListener(ohos_external_gl->nativeImage_, nativeImageFrameAvailableListener_); if (ret != 0) { @@ -434,11 +438,23 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { } void PlatformViewOHOS::OnNativeImageFrameAvailable(void *data) { - auto renderThread = reinterpret_cast(data); - if (renderThread == nullptr) { + auto frameData = reinterpret_cast(data); + if (frameData == nullptr || frameData->context_ == nullptr) { + FML_DLOG(ERROR) << "OnNativeImageFrameAvailable, frameData or context_ is null."; return; } - renderThread->MarkNewFrameAvailable(); + std::shared_ptr ohos_surface = frameData->context_->ohos_surface_; + const TaskRunners task_runners = frameData->context_->task_runners_;; + if (ohos_surface) { + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask( + task_runners.GetPlatformTaskRunner(), + [&latch, surface = ohos_surface.get(), frameData]() { + frameData->context_->MarkTextureFrameAvailable(frameData->texture_id_); + latch.Signal(); + }); + latch.Wait(); + } } void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) @@ -463,4 +479,11 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat } } +OhosImageFrameData::OhosImageFrameData( + PlatformViewOHOS* context, + int64_t texture_id) + : context_(context), texture_id_(texture_id) {} + +OhosImageFrameData::~OhosImageFrameData() = default; + } // namespace flutter diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 572f8640ac..387022cc08 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -182,5 +182,18 @@ class PlatformViewOHOS final : public PlatformView { static void OnNativeImageFrameAvailable(void *data); }; + +class OhosImageFrameData { + public: + OhosImageFrameData(PlatformViewOHOS* context, + int64_t texture_id); + + ~OhosImageFrameData(); + + PlatformViewOHOS* context_; + + int64_t texture_id_; +}; + } // namespace flutter #endif -- Gitee From 157451adf9bce4c71a6752160619a189e5a23548 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Wed, 31 Jan 2024 19:25:21 +0800 Subject: [PATCH 20/69] add log Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 2574c5446f..db95635f06 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -67,7 +67,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, InitEGLEnv(); glGenTextures(1, &texture_name_); // Attach(static_cast(texture_name_)); - OH_NativeImage_AttachContext(nativeImage_, texture_name_); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if(ret != 0) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; + } state_ = AttachmentState::attached; } if (!freeze && new_frame_ready_) { @@ -149,7 +152,10 @@ void OHOSExternalTextureGL::Attach(int textureName) { nativeWindow_ = OH_NativeImage_AcquireNativeWindow(nativeImage_); } - OH_NativeImage_AttachContext(nativeImage_, textureName); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, textureName); + if(ret != 0) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; + } } void OHOSExternalTextureGL::Update() { -- Gitee From a596297229a45eb7e8b10fd1bba18078eb047b25 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Thu, 1 Feb 2024 10:39:58 +0800 Subject: [PATCH 21/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E8=AF=95?= 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 | 7 +++++-- shell/platform/ohos/platform_view_ohos.cpp | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index db95635f06..1616128984 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -64,10 +64,13 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - InitEGLEnv(); glGenTextures(1, &texture_name_); - // Attach(static_cast(texture_name_)); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index dee61402d1..a3df1b93ce 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -416,10 +416,7 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; return surface_id; } - // std::make_shared(this); - // std::shared_ptr* p = std::make_shared(this); void* contextData = new OhosImageFrameData(this, texture_id); - // std::shared_ptr contextData = std::make_shared(std::make_shared(this), texture_id); nativeImageFrameAvailableListener_.context = contextData; nativeImageFrameAvailableListener_.onFrameAvailable = &PlatformViewOHOS::OnNativeImageFrameAvailable; ret = OH_NativeImage_SetOnFrameAvailableListener(ohos_external_gl->nativeImage_, nativeImageFrameAvailableListener_); -- Gitee From 22cce9aabd7bd99bd494a7a0a63fc7a624bdaf08 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 4 Feb 2024 15:03:22 +0800 Subject: [PATCH 22/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E8=B0=83=E8=AF=95,=E6=97=A0=E9=97=AA=E9=80=80,=E5=8F=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=AE=80=E5=8D=95=E5=9B=BE=E5=BD=A2?= 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 | 147 +++++++++++++++--- .../platform/ohos/ohos_external_texture_gl.h | 10 ++ 2 files changed, 133 insertions(+), 24 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 1616128984..2cbccebe51 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -23,6 +23,10 @@ #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" +#include "third_party/skia/src/gpu/gl/GrGLDefines.h" +#include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/effects/Sk1DPathEffect.h" +#include "third_party/skia/tools/Registry.h" #include #include @@ -55,37 +59,122 @@ OHOSExternalTextureGL::~OHOSExternalTextureGL() { } } +// copy from src/third_party/skia/docs/examples/skpaint_skia.cpp +void drawSample(SkCanvas* canvas) { + SkPaint paint1, paint2, paint3; + + paint1.setAntiAlias(true); + paint1.setColor(SkColorSetRGB(255, 0, 0)); + paint1.setStyle(SkPaint::kFill_Style); + + paint2.setAntiAlias(true); + paint2.setColor(SkColorSetRGB(0, 136, 0)); + paint2.setStyle(SkPaint::kStroke_Style); + paint2.setStrokeWidth(SkIntToScalar(3)); + + paint3.setAntiAlias(true); + paint3.setColor(SkColorSetRGB(136, 136, 136)); + + sk_sp blob1 = + SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.0f, 0.0f)); + sk_sp blob2 = + SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.5f, 0.0f)); + + canvas->clear(SK_ColorWHITE); + canvas->drawTextBlob(blob1.get(), 20.0f, 64.0f, paint1); + canvas->drawTextBlob(blob1.get(), 20.0f, 144.0f, paint2); + canvas->drawTextBlob(blob2.get(), 20.0f, 224.0f, paint3); +} + +// copy from src/third_party/skia/docs/examples/skpaint_path_1d_path_effect.cpp +void drawSample2(SkCanvas* canvas) { + SkPaint paint; + SkPath path; + path.addOval(SkRect::MakeWH(16.0f, 6.0f)); + paint.setPathEffect( + SkPath1DPathEffect::Make(path, 32.0f, 0.0f, SkPath1DPathEffect::kRotate_Style)); + paint.setAntiAlias(true); + canvas->clear(SK_ColorWHITE); + canvas->drawCircle(128.0f, 128.0f, 122.0f, paint); +} + +// start drawSample3 +// copy from src/third_party/skia/docs/examples/alpha_bitmap_color_filter_mask_filter.cpp +static SkBitmap make_alpha_image(int w, int h) { + SkBitmap bm; + bm.allocPixels(SkImageInfo::MakeA8(w, h)); + bm.eraseARGB(10, 0, 0, 0); + for (int y = 0; y < bm.height(); ++y) { + for (int x = y; x < bm.width(); ++x) { + *bm.getAddr8(x, y) = 0xFF; + } + } + bm.setImmutable(); + return bm; +} + +static sk_sp make_color_filter() { + SkScalar colorMatrix[20] = { + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 0.5, 0.5, 0, + 0, 0, 0.5, 0.5, 0}; // mix G and A. + return SkColorFilters::Matrix(colorMatrix); +} + +void drawSample3(SkCanvas* canvas) { + auto image = make_alpha_image(96, 96).asImage(); + SkSamplingOptions sampling; + SkPaint paint; + + paint.setColorFilter(make_color_filter()); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 10.0f, false)); + canvas->drawImage(image.get(), 16, 16, sampling, &paint); + + paint.setColorFilter(nullptr); + paint.setShader(SkShaders::Color(SK_ColorCYAN)); + canvas->drawImage(image.get(), 144, 16, sampling, &paint); + + paint.setColorFilter(make_color_filter()); + canvas->drawImage(image.get(), 16, 144, sampling, &paint); + + paint.setMaskFilter(nullptr); + canvas->drawImage(image.get(), 144, 144, sampling, &paint); +} +// end drawSample3 + void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { + FML_DLOG(ERROR) << "OHOSExternalTextureGL::Paint"; return; } if (state_ == AttachmentState::uninitialized) { - glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if(ret != 0) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; - } + Attach(static_cast(texture_name_)); state_ = AttachmentState::attached; } if (!freeze && new_frame_ready_) { Update(); new_frame_ready_ = false; } + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, texture_name_=" << texture_name_; + PaintOrigin(context, bounds, freeze, sampling); +} + +void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, + const SkRect& bounds, + bool freeze, + const SkSamplingOptions& sampling) { GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, - GL_RGBA8_OES}; - GrBackendTexture backendTexture(pixelMapInfo.width, pixelMapInfo.height, GrMipMapped::kNo, textureInfo); + GR_GL_RGBA8}; + GrBackendTexture backendTexture(bounds.width(), bounds.height(), GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, - kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); + kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr); // 修改这里后不闪退了 + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, image=" << image; if (image) { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 1"; SkAutoCanvasRestore autoRestore(context.canvas, true); @@ -109,11 +198,20 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, context.canvas->drawRect(SkRect::MakeWH(1, 1), paintWithShader); } else { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 3"; + // todo 看这里对不对 context.canvas->drawImage(image, 0, 0, sampling, context.sk_paint); + FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 4"; } } } +void OHOSExternalTextureGL::PaintOhImage(PaintContext& context, + const SkRect& bounds, + bool freeze, + const SkSamplingOptions& sampling) { + // todo 参考Demo中的方式,测试直接使用egl绘制视频纹理是否可行 +} + void OHOSExternalTextureGL::OnGrContextCreated() { FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextCreated"; state_ = AttachmentState::uninitialized; @@ -144,21 +242,17 @@ void OHOSExternalTextureGL::Attach(int textureName) { FML_DLOG(INFO)<<"OHOSExternalTextureGL eglContext_ no context, need init"; InitEGLEnv(); } - if(nativeImage_ == nullptr) { - // glGenTextures(1, &texture_name_); - nativeImage_ = OH_NativeImage_Create(textureName, GL_TEXTURE_2D); - FML_DLOG(INFO)<<"OHOSExternalTextureGL texture_name_:"<(textureName); - FML_DLOG(INFO)<<"OHOSExternalTextureGL nativeImage addr:"< Date: Sun, 4 Feb 2024 15:20:08 +0800 Subject: [PATCH 23/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E8=B0=83=E8=AF=95,=E6=97=A0=E9=97=AA=E9=80=80,=E5=8F=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=AE=80=E5=8D=95=E5=9B=BE=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../platform/ohos/ohos_external_texture_gl.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 2cbccebe51..5cd16db924 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -203,6 +203,12 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 4"; } } + + FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag1"; + // drawSample(context.canvas); + drawSample2(context.canvas); + drawSample3(context.canvas); + FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag2"; } void OHOSExternalTextureGL::PaintOhImage(PaintContext& context, @@ -244,15 +250,16 @@ void OHOSExternalTextureGL::Attach(int textureName) { } glGenTextures(1, &texture_name_); + + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, textureName); + if (ret != 0) { + FML_DLOG(FATAL) << "OHOSExternalTextureGL OH_NativeImage_AttachContext err code:" << ret; + } + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, textureName); - if(ret != 0) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; - } } void OHOSExternalTextureGL::Update() { -- Gitee From 75f65842667ae500242505dbb4644f12d7897c5d Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Sun, 4 Feb 2024 22:36:26 +0800 Subject: [PATCH 24/69] add ohos_surface in OHOSExternalTextureGL Signed-off-by: 18719058668 <718092089@qq.com> --- .../platform/ohos/ohos_external_texture_gl.cpp | 17 +++++++++++++---- shell/platform/ohos/ohos_external_texture_gl.h | 4 +++- shell/platform/ohos/platform_view_ohos.cpp | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 5cd16db924..85f81c5e50 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,8 +42,8 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) - : Texture(id),transform(SkMatrix::I()) { +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, std::shared_ptr ohos_surface) + : Texture(id), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; eglContext_ = EGL_NO_CONTEXT; @@ -153,8 +153,17 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - Attach(static_cast(texture_name_)); - state_ = AttachmentState::attached; + if (ohos_surface_->ResourceContextMakeCurrent()) { + glGenTextures(1, &texture_name_); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if(ret != 0) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; + } + state_ = AttachmentState::attached; + } else { + FML_DLOG(FATAL)<<"ResourceContextMakeCurrent failed"; + } + } if (!freeze && new_frame_ready_) { Update(); diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 85ff93cf45..454fe4dd47 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -21,6 +21,7 @@ #include #include "flutter/common/graphics/texture.h" +#include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "napi/platform_view_ohos_napi.h" #include #include @@ -33,7 +34,7 @@ namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id); + explicit OHOSExternalTextureGL(int64_t id, std::shared_ptr ohos_surface); ~OHOSExternalTextureGL() override; @@ -105,6 +106,7 @@ class OHOSExternalTextureGL : public flutter::Texture { OhosPixelMapInfos pixelMapInfo; + std::shared_ptr ohos_surface_; int fenceFd = -1; EGLContext eglContext_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index a3df1b93ce..5a2c1e2b91 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -410,7 +410,7 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { uint64_t surface_id = 0; int ret = -1; if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); ohos_external_gl->nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); if (ohos_external_gl->nativeImage_ == nullptr) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; -- Gitee From 020c7016f9ddca83ed21a91264df8b9e8a542e21 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Sun, 4 Feb 2024 23:30:27 +0800 Subject: [PATCH 25/69] modify error Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 4 ++-- shell/platform/ohos/ohos_external_texture_gl.h | 5 +++-- shell/platform/ohos/platform_view_ohos.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 85f81c5e50..67df1f27ed 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,8 +42,8 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, std::shared_ptr ohos_surface) - : Texture(id), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) + : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; eglContext_ = EGL_NO_CONTEXT; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 454fe4dd47..84cbcee890 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -34,7 +34,7 @@ namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id, std::shared_ptr ohos_surface); + explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface); ~OHOSExternalTextureGL() override; @@ -94,6 +94,8 @@ class OHOSExternalTextureGL : public flutter::Texture { GLuint texture_name_ = 0; + std::shared_ptr ohos_surface_; + SkMatrix transform; OHNativeWindow *nativeWindow_; @@ -106,7 +108,6 @@ class OHOSExternalTextureGL : public flutter::Texture { OhosPixelMapInfos pixelMapInfo; - std::shared_ptr ohos_surface_; int fenceFd = -1; EGLContext eglContext_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 5a2c1e2b91..c32b7d30bf 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -398,7 +398,7 @@ void PlatformViewOHOS::RegisterExternalTextureByImage( if(iter != external_texture_gl_.end()) { iter->second->DispatchImage(image); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_)); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchImage(image); @@ -467,7 +467,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat if(iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_)); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchPixelMap(pixelMap); -- Gitee From 474c5445775f9920031118d19386dc9f1c914dcc Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 10:45:17 +0800 Subject: [PATCH 26/69] add GLContextMakeCurrent Signed-off-by: 18719058668 <718092089@qq.com> --- 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 67df1f27ed..32cfbf7ad2 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -153,7 +153,8 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - if (ohos_surface_->ResourceContextMakeCurrent()) { + GLContextResult result = ohos_surface_->GLContextMakeCurrent(); + if (result.GetResult()) { glGenTextures(1, &texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { -- Gitee From d7476cc78ce4e38d82400294b7bbc0aa7290f3b4 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 4 Feb 2024 22:40:03 +0800 Subject: [PATCH 27/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 32cfbf7ad2..84673e95d0 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -179,11 +179,11 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, bool freeze, const SkSamplingOptions& sampling) { GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, - GR_GL_RGBA8}; - GrBackendTexture backendTexture(bounds.width(), bounds.height(), GrMipMapped::kNo, textureInfo); + GL_RGBA8_OES}; + GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, - kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr); // 修改这里后不闪退了 + kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, image=" << image; if (image) { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 1"; @@ -216,7 +216,7 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag1"; // drawSample(context.canvas); - drawSample2(context.canvas); + // drawSample2(context.canvas); drawSample3(context.canvas); FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag2"; } @@ -254,12 +254,13 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { } void OHOSExternalTextureGL::Attach(int textureName) { - if(eglContext_ == EGL_NO_CONTEXT) { + if (eglContext_ == EGL_NO_CONTEXT) { FML_DLOG(INFO)<<"OHOSExternalTextureGL eglContext_ no context, need init"; InitEGLEnv(); } glGenTextures(1, &texture_name_); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, textureName); if (ret != 0) { -- Gitee From b7756da6339bbe245b37e6892be2fdd189ec8414 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 12:06:15 +0800 Subject: [PATCH 28/69] change OHossurface to OhosSurfaceGLSkia Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 2 +- shell/platform/ohos/ohos_external_texture_gl.h | 4 ++-- shell/platform/ohos/platform_view_ohos.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 32cfbf7ad2..f3e78b3cae 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,7 +42,7 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 84cbcee890..9ec38c7b18 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -34,7 +34,7 @@ namespace flutter { 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); ~OHOSExternalTextureGL() override; @@ -94,7 +94,7 @@ class OHOSExternalTextureGL : public flutter::Texture { GLuint texture_name_ = 0; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; SkMatrix transform; diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 387022cc08..02333cd29b 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -125,7 +125,7 @@ class PlatformViewOHOS final : public PlatformView { const std::shared_ptr napi_facade_; std::shared_ptr ohos_context_; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; -- Gitee From 9304e17ddc63bc05e4fc075583bb2db4d8116935 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 21:23:02 +0800 Subject: [PATCH 29/69] temporarily modify CreateSurface Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/platform_view_ohos.cpp | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index c32b7d30bf..d74bd64d23 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -38,21 +38,25 @@ OhosSurfaceFactoryImpl::OhosSurfaceFactoryImpl( OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; -std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { - switch (ohos_context_->RenderingApi()) { - case OHOSRenderingAPI::kSoftware: - return std::make_unique(ohos_context_); - case OHOSRenderingAPI::kOpenGLES: - if (enable_impeller_) { - return std::make_unique(ohos_context_); - } else { - FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; - return std::make_unique(ohos_context_); - } - default: - FML_DCHECK(false); - return nullptr; - } +// std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { +// switch (ohos_context_->RenderingApi()) { +// case OHOSRenderingAPI::kSoftware: +// return std::make_unique(ohos_context_); +// case OHOSRenderingAPI::kOpenGLES: +// if (enable_impeller_) { +// return std::make_unique(ohos_context_); +// } else { +// FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; +// return std::make_unique(ohos_context_); +// } +// default: +// FML_DCHECK(false); +// return nullptr; +// } +// } +std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { + FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; + return std::make_unique(ohos_context_); } std::unique_ptr CreateOHOSContext( -- Gitee From 0de941a7c5cc051796925ffdb14846dd24a12732 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 22:52:50 +0800 Subject: [PATCH 30/69] add ohos_surface_gl_skia.h Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/platform_view_ohos.h | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 02333cd29b..5ef9092bb4 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,6 +31,7 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" +#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include #include "ohos_external_texture_gl.h" #include -- Gitee From 6ea9b50f695a472be88ffffd35c572b74b0e165f Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 23:01:34 +0800 Subject: [PATCH 31/69] add h file Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 9ec38c7b18..22d698e078 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -22,6 +22,7 @@ #include "flutter/common/graphics/texture.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" +#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "napi/platform_view_ohos_napi.h" #include #include -- Gitee From 0f805362e91792a9ff063f5aeef730de502008ea Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 23:05:13 +0800 Subject: [PATCH 32/69] modify auto Signed-off-by: 18719058668 <718092089@qq.com> --- 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 74cd23a0cb..3096023647 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -153,7 +153,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - GLContextResult result = ohos_surface_->GLContextMakeCurrent(); + auto result = ohos_surface_->GLContextMakeCurrent(); if (result.GetResult()) { glGenTextures(1, &texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); -- Gitee From 5342449c9155f5678aa1f6e93d1983e910b64d34 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 23:09:29 +0800 Subject: [PATCH 33/69] modify ohos_external_texture_gl.cpp Signed-off-by: 18719058668 <718092089@qq.com> --- 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 3096023647..2af8911782 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -154,7 +154,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, } if (state_ == AttachmentState::uninitialized) { auto result = ohos_surface_->GLContextMakeCurrent(); - if (result.GetResult()) { + if (result->GetResult()) { glGenTextures(1, &texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { -- Gitee From f061f502730343abf25e1b9bc1c39044e0117180 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 5 Feb 2024 23:15:23 +0800 Subject: [PATCH 34/69] test Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/platform_view_ohos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index d74bd64d23..a4c1fc8afb 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -471,7 +471,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat if(iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_)); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchPixelMap(pixelMap); -- Gitee From 4a2f6cbdfb55d560caee25e81d3304cdf4f8303e Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 08:48:43 +0800 Subject: [PATCH 35/69] modify CreateSurface Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/platform_view_ohos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 5ef9092bb4..e2358c9709 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -45,7 +45,7 @@ class OhosSurfaceFactoryImpl : public OhosSurfaceFactory { ~OhosSurfaceFactoryImpl() override; - std::unique_ptr CreateSurface() override; + std::unique_ptr CreateSurface() override; private: const std::shared_ptr& ohos_context_; -- Gitee From ac3c973b5dd260aa7f9735ea2dac78769082d91f Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 09:00:34 +0800 Subject: [PATCH 36/69] modify ohos_surface.h Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/surface/ohos_surface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/ohos/surface/ohos_surface.h b/shell/platform/ohos/surface/ohos_surface.h index b87757d5f5..ecce30bc8b 100644 --- a/shell/platform/ohos/surface/ohos_surface.h +++ b/shell/platform/ohos/surface/ohos_surface.h @@ -20,6 +20,7 @@ #include "flutter/flow/surface.h" #include "flutter/shell/platform/ohos/context/ohos_context.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" +#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "third_party/skia/include/core/SkSize.h" namespace impeller { @@ -60,7 +61,7 @@ class OhosSurfaceFactory { virtual ~OhosSurfaceFactory() = default; - virtual std::unique_ptr CreateSurface() = 0; + virtual std::unique_ptr CreateSurface() = 0; }; } // namespace flutter -- Gitee From 1e48dc05591c8729fec44a5ef39467e0993d310b Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 11:15:30 +0800 Subject: [PATCH 37/69] revert ohos_surface in ohos_external_texture_gl Signed-off-by: 18719058668 <718092089@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 22 +++++----- .../platform/ohos/ohos_external_texture_gl.h | 6 +-- shell/platform/ohos/platform_view_ohos.cpp | 40 +++++++++---------- shell/platform/ohos/platform_view_ohos.h | 5 +-- shell/platform/ohos/surface/ohos_surface.h | 3 +- 5 files changed, 31 insertions(+), 45 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 2af8911782..2cd59154db 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,8 +42,8 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) - : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) + : Texture(id),transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; eglContext_ = EGL_NO_CONTEXT; @@ -153,18 +153,14 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - auto result = ohos_surface_->GLContextMakeCurrent(); - if (result->GetResult()) { - glGenTextures(1, &texture_name_); - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); - if(ret != 0) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; - } - state_ = AttachmentState::attached; - } else { - FML_DLOG(FATAL)<<"ResourceContextMakeCurrent failed"; + InitEGLEnv(); + glGenTextures(1, &texture_name_); + // Attach(static_cast(texture_name_)); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if(ret != 0) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } - + state_ = AttachmentState::attached; } if (!freeze && new_frame_ready_) { Update(); diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 22d698e078..85ff93cf45 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -21,8 +21,6 @@ #include #include "flutter/common/graphics/texture.h" -#include "flutter/shell/platform/ohos/surface/ohos_surface.h" -#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "napi/platform_view_ohos_napi.h" #include #include @@ -35,7 +33,7 @@ namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface); + explicit OHOSExternalTextureGL(int64_t id); ~OHOSExternalTextureGL() override; @@ -95,8 +93,6 @@ class OHOSExternalTextureGL : public flutter::Texture { GLuint texture_name_ = 0; - std::shared_ptr ohos_surface_; - SkMatrix transform; OHNativeWindow *nativeWindow_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index a4c1fc8afb..a3df1b93ce 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -38,25 +38,21 @@ OhosSurfaceFactoryImpl::OhosSurfaceFactoryImpl( OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; -// std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { -// switch (ohos_context_->RenderingApi()) { -// case OHOSRenderingAPI::kSoftware: -// return std::make_unique(ohos_context_); -// case OHOSRenderingAPI::kOpenGLES: -// if (enable_impeller_) { -// return std::make_unique(ohos_context_); -// } else { -// FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; -// return std::make_unique(ohos_context_); -// } -// default: -// FML_DCHECK(false); -// return nullptr; -// } -// } -std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { - FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; - return std::make_unique(ohos_context_); +std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { + switch (ohos_context_->RenderingApi()) { + case OHOSRenderingAPI::kSoftware: + return std::make_unique(ohos_context_); + case OHOSRenderingAPI::kOpenGLES: + if (enable_impeller_) { + return std::make_unique(ohos_context_); + } else { + FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; + return std::make_unique(ohos_context_); + } + default: + FML_DCHECK(false); + return nullptr; + } } std::unique_ptr CreateOHOSContext( @@ -402,7 +398,7 @@ void PlatformViewOHOS::RegisterExternalTextureByImage( if(iter != external_texture_gl_.end()) { iter->second->DispatchImage(image); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_)); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchImage(image); @@ -414,7 +410,7 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { uint64_t surface_id = 0; int ret = -1; if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); ohos_external_gl->nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); if (ohos_external_gl->nativeImage_ == nullptr) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; @@ -471,7 +467,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat if(iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchPixelMap(pixelMap); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index e2358c9709..387022cc08 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -31,7 +31,6 @@ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" -#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include #include "ohos_external_texture_gl.h" #include @@ -45,7 +44,7 @@ class OhosSurfaceFactoryImpl : public OhosSurfaceFactory { ~OhosSurfaceFactoryImpl() override; - std::unique_ptr CreateSurface() override; + std::unique_ptr CreateSurface() override; private: const std::shared_ptr& ohos_context_; @@ -126,7 +125,7 @@ class PlatformViewOHOS final : public PlatformView { const std::shared_ptr napi_facade_; std::shared_ptr ohos_context_; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; diff --git a/shell/platform/ohos/surface/ohos_surface.h b/shell/platform/ohos/surface/ohos_surface.h index ecce30bc8b..b87757d5f5 100644 --- a/shell/platform/ohos/surface/ohos_surface.h +++ b/shell/platform/ohos/surface/ohos_surface.h @@ -20,7 +20,6 @@ #include "flutter/flow/surface.h" #include "flutter/shell/platform/ohos/context/ohos_context.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" -#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "third_party/skia/include/core/SkSize.h" namespace impeller { @@ -61,7 +60,7 @@ class OhosSurfaceFactory { virtual ~OhosSurfaceFactory() = default; - virtual std::unique_ptr CreateSurface() = 0; + virtual std::unique_ptr CreateSurface() = 0; }; } // namespace flutter -- Gitee From 955e96a49e9e8a702a1273f98580d8b5de813619 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 11:44:20 +0800 Subject: [PATCH 38/69] makecurrent Signed-off-by: 18719058668 <718092089@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 2cd59154db..568dd1495c 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -153,14 +153,19 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - InitEGLEnv(); - glGenTextures(1, &texture_name_); - // Attach(static_cast(texture_name_)); - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); - if(ret != 0) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; + EGLContext current_egl_context = eglGetCurrentContext(); + EGLDisplay current_egl_display = eglGetCurrentDisplay(); + if (eglMakeCurrent(current_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, current_egl_context) != EGL_TRUE) { + FML_DLOG(ERROR) << "OHOSExternalTextureGL::Could not make the context current"; + } else { + glGenTextures(1, &texture_name_); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if(ret != 0) { + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; + } + state_ = AttachmentState::attached; } - state_ = AttachmentState::attached; + } if (!freeze && new_frame_ready_) { Update(); -- Gitee From 9636dd367cbb8f0bacdb203c41ce3446c8a381a3 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 12:23:53 +0800 Subject: [PATCH 39/69] comment drawsample3 Signed-off-by: 18719058668 <718092089@qq.com> --- 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 568dd1495c..d617a62f89 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -218,7 +218,7 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag1"; // drawSample(context.canvas); // drawSample2(context.canvas); - drawSample3(context.canvas); + //drawSample3(context.canvas); FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag2"; } -- Gitee From 3235e759cd733c8a40016dedc481010971b0f309 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 14:04:22 +0800 Subject: [PATCH 40/69] modify height and width Signed-off-by: 18719058668 <718092089@qq.com> --- 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 d617a62f89..9e7cf2c6e7 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -181,7 +181,7 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, const SkSamplingOptions& sampling) { GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, GL_RGBA8_OES}; - GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); + GrBackendTexture backendTexture(720, 1280, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); -- Gitee From 196abed991a319011617efc588f63ddd7c43993c Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 16:51:35 +0800 Subject: [PATCH 41/69] git add OHOSUnifiedSurface Signed-off-by: 18719058668 <718092089@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 14 +-- .../platform/ohos/ohos_external_texture_gl.h | 7 +- .../platform/ohos/ohos_surface_gl_impeller.h | 5 +- shell/platform/ohos/ohos_surface_gl_skia.h | 5 +- shell/platform/ohos/ohos_surface_software.h | 6 +- shell/platform/ohos/ohos_unified_surface.cpp | 22 +++++ shell/platform/ohos/ohos_unified_surface.h | 86 +++++++++++++++++++ shell/platform/ohos/platform_view_ohos.cpp | 10 +-- shell/platform/ohos/platform_view_ohos.h | 5 +- shell/platform/ohos/surface/ohos_surface.h | 3 +- 10 files changed, 140 insertions(+), 23 deletions(-) create mode 100644 shell/platform/ohos/ohos_unified_surface.cpp create mode 100644 shell/platform/ohos/ohos_unified_surface.h diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 9e7cf2c6e7..a36b1aeac4 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,8 +42,8 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id) - : Texture(id),transform(SkMatrix::I()) { +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) + : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; eglContext_ = EGL_NO_CONTEXT; @@ -153,17 +153,17 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - EGLContext current_egl_context = eglGetCurrentContext(); - EGLDisplay current_egl_display = eglGetCurrentDisplay(); - if (eglMakeCurrent(current_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, current_egl_context) != EGL_TRUE) { - FML_DLOG(ERROR) << "OHOSExternalTextureGL::Could not make the context current"; - } else { + auto result = ohos_surface_->GLContextMakeCurrent(); + if (result->GetResult()) { + FML_DLOG(FATAL)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } state_ = AttachmentState::attached; + } else { + FML_DLOG(FATAL)<<"ResourceContextMakeCurrent failed"; } } diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 85ff93cf45..d89bc16d62 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -21,19 +21,22 @@ #include #include "flutter/common/graphics/texture.h" +#include "flutter/shell/platform/ohos/surface/ohos_surface.h" +#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "napi/platform_view_ohos_napi.h" #include #include #include #include #include +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" // maybe now unused namespace flutter { class OHOSExternalTextureGL : public flutter::Texture { public: - explicit OHOSExternalTextureGL(int64_t id); + explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface); ~OHOSExternalTextureGL() override; @@ -93,6 +96,8 @@ class OHOSExternalTextureGL : public flutter::Texture { GLuint texture_name_ = 0; + std::shared_ptr ohos_surface_; + SkMatrix transform; OHNativeWindow *nativeWindow_; diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index 87b2fa4bf6..be6ce8c662 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -22,11 +22,12 @@ #include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "surface/ohos_native_window.h" #include "surface/ohos_surface.h" +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { -class OHOSSurfaceGLImpeller final : public GPUSurfaceGLDelegate, - public OHOSSurface { +class OHOSSurfaceGLImpeller final : public OHOSUnifiedSurface + { public: OHOSSurfaceGLImpeller(const std::shared_ptr& ohos_context); diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 4a99529433..69d16a0138 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -24,11 +24,12 @@ #include "flutter/shell/platform/ohos/ohos_context_gl_skia.h" #include "flutter/shell/platform/ohos/ohos_environment_gl.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { -class OhosSurfaceGLSkia final : public GPUSurfaceGLDelegate, - public OHOSSurface { +class OhosSurfaceGLSkia final : public OHOSUnifiedSurface + { public: OhosSurfaceGLSkia(const std::shared_ptr& ohos_context); diff --git a/shell/platform/ohos/ohos_surface_software.h b/shell/platform/ohos/ohos_surface_software.h index a0dfd8ae00..1fc736a1d3 100644 --- a/shell/platform/ohos/ohos_surface_software.h +++ b/shell/platform/ohos/ohos_surface_software.h @@ -19,13 +19,13 @@ #include "flutter/fml/macros.h" #include "flutter/shell/gpu/gpu_surface_software.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" - +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" namespace flutter { -class OHOSSurfaceSoftware final : public OHOSSurface, - public GPUSurfaceSoftwareDelegate { +class OHOSSurfaceSoftware final : public OHOSUnifiedSurface + { public: OHOSSurfaceSoftware(const std::shared_ptr& ohos_context); ~OHOSSurfaceSoftware() override; diff --git a/shell/platform/ohos/ohos_unified_surface.cpp b/shell/platform/ohos/ohos_unified_surface.cpp new file mode 100644 index 0000000000..73c3a0c954 --- /dev/null +++ b/shell/platform/ohos/ohos_unified_surface.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" +namespace flutter { + +OHOSUnifiedSurface::OHOSUnifiedSurface() {} + + +} // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h new file mode 100644 index 0000000000..7c7833448a --- /dev/null +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_UNIFIED_SURFACE_H +#define OHOS_UNIFIED_SURFACE_H + +#include +#include "flutter/flow/surface.h" +#include "flutter/shell/platform/ohos/context/ohos_context.h" +#include "flutter/shell/platform/ohos/surface/ohos_native_window.h" +#include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" +#include "third_party/skia/include/core/SkSize.h" + +namespace impeller { +class Context; +} // namespace impeller + +namespace flutter { + +class OHOSUnifiedSurface : public GPUSurfaceGLDelegate, + public OHOSSurface { + public: + virtual ~OHOSUnifiedSurface(); + virtual bool IsValid() const = 0; + virtual void TeardownOnScreenContext() = 0; + + virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; + + virtual bool ResourceContextMakeCurrent() = 0; + + virtual bool ResourceContextClearCurrent() = 0; + + virtual bool SetNativeWindow(fml::RefPtr window) = 0; + + virtual std::unique_ptr CreateSnapshotSurface(); + + virtual std::unique_ptr CreateGPUSurface( + GrDirectContext* gr_context = nullptr) = 0; + + virtual std::shared_ptr GetImpellerContext(); + + virtual std::unique_ptr GLContextMakeCurrent() = 0; + + virtual bool GLContextClearCurrent() = 0; + + virtual void GLContextSetDamageRegion(const std::optional& region) {} + + virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0; + + virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const = 0; + + virtual bool GLContextFBOResetAfterPresent() const; + + virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const; + + virtual SkMatrix GLContextSurfaceTransformation() const; + + virtual sk_sp GetGLInterface() const; + + static sk_sp GetDefaultPlatformGLInterface(); + + using GLProcResolver = + std::function; + + virtual GLProcResolver GetGLProcResolver() const; + + virtual bool AllowsDrawingWhenGpuDisabled() const; + +}; + + +} // namespace flutter + +#endif \ No newline at end of file diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index a3df1b93ce..4ab3d7e9fb 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -32,13 +32,13 @@ namespace flutter { OhosSurfaceFactoryImpl::OhosSurfaceFactoryImpl( - const std::shared_ptr& context, + const std::shared_ptr& context, bool enable_impeller) : ohos_context_(context), enable_impeller_(enable_impeller) {} OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; -std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { +std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { switch (ohos_context_->RenderingApi()) { case OHOSRenderingAPI::kSoftware: return std::make_unique(ohos_context_); @@ -398,7 +398,7 @@ void PlatformViewOHOS::RegisterExternalTextureByImage( if(iter != external_texture_gl_.end()) { iter->second->DispatchImage(image); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchImage(image); @@ -410,7 +410,7 @@ uint64_t PlatformViewOHOS::RegisterExternalTexture(int64_t texture_id) { uint64_t surface_id = 0; int ret = -1; if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); ohos_external_gl->nativeImage_ = OH_NativeImage_Create(texture_id, GL_TEXTURE_EXTERNAL_OES); if (ohos_external_gl->nativeImage_ == nullptr) { FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; @@ -467,7 +467,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat if(iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); } else { - std::shared_ptr ohos_external_gl = std::make_shared(texture_id); + std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); external_texture_gl_[texture_id] = ohos_external_gl; RegisterTexture(ohos_external_gl); ohos_external_gl->DispatchPixelMap(pixelMap); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 387022cc08..de3737bda6 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -34,6 +34,7 @@ #include #include "ohos_external_texture_gl.h" #include +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { @@ -44,7 +45,7 @@ class OhosSurfaceFactoryImpl : public OhosSurfaceFactory { ~OhosSurfaceFactoryImpl() override; - std::unique_ptr CreateSurface() override; + std::unique_ptr CreateSurface() override; private: const std::shared_ptr& ohos_context_; @@ -125,7 +126,7 @@ class PlatformViewOHOS final : public PlatformView { const std::shared_ptr napi_facade_; std::shared_ptr ohos_context_; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; diff --git a/shell/platform/ohos/surface/ohos_surface.h b/shell/platform/ohos/surface/ohos_surface.h index b87757d5f5..6ce4069874 100644 --- a/shell/platform/ohos/surface/ohos_surface.h +++ b/shell/platform/ohos/surface/ohos_surface.h @@ -21,6 +21,7 @@ #include "flutter/shell/platform/ohos/context/ohos_context.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "third_party/skia/include/core/SkSize.h" +#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace impeller { class Context; @@ -60,7 +61,7 @@ class OhosSurfaceFactory { virtual ~OhosSurfaceFactory() = default; - virtual std::unique_ptr CreateSurface() = 0; + virtual std::unique_ptr CreateSurface() = 0; }; } // namespace flutter -- Gitee From 1b9f291f8048f33f694d53bc56833effc314961a Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 16:53:48 +0800 Subject: [PATCH 42/69] add OHOSUnifiedSurface Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/platform_view_ohos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index de3737bda6..fffe2c97c8 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -126,7 +126,7 @@ class PlatformViewOHOS final : public PlatformView { const std::shared_ptr napi_facade_; std::shared_ptr ohos_context_; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; -- Gitee From b2d17ddec0769151acc504aeeb19ed34335ed214 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:07:06 +0800 Subject: [PATCH 43/69] delete override Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_surface_gl_skia.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 69d16a0138..17a70bce38 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -36,7 +36,7 @@ class OhosSurfaceGLSkia final : public OHOSUnifiedSurface ~OhosSurfaceGLSkia() override; // |OhosSurface| - bool IsValid() const override; + bool IsValid(); // |OhosSurface| std::unique_ptr CreateGPUSurface( -- Gitee From 44e6b04554be8b69ae50ee063cf4a16d28680163 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:23:42 +0800 Subject: [PATCH 44/69] modify OHOSUnifiedSurface Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_surface_gl_skia.h | 2 +- shell/platform/ohos/ohos_unified_surface.h | 52 +++++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 17a70bce38..69d16a0138 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -36,7 +36,7 @@ class OhosSurfaceGLSkia final : public OHOSUnifiedSurface ~OhosSurfaceGLSkia() override; // |OhosSurface| - bool IsValid(); + bool IsValid() const override; // |OhosSurface| std::unique_ptr CreateGPUSurface( diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index 7c7833448a..6df41f1c79 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -31,52 +31,52 @@ namespace flutter { class OHOSUnifiedSurface : public GPUSurfaceGLDelegate, public OHOSSurface { - public: - virtual ~OHOSUnifiedSurface(); - virtual bool IsValid() const = 0; - virtual void TeardownOnScreenContext() = 0; +// public: +// virtual ~OHOSUnifiedSurface(); +// virtual bool IsValid() const = 0; +// virtual void TeardownOnScreenContext() = 0; - virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; +// virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; - virtual bool ResourceContextMakeCurrent() = 0; +// virtual bool ResourceContextMakeCurrent() = 0; - virtual bool ResourceContextClearCurrent() = 0; +// virtual bool ResourceContextClearCurrent() = 0; - virtual bool SetNativeWindow(fml::RefPtr window) = 0; +// virtual bool SetNativeWindow(fml::RefPtr window) = 0; - virtual std::unique_ptr CreateSnapshotSurface(); +// virtual std::unique_ptr CreateSnapshotSurface(); - virtual std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context = nullptr) = 0; +// virtual std::unique_ptr CreateGPUSurface( +// GrDirectContext* gr_context = nullptr) = 0; - virtual std::shared_ptr GetImpellerContext(); +// virtual std::shared_ptr GetImpellerContext(); - virtual std::unique_ptr GLContextMakeCurrent() = 0; +// virtual std::unique_ptr GLContextMakeCurrent() = 0; - virtual bool GLContextClearCurrent() = 0; +// virtual bool GLContextClearCurrent() = 0; - virtual void GLContextSetDamageRegion(const std::optional& region) {} +// virtual void GLContextSetDamageRegion(const std::optional& region) {} - virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0; +// virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0; - virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const = 0; +// virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const = 0; - virtual bool GLContextFBOResetAfterPresent() const; +// virtual bool GLContextFBOResetAfterPresent() const; - virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const; +// virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const; - virtual SkMatrix GLContextSurfaceTransformation() const; +// virtual SkMatrix GLContextSurfaceTransformation() const; - virtual sk_sp GetGLInterface() const; +// virtual sk_sp GetGLInterface() const; - static sk_sp GetDefaultPlatformGLInterface(); +// static sk_sp GetDefaultPlatformGLInterface(); - using GLProcResolver = - std::function; +// using GLProcResolver = +// std::function; - virtual GLProcResolver GetGLProcResolver() const; +// virtual GLProcResolver GetGLProcResolver() const; - virtual bool AllowsDrawingWhenGpuDisabled() const; +// virtual bool AllowsDrawingWhenGpuDisabled() const; }; -- Gitee From b273b0c30df95c1a909029e3f3f507d8bf168a01 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:33:55 +0800 Subject: [PATCH 45/69] modify final Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_surface_gl_impeller.h | 2 +- shell/platform/ohos/ohos_surface_gl_skia.h | 2 +- shell/platform/ohos/ohos_surface_software.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index be6ce8c662..adc4d41ce6 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -26,7 +26,7 @@ namespace flutter { -class OHOSSurfaceGLImpeller final : public OHOSUnifiedSurface +class OHOSSurfaceGLImpeller : public OHOSUnifiedSurface { public: OHOSSurfaceGLImpeller(const std::shared_ptr& ohos_context); diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 69d16a0138..255de790e3 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -28,7 +28,7 @@ namespace flutter { -class OhosSurfaceGLSkia final : public OHOSUnifiedSurface +class OhosSurfaceGLSkia : public OHOSUnifiedSurface { public: OhosSurfaceGLSkia(const std::shared_ptr& ohos_context); diff --git a/shell/platform/ohos/ohos_surface_software.h b/shell/platform/ohos/ohos_surface_software.h index 1fc736a1d3..7b7f4bf6fa 100644 --- a/shell/platform/ohos/ohos_surface_software.h +++ b/shell/platform/ohos/ohos_surface_software.h @@ -24,7 +24,7 @@ namespace flutter { -class OHOSSurfaceSoftware final : public OHOSUnifiedSurface +class OHOSSurfaceSoftware : public OHOSUnifiedSurface { public: OHOSSurfaceSoftware(const std::shared_ptr& ohos_context); -- Gitee From ccacabc32e9563b396c822dd2a8acc7c35c69426 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:50:26 +0800 Subject: [PATCH 46/69] modify OHOSUnifiedSurface Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_unified_surface.h | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index 6df41f1c79..29bda130e3 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -31,52 +31,52 @@ namespace flutter { class OHOSUnifiedSurface : public GPUSurfaceGLDelegate, public OHOSSurface { -// public: -// virtual ~OHOSUnifiedSurface(); -// virtual bool IsValid() const = 0; -// virtual void TeardownOnScreenContext() = 0; + public: + ~OHOSUnifiedSurface() {} + bool IsValid() {} + void TeardownOnScreenContext() {} -// virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; + bool OnScreenSurfaceResize(const SkISize& size) {} -// virtual bool ResourceContextMakeCurrent() = 0; + bool ResourceContextMakeCurrent() {} -// virtual bool ResourceContextClearCurrent() = 0; + bool ResourceContextClearCurrent() {} -// virtual bool SetNativeWindow(fml::RefPtr window) = 0; + bool SetNativeWindow(fml::RefPtr window) {} -// virtual std::unique_ptr CreateSnapshotSurface(); + std::unique_ptr CreateSnapshotSurface() -// virtual std::unique_ptr CreateGPUSurface( -// GrDirectContext* gr_context = nullptr) = 0; + std::unique_ptr CreateGPUSurface( + GrDirectContext* gr_context = nullptr) {} -// virtual std::shared_ptr GetImpellerContext(); + std::shared_ptr GetImpellerContext() {} -// virtual std::unique_ptr GLContextMakeCurrent() = 0; + std::unique_ptr GLContextMakeCurrent() {} -// virtual bool GLContextClearCurrent() = 0; + bool GLContextClearCurrent() {} -// virtual void GLContextSetDamageRegion(const std::optional& region) {} + void GLContextSetDamageRegion(const std::optional& region) {} -// virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0; + bool GLContextPresent(const GLPresentInfo& present_info) {} -// virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const = 0; + GLFBOInfo GLContextFBO(GLFrameInfo frame_info) {} -// virtual bool GLContextFBOResetAfterPresent() const; + bool GLContextFBOResetAfterPresent() {} -// virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const; + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() {} -// virtual SkMatrix GLContextSurfaceTransformation() const; + SkMatrix GLContextSurfaceTransformation() {} -// virtual sk_sp GetGLInterface() const; + sk_sp GetGLInterface() {} -// static sk_sp GetDefaultPlatformGLInterface(); + static sk_sp GetDefaultPlatformGLInterface() {} -// using GLProcResolver = -// std::function; + using GLProcResolver = + std::function; -// virtual GLProcResolver GetGLProcResolver() const; + GLProcResolver GetGLProcResolver() {} -// virtual bool AllowsDrawingWhenGpuDisabled() const; + bool AllowsDrawingWhenGpuDisabled() {} }; -- Gitee From f38b853f0bcb933bdc98c0a6c8bc04b3f078c9b7 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:57:19 +0800 Subject: [PATCH 47/69] modify Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_surface_gl_skia.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 255de790e3..742dec98fe 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -33,14 +33,19 @@ class OhosSurfaceGLSkia : public OHOSUnifiedSurface public: OhosSurfaceGLSkia(const std::shared_ptr& ohos_context); - ~OhosSurfaceGLSkia() override; + ~OhosSurfaceGLSkia(); + + // |OhosSurface| - bool IsValid() const override; + bool IsValid(); + + + // |OhosSurface| std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context) override; + GrDirectContext* gr_context); // |OhosSurface| void TeardownOnScreenContext() override; -- Gitee From d811f2935a90a0053fae773e8fcacd341190e3a2 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 17:59:27 +0800 Subject: [PATCH 48/69] modify Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_surface_gl_skia.h | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 742dec98fe..d91e0251f0 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -48,43 +48,43 @@ class OhosSurfaceGLSkia : public OHOSUnifiedSurface GrDirectContext* gr_context); // |OhosSurface| - void TeardownOnScreenContext() override; + void TeardownOnScreenContext(); // |OhosSurface| - bool OnScreenSurfaceResize(const SkISize& size) override; + bool OnScreenSurfaceResize(const SkISize& size); // |OhosSurface| - bool ResourceContextMakeCurrent() override; + bool ResourceContextMakeCurrent(); // |OhosSurface| - bool ResourceContextClearCurrent() override; + bool ResourceContextClearCurrent(); // |OhosSurface| - bool SetNativeWindow(fml::RefPtr window) override; + bool SetNativeWindow(fml::RefPtr window); // |OhosSurface| - virtual std::unique_ptr CreateSnapshotSurface() override; + virtual std::unique_ptr CreateSnapshotSurface(); // |GPUSurfaceGLDelegate| - std::unique_ptr GLContextMakeCurrent() override; + std::unique_ptr GLContextMakeCurrent(); // |GPUSurfaceGLDelegate| - bool GLContextClearCurrent() override; + bool GLContextClearCurrent(); // |GPUSurfaceGLDelegate| - SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo(); // |GPUSurfaceGLDelegate| - void GLContextSetDamageRegion(const std::optional& region) override; + void GLContextSetDamageRegion(const std::optional& region); // |GPUSurfaceGLDelegate| - bool GLContextPresent(const GLPresentInfo& present_info) override; + bool GLContextPresent(const GLPresentInfo& present_info); // |GPUSurfaceGLDelegate| - GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; + GLFBOInfo GLContextFBO(GLFrameInfo frame_info); // |GPUSurfaceGLDelegate| - sk_sp GetGLInterface() const override; + sk_sp GetGLInterface(); // Obtain a raw pointer to the on-screen OhosEGLSurface. // -- Gitee From 4a7638d04356db039ef1f419931295e886a872da Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 18:08:04 +0800 Subject: [PATCH 49/69] modify Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_unified_surface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index 29bda130e3..6ae3d474c4 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -20,6 +20,7 @@ #include "flutter/flow/surface.h" #include "flutter/shell/platform/ohos/context/ohos_context.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" +#include "flutter/shell/platform/ohos/surface/ohos_surface.h" #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "third_party/skia/include/core/SkSize.h" -- Gitee From 4354e7c53aacbd325cc024532f4b7524a918c905 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 18:50:47 +0800 Subject: [PATCH 50/69] modify Signed-off-by: 18719058668 <718092089@qq.com> --- .../platform/ohos/ohos_surface_gl_impeller.h | 34 +++++++++--------- shell/platform/ohos/ohos_surface_gl_skia.h | 35 ++++++++----------- shell/platform/ohos/ohos_surface_software.h | 20 +++++------ shell/platform/ohos/ohos_unified_surface.h | 4 --- 4 files changed, 42 insertions(+), 51 deletions(-) diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index adc4d41ce6..104f34d5cc 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -31,56 +31,56 @@ class OHOSSurfaceGLImpeller : public OHOSUnifiedSurface public: OHOSSurfaceGLImpeller(const std::shared_ptr& ohos_context); - ~OHOSSurfaceGLImpeller() override; + ~OHOSSurfaceGLImpeller(); // OHOSSurface - bool IsValid() const override; + bool IsValid(); // OHOSSurface std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context) override; + GrDirectContext* gr_context); // OHOSSurface - void TeardownOnScreenContext() override; + void TeardownOnScreenContext(); // OHOSSurface - bool OnScreenSurfaceResize(const SkISize& size) override; + bool OnScreenSurfaceResize(const SkISize& size); // OHOSSurface - bool ResourceContextMakeCurrent() override; + bool ResourceContextMakeCurrent(); // OHOSSurface - bool ResourceContextClearCurrent() override; + bool ResourceContextClearCurrent(); // OHOSSurface - bool SetNativeWindow(fml::RefPtr window) override; + bool SetNativeWindow(fml::RefPtr window); // OHOSSurface - std::unique_ptr CreateSnapshotSurface() override; + std::unique_ptr CreateSnapshotSurface(); // OHOSSurface - std::shared_ptr GetImpellerContext() override; + std::shared_ptr GetImpellerContext(); // |GPUSurfaceGLDelegate| - std::unique_ptr GLContextMakeCurrent() override; + std::unique_ptr GLContextMakeCurrent(); // |GPUSurfaceGLDelegate| - bool GLContextClearCurrent() override; + bool GLContextClearCurrent(); // |GPUSurfaceGLDelegate| - SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo(); // |GPUSurfaceGLDelegate| - void GLContextSetDamageRegion(const std::optional& region) override; + void GLContextSetDamageRegion(const std::optional& region); // |GPUSurfaceGLDelegate| - bool GLContextPresent(const GLPresentInfo& present_info) override; + bool GLContextPresent(const GLPresentInfo& present_info); // |GPUSurfaceGLDelegate| - GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; + GLFBOInfo GLContextFBO(GLFrameInfo frame_info); // |GPUSurfaceGLDelegate| - sk_sp GetGLInterface() const override; + sk_sp GetGLInterface(); private: class ReactorWorker; diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index d91e0251f0..55990e2380 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -33,58 +33,53 @@ class OhosSurfaceGLSkia : public OHOSUnifiedSurface public: OhosSurfaceGLSkia(const std::shared_ptr& ohos_context); - ~OhosSurfaceGLSkia(); - - + ~OhosSurfaceGLSkia() override; // |OhosSurface| bool IsValid(); - - - // |OhosSurface| std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context); + GrDirectContext* gr_context) override; // |OhosSurface| - void TeardownOnScreenContext(); + void TeardownOnScreenContext() override; // |OhosSurface| - bool OnScreenSurfaceResize(const SkISize& size); + bool OnScreenSurfaceResize(const SkISize& size) override; // |OhosSurface| - bool ResourceContextMakeCurrent(); + bool ResourceContextMakeCurrent() override; // |OhosSurface| - bool ResourceContextClearCurrent(); + bool ResourceContextClearCurrent() override; // |OhosSurface| - bool SetNativeWindow(fml::RefPtr window); + bool SetNativeWindow(fml::RefPtr window) override; // |OhosSurface| - virtual std::unique_ptr CreateSnapshotSurface(); + virtual std::unique_ptr CreateSnapshotSurface() override; // |GPUSurfaceGLDelegate| - std::unique_ptr GLContextMakeCurrent(); + std::unique_ptr GLContextMakeCurrent() override; // |GPUSurfaceGLDelegate| - bool GLContextClearCurrent(); + bool GLContextClearCurrent() override; // |GPUSurfaceGLDelegate| - SurfaceFrame::FramebufferInfo GLContextFramebufferInfo(); + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; // |GPUSurfaceGLDelegate| - void GLContextSetDamageRegion(const std::optional& region); + void GLContextSetDamageRegion(const std::optional& region) override; // |GPUSurfaceGLDelegate| - bool GLContextPresent(const GLPresentInfo& present_info); + bool GLContextPresent(const GLPresentInfo& present_info) override; // |GPUSurfaceGLDelegate| - GLFBOInfo GLContextFBO(GLFrameInfo frame_info); + GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; // |GPUSurfaceGLDelegate| - sk_sp GetGLInterface(); + sk_sp GetGLInterface() const override; // Obtain a raw pointer to the on-screen OhosEGLSurface. // diff --git a/shell/platform/ohos/ohos_surface_software.h b/shell/platform/ohos/ohos_surface_software.h index 7b7f4bf6fa..ca98d5b9aa 100644 --- a/shell/platform/ohos/ohos_surface_software.h +++ b/shell/platform/ohos/ohos_surface_software.h @@ -28,34 +28,34 @@ class OHOSSurfaceSoftware : public OHOSUnifiedSurface { public: OHOSSurfaceSoftware(const std::shared_ptr& ohos_context); - ~OHOSSurfaceSoftware() override; + ~OHOSSurfaceSoftware(); - bool IsValid() const override; + bool IsValid() ; // |OHOSSurface| - bool ResourceContextMakeCurrent() override; + bool ResourceContextMakeCurrent(); // |OHOSSurface| - bool ResourceContextClearCurrent() override; + bool ResourceContextClearCurrent(); // |OHOSSurface| std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context) override; + GrDirectContext* gr_context); // |OHOSSurface| - void TeardownOnScreenContext() override; + void TeardownOnScreenContext(); // |OHOSSurface| - bool OnScreenSurfaceResize(const SkISize& size) override; + bool OnScreenSurfaceResize(const SkISize& size); // |OHOSSurface| - bool SetNativeWindow(fml::RefPtr window) override; + bool SetNativeWindow(fml::RefPtr window); // |GPUSurfaceSoftwareDelegate| - sk_sp AcquireBackingStore(const SkISize& size) override; + sk_sp AcquireBackingStore(const SkISize& size); // |GPUSurfaceSoftwareDelegate| - bool PresentBackingStore(sk_sp backing_store) override; + bool PresentBackingStore(sk_sp backing_store); private: sk_sp sk_surface_; diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index 6ae3d474c4..ef07545e42 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -24,10 +24,6 @@ #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include "third_party/skia/include/core/SkSize.h" -namespace impeller { -class Context; -} // namespace impeller - namespace flutter { class OHOSUnifiedSurface : public GPUSurfaceGLDelegate, -- Gitee From 299a8a250df0519204b35d25221228bb8fd79f64 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 20:23:51 +0800 Subject: [PATCH 51/69] =?UTF-8?q?=E6=8D=A2=E5=BC=BA=E8=BD=AC=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18719058668 <718092089@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 7 +++- .../platform/ohos/ohos_external_texture_gl.h | 5 +-- .../platform/ohos/ohos_surface_gl_impeller.h | 39 +++++++++---------- shell/platform/ohos/ohos_surface_gl_skia.h | 7 ++-- shell/platform/ohos/ohos_surface_software.h | 26 ++++++------- shell/platform/ohos/platform_view_ohos.cpp | 4 +- shell/platform/ohos/platform_view_ohos.h | 5 +-- shell/platform/ohos/surface/ohos_surface.h | 3 +- 8 files changed, 47 insertions(+), 49 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index a36b1aeac4..0d00b6c71a 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -42,7 +42,7 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; -OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) +OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; @@ -153,7 +153,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - auto result = ohos_surface_->GLContextMakeCurrent(); + // InitEGLEnv(); + OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); + OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; + auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { FML_DLOG(FATAL)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index d89bc16d62..ad1bc0e727 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -29,14 +29,13 @@ #include #include #include -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" // maybe now unused namespace flutter { 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); ~OHOSExternalTextureGL() override; @@ -96,7 +95,7 @@ class OHOSExternalTextureGL : public flutter::Texture { GLuint texture_name_ = 0; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; SkMatrix transform; diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index 104f34d5cc..87b2fa4bf6 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -22,65 +22,64 @@ #include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "surface/ohos_native_window.h" #include "surface/ohos_surface.h" -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { -class OHOSSurfaceGLImpeller : public OHOSUnifiedSurface - { +class OHOSSurfaceGLImpeller final : public GPUSurfaceGLDelegate, + public OHOSSurface { public: OHOSSurfaceGLImpeller(const std::shared_ptr& ohos_context); - ~OHOSSurfaceGLImpeller(); + ~OHOSSurfaceGLImpeller() override; // OHOSSurface - bool IsValid(); + bool IsValid() const override; // OHOSSurface std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context); + GrDirectContext* gr_context) override; // OHOSSurface - void TeardownOnScreenContext(); + void TeardownOnScreenContext() override; // OHOSSurface - bool OnScreenSurfaceResize(const SkISize& size); + bool OnScreenSurfaceResize(const SkISize& size) override; // OHOSSurface - bool ResourceContextMakeCurrent(); + bool ResourceContextMakeCurrent() override; // OHOSSurface - bool ResourceContextClearCurrent(); + bool ResourceContextClearCurrent() override; // OHOSSurface - bool SetNativeWindow(fml::RefPtr window); + bool SetNativeWindow(fml::RefPtr window) override; // OHOSSurface - std::unique_ptr CreateSnapshotSurface(); + std::unique_ptr CreateSnapshotSurface() override; // OHOSSurface - std::shared_ptr GetImpellerContext(); + std::shared_ptr GetImpellerContext() override; // |GPUSurfaceGLDelegate| - std::unique_ptr GLContextMakeCurrent(); + std::unique_ptr GLContextMakeCurrent() override; // |GPUSurfaceGLDelegate| - bool GLContextClearCurrent(); + bool GLContextClearCurrent() override; // |GPUSurfaceGLDelegate| - SurfaceFrame::FramebufferInfo GLContextFramebufferInfo(); + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; // |GPUSurfaceGLDelegate| - void GLContextSetDamageRegion(const std::optional& region); + void GLContextSetDamageRegion(const std::optional& region) override; // |GPUSurfaceGLDelegate| - bool GLContextPresent(const GLPresentInfo& present_info); + bool GLContextPresent(const GLPresentInfo& present_info) override; // |GPUSurfaceGLDelegate| - GLFBOInfo GLContextFBO(GLFrameInfo frame_info); + GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; // |GPUSurfaceGLDelegate| - sk_sp GetGLInterface(); + sk_sp GetGLInterface() const override; private: class ReactorWorker; diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 55990e2380..4a99529433 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -24,19 +24,18 @@ #include "flutter/shell/platform/ohos/ohos_context_gl_skia.h" #include "flutter/shell/platform/ohos/ohos_environment_gl.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { -class OhosSurfaceGLSkia : public OHOSUnifiedSurface - { +class OhosSurfaceGLSkia final : public GPUSurfaceGLDelegate, + public OHOSSurface { public: OhosSurfaceGLSkia(const std::shared_ptr& ohos_context); ~OhosSurfaceGLSkia() override; // |OhosSurface| - bool IsValid(); + bool IsValid() const override; // |OhosSurface| std::unique_ptr CreateGPUSurface( diff --git a/shell/platform/ohos/ohos_surface_software.h b/shell/platform/ohos/ohos_surface_software.h index ca98d5b9aa..a0dfd8ae00 100644 --- a/shell/platform/ohos/ohos_surface_software.h +++ b/shell/platform/ohos/ohos_surface_software.h @@ -19,43 +19,43 @@ #include "flutter/fml/macros.h" #include "flutter/shell/gpu/gpu_surface_software.h" #include "flutter/shell/platform/ohos/surface/ohos_surface.h" -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" + #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" namespace flutter { -class OHOSSurfaceSoftware : public OHOSUnifiedSurface - { +class OHOSSurfaceSoftware final : public OHOSSurface, + public GPUSurfaceSoftwareDelegate { public: OHOSSurfaceSoftware(const std::shared_ptr& ohos_context); - ~OHOSSurfaceSoftware(); + ~OHOSSurfaceSoftware() override; - bool IsValid() ; + bool IsValid() const override; // |OHOSSurface| - bool ResourceContextMakeCurrent(); + bool ResourceContextMakeCurrent() override; // |OHOSSurface| - bool ResourceContextClearCurrent(); + bool ResourceContextClearCurrent() override; // |OHOSSurface| std::unique_ptr CreateGPUSurface( - GrDirectContext* gr_context); + GrDirectContext* gr_context) override; // |OHOSSurface| - void TeardownOnScreenContext(); + void TeardownOnScreenContext() override; // |OHOSSurface| - bool OnScreenSurfaceResize(const SkISize& size); + bool OnScreenSurfaceResize(const SkISize& size) override; // |OHOSSurface| - bool SetNativeWindow(fml::RefPtr window); + bool SetNativeWindow(fml::RefPtr window) override; // |GPUSurfaceSoftwareDelegate| - sk_sp AcquireBackingStore(const SkISize& size); + sk_sp AcquireBackingStore(const SkISize& size) override; // |GPUSurfaceSoftwareDelegate| - bool PresentBackingStore(sk_sp backing_store); + bool PresentBackingStore(sk_sp backing_store) override; private: sk_sp sk_surface_; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 4ab3d7e9fb..c21987440e 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -32,13 +32,13 @@ namespace flutter { OhosSurfaceFactoryImpl::OhosSurfaceFactoryImpl( - const std::shared_ptr& context, + const std::shared_ptr& context, bool enable_impeller) : ohos_context_(context), enable_impeller_(enable_impeller) {} OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; -std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { +std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { switch (ohos_context_->RenderingApi()) { case OHOSRenderingAPI::kSoftware: return std::make_unique(ohos_context_); diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index fffe2c97c8..387022cc08 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -34,7 +34,6 @@ #include #include "ohos_external_texture_gl.h" #include -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace flutter { @@ -45,7 +44,7 @@ class OhosSurfaceFactoryImpl : public OhosSurfaceFactory { ~OhosSurfaceFactoryImpl() override; - std::unique_ptr CreateSurface() override; + std::unique_ptr CreateSurface() override; private: const std::shared_ptr& ohos_context_; @@ -126,7 +125,7 @@ class PlatformViewOHOS final : public PlatformView { const std::shared_ptr napi_facade_; std::shared_ptr ohos_context_; - std::shared_ptr ohos_surface_; + std::shared_ptr ohos_surface_; std::shared_ptr platform_message_handler_; std::shared_ptr surface_factory_; diff --git a/shell/platform/ohos/surface/ohos_surface.h b/shell/platform/ohos/surface/ohos_surface.h index 6ce4069874..b87757d5f5 100644 --- a/shell/platform/ohos/surface/ohos_surface.h +++ b/shell/platform/ohos/surface/ohos_surface.h @@ -21,7 +21,6 @@ #include "flutter/shell/platform/ohos/context/ohos_context.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "third_party/skia/include/core/SkSize.h" -#include "flutter/shell/platform/ohos/ohos_unified_surface.h" namespace impeller { class Context; @@ -61,7 +60,7 @@ class OhosSurfaceFactory { virtual ~OhosSurfaceFactory() = default; - virtual std::unique_ptr CreateSurface() = 0; + virtual std::unique_ptr CreateSurface() = 0; }; } // namespace flutter -- Gitee From 9a4367cf4de810403ff441bf2d318d275d0b1855 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:00:05 +0800 Subject: [PATCH 52/69] change log Signed-off-by: 18719058668 <718092089@qq.com> --- 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 0d00b6c71a..fd505e3b10 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -158,7 +158,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - FML_DLOG(FATAL)<<"ResourceContextMakeCurrent successed"; + FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { -- Gitee From 1b0b49a7ebaa2480715f93c1d9893d5f499220f7 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:09:20 +0800 Subject: [PATCH 53/69] add glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index fd505e3b10..15c407b04e 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -160,6 +160,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, if (result->GetResult()) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; -- Gitee From 6bff56e1006147384d4e2ee2509727fd069aac08 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:21:43 +0800 Subject: [PATCH 54/69] add params Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 15c407b04e..c913baf12d 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -161,6 +161,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; -- Gitee From 06c007ea87b80dabc6dfc2a88dda1eb84bfb160d Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:25:07 +0800 Subject: [PATCH 55/69] 1 Signed-off-by: 18719058668 <718092089@qq.com> --- 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 c913baf12d..b08bd4d108 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -160,7 +160,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, if (result->GetResult()) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + // glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -- Gitee From fcb3c1700486273593835ce122e2d7dfb4b50b5b Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:27:13 +0800 Subject: [PATCH 56/69] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18719058668 <718092089@qq.com> --- 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 b08bd4d108..1c027af0b4 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -161,11 +161,12 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); // glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } -- Gitee From 557093074de85d6b56a24673f600391e1ef543bf Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:40:57 +0800 Subject: [PATCH 57/69] add ResourceContextMakeCurrent Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 1c027af0b4..446d6c2b82 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -156,11 +156,13 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // InitEGLEnv(); OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; - auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); - if (result->GetResult()) { + // auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); + // if (result->GetResult()) { + bool result = ohosSurfaceGLSkia_->ResourceContextMakeCurrent(); + if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - // glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); -- Gitee From 23767a076d388792dd90dd6fa213380d775c49ff Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:43:39 +0800 Subject: [PATCH 58/69] change extexture Signed-off-by: 18719058668 <718092089@qq.com> --- 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 446d6c2b82..3d6f7de40a 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -164,11 +164,12 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, glGenTextures(1, &texture_name_); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } -- Gitee From 94f064085ceb1758b397b94e4feaa9a7016ce716 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 21:46:56 +0800 Subject: [PATCH 59/69] test Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 3d6f7de40a..afed1050e9 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -162,8 +162,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -- Gitee From afda093c29a7c34655b9af61c33f4262201811aa Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 22:08:16 +0800 Subject: [PATCH 60/69] test Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index afed1050e9..69cdba96b3 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -156,10 +156,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // InitEGLEnv(); OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; - // auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); - // if (result->GetResult()) { - bool result = ohosSurfaceGLSkia_->ResourceContextMakeCurrent(); - if (result) { + auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); + if (result->GetResult()) { + // bool result = ohosSurfaceGLSkia_->ResourceContextMakeCurrent(); + // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); -- Gitee From 8ba32441bfeb866d87cd2e8869f168b9c183c502 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Tue, 6 Feb 2024 22:28:57 +0800 Subject: [PATCH 61/69] test Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 69cdba96b3..ac009aac8e 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -162,10 +162,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { -- Gitee From cd1f2316dbf2ebd87e4ef14d6b6475a0de89d7a6 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 17 Feb 2024 21:44:06 +0800 Subject: [PATCH 62/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=9C=BA=E6=99=AF=E5=88=9D=E6=AD=A5=E8=B0=83?= =?UTF-8?q?=E9=80=9A?= 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 | 154 ++++-------------- .../platform/ohos/ohos_external_texture_gl.h | 2 +- 2 files changed, 36 insertions(+), 120 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index ac009aac8e..6efd4bc531 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -23,10 +23,6 @@ #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" -#include "third_party/skia/src/gpu/gl/GrGLDefines.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "third_party/skia/include/effects/Sk1DPathEffect.h" -#include "third_party/skia/tools/Registry.h" #include #include @@ -59,89 +55,6 @@ OHOSExternalTextureGL::~OHOSExternalTextureGL() { } } -// copy from src/third_party/skia/docs/examples/skpaint_skia.cpp -void drawSample(SkCanvas* canvas) { - SkPaint paint1, paint2, paint3; - - paint1.setAntiAlias(true); - paint1.setColor(SkColorSetRGB(255, 0, 0)); - paint1.setStyle(SkPaint::kFill_Style); - - paint2.setAntiAlias(true); - paint2.setColor(SkColorSetRGB(0, 136, 0)); - paint2.setStyle(SkPaint::kStroke_Style); - paint2.setStrokeWidth(SkIntToScalar(3)); - - paint3.setAntiAlias(true); - paint3.setColor(SkColorSetRGB(136, 136, 136)); - - sk_sp blob1 = - SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.0f, 0.0f)); - sk_sp blob2 = - SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.5f, 0.0f)); - - canvas->clear(SK_ColorWHITE); - canvas->drawTextBlob(blob1.get(), 20.0f, 64.0f, paint1); - canvas->drawTextBlob(blob1.get(), 20.0f, 144.0f, paint2); - canvas->drawTextBlob(blob2.get(), 20.0f, 224.0f, paint3); -} - -// copy from src/third_party/skia/docs/examples/skpaint_path_1d_path_effect.cpp -void drawSample2(SkCanvas* canvas) { - SkPaint paint; - SkPath path; - path.addOval(SkRect::MakeWH(16.0f, 6.0f)); - paint.setPathEffect( - SkPath1DPathEffect::Make(path, 32.0f, 0.0f, SkPath1DPathEffect::kRotate_Style)); - paint.setAntiAlias(true); - canvas->clear(SK_ColorWHITE); - canvas->drawCircle(128.0f, 128.0f, 122.0f, paint); -} - -// start drawSample3 -// copy from src/third_party/skia/docs/examples/alpha_bitmap_color_filter_mask_filter.cpp -static SkBitmap make_alpha_image(int w, int h) { - SkBitmap bm; - bm.allocPixels(SkImageInfo::MakeA8(w, h)); - bm.eraseARGB(10, 0, 0, 0); - for (int y = 0; y < bm.height(); ++y) { - for (int x = y; x < bm.width(); ++x) { - *bm.getAddr8(x, y) = 0xFF; - } - } - bm.setImmutable(); - return bm; -} - -static sk_sp make_color_filter() { - SkScalar colorMatrix[20] = { - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 0.5, 0.5, 0, - 0, 0, 0.5, 0.5, 0}; // mix G and A. - return SkColorFilters::Matrix(colorMatrix); -} - -void drawSample3(SkCanvas* canvas) { - auto image = make_alpha_image(96, 96).asImage(); - SkSamplingOptions sampling; - SkPaint paint; - - paint.setColorFilter(make_color_filter()); - paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 10.0f, false)); - canvas->drawImage(image.get(), 16, 16, sampling, &paint); - - paint.setColorFilter(nullptr); - paint.setShader(SkShaders::Color(SK_ColorCYAN)); - canvas->drawImage(image.get(), 144, 16, sampling, &paint); - - paint.setColorFilter(make_color_filter()); - canvas->drawImage(image.get(), 16, 144, sampling, &paint); - - paint.setMaskFilter(nullptr); - canvas->drawImage(image.get(), 144, 144, sampling, &paint); -} -// end drawSample3 void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, @@ -153,6 +66,8 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { + // Attach(); + // state_ = AttachmentState::attached; // InitEGLEnv(); OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; @@ -162,10 +77,11 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { @@ -175,7 +91,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, } else { FML_DLOG(FATAL)<<"ResourceContextMakeCurrent failed"; } - } if (!freeze && new_frame_ready_) { Update(); @@ -192,10 +107,11 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, GL_RGBA8_OES}; GrBackendTexture backendTexture(720, 1280, GrMipMapped::kNo, textureInfo); + FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, backendTexture.isValid=" << backendTexture.isValid(); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, image=" << image; + // glFinish(); if (image) { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 1"; SkAutoCanvasRestore autoRestore(context.canvas, true); @@ -203,8 +119,8 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, // The incoming texture is vertically flipped, so we flip it // back. OpenGL's coordinate system has Positive Y equivalent to up, while // Skia's coordinate system has Negative Y equvalent to up. - context.canvas->translate(bounds.x(), bounds.y() + bounds.height()); - context.canvas->scale(bounds.width(), -bounds.height()); + // context.canvas->translate(bounds.x(), bounds.y() + bounds.height()); + // context.canvas->scale(bounds.width(), -bounds.height()); if (!transform.isIdentity()) { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 2"; @@ -220,16 +136,11 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, } else { FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 3"; // todo 看这里对不对 - context.canvas->drawImage(image, 0, 0, sampling, context.sk_paint); - FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 4"; + SkSamplingOptions samplingTemp; + context.canvas->drawImageRect(image, bounds, samplingTemp, nullptr); + // glFinish(); } } - - FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag1"; - // drawSample(context.canvas); - // drawSample2(context.canvas); - //drawSample3(context.canvas); - FML_DLOG(INFO) << "OHOSExternalTextureGL, drawSample tag2"; } void OHOSExternalTextureGL::PaintOhImage(PaintContext& context, @@ -264,24 +175,34 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { // do nothing } -void OHOSExternalTextureGL::Attach(int textureName) { +void OHOSExternalTextureGL::Attach() { if (eglContext_ == EGL_NO_CONTEXT) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL eglContext_ no context, need init"; + FML_DLOG(INFO) << "OHOSExternalTextureGL eglContext_ no context, need init"; InitEGLEnv(); } - glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + if (texture_name_ == 0) { + glGenTextures(1, &texture_name_); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + + // 关联上下文 + if (!eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_)) { + EGLint surfaceId = -1; + eglQuerySurface(eglDisplay_, EGL_NO_SURFACE, EGL_CONFIG_ID, &surfaceId); + FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to call eglMakeCurrent, error:" + << eglGetError(); + } - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, textureName); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if (ret != 0) { FML_DLOG(FATAL) << "OHOSExternalTextureGL OH_NativeImage_AttachContext err code:" << ret; } - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } void OHOSExternalTextureGL::Update() { @@ -407,6 +328,7 @@ EGLDisplay OHOSExternalTextureGL::GetPlatformEglDisplay(EGLenum platform, void * void OHOSExternalTextureGL::InitEGLEnv() { + FML_DLOG(INFO) << "OHOSExternalTextureGL InitEGLEnv"; // 获取当前的显示设备 eglDisplay_ = GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL); @@ -456,13 +378,7 @@ void OHOSExternalTextureGL::InitEGLEnv() << eglGetError(); } - // 关联上下文 - if (!eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_)) { - EGLint surfaceId = -1; - eglQuerySurface(eglDisplay_, EGL_NO_SURFACE, EGL_CONFIG_ID, &surfaceId); - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to call eglMakeCurrent, error:" - << eglGetError(); - } + FML_DLOG(INFO) << "OHOSExternalTextureGL InitEGLEnv finish"; } bool OHOSExternalTextureGL::CheckEglExtension(const char *extensions, const char *extension) diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index ad1bc0e727..f30c530af3 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -69,7 +69,7 @@ class OHOSExternalTextureGL : public flutter::Texture { void DispatchPixelMap(NativePixelMap* pixelMap); private: - void Attach(int textureName); + void Attach(); void Update(); -- Gitee From 1d97f1913da0f5a939a15d7c2746de06703d97e8 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 18 Feb 2024 15:25:10 +0800 Subject: [PATCH 63/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E8=B0=83=E8=AF=95,=E5=88=A0=E5=87=8F=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= 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 | 43 +++++-------------- .../platform/ohos/ohos_external_texture_gl.h | 10 ----- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 6efd4bc531..59a60d4a64 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -60,7 +60,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, const SkRect& bounds, bool freeze, const SkSamplingOptions& sampling) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint"; if (state_ == AttachmentState::detached) { FML_DLOG(ERROR) << "OHOSExternalTextureGL::Paint"; return; @@ -77,11 +76,13 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + // glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_; + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); if(ret != 0) { @@ -96,34 +97,23 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, Update(); new_frame_ready_ = false; } - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, texture_name_=" << texture_name_; - PaintOrigin(context, bounds, freeze, sampling); -} -void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, - const SkRect& bounds, - bool freeze, - const SkSamplingOptions& sampling) { GrGLTextureInfo textureInfo = {GL_TEXTURE_EXTERNAL_OES, texture_name_, GL_RGBA8_OES}; - GrBackendTexture backendTexture(720, 1280, GrMipMapped::kNo, textureInfo); - FML_DLOG(INFO)<<"OHOSExternalTextureGL::Paint, backendTexture.isValid=" << backendTexture.isValid(); + GrBackendTexture backendTexture(1, 1, GrMipMapped::kNo, textureInfo); sk_sp image = SkImage::MakeFromTexture( context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); - // glFinish(); if (image) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 1"; SkAutoCanvasRestore autoRestore(context.canvas, true); // The incoming texture is vertically flipped, so we flip it // back. OpenGL's coordinate system has Positive Y equivalent to up, while // Skia's coordinate system has Negative Y equvalent to up. - // context.canvas->translate(bounds.x(), bounds.y() + bounds.height()); - // context.canvas->scale(bounds.width(), -bounds.height()); + context.canvas->translate(bounds.x(), bounds.y()); + context.canvas->scale(bounds.width(), bounds.height()); if (!transform.isIdentity()) { - FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 2"; sk_sp shader = image->makeShader( SkTileMode::kRepeat, SkTileMode::kRepeat, sampling, transform); @@ -134,22 +124,11 @@ void OHOSExternalTextureGL::PaintOrigin(PaintContext& context, paintWithShader.setShader(shader); context.canvas->drawRect(SkRect::MakeWH(1, 1), paintWithShader); } else { - FML_DLOG(INFO)<<"OHOSExternalTextureGL begin draw 3"; - // todo 看这里对不对 - SkSamplingOptions samplingTemp; - context.canvas->drawImageRect(image, bounds, samplingTemp, nullptr); - // glFinish(); + context.canvas->drawImage(image, 0, 0, sampling, context.sk_paint); } } } -void OHOSExternalTextureGL::PaintOhImage(PaintContext& context, - const SkRect& bounds, - bool freeze, - const SkSamplingOptions& sampling) { - // todo 参考Demo中的方式,测试直接使用egl绘制视频纹理是否可行 -} - void OHOSExternalTextureGL::OnGrContextCreated() { FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextCreated"; state_ = AttachmentState::uninitialized; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index f30c530af3..89bc1549c7 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -46,16 +46,6 @@ class OHOSExternalTextureGL : public flutter::Texture { bool freeze, const SkSamplingOptions& sampling) override; - void PaintOrigin(PaintContext& context, - const SkRect& bounds, - bool freeze, - const SkSamplingOptions& sampling); - - void PaintOhImage(PaintContext& context, - const SkRect& bounds, - bool freeze, - const SkSamplingOptions& sampling); - void OnGrContextCreated() override; void OnGrContextDestroyed() override; -- Gitee From 67227416c0c9c5e492c64c00a113b930b808d160 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 20 Feb 2024 15:01:33 +0800 Subject: [PATCH 64/69] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E9=80=BB=E8=BE=91=E8=B0=83=E9=80=9A?= 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 | 73 +++++++++++++------ 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 59a60d4a64..b7f60ad63f 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -82,6 +82,18 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_; + if (nativeImage_ == nullptr) { + nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); + if (nativeImage_ == nullptr) { + FML_DLOG(ERROR) << "Error with OH_NativeImage_Create"; + return; + } + nativeWindow_ = OH_NativeImage_AcquireNativeWindow(nativeImage_); + if (nativeWindow_ == nullptr) { + FML_DLOG(ERROR) << "Error with OH_NativeImage_AcquireNativeWindow"; + return; + } + } int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); @@ -105,6 +117,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); if (image) { + FML_LOG(INFO) << "OHOSExternalTextureGL image w=" << bounds.width() << ", h=" << bounds.height(); SkAutoCanvasRestore autoRestore(context.canvas, true); // The incoming texture is vertically flipped, so we flip it @@ -185,7 +198,7 @@ void OHOSExternalTextureGL::Attach() { } void OHOSExternalTextureGL::Update() { - //ProducePixelMapToNativeImage(); + ProducePixelMapToNativeImage(); int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_UpdateSurfaceImage err code:"<< ret; @@ -228,26 +241,34 @@ void OHOSExternalTextureGL::DispatchImage(ImageNative* image) void OHOSExternalTextureGL::ProducePixelMapToNativeImage() { - FML_DLOG(INFO)<<"OHOSExternalTextureGL::ProducePixelMapToNativeImage enter"; if(pixelMap_ == nullptr) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL pixelMap in null"; + FML_DLOG(ERROR) << "OHOSExternalTextureGL pixelMap in null"; return; } if (state_ == AttachmentState::detached) { - FML_DLOG(FATAL)<<"OHOSExternalTextureGL ProducePixelMapToNativeImage AttachmentState err"; + FML_DLOG(ERROR) << "OHOSExternalTextureGL AttachmentState err"; return; } - - OH_PixelMap_GetImageInfo(pixelMap_, &pixelMapInfo); - FML_DLOG(INFO)<<"OHOSExternalTextureGL pixelMapInfo w:"<virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); @@ -255,21 +276,32 @@ void OHOSExternalTextureGL::ProducePixelMapToNativeImage() FML_DLOG(FATAL)<<"OHOSExternalTextureGL mmap failed"; return; } + void *pixelAddr = nullptr; - int32_t ret = OH_PixelMap_AccessPixels(pixelMap_, &pixelAddr); - if(ret != IMAGE_RESULT_SUCCESS) { + ret = OH_PixelMap_AccessPixels(pixelMap_, &pixelAddr); + if (ret != IMAGE_RESULT_SUCCESS) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_PixelMap_AccessPixels err:"<< ret; return; } - FML_DLOG(INFO)<<"OHOSExternalTextureGL pixelAddr:"<(pixelAddr); + + uint32_t *value = static_cast(pixelAddr); uint32_t *pixel = static_cast(mappedAddr); - for (uint32_t x = 0; x < pixelMapInfo.width; x++) { - for (uint32_t y = 0; y < pixelMapInfo.height; y++) { - *pixel++ = *value++; - } + uint32_t rowDataSize = 256; // DMA内存会自动补齐,分配内存时是 256 的整数倍 + while (rowDataSize < pixelMapInfo.rowSize) { + rowDataSize += 256; } + + FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo w:" << pixelMapInfo.width << " h:" << pixelMapInfo.height; + FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo rowSize:" << pixelMapInfo.rowSize << " format:" << pixelMapInfo.pixelFormat; + FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo rowDataSize:" << rowDataSize; + + // 复制图片纹理数据到内存中,需要处理DMA内存补齐相关的逻辑 + for (uint32_t i = 0; i < pixelMapInfo.height; i++) { + memcpy(pixel, value, rowDataSize); + pixel += rowDataSize / 4; + value += pixelMapInfo.width; + } + OH_PixelMap_UnAccessPixels(pixelMap_); //munmap after use ret = munmap(mappedAddr, handle->size); @@ -280,9 +312,8 @@ void OHOSExternalTextureGL::ProducePixelMapToNativeImage() Region region{nullptr, 0}; ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer_, fenceFd, region); if(ret != 0) { - FML_DLOG(FATAL)<<"OH_NativeWindow_NativeWindowFlushBuffer err code:"<< ret; + FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeWindow_NativeWindowFlushBuffer err:"<< ret; } - } EGLDisplay OHOSExternalTextureGL::GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list) -- Gitee From 2a9c7d4339a76174f663dcadf6f11ac5016508ae Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Thu, 22 Feb 2024 21:18:19 +0800 Subject: [PATCH 65/69] =?UTF-8?q?=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../plugin/common/StandardMessageCodec.ets | 2 +- .../ohos/ohos_external_texture_gl.cpp | 95 ------------------- .../platform/ohos/ohos_external_texture_gl.h | 5 - 3 files changed, 1 insertion(+), 101 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets index df27a12328..8e740f95fd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets @@ -339,7 +339,7 @@ export default class StandardMessageCodec implements MessageCodec { break; } default: - throw new Error("Message corrupted"); + throw new Error("Message corrupted, type=" + type); } return result; } diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index b7f60ad63f..c1f9ccc66a 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -36,7 +36,6 @@ constexpr const char *CHARACTER_STRING_WHITESPACE = " "; constexpr const char *EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland"; constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; -constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) : Texture(id),ohos_surface_(std::move(ohos_surface)),transform(SkMatrix::I()) { @@ -65,9 +64,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, return; } if (state_ == AttachmentState::uninitialized) { - // Attach(); - // state_ = AttachmentState::attached; - // InitEGLEnv(); OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); @@ -76,11 +72,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - // glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_; if (nativeImage_ == nullptr) { nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); @@ -117,7 +108,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, context.gr_context, backendTexture, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr); if (image) { - FML_LOG(INFO) << "OHOSExternalTextureGL image w=" << bounds.width() << ", h=" << bounds.height(); SkAutoCanvasRestore autoRestore(context.canvas, true); // The incoming texture is vertically flipped, so we flip it @@ -167,36 +157,6 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { // do nothing } -void OHOSExternalTextureGL::Attach() { - if (eglContext_ == EGL_NO_CONTEXT) { - FML_DLOG(INFO) << "OHOSExternalTextureGL eglContext_ no context, need init"; - InitEGLEnv(); - } - - if (texture_name_ == 0) { - glGenTextures(1, &texture_name_); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_name_); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - - // 关联上下文 - if (!eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_)) { - EGLint surfaceId = -1; - eglQuerySurface(eglDisplay_, EGL_NO_SURFACE, EGL_CONFIG_ID, &surfaceId); - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to call eglMakeCurrent, error:" - << eglGetError(); - } - - int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); - if (ret != 0) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL OH_NativeImage_AttachContext err code:" << ret; - } - -} - void OHOSExternalTextureGL::Update() { ProducePixelMapToNativeImage(); int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); @@ -336,61 +296,6 @@ EGLDisplay OHOSExternalTextureGL::GetPlatformEglDisplay(EGLenum platform, void * return eglGetDisplay((EGLNativeDisplayType)native_display); } -void OHOSExternalTextureGL::InitEGLEnv() -{ - FML_DLOG(INFO) << "OHOSExternalTextureGL InitEGLEnv"; - // 获取当前的显示设备 - eglDisplay_ = - GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL); - if (eglDisplay_ == EGL_NO_DISPLAY) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to create EGLDisplay gl errno : " - << eglGetError(); - } - EGLint major, minor; - // 初始化EGLDisplay - if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to initialize EGLDisplay"; - } - - // 绑定图形绘制的API为OpenGLES - if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to bind OpenGL ES API"; - } - unsigned int ret; - EGLint count; - EGLint config_attribs[] = {EGL_SURFACE_TYPE, - EGL_WINDOW_BIT, - EGL_RED_SIZE, - 8, - EGL_GREEN_SIZE, - 8, - EGL_BLUE_SIZE, - 8, - EGL_ALPHA_SIZE, - 8, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES3_BIT, - EGL_NONE}; - // 获取一个有效的系统配置信息 - ret = eglChooseConfig(eglDisplay_, config_attribs, &config_, 1, &count); - if (!(ret && static_cast(count) >= 1)) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to eglChooseConfig"; - } - - const EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE}; - - // 创建上下文 - eglContext_ = - eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs); - if (eglContext_ == EGL_NO_CONTEXT) { - FML_DLOG(FATAL) << "OHOSExternalTextureGL Failed to create egl context, error:" - << eglGetError(); - } - - FML_DLOG(INFO) << "OHOSExternalTextureGL InitEGLEnv finish"; -} - bool OHOSExternalTextureGL::CheckEglExtension(const char *extensions, const char *extension) { size_t extlen = strlen(extension); diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 89bc1549c7..8e2de271f6 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -59,8 +59,6 @@ class OHOSExternalTextureGL : public flutter::Texture { void DispatchPixelMap(NativePixelMap* pixelMap); private: - void Attach(); - void Update(); void Detach(); @@ -69,8 +67,6 @@ class OHOSExternalTextureGL : public flutter::Texture { EGLDisplay GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list); - void InitEGLEnv(); - bool CheckEglExtension(const char *extensions, const char *extension); void ProducePixelMapToNativeImage(); @@ -103,7 +99,6 @@ class OHOSExternalTextureGL : public flutter::Texture { EGLContext eglContext_; EGLDisplay eglDisplay_; - EGLConfig config_; FML_DISALLOW_COPY_AND_ASSIGN(OHOSExternalTextureGL); }; -- Gitee From 5845ff712331cd50e8f2096896e99ad3df834ddf Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Fri, 23 Feb 2024 21:34:04 +0800 Subject: [PATCH 66/69] modify copyright header Signed-off-by: 18719058668 <718092089@qq.com> --- .../engine/renderer/SurfaceTextureWrapper.ets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets index cbb7e8f64d..b1da18061b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import image from '@ohos.multimedia.image'; export class SurfaceTextureWrapper { -- Gitee From 2156c500c853ce1c9651063614d39bcf2c945812 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Fri, 23 Feb 2024 21:45:04 +0800 Subject: [PATCH 67/69] modify codecheck error Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index c1f9ccc66a..3e8ad97dfa 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -38,7 +38,7 @@ constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; 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()) { + : Texture(id), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { nativeImage_ = nullptr; nativeWindow_ = nullptr; eglContext_ = EGL_NO_CONTEXT; @@ -68,8 +68,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - // bool result = ohosSurfaceGLSkia_->ResourceContextMakeCurrent(); - // if (result) { FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_; @@ -87,7 +85,6 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, } int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); - if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_AttachContext err code:"<< ret; } -- Gitee From 6939dfa4c8c80435ed7cfb1f3d7b85777a1bbb5d Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Fri, 23 Feb 2024 22:16:10 +0800 Subject: [PATCH 68/69] modify codecheck error Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/napi/platform_view_ohos_napi.cpp | 2 +- shell/platform/ohos/ohos_external_texture_gl.h | 2 -- shell/platform/ohos/ohos_unified_surface.h | 5 +---- shell/platform/ohos/platform_view_ohos.cpp | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 5564b1c089..528abbcd7f 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1482,7 +1482,7 @@ napi_value PlatformViewOHOSNapi::nativeMarkTextureFrameAvailable( } napi_value PlatformViewOHOSNapi::nativeRegisterPixelMap(napi_env env, - napi_callback_info info) + napi_callback_info info) { FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeRegisterPixelMap"; size_t argc = 3; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 8e2de271f6..0e900e60a4 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -73,8 +73,6 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - // ImageNative* image_; - AttachmentState state_ = AttachmentState::uninitialized; bool new_frame_ready_ = false; diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index ef07545e42..49aa35a3d6 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -69,15 +69,12 @@ class OHOSUnifiedSurface : public GPUSurfaceGLDelegate, static sk_sp GetDefaultPlatformGLInterface() {} using GLProcResolver = - std::function; + std::function; GLProcResolver GetGLProcResolver() {} bool AllowsDrawingWhenGpuDisabled() {} - }; - - } // namespace flutter #endif \ No newline at end of file diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index c21987440e..7911c45cac 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -462,7 +462,7 @@ void PlatformViewOHOS::UnRegisterExternalTexture(int64_t texture_id) void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, NativePixelMap* pixelMap) { - if(ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { auto iter = external_texture_gl_.find(texture_id); if(iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); -- Gitee From 6778ac4462bdced6ae48115b434c558e5c6281c4 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 26 Feb 2024 09:22:03 +0800 Subject: [PATCH 69/69] modify checkerror Signed-off-by: 18719058668 <718092089@qq.com> --- shell/platform/ohos/napi/platform_view_ohos_napi.cpp | 4 ++-- shell/platform/ohos/ohos_external_texture_gl.cpp | 6 +++--- shell/platform/ohos/platform_view_ohos.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 528abbcd7f..848ac957d7 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1423,8 +1423,8 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( } napi_value PlatformViewOHOSNapi::nativeInitNativeImage( - napi_env env, napi_callback_info info) -{ + napi_env env, + napi_callback_info info) { FML_DLOG(INFO)<<"PlatformViewOHOSNapi::nativeInitNativeImage"; size_t argc = 3; napi_value args[3] = {nullptr}; diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 3e8ad97dfa..b24c181e38 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -157,7 +157,7 @@ void OHOSExternalTextureGL::OnTextureUnregistered() { void OHOSExternalTextureGL::Update() { ProducePixelMapToNativeImage(); int32_t ret = OH_NativeImage_UpdateSurfaceImage(nativeImage_); - if(ret != 0) { + if (ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_UpdateSurfaceImage err code:"<< ret; } UpdateTransform(); @@ -174,7 +174,7 @@ void OHOSExternalTextureGL::UpdateTransform() { if(ret != 0) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL OH_NativeImage_GetTransformMatrix err code:"<< ret; } - //transform ohos 4x4 matrix to skia 3x3 matrix + // transform ohos 4x4 matrix to skia 3x3 matrix FML_DLOG(INFO)<<"OHOSExternalTextureGL::UpdateTransform "<virAddr, handle->size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); if (mappedAddr == MAP_FAILED) { FML_DLOG(FATAL)<<"OHOSExternalTextureGL mmap failed"; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 7911c45cac..19f45611cf 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -464,7 +464,7 @@ void PlatformViewOHOS::RegisterExternalTextureByPixelMap(int64_t texture_id, Nat { if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { auto iter = external_texture_gl_.find(texture_id); - if(iter != external_texture_gl_.end()) { + if (iter != external_texture_gl_.end()) { iter->second->DispatchPixelMap(pixelMap); } else { std::shared_ptr ohos_external_gl = std::make_shared(texture_id, ohos_surface_); -- Gitee