From 8396b67c283992f0042d427825adf090107b29d9 Mon Sep 17 00:00:00 2001 From: xuchang Date: Tue, 10 Oct 2023 18:41:21 -0700 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I86KNH=20codecheck=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9=20Description:=20codecheck=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9=20Sig:=20OpenHarmony-SIG/flutter-en?= =?UTF-8?q?gine=20Feature=20or=20Bugfix:=20Feature=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuchang --- fml/backtrace.cc | 2 +- fml/logging.cc | 63 +++++++++++-------- fml/logging.h | 3 +- fml/platform/ohos/message_loop_ohos.cc | 4 -- fml/platform/ohos/napi_util.cc | 6 -- fml/platform/ohos/timerfd.cc | 6 +- runtime/dart_isolate.cc | 6 +- runtime/dart_service_isolate.cc | 6 +- shell/platform/ohos/BUILD.gn | 1 + shell/platform/ohos/library_loader.cpp | 2 - .../ohos/napi/platform_view_ohos_napi.cpp | 27 ++++---- .../ohos/napi/platform_view_ohos_napi.h | 2 +- shell/platform/ohos/napi_common.h | 2 - .../platform/ohos/ohos_context_gl_impeller.h | 2 +- shell/platform/ohos/ohos_display.cpp | 2 +- shell/platform/ohos/ohos_egl_surface.cpp | 36 +++++------ .../ohos/ohos_external_texture_gl.cpp | 3 - shell/platform/ohos/ohos_image_generator.cpp | 1 - shell/platform/ohos/ohos_main.cpp | 4 -- shell/platform/ohos/ohos_shell_holder.h | 3 - .../ohos/ohos_surface_gl_impeller.cpp | 2 +- .../platform/ohos/ohos_surface_gl_impeller.h | 2 +- shell/platform/ohos/ohos_surface_gl_skia.cpp | 1 - shell/platform/ohos/ohos_surface_software.cpp | 3 +- shell/platform/ohos/ohos_touch_processor.cpp | 6 +- .../platform/ohos/ohos_xcomponent_adapter.cpp | 8 +-- .../ohos/platform_message_response_ohos.cpp | 1 - shell/platform/ohos/platform_view_ohos.h | 2 - shell/platform/ohos/types.h | 28 +++++++++ 29 files changed, 113 insertions(+), 121 deletions(-) create mode 100644 shell/platform/ohos/types.h diff --git a/fml/backtrace.cc b/fml/backtrace.cc index 3a3be765a6..264fa7d0bc 100644 --- a/fml/backtrace.cc +++ b/fml/backtrace.cc @@ -17,7 +17,7 @@ #include #include #else // FML_OS_WIN -//#include +#include #endif // FML_OS_WIN namespace fml { diff --git a/fml/logging.cc b/fml/logging.cc index 88c537dab0..84c465a1f8 100644 --- a/fml/logging.cc +++ b/fml/logging.cc @@ -21,27 +21,40 @@ #ifdef FML_OS_OHOS #include -extern "C"{ +extern "C" { #define OHOS_LOG_TYPE_APP 0 #define HILOG_LOG_DOMAIN 0 #define HILOG_LOG_TAG "XComFlutterEngine" - typedef enum { - /** Debug level to be used by {@link OH_LOG_DEBUG} */ - HILOG_LOG_DEBUG = 3, - /** Informational level to be used by {@link OH_LOG_INFO} */ - HILOG_LOG_INFO = 4, - /** Warning level to be used by {@link OH_LOG_WARN} */ - HILOG_LOG_WARN = 5, - /** Error level to be used by {@link OH_LOG_ERROR} */ - HILOG_LOG_ERROR = 6, - /** Fatal level to be used by {@link OH_LOG_FATAL} */ - HILOG_LOG_FATAL = 7, +typedef enum { + /** Debug level to be used by {@link OH_LOG_DEBUG} */ + HILOG_LOG_DEBUG = 3, + /** Informational level to be used by {@link OH_LOG_INFO} */ + HILOG_LOG_INFO = 4, + /** Warning level to be used by {@link OH_LOG_WARN} */ + HILOG_LOG_WARN = 5, + /** Error level to be used by {@link OH_LOG_ERROR} */ + HILOG_LOG_ERROR = 6, + /** Fatal level to be used by {@link OH_LOG_FATAL} */ + HILOG_LOG_FATAL = 7, } HiLog_LogLevel; -int OH_LOG_Print(int type, HiLog_LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) ; -#define HILOG_LOG(level,...) ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, (level), HILOG_LOG_DOMAIN, HILOG_LOG_TAG, __VA_ARGS__)) -#define HILOG_DEBUG(...) ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_DEBUG, HILOG_LOG_DOMAIN, HILOG_LOG_TAG, __VA_ARGS__)) -#define HILOG_ERROR(...) ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_ERROR, HILOG_LOG_DOMAIN, HILOG_LOG_TAG, __VA_ARGS__)) -#define HILOG_INFO(...) ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_INFO, HILOG_LOG_DOMAIN, HILOG_LOG_TAG, __VA_ARGS__)) +int OH_LOG_Print(int type, + HiLog_LogLevel level, + unsigned int domain, + const char* tag, + const char* fmt, + ...); +#define HILOG_LOG(level, ...) \ + ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, (level), HILOG_LOG_DOMAIN, \ + HILOG_LOG_TAG, __VA_ARGS__)) +#define HILOG_DEBUG(...) \ + ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_DEBUG, HILOG_LOG_DOMAIN, \ + HILOG_LOG_TAG, __VA_ARGS__)) +#define HILOG_ERROR(...) \ + ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_ERROR, HILOG_LOG_DOMAIN, \ + HILOG_LOG_TAG, __VA_ARGS__)) +#define HILOG_INFO(...) \ + ((void)OH_LOG_Print(OHOS_LOG_TYPE_APP, HILOG_LOG_INFO, HILOG_LOG_DOMAIN, \ + HILOG_LOG_TAG, __VA_ARGS__)) } #endif namespace fml { @@ -148,12 +161,12 @@ LogMessage::~LogMessage() { } fx_logger_log_with_source(fx_log_get_logger(), fx_severity, nullptr, file_, line_, stream_.str().c_str()); -#elif defined(FML_OS_OHOS) +#elif defined(FML_OS_OHOS) HiLog_LogLevel fx_severity; switch (severity_) { case LOG_INFO: - fx_severity= HILOG_LOG_INFO; + fx_severity = HILOG_LOG_INFO; break; case LOG_WARNING: fx_severity = HILOG_LOG_WARN; @@ -165,10 +178,10 @@ LogMessage::~LogMessage() { fx_severity = HILOG_LOG_FATAL; break; default: - fx_severity = HILOG_LOG_INFO; - //fx_severity = HILOG_LOG_DEBUG; - }//end switch - HILOG_LOG(fx_severity,"Thread:%{public}lu %{public}s",pthread_self(),stream_.str().c_str() ); + fx_severity = HILOG_LOG_INFO; + } // end switch + HILOG_LOG(fx_severity, "Thread:%{public}lu %{public}s", pthread_self(), + stream_.str().c_str()); std::cerr << stream_.str(); std::cerr.flush(); @@ -192,9 +205,9 @@ bool ShouldCreateLogMessage(LogSeverity severity) { void KillProcess() { #ifdef FML_OS_OHOS - HILOG_ERROR("FML KILL PROCESS"); + HILOG_ERROR("FML KILL PROCESS"); #else - abort(); + abort(); #endif } diff --git a/fml/logging.h b/fml/logging.h index cd07846805..76457f5f10 100644 --- a/fml/logging.h +++ b/fml/logging.h @@ -43,8 +43,7 @@ int GetVlogVerbosity(); // LOG_FATAL and above is always true. bool ShouldCreateLogMessage(LogSeverity severity); -//[[noreturn]] void KillProcess(); - void KillProcess(); +void KillProcess(); } // namespace fml diff --git a/fml/platform/ohos/message_loop_ohos.cc b/fml/platform/ohos/message_loop_ohos.cc index 9a0f7b52bf..c91a061a63 100644 --- a/fml/platform/ohos/message_loop_ohos.cc +++ b/fml/platform/ohos/message_loop_ohos.cc @@ -14,10 +14,6 @@ */ #include "flutter/fml/platform/ohos/message_loop_ohos.h" - -#include -#include - #include "flutter/fml/eintr_wrapper.h" #include "flutter/fml/logging.h" #include "flutter/fml/platform/ohos/timerfd.h" diff --git a/fml/platform/ohos/napi_util.cc b/fml/platform/ohos/napi_util.cc index 87a32b2554..e08e22f642 100644 --- a/fml/platform/ohos/napi_util.cc +++ b/fml/platform/ohos/napi_util.cc @@ -133,7 +133,6 @@ void NapiPrintValueType(napi_env env, napi_value cur) { if (ok) { FML_DLOG(INFO) << "args[" << i << "],type: " << argType << " is_array "; } - //(env,cur,&ok); if (IsArrayBuffer(env, cur)) { FML_DLOG(INFO) << "args[" << i << "],type: " << argType << " is_arraybuffer "; @@ -194,18 +193,13 @@ int32_t GetArrayBuffer(napi_env env, void** message, size_t* lenth) { napi_status status; - // bool ok = false ; if (NapiIsType(env, arg, napi_null)) { FML_DLOG(ERROR) << "GetArrayBuffer value is null :"; return ERROR_NULL; } - // if( napi_ok != (status = napi_is_arraybuffer(env,arg,& ok )) ){ if (!IsArrayBuffer(env, arg)) { - // FML_DLOG(ERROR)<<"GetArrayBuffer valueType is Not arraybuffer - // status:"< #include #include +#include "../types.h" #include "flutter/fml/make_copyable.h" #include "flutter/fml/platform/ohos/napi_util.h" #include "flutter/shell/platform/ohos/ohos_main.h" @@ -29,7 +30,7 @@ #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { -int64_t PlatformViewOHOSNapi::shell_holder; +int64_t PlatformViewOHOSNapi::shell_holder_value; napi_env PlatformViewOHOSNapi::env_; napi_ref PlatformViewOHOSNapi::ref_napi_obj_; std::vector PlatformViewOHOSNapi::system_languages; @@ -91,9 +92,6 @@ napi_value PlatformViewOHOSNapi::nativeDispatchPlatformMessage( int32_t status; - // flutter.nativeDispatchPlatformMessage(this.nativeShellHolderId, channel, - // message, position, responseId); - // ret = napi_get_cb_info(env, info, &argc, args, &thisArg, nullptr); if (argc < 5 || ret != napi_ok) { FML_DLOG(ERROR) << "nativeDispatchPlatformMessage napi get argc ,argc=" @@ -101,10 +99,6 @@ napi_value PlatformViewOHOSNapi::nativeDispatchPlatformMessage( napi_throw_type_error(env, nullptr, "Wrong number of arguments"); return nullptr; } - // #ifndef NDEBUG - fml::napi::NapiPrintValueTypes(env, argc, args); - // #endif - napi_value napiShellHolder = args[0]; napi_value napiChannel = args[1]; napi_value napiMessage = args[2]; @@ -395,9 +389,9 @@ PlatformViewOHOSNapi::FlutterViewComputePlatformResolvedLocales( const int localeDataLength = 3; flutter::locale mlocale; for (size_t i = 0; i < support_locale_data.size(); i += localeDataLength) { - mlocale.language = support_locale_data[i + 0]; - mlocale.region = support_locale_data[i + 1]; - mlocale.script = support_locale_data[i + 2]; + mlocale.language = support_locale_data[i + LANGUAGE_INDEX]; + mlocale.region = support_locale_data[i + REGION_INDEX]; + mlocale.script = support_locale_data[i + SCRIPT_INDEX]; supportedLocales.push_back(mlocale); } mlocale = resolveNativeLocale(supportedLocales); @@ -405,8 +399,9 @@ PlatformViewOHOSNapi::FlutterViewComputePlatformResolvedLocales( result.push_back(mlocale.region); result.push_back(mlocale.script); FML_DLOG(INFO) << "resolveNativeLocale result to flutter language: " - << result[0] << " region: " << result[1] - << " script: " << result[2]; + << result[LANGUAGE_INDEX] + << " region: " << result[REGION_INDEX] + << " script: " << result[SCRIPT_INDEX]; return std::make_unique>(std::move(result)); } @@ -464,10 +459,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 = + PlatformViewOHOSNapi::shell_holder_value = reinterpret_cast(shell_holder.get()); FML_DLOG(INFO) << "PlatformViewOHOSNapi shell_holder:" - << PlatformViewOHOSNapi::shell_holder; + << PlatformViewOHOSNapi::shell_holder_value; napi_value id; napi_create_int64(env, reinterpret_cast(shell_holder.release()), &id); @@ -1370,7 +1365,7 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( } int64_t PlatformViewOHOSNapi::GetShellHolder() { - return PlatformViewOHOSNapi::shell_holder; + return PlatformViewOHOSNapi::shell_holder_value; } void PlatformViewOHOSNapi::SurfaceCreated(int64_t shell_holder, void* window) { diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 8e698dc6e5..d32a6fe996 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -154,7 +154,7 @@ class PlatformViewOHOSNapi { private: static napi_env env_; static napi_ref ref_napi_obj_; - static int64_t shell_holder; + static int64_t shell_holder_value; static std::vector system_languages; fml::RefPtr platform_task_runner_; }; diff --git a/shell/platform/ohos/napi_common.h b/shell/platform/ohos/napi_common.h index 1783f07181..43b2b3cbef 100644 --- a/shell/platform/ohos/napi_common.h +++ b/shell/platform/ohos/napi_common.h @@ -28,8 +28,6 @@ #define LOGI(...) \ ((void)OH_LOG_Print(LOG_APP, LOG_INFO, APP_LOG_DOMAIN, APP_LOG_TAG, \ __VA_ARGS__)) -// #define LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, APP_LOG_DOMAIN, -// APP_LOG_TAG, __VA_ARGS__)) #define LOGD(...) \ ((void)OH_LOG_Print(LOG_APP, LOG_INFO, APP_LOG_DOMAIN, APP_LOG_TAG, \ __VA_ARGS__)) diff --git a/shell/platform/ohos/ohos_context_gl_impeller.h b/shell/platform/ohos/ohos_context_gl_impeller.h index 3947b457d1..9be28a018c 100755 --- a/shell/platform/ohos/ohos_context_gl_impeller.h +++ b/shell/platform/ohos/ohos_context_gl_impeller.h @@ -23,7 +23,7 @@ class OHOSContextGLImpeller : public OHOSContext { public: OHOSContextGLImpeller(); - ~OHOSContextGLImpeller(); + ~OHOSContextGLImpeller() override; bool IsValid() const override; diff --git a/shell/platform/ohos/ohos_display.cpp b/shell/platform/ohos/ohos_display.cpp index 32feddb2c3..3f23e95b00 100644 --- a/shell/platform/ohos/ohos_display.cpp +++ b/shell/platform/ohos/ohos_display.cpp @@ -20,7 +20,7 @@ namespace flutter { const double defaultFPS = 60; OHOSDisplay::OHOSDisplay(std::shared_ptr napi_facade) - : Display(60), napi_facade_(std::move(napi_facade)) {} + : Display(defaultFPS), napi_facade_(std::move(napi_facade)) {} double OHOSDisplay::GetRefreshRate() const { return defaultFPS; diff --git a/shell/platform/ohos/ohos_egl_surface.cpp b/shell/platform/ohos/ohos_egl_surface.cpp index b416d1269f..1621f11855 100755 --- a/shell/platform/ohos/ohos_egl_surface.cpp +++ b/shell/platform/ohos/ohos_egl_surface.cpp @@ -30,28 +30,22 @@ void LogLastEGLError() { EGLint code; }; -#define _EGL_ERROR_DESC(a) \ - { #a, a } - const EGLNameErrorPair pairs[] = { - _EGL_ERROR_DESC(EGL_SUCCESS), - _EGL_ERROR_DESC(EGL_NOT_INITIALIZED), - _EGL_ERROR_DESC(EGL_BAD_ACCESS), - _EGL_ERROR_DESC(EGL_BAD_ALLOC), - _EGL_ERROR_DESC(EGL_BAD_ATTRIBUTE), - _EGL_ERROR_DESC(EGL_BAD_CONTEXT), - _EGL_ERROR_DESC(EGL_BAD_CONFIG), - _EGL_ERROR_DESC(EGL_BAD_CURRENT_SURFACE), - _EGL_ERROR_DESC(EGL_BAD_DISPLAY), - _EGL_ERROR_DESC(EGL_BAD_SURFACE), - _EGL_ERROR_DESC(EGL_BAD_MATCH), - _EGL_ERROR_DESC(EGL_BAD_PARAMETER), - _EGL_ERROR_DESC(EGL_BAD_NATIVE_PIXMAP), - _EGL_ERROR_DESC(EGL_BAD_NATIVE_WINDOW), - _EGL_ERROR_DESC(EGL_CONTEXT_LOST), - }; - -#undef _EGL_ERROR_DESC + {"EGL_SUCCESS", EGL_SUCCESS}, + {"EGL_NOT_INITIALIZED", EGL_NOT_INITIALIZED}, + {"EGL_BAD_ACCESS", EGL_BAD_ACCESS}, + {"EGL_BAD_ALLOC", EGL_BAD_ALLOC}, + {"EGL_BAD_ATTRIBUTE", EGL_BAD_ATTRIBUTE}, + {"EGL_BAD_CONTEXT", EGL_BAD_CONTEXT}, + {"EGL_BAD_CONFIG", EGL_BAD_CONFIG}, + {"EGL_BAD_CURRENT_SURFACE", EGL_BAD_CURRENT_SURFACE}, + {"EGL_BAD_DISPLAY", EGL_BAD_DISPLAY}, + {"EGL_BAD_SURFACE", EGL_BAD_SURFACE}, + {"EGL_BAD_MATCH", EGL_BAD_MATCH}, + {"EGL_BAD_PARAMETER", EGL_BAD_PARAMETER}, + {"EGL_BAD_NATIVE_PIXMAP", EGL_BAD_NATIVE_PIXMAP}, + {"EGL_BAD_NATIVE_WINDOW", EGL_BAD_NATIVE_WINDOW}, + {"EGL_CONTEXT_LOST", EGL_CONTEXT_LOST}}; const auto count = sizeof(pairs) / sizeof(EGLNameErrorPair); diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 8c5c6a6826..f2ffccbaa8 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -32,7 +32,6 @@ OHOSExternalTextureGL::OHOSExternalTextureGL(int id) OHOSExternalTextureGL::~OHOSExternalTextureGL() { if (state_ == AttachmentState::attached) { - // glDeleteTextures(1, &texture_name_); } } @@ -44,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; } @@ -89,7 +87,6 @@ void OHOSExternalTextureGL::OnGrContextCreated() { void OHOSExternalTextureGL::OnGrContextDestroyed() { if (state_ == AttachmentState::attached) { Detach(); - // glDeleteTextures(1, &texture_name_); } state_ = AttachmentState::detached; } diff --git a/shell/platform/ohos/ohos_image_generator.cpp b/shell/platform/ohos/ohos_image_generator.cpp index 0e0e525f60..b44acf24a8 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -151,7 +151,6 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( size_t argc = 4; - // width, height, OHOSImageGenerator this, pixmap; napi_value args[4] = {nullptr}; napi_status status = diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index 041de2e180..a367e1114d 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -95,7 +95,6 @@ const flutter::Settings& OhosMain::GetSettings() const { void OhosMain::Init(napi_env env, napi_callback_info info) { size_t argc = 6; napi_value param[6]; - // char kernelPath[512], appStoragePath[512], engineCachesPath[512]; std::string kernelPath, appStoragePath, engineCachesPath; int64_t initTimeMillis; napi_get_cb_info(env, info, &argc, param, nullptr, nullptr); @@ -119,8 +118,6 @@ void OhosMain::Init(napi_env env, napi_callback_info info) { flutter::DartCallbackCache::SetCachePath(appStoragePath); fml::paths::InitializeOhosCachesPath(std::string(engineCachesPath)); flutter::DartCallbackCache::LoadCacheFromDisk(); - // TODO 使用CPU - // settings.skia_deterministic_rendering_on_cpu = true; if (!flutter::DartVM::IsRunningPrecompiledCode() && kernelPath[0]) { auto application_kernel_path = kernelPath; @@ -140,7 +137,6 @@ void OhosMain::Init(napi_env env, napi_callback_info info) { }; settings.log_message_callback = [](const std::string& tag, const std::string& message) { - // TODO: Hilog print FML_DLOG(INFO) << tag << " " << message; }; diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 7d5fb0d64a..760cc6f15e 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -48,9 +48,6 @@ class OHOSShellHolder { fml::WeakPtr GetPlatformView(); - // Rasterizer::Screenshot Screenshot(Rasterizer::ScreenshotType type, - // bool base64_encode); - void NotifyLowMemoryWarning(); void Launch(std::unique_ptr apk_asset_provider, diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.cpp b/shell/platform/ohos/ohos_surface_gl_impeller.cpp index 6579e8f1fe..b50e8c8d7b 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.cpp +++ b/shell/platform/ohos/ohos_surface_gl_impeller.cpp @@ -92,7 +92,7 @@ static std::shared_ptr CreateImpellerContext( OHOSSurfaceGLImpeller::OHOSSurfaceGLImpeller( const std::shared_ptr& ohos_context) : OHOSSurface(ohos_context), - reactor_worker_(std::shared_ptr(new ReactorWorker())) { + reactor_worker_(std::make_shared()) { auto display = std::make_unique(); if (!display->IsValid()) { FML_DLOG(ERROR) << "Could not create EGL display."; diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index dfd1ee7ac3..87b2fa4bf6 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -58,7 +58,7 @@ class OHOSSurfaceGLImpeller final : public GPUSurfaceGLDelegate, std::unique_ptr CreateSnapshotSurface() override; // OHOSSurface - virtual std::shared_ptr GetImpellerContext() override; + std::shared_ptr GetImpellerContext() override; // |GPUSurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; diff --git a/shell/platform/ohos/ohos_surface_gl_skia.cpp b/shell/platform/ohos/ohos_surface_gl_skia.cpp index bcc08639aa..36609d4b63 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.cpp +++ b/shell/platform/ohos/ohos_surface_gl_skia.cpp @@ -16,7 +16,6 @@ #include "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include -#include #include "flutter/fml/logging.h" #include "flutter/fml/memory/ref_ptr.h" diff --git a/shell/platform/ohos/ohos_surface_software.cpp b/shell/platform/ohos/ohos_surface_software.cpp index cebb31fd1e..b5c9271596 100644 --- a/shell/platform/ohos/ohos_surface_software.cpp +++ b/shell/platform/ohos/ohos_surface_software.cpp @@ -19,6 +19,7 @@ #include "flutter/fml/logging.h" #include "napi_common.h" #include "third_party/skia/include/core/SkImage.h" +#include "types.h" namespace flutter { @@ -26,7 +27,7 @@ bool GetSkColorType(int32_t buffer_format, SkColorType* color_type, SkAlphaType* alpha_type) { switch (buffer_format) { - case 12: // PIXEL_FMT_RGBA_8888 + case PIXEL_FMT_RGBA_8888: // PIXEL_FMT_RGBA_8888 *color_type = kRGBA_8888_SkColorType; *alpha_type = kPremul_SkAlphaType; return true; diff --git a/shell/platform/ohos/ohos_touch_processor.cpp b/shell/platform/ohos/ohos_touch_processor.cpp index 45938c990a..202f07ddb9 100644 --- a/shell/platform/ohos/ohos_touch_processor.cpp +++ b/shell/platform/ohos/ohos_touch_processor.cpp @@ -18,6 +18,9 @@ #include "flutter/shell/platform/ohos/ohos_shell_holder.h" namespace flutter { + +constexpr int MSEC_PER_SECOND = 1000; + PointerData::Change OhosTouchProcessor::getPointerChangeForAction( int maskedAction) { switch (maskedAction) { @@ -72,7 +75,8 @@ void OhosTouchProcessor::HandleTouchEvent( PointerData pointerData; pointerData.Clear(); pointerData.embedder_id = touchEvent->id; - pointerData.time_stamp = touchEvent->touchPoints[index].timeStamp / 1000; + pointerData.time_stamp = + touchEvent->touchPoints[index].timeStamp / MSEC_PER_SECOND; pointerData.change = getPointerChangeForAction(touchEvent->touchPoints[index].type); pointerData.physical_y = touchEvent->touchPoints[index].screenY; diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index b55625845f..21fa8c51fd 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -15,6 +15,7 @@ #include "ohos_xcomponent_adapter.h" #include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" +#include "types.h" namespace flutter { enum ContextType { @@ -177,11 +178,6 @@ static int32_t SetNativeWindowOpt(OHNativeWindow* nativeWindow, } // Set the format of the native window buffer. code = SET_FORMAT; -#ifndef PIXEL_FMT_RGBA_8888 -// foundation/graphic/graphic_2d/interfaces/inner_api/surface/surface_type.h -// GRAPHIC_PIXEL_FMT_RGBA_8888, -#define PIXEL_FMT_RGBA_8888 12 -#endif int32_t format = PIXEL_FMT_RGBA_8888; ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, format); @@ -204,8 +200,6 @@ void XComponentAdapter::OnSurfaceCreated(OH_NativeXComponent* component, if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { LOGD("XComponent Current width:%{public}d,height:%{public}d", static_cast(width_), static_cast(height_)); - // mXComponentRender.XComponentRenderInit(window, width_, height_); - // mXComponentRender.Draw(); } else { LOGE("GetXComponentSize result:%{public}d", ret); } diff --git a/shell/platform/ohos/platform_message_response_ohos.cpp b/shell/platform/ohos/platform_message_response_ohos.cpp index 5d24283f79..75954cd0ac 100644 --- a/shell/platform/ohos/platform_message_response_ohos.cpp +++ b/shell/platform/ohos/platform_message_response_ohos.cpp @@ -14,7 +14,6 @@ */ #include "flutter/shell/platform/ohos/platform_message_response_ohos.h" -#include #include "flutter/fml/make_copyable.h" #include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 3e81fc44a7..1debe9617e 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -118,8 +118,6 @@ class PlatformViewOHOS final : public PlatformView { std::shared_ptr surface_factory_; - // PlatformViewOhosdDelegate platform_view_ohos_delegate_; - // |PlatformView| void UpdateSemantics( flutter::SemanticsNodeUpdates update, diff --git a/shell/platform/ohos/types.h b/shell/platform/ohos/types.h new file mode 100644 index 0000000000..9be037096b --- /dev/null +++ b/shell/platform/ohos/types.h @@ -0,0 +1,28 @@ +/* + * 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_TYPES_H +#define OHOS_TYPES_H +namespace flutter { + +constexpr int PIXEL_FMT_RGBA_8888 = 12; + +enum Locales { + LANGUAGE_INDEX = 0, + REGION_INDEX, + SCRIPT_INDEX, +}; + +} // namespace flutter +#endif \ No newline at end of file -- Gitee