From 0f90810a6fdac9eec12bbac2af3d81e5b4fa612b Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Fri, 31 May 2024 18:22:19 +0800 Subject: [PATCH 1/9] =?UTF-8?q?buffer=E5=A4=8D=E7=94=A8=EF=BC=8C=E5=87=8F?= =?UTF-8?q?=E5=B0=91=E9=87=8D=E5=A4=8D=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- shell/platform/ohos/ohos_egl_surface.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/ohos_egl_surface.cpp b/shell/platform/ohos/ohos_egl_surface.cpp index e7ee3d9a8f..ac0ce2928a 100755 --- a/shell/platform/ohos/ohos_egl_surface.cpp +++ b/shell/platform/ohos/ohos_egl_surface.cpp @@ -78,13 +78,17 @@ class OhosEGLSurfaceDamage { void init(EGLDisplay display, EGLContext context) { const char* extensions = eglQueryString(display, EGL_EXTENSIONS); if (HasExtension(extensions, "EGL_KHR_partial_update")) { - set_damage_region_ = reinterpret_cast( - eglGetProcAddress("eglSetDamageRegionKHR")); + set_damage_region_ = reinterpret_cast( + glGetProcAddress("eglSetDamageRegionKHR")); + } + + if (HasExtension(extensions, "EGL_EXT_swap_buffers_with_damage")) { + swap_buffers_with_damage_ = reinterpret_cast( + eglGetProcAddress("eglSwapBuffersWithDamageEXT")); + } else if (HasExtension(extensions, "EGL_KHR_swap_buffers_with_damage")) { + swap_buffers_with_damage_ = reinterpret_cast( + eglGetProcAddress("eglSwapBuffersWithDamageKHR")); } - // ohos 暂没公开拓展,但支持接口调用 - swap_buffers_with_damage_ = - reinterpret_cast( - eglGetProcAddress("eglSwapBuffersWithDamageKHR")); partial_redraw_supported_ = set_damage_region_ != nullptr && swap_buffers_with_damage_ != nullptr; -- Gitee From e7e1e6d2d6face42d2840c22c65d3979ac7957fd Mon Sep 17 00:00:00 2001 From: huangxiaoyao <976125628@qq.com> Date: Mon, 3 Jun 2024 14:17:34 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangxiaoyao <976125628@qq.com> --- .../flutter/src/main/ets/embedding/ohos/FlutterManager.ets | 4 ++++ 1 file changed, 4 insertions(+) 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 index bfe5cb7eb8..086d11979b 100644 --- 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 @@ -80,6 +80,10 @@ export default class FlutterManager { } } + /** + * It's suggested to keep 'oh_flutter_' as the prefix for xcomponent_id. + * Otherwise it might affect the performance. + */ createFlutterView(context: Context): FlutterView { let flutterView = new FlutterView(`oh_flutter_${this.flutterViewIndex++}`, context); this.putFlutterView(flutterView.getId(), flutterView); -- Gitee From 7912416e41de5c714455c50486652e5b91dc3252 Mon Sep 17 00:00:00 2001 From: 18719058668 <718092089@qq.com> Date: Mon, 3 Jun 2024 15:38:26 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=A7=A3=E5=86=B3Platformview=E8=A7=84?= =?UTF-8?q?=E9=81=BF=E8=BD=AF=E9=94=AE=E7=9B=98=E5=8C=BA=E5=9F=9F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18719058668 <718092089@qq.com> --- .../main/ets/plugin/platform/PlatformViewsController.ets | 2 +- .../flutter/src/main/ets/view/FlutterView.ets | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) 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 f0fe1ae96c..8f3689dfac 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 @@ -143,7 +143,7 @@ export default class PlatformViewsController implements PlatformViewsAccessibili let nodeHeightLink: SubscribedAbstractProperty = AppStorage.link('nodeHeight'); let oldNodeWidth: number = AppStorage.get('nodeWidth')! let oldNodeHeight: number = AppStorage.get('nodeHeight')! - if (oldNodeWidth == physicalWidth) { + if ((oldNodeWidth == physicalWidth) && (oldNodeHeight == physicalHeight)) { onComplete.run(new PlatformViewBufferSize(physicalWidth, physicalHeight)); return; } 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 1f015592af..bab625748a 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 @@ -228,7 +228,6 @@ export class FlutterView { let systemAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); let navigationAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); 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); @@ -247,11 +246,6 @@ export class FlutterView { this.viewportMetrics.physicalViewPaddingLeft = systemAvoidArea!.leftRect.width 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 -- Gitee From 6f305defba2bcf885b4f745d443ff78fd7f6cde0 Mon Sep 17 00:00:00 2001 From: keminLuo <541416002@qq.com> Date: Wed, 29 May 2024 10:36:09 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9A=84=E8=BD=AF=E4=BB=B6=E7=BB=98=E5=88=B6=E5=92=8C?= =?UTF-8?q?impeller=E7=BB=98=E5=88=B6=20Signed-off-by:=20=E7=BD=97?= =?UTF-8?q?=E9=94=AE=E9=93=AD=20<541416002@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- impeller/tools/impeller.gni | 2 +- shell/platform/ohos/BUILD.gn | 10 ++++----- .../embedding/engine/loader/FlutterLoader.ets | 5 ++++- shell/platform/ohos/platform_view_ohos.cpp | 22 +++++++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/impeller/tools/impeller.gni b/impeller/tools/impeller.gni index e5dea68e12..37b4164707 100644 --- a/impeller/tools/impeller.gni +++ b/impeller/tools/impeller.gni @@ -14,7 +14,7 @@ declare_args() { impeller_enable_metal = is_ios # Whether the OpenGLES backend is enabled. - impeller_enable_opengles = is_linux || is_win || is_android || is_ohos + impeller_enable_opengles = (is_linux || is_win || is_android) && !is_ohos # Whether the Vulkan backend is enabled. impeller_enable_vulkan = (is_win || is_android || is_linux) && !is_ohos diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index e6783f1d65..5fe32a2c41 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -34,7 +34,7 @@ group("ohos") { } } shell_gpu_configuration("ohos_gpu_configuration") { - enable_software = true + enable_software = false enable_gl = true enable_vulkan = false enable_metal = false @@ -73,7 +73,7 @@ source_set("flutter_ohos_sources") { "vsync_waiter_ohos.h", "ohos_logger.h" , "ohos_display.h", - "ohos_surface_software.h", + # "ohos_surface_software.h", "./context/ohos_context.h", "./surface/ohos_native_window.h", "./surface/ohos_surface.h", @@ -94,7 +94,7 @@ source_set("flutter_ohos_sources") { "ohos_shell_holder.cpp", "platform_view_ohos.cpp", "ohos_display.cpp", - "ohos_surface_software.cpp", + # "ohos_surface_software.cpp", "platform_message_handler_ohos.cpp", "platform_message_response_ohos.cpp", "vsync_waiter_ohos.cpp", @@ -105,8 +105,8 @@ source_set("flutter_ohos_sources") { "ohos_touch_processor.cpp", "ohos_main.cpp" , "ohos_logger.c" , - "ohos_context_gl_impeller.cpp", - "ohos_surface_gl_impeller.cpp", + # "ohos_context_gl_impeller.cpp", + # "ohos_surface_gl_impeller.cpp", # "//flutter/impeller/toolkit/egl/display.cc", "ohos_context_gl_skia.cpp" , "ohos_egl_surface.cpp" , 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 347db9b834..13e6355fbf 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 @@ -209,7 +209,10 @@ export default class FlutterLoader { shellArgs.push("--leak-vm=" + true); - //shellArgs.push("--enable-impeller"); + // It does not support Impeller. + // shellArgs.push("--enable-impeller"); + // It does not support Software Rendering. + // shellArgs.push("--enable-software-rendering"); // //最终初始化操作 const costTime = Date.now() - this.initStartTimestampMillis; diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index bf65b2252e..e8fe8fcd8e 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -20,11 +20,11 @@ #include "flutter/shell/common/shell_io_manager.h" #include "flutter/shell/platform/ohos/ohos_context_gl_skia.h" #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" -#include "flutter/shell/platform/ohos/ohos_surface_software.h" +// #include "flutter/shell/platform/ohos/ohos_surface_software.h" #include "flutter/shell/platform/ohos/platform_message_response_ohos.h" #include "napi_common.h" -#include "ohos_context_gl_impeller.h" -#include "ohos_surface_gl_impeller.h" +// #include "ohos_context_gl_impeller.h" +// #include "ohos_surface_gl_impeller.h" #include "ohos_external_texture_gl.h" #include @@ -41,10 +41,14 @@ OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { switch (ohos_context_->RenderingApi()) { case OHOSRenderingAPI::kSoftware: - return std::make_unique(ohos_context_); + FML_LOG(ERROR) << "It does not support Software Rendering."; + return nullptr; + // return std::make_unique(ohos_context_); case OHOSRenderingAPI::kOpenGLES: if (enable_impeller_) { - return std::make_unique(ohos_context_); + FML_LOG(ERROR) << "It does not support Impeller."; + return nullptr; + // return std::make_unique(ohos_context_); } else { FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; return std::make_unique(ohos_context_); @@ -61,10 +65,14 @@ std::unique_ptr CreateOHOSContext( uint8_t msaa_samples, bool enable_impeller) { if (use_software_rendering) { - return std::make_unique(OHOSRenderingAPI::kSoftware); + FML_LOG(ERROR) << "It does not support Software Rendering."; + return nullptr; + // return std::make_unique(OHOSRenderingAPI::kSoftware); } if (enable_impeller) { - return std::make_unique(); + FML_LOG(ERROR) << "It does not support Impeller."; + return nullptr; + // return std::make_unique(); } return std::make_unique( -- Gitee From c4efcb730de6a73edff569f2905e75b3cfbedd83 Mon Sep 17 00:00:00 2001 From: keminLuo <541416002@qq.com> Date: Wed, 29 May 2024 11:01:05 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=20Signed-off-by:=20=E7=BD=97=E9=94=AE?= =?UTF-8?q?=E9=93=AD=20<541416002@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/platform/ohos/BUILD.gn | 4 ---- .../main/ets/embedding/engine/loader/FlutterLoader.ets | 8 +++----- shell/platform/ohos/platform_view_ohos.cpp | 7 ------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 5fe32a2c41..dc654a4efe 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -73,7 +73,6 @@ source_set("flutter_ohos_sources") { "vsync_waiter_ohos.h", "ohos_logger.h" , "ohos_display.h", - # "ohos_surface_software.h", "./context/ohos_context.h", "./surface/ohos_native_window.h", "./surface/ohos_surface.h", @@ -94,7 +93,6 @@ source_set("flutter_ohos_sources") { "ohos_shell_holder.cpp", "platform_view_ohos.cpp", "ohos_display.cpp", - # "ohos_surface_software.cpp", "platform_message_handler_ohos.cpp", "platform_message_response_ohos.cpp", "vsync_waiter_ohos.cpp", @@ -105,8 +103,6 @@ source_set("flutter_ohos_sources") { "ohos_touch_processor.cpp", "ohos_main.cpp" , "ohos_logger.c" , - # "ohos_context_gl_impeller.cpp", - # "ohos_surface_gl_impeller.cpp", # "//flutter/impeller/toolkit/egl/display.cc", "ohos_context_gl_skia.cpp" , "ohos_egl_surface.cpp" , 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 13e6355fbf..fd2ef0aa4f 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 @@ -144,6 +144,9 @@ export default class FlutterLoader { /** * 初始化dart虚拟机方法 + *

It does not support Impeller. Do not allow adding shellArgs "--enable-impeller". + *

It does not support Software Rendering. Do not allow adding shellArgs "--enable-software-rendering". + * * @param flutterShellArgs */ ensureInitializationComplete(shellArgs: Array | null) { @@ -209,11 +212,6 @@ export default class FlutterLoader { shellArgs.push("--leak-vm=" + true); - // It does not support Impeller. - // shellArgs.push("--enable-impeller"); - // It does not support Software Rendering. - // shellArgs.push("--enable-software-rendering"); - // //最终初始化操作 const costTime = Date.now() - this.initStartTimestampMillis; this.flutterNapi!.init( diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index e8fe8fcd8e..5eb13c167c 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -20,11 +20,8 @@ #include "flutter/shell/common/shell_io_manager.h" #include "flutter/shell/platform/ohos/ohos_context_gl_skia.h" #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" -// #include "flutter/shell/platform/ohos/ohos_surface_software.h" #include "flutter/shell/platform/ohos/platform_message_response_ohos.h" #include "napi_common.h" -// #include "ohos_context_gl_impeller.h" -// #include "ohos_surface_gl_impeller.h" #include "ohos_external_texture_gl.h" #include @@ -43,12 +40,10 @@ std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { case OHOSRenderingAPI::kSoftware: FML_LOG(ERROR) << "It does not support Software Rendering."; return nullptr; - // return std::make_unique(ohos_context_); case OHOSRenderingAPI::kOpenGLES: if (enable_impeller_) { FML_LOG(ERROR) << "It does not support Impeller."; return nullptr; - // return std::make_unique(ohos_context_); } else { FML_LOG(INFO) << "OhosSurfaceFactoryImpl::OhosSurfaceGLSkia "; return std::make_unique(ohos_context_); @@ -67,12 +62,10 @@ std::unique_ptr CreateOHOSContext( if (use_software_rendering) { FML_LOG(ERROR) << "It does not support Software Rendering."; return nullptr; - // return std::make_unique(OHOSRenderingAPI::kSoftware); } if (enable_impeller) { FML_LOG(ERROR) << "It does not support Impeller."; return nullptr; - // return std::make_unique(); } return std::make_unique( -- Gitee From c3babf747e08bab955037f67e50d5cfd7bf298c6 Mon Sep 17 00:00:00 2001 From: keminLuo Date: Mon, 3 Jun 2024 15:55:04 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20Signed-off-by:=20=E7=BD=97=E9=94=AE?= =?UTF-8?q?=E9=93=AD=20<541416002@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/platform/ohos/BUILD.gn | 4 +++- .../src/main/ets/embedding/engine/loader/FlutterLoader.ets | 1 - shell/platform/ohos/platform_view_ohos.cpp | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index dc654a4efe..02963b0690 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -34,7 +34,7 @@ group("ohos") { } } shell_gpu_configuration("ohos_gpu_configuration") { - enable_software = false + enable_software = true enable_gl = true enable_vulkan = false enable_metal = false @@ -73,6 +73,7 @@ source_set("flutter_ohos_sources") { "vsync_waiter_ohos.h", "ohos_logger.h" , "ohos_display.h", + "ohos_surface_software.h", "./context/ohos_context.h", "./surface/ohos_native_window.h", "./surface/ohos_surface.h", @@ -93,6 +94,7 @@ source_set("flutter_ohos_sources") { "ohos_shell_holder.cpp", "platform_view_ohos.cpp", "ohos_display.cpp", + "ohos_surface_software.cpp", "platform_message_handler_ohos.cpp", "platform_message_response_ohos.cpp", "vsync_waiter_ohos.cpp", 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 fd2ef0aa4f..96589b090c 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 @@ -145,7 +145,6 @@ export default class FlutterLoader { /** * 初始化dart虚拟机方法 *

It does not support Impeller. Do not allow adding shellArgs "--enable-impeller". - *

It does not support Software Rendering. Do not allow adding shellArgs "--enable-software-rendering". * * @param flutterShellArgs */ diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index 5eb13c167c..11adce3802 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -20,6 +20,7 @@ #include "flutter/shell/common/shell_io_manager.h" #include "flutter/shell/platform/ohos/ohos_context_gl_skia.h" #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" +#include "flutter/shell/platform/ohos/ohos_surface_software.h" #include "flutter/shell/platform/ohos/platform_message_response_ohos.h" #include "napi_common.h" #include "ohos_external_texture_gl.h" @@ -38,8 +39,7 @@ OhosSurfaceFactoryImpl::~OhosSurfaceFactoryImpl() = default; std::unique_ptr OhosSurfaceFactoryImpl::CreateSurface() { switch (ohos_context_->RenderingApi()) { case OHOSRenderingAPI::kSoftware: - FML_LOG(ERROR) << "It does not support Software Rendering."; - return nullptr; + return std::make_unique(ohos_context_); case OHOSRenderingAPI::kOpenGLES: if (enable_impeller_) { FML_LOG(ERROR) << "It does not support Impeller."; @@ -60,8 +60,7 @@ std::unique_ptr CreateOHOSContext( uint8_t msaa_samples, bool enable_impeller) { if (use_software_rendering) { - FML_LOG(ERROR) << "It does not support Software Rendering."; - return nullptr; + return std::make_unique(OHOSRenderingAPI::kSoftware); } if (enable_impeller) { FML_LOG(ERROR) << "It does not support Impeller."; -- Gitee From d86c95f29c5647fbc761c654bf26fa00dba0a86a Mon Sep 17 00:00:00 2001 From: Diemit <598757652@qq.com> Date: Tue, 4 Jun 2024 15:40:00 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E4=B8=8D=E5=87=BAzip=E5=8C=85=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E7=BC=96=E8=AF=91=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Diemit <598757652@qq.com> --- attachment/repos/bootstrap/auto_complie.py | 234 +++++++++++++++++++++ attachment/repos/bootstrap/ohos.py | 5 +- 2 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 attachment/repos/bootstrap/auto_complie.py diff --git a/attachment/repos/bootstrap/auto_complie.py b/attachment/repos/bootstrap/auto_complie.py new file mode 100644 index 0000000000..fa39a623fa --- /dev/null +++ b/attachment/repos/bootstrap/auto_complie.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2024 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 os +import platform +import subprocess +import sys +import traceback +from obs import ObsClient, PutObjectHeader + +# 使用华为obs +# pip install esdk-obs-python --trusted-host pypi.org + +OS_NAME = platform.system().lower() +IS_WINDOWS = OS_NAME.startswith("win") +IS_MAC = OS_NAME.startswith("darwin") +FLUTTER_ENGINE_PATH = os.path.join(os.getcwd(), 'src', 'flutter') +OHOS_ENGINE_TYPE_OUT = {'ohos-arm64' : 'ohos_debug_unopt_arm64', + 'ohos-arm64-profile' : 'ohos_profile_arm64', + 'ohos-arm64-release' : 'ohos_release_arm64', + 'ohos-x64' : 'ohos_debug_unopt_x64', + 'ohos-x64-profile' : 'ohos_profile_x64', + 'ohos-x64-release' : 'ohos_release_x64', + } + +# OBS 环境变量配置key信息 +ACCESS_KEY = os.getenv("AccessKeyID") +SECRET_KEY = os.getenv("SecretAccessKey") + +# 服务器地址 华南-广州 +SERVER = "https://obs.cn-south-1.myhuaweicloud.com" + +# OBS桶 +FLUTTER_OHOS = 'flutter-ohos-test' + +def log(msg): + print(f'================{msg}============') + +def runGitCommand(command): + result = subprocess.run(command, capture_output=True, text=True, shell=True) + if result.returncode != 0: + raise Exception(f"Git command failed: {result.stderr}") + return result.stdout + +def runPyCommand(command): + + if IS_WINDOWS: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + else: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) + + # 获取实时输出 + for line in iter(proc.stdout.readline, b''): + print(line.decode('utf-8').strip()) + + # 等待命令执行完成 + proc.wait() + +def getRemoteTags(repoPath, remoteName='origin'): + + # 获取远程仓库的所有标签 + tagsOutput = runGitCommand(f'git -C {repoPath} ls-remote --tags {remoteName}') + + # 分割输出,每一行都是一个tag + tags = tagsOutput.split('\n') + + # 去除空行和解析tag信息 + parsedTags = [line.split()[0] for line in tags if line] + + return parsedTags + +# 在指定目录及其子目录中查找指定的文件 +def findFile(directory, filename): + for root, dirs, files in os.walk(directory): + if filename in files: + return (os.path.join(root, filename)) + +# 获取上传对象的进度 +def uploadCallback(transferredAmount, totalAmount, totalSeconds): + # 获取上传平均速率(KB/S) + speed = int(transferredAmount / totalSeconds / 1024) + # 获取上传进度百分比 + progress = int(transferredAmount * 100.0 / totalAmount) + print("\r", end="") + print("速度:{} KB/S 进度: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") + sys.stdout.flush() + if progress == 100: + print("") + +# 检查TAG版本 +def checkRemoteTagsUpdates(): + # 获取远程TAG的最新提交哈希 + remoteTags = getRemoteTags(FLUTTER_ENGINE_PATH) + remoteLatestTag = remoteTags[-1] + + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + + if remoteLatestTag != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False + +# 检查分支更新 +def checkRemoteBranchUpdates(repoPath, remoteName='origin', branch='dev'): + # 切换到你的Git仓库目录 + os.chdir(repoPath) + + # 获取远程分支的最新提交哈希 + remoteLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse {remoteName}/{branch}') + + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse HEAD') + + if remoteLatestCommit != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False + +# 更新代码 +def updateCode(): + # 调用ohos.py更新代码 + log('update source code') + runPyCommand(['python3', os.path.join(os.getcwd(), 'ohos.py'), '-b', 'dev']) + +# 执行编译 +def compileCode(): + # 调用ohhos.py编译flutter engine + log('compile flutter engine debug') + runPyCommand(['python3', os.path.join(os.getcwd(), 'ohos.py'), '-t', 'debug']) + + log('compile flutter engine profile') + runPyCommand(['python3', os.path.join(os.getcwd(), 'ohos.py'), '-t', 'profile']) + + log('compile flutter engine release') + runPyCommand(['python3', os.path.join(os.getcwd(), 'ohos.py'), '-t', 'release']) + +# 获取编译产物 +def getCompileFiles(buildType): + zipfiles = ['artifacts.zip','linux-x64.zip','windows-x64.zip','darwin-x64.zip','symbols.zip'] + + files = [] + for fileName in zipfiles: + if IS_WINDOWS and fileName != 'windows-x64.zip': + continue + if IS_MAC and fileName != 'darwin-x64.zip': + continue + + files.append(findFile(os.path.join(os.getcwd(), 'src', 'out', buildType), fileName)) + + return files + +# 上传服务器 +def uploadServer(version, buildType, filePath): + try: + log(f'upload: {filePath}') + + bucketName = FLUTTER_OHOS + obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) + + # 上传对象的附加头域 + headers = PutObjectHeader() + # 【可选】待上传对象的MIME类型 + headers.contentType = 'text/plain' + + # https://storage.flutter-io.cn/flutter_infra_release/flutter/cececddab019a56da828c41d55cb54484278e880/ohos-arm64-profile/linux-x64.zip + fileName = os.path.basename(filePath) + objectKey = f'flutter_infra_release/flutter/{version}/{buildType}/{fileName}' + + # 待上传文件/文件夹的完整路径,如aa/bb.txt,或aa/ + file_path = filePath + + # 文件上传 + resp = obsClient.putFile(bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback) + # 返回码为2xx时,接口调用成功,否则接口调用失败 + if resp.status < 300: + print('Put Content Succeeded') + print('requestId:', resp.requestId) + print('etag:', resp.body.etag) + else: + print('Put Content Failed') + print('requestId:', resp.requestId) + print('errorCode:', resp.errorCode) + print('errorMessage:', resp.errorMessage) + + except: + log('Put Content Failed') + log(traceback.format_exc()) + + +def main(): + + # if checkRemoteBranchUpdates(FLUTTER_ENGINE_PATH) : + if checkRemoteTagsUpdates() : + updateCode() + compileCode() + log("编译完成") + + engineRevision = os.path.join(FLUTTER_ENGINE_PATH, 'build', 'git_revision.py') + localVersion = subprocess.getoutput(f'python {engineRevision} --repository {FLUTTER_ENGINE_PATH}') + log(localVersion) + + # 获取编译产物 + for buildType in OHOS_ENGINE_TYPE_OUT: + zipfiles = getCompileFiles(OHOS_ENGINE_TYPE_OUT[buildType]) + for filePath in zipfiles: + if not filePath or not os.path.exists(filePath): + continue + print(filePath) + # uploadServer(localVersion, buildType, filePath) + + log('上传完成') + + else : + log("本地代码已经是最新") + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/repos/bootstrap/ohos.py b/attachment/repos/bootstrap/ohos.py index e759617c1f..8b67f605b7 100644 --- a/attachment/repos/bootstrap/ohos.py +++ b/attachment/repos/bootstrap/ohos.py @@ -207,7 +207,10 @@ def engineConfig(buildInfo, args): # 执行engine编译操作 def engineCompile(buildInfo): - runCommand("ninja -C %s" % os.path.join("src", "out", getOutput(buildInfo))) + command = "ninja -C %s default " % os.path.join("src", "out", getOutput(buildInfo)) + if IS_WINDOWS and buildInfo.buildType != "debug": + command += "flutter/build/archives:archive_win_gen_snapshot " + runCommand(command) # 编译har文件 -- Gitee From 7599af53dc40f24501d2704f0d24761d93e5e971 Mon Sep 17 00:00:00 2001 From: Diemit Date: Tue, 4 Jun 2024 08:45:55 +0000 Subject: [PATCH 8/9] update attachment/repos/bootstrap/auto_complie.py. Signed-off-by: Diemit --- attachment/repos/bootstrap/auto_complie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachment/repos/bootstrap/auto_complie.py b/attachment/repos/bootstrap/auto_complie.py index fa39a623fa..325caa282c 100644 --- a/attachment/repos/bootstrap/auto_complie.py +++ b/attachment/repos/bootstrap/auto_complie.py @@ -43,7 +43,7 @@ SECRET_KEY = os.getenv("SecretAccessKey") SERVER = "https://obs.cn-south-1.myhuaweicloud.com" # OBS桶 -FLUTTER_OHOS = 'flutter-ohos-test' +FLUTTER_OHOS = 'flutter-ohos' def log(msg): print(f'================{msg}============') -- Gitee From 79c865645b0e44bb829fe375566bc07b8aecea98 Mon Sep 17 00:00:00 2001 From: Mingfeng Zhong Date: Tue, 4 Jun 2024 19:31:07 +0800 Subject: [PATCH 9/9] =?UTF-8?q?1.=20=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8su?= =?UTF-8?q?rface=E6=A8=A1=E5=BC=8F=EF=BC=8C=E6=80=A7=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E4=BC=98=202.=20=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mingfeng Zhong --- .../main/ets/component/XComponentStruct.ets | 58 ------------------- .../main/ets/embedding/ohos/FlutterPage.ets | 2 +- 2 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets 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 deleted file mode 100644 index 38f9c9d8be..0000000000 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets +++ /dev/null @@ -1,58 +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 Any from '../plugin/common/Any'; -import ApplicationInfoLoader from '../embedding/engine/loader/ApplicationInfoLoader'; - -import { BuilderParams, DVModelParameters } from '../view/DynamicView/dynamicView'; - -@Component -struct XComponentStruct { - private context: Any; - private applicationInfo = ApplicationInfoLoader.load(getContext()); - dvModelParams: DVModelParameters = new DVModelParameters(); - - build() { - // todo OS解决默认背景色后可以移除冗余重复代码,仅保留差异的backgroundColor属性条件配置 - if (this.applicationInfo.isDebugMode) { - XComponent({ - id: (this.dvModelParams as Record)["xComponentId"], - type: XComponentType.TEXTURE, - libraryname: 'flutter' - }) - .onLoad((context) => { - this.context = context; - }) - .onDestroy(() => { - }) - .backgroundColor(Color.White) - } else { - XComponent({ - id: (this.dvModelParams as Record)["xComponentId"], - type: XComponentType.TEXTURE, - libraryname: 'flutter' - }) - .onLoad((context) => { - this.context = context; - }) - .onDestroy(() => { - }) - } - } - -} - -@Builder export function BuildXComponentStruct(buildParams: BuilderParams) { - XComponentStruct({dvModelParams: buildParams.params}); -} \ 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 3d5c995020..f67b1d0ef7 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 @@ -26,7 +26,7 @@ const TAG = "FlutterPage"; @Component export struct FlutterPage { @Prop viewId: string = "" - @Prop xComponentType: XComponentType = XComponentType.TEXTURE + @Prop xComponentType: XComponentType = XComponentType.SURFACE @Builder doNothingBuilder() {} @BuilderParam splashScreenView: () => void = this.doNothingBuilder; -- Gitee