diff --git a/fml/backtrace.cc b/fml/backtrace.cc index 3a3be765a6e63b33b2c11ae6c92e940f7164ca88..264fa7d0bcda5099689a42f5d4f5831d18b3a0b9 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 88c537dab0ad43bed282cb50c509d9e9dba6889f..84c465a1f84be356fe4bccdd4d4ae6949b7ff004 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 cd07846805dc1ab889320adcfafc785c06f64930..76457f5f1003d1568234db9451925ca0354bc43f 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 9a0f7b52bf4c7918a5e5863ae654df691bbf0fab..c91a061a637c638707d680bdb40a796dc7c227fd 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 87a32b2554dba578e431091e6aa6e6cb13dff9d4..e08e22f642bcbb0d4ddada0698eaeb44671ee165 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:"<(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; @@ -50,14 +51,14 @@ napi_value PlatformViewOHOSNapi::nativeDispatchEmptyPlatformMessage( napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); int64_t shell_holder, responseId; std::string channel; - ret = napi_get_value_int64(env, args[0], &shell_holder); + ret = napi_get_value_int64(env, args[ZERO], &shell_holder); if (ret != napi_ok) { LOGE("nativeDispatchEmptyPlatformMessage napi get shell_holder error"); return nullptr; } - fml::napi::GetString(env, args[1], channel); + fml::napi::GetString(env, args[FIRST], channel); FML_DLOG(INFO) << "nativeDispatchEmptyPlatformMessage channel:" << channel; - ret = napi_get_value_int64(env, args[2], &responseId); + ret = napi_get_value_int64(env, args[SECOND], &responseId); if (ret != napi_ok) { LOGE("nativeDispatchEmptyPlatformMessage napi get responseId error"); return nullptr; @@ -91,20 +92,14 @@ 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) { + if (argc < FIVE || ret != napi_ok) { FML_DLOG(ERROR) << "nativeDispatchPlatformMessage napi get argc ,argc=" << argc << "<5,error:" << ret; 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]; @@ -228,7 +223,7 @@ napi_value PlatformViewOHOSNapi::nativeInvokePlatformMessageResponseCallback( << "nativeInvokePlatformMessageResponseCallback message null"; return nullptr; } - ret = napi_get_value_int64(env, args[3], &position); + ret = napi_get_value_int64(env, args[THIRD], &position); if (ret != napi_ok) { LOGE("nativeInvokePlatformMessageResponseCallback napi get position error"); return nullptr; @@ -271,7 +266,7 @@ void PlatformViewOHOSNapi::FlutterViewHandlePlatformMessageResponse( } status = fml::napi::InvokeJsMethod( - env_, ref_napi_obj_, "handlePlatformMessageResponse", 2, callbackParam); + env_, ref_napi_obj_, "handlePlatformMessageResponse", TWO, callbackParam); if (status != napi_ok) { FML_DLOG(ERROR) << "InvokeJsMethod fail "; } @@ -297,7 +292,7 @@ void PlatformViewOHOSNapi::FlutterViewHandlePlatformMessage( callbackParam[1] = fml::napi::CreateArrayBuffer( env_, (void*)message->data().GetMapping(), message->data().GetSize()); - status = napi_create_int64(env_, reponse_id, &callbackParam[2]); + status = napi_create_int64(env_, reponse_id, &callbackParam[SECOND]); if (status != napi_ok) { FML_DLOG(ERROR) << "napi_create_int64 err " << status; return; @@ -306,7 +301,7 @@ void PlatformViewOHOSNapi::FlutterViewHandlePlatformMessage( fml::MallocMapping mapping = message->releaseData(); char* mapData = (char*)mapping.Release(); status = napi_create_string_utf8(env_, mapData, strlen(mapData), - &callbackParam[3]); + &callbackParam[THIRD]); if (status != napi_ok) { FML_DLOG(ERROR) << "napi_create_string_utf8 err " << status; return; @@ -317,7 +312,7 @@ void PlatformViewOHOSNapi::FlutterViewHandlePlatformMessage( } status = fml::napi::InvokeJsMethod( - env_, ref_napi_obj_, "handlePlatformMessage", 4, callbackParam); + env_, ref_napi_obj_, "handlePlatformMessage", FOUR, callbackParam); if (status != napi_ok) { FML_DLOG(ERROR) << "InvokeJsMethod fail "; } @@ -395,9 +390,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 +400,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)); } @@ -427,7 +423,7 @@ void PlatformViewOHOSNapi::DecodeImage(int64_t imageGeneratorAddress, FML_DLOG(ERROR) << "napi_create_int64 decodeImage fail "; } status = fml::napi::InvokeJsMethod(env_, ref_napi_obj_, "decodeImage", - 2, callbackParam); + TWO, callbackParam); if (status != napi_ok) { FML_DLOG(ERROR) << "InvokeJsMethod decodeImage fail "; } @@ -464,10 +460,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); @@ -514,7 +510,7 @@ napi_value PlatformViewOHOSNapi::nativeRunBundleAndSnapshotFromLibrary( std::string entrypointFunctionName; if (fml::napi::SUCCESS != - fml::napi::GetString(env, args[2], entrypointFunctionName)) { + fml::napi::GetString(env, args[SECOND], entrypointFunctionName)) { LOGE(" napi_get_value_string_utf8 error"); return nullptr; } @@ -522,7 +518,7 @@ napi_value PlatformViewOHOSNapi::nativeRunBundleAndSnapshotFromLibrary( std::string pathToEntrypointFunction; if (fml::napi::SUCCESS != - fml::napi::GetString(env, args[3], pathToEntrypointFunction)) { + fml::napi::GetString(env, args[THIRD], pathToEntrypointFunction)) { LOGE(" napi_get_value_string_utf8 error"); return nullptr; } @@ -530,11 +526,11 @@ napi_value PlatformViewOHOSNapi::nativeRunBundleAndSnapshotFromLibrary( pathToEntrypointFunction.c_str()); NativeResourceManager* ResourceManager = - OH_ResourceManager_InitNativeResourceManager(env, args[4]); + OH_ResourceManager_InitNativeResourceManager(env, args[FOURTH]); std::vector entrypointArgs; if (fml::napi::SUCCESS != - fml::napi::GetArrayString(env, args[5], entrypointArgs)) { + fml::napi::GetArrayString(env, args[FIFTH], entrypointArgs)) { LOGE("nativeRunBundleAndSnapshotFromLibrary GetArrayString error"); return nullptr; } @@ -626,7 +622,7 @@ napi_value PlatformViewOHOSNapi::nativeLoadDartDeferredLibrary( std::vector search_paths; if (fml::napi::SUCCESS != - fml::napi::GetArrayString(env, args[2], search_paths)) { + fml::napi::GetArrayString(env, args[SECOND], search_paths)) { LOGE("nativeLoadDartDeferredLibrary GetArrayString error"); return nullptr; } @@ -686,7 +682,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( } int64_t shell_holder; - ret = napi_get_value_int64(env, args[0], &shell_holder); + ret = napi_get_value_int64(env, args[ZEROTH], &shell_holder); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -694,7 +690,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( LOGD("nativeSetViewportMetrics::shell_holder : %{public}ld", shell_holder); double devicePixelRatio; - ret = napi_get_value_double(env, args[1], &devicePixelRatio); + ret = napi_get_value_double(env, args[FIRST], &devicePixelRatio); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -703,7 +699,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( devicePixelRatio); int64_t physicalWidth; - ret = napi_get_value_int64(env, args[2], &physicalWidth); + ret = napi_get_value_int64(env, args[SECOND], &physicalWidth); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -711,7 +707,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( LOGD("nativeSetViewportMetrics::physicalWidth : %{public}ld", physicalWidth); int64_t physicalHeight; - ret = napi_get_value_int64(env, args[3], &physicalHeight); + ret = napi_get_value_int64(env, args[THIRD], &physicalHeight); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -720,7 +716,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalHeight); int64_t physicalPaddingTop; - ret = napi_get_value_int64(env, args[4], &physicalPaddingTop); + ret = napi_get_value_int64(env, args[FOURTH], &physicalPaddingTop); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -729,7 +725,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalPaddingTop); int64_t physicalPaddingRight; - ret = napi_get_value_int64(env, args[5], &physicalPaddingRight); + ret = napi_get_value_int64(env, args[FIFTH], &physicalPaddingRight); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -738,7 +734,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalPaddingRight); int64_t physicalPaddingBottom; - ret = napi_get_value_int64(env, args[6], &physicalPaddingBottom); + ret = napi_get_value_int64(env, args[SIXTH], &physicalPaddingBottom); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -747,7 +743,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalPaddingBottom); int64_t physicalPaddingLeft; - ret = napi_get_value_int64(env, args[7], &physicalPaddingLeft); + ret = napi_get_value_int64(env, args[SEVENTH], &physicalPaddingLeft); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -756,7 +752,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalPaddingLeft); int64_t physicalViewInsetTop; - ret = napi_get_value_int64(env, args[8], &physicalViewInsetTop); + ret = napi_get_value_int64(env, args[EIGHTH], &physicalViewInsetTop); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -765,7 +761,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalViewInsetTop); int64_t physicalViewInsetRight; - ret = napi_get_value_int64(env, args[9], &physicalViewInsetRight); + ret = napi_get_value_int64(env, args[NINTH], &physicalViewInsetRight); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -774,7 +770,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalViewInsetRight); int64_t physicalViewInsetBottom; - ret = napi_get_value_int64(env, args[10], &physicalViewInsetBottom); + ret = napi_get_value_int64(env, args[TENTH], &physicalViewInsetBottom); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -783,7 +779,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalViewInsetBottom); int64_t physicalViewInsetLeft; - ret = napi_get_value_int64(env, args[11], &physicalViewInsetLeft); + ret = napi_get_value_int64(env, args[ELEVENTH], &physicalViewInsetLeft); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -791,7 +787,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( LOGD("nativeSetViewportMetrics::physicalViewInsetLeft : %{public}ld", physicalViewInsetLeft); int64_t systemGestureInsetTop; - ret = napi_get_value_int64(env, args[12], &systemGestureInsetTop); + ret = napi_get_value_int64(env, args[TWELFTH], &systemGestureInsetTop); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -799,7 +795,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( LOGD("nativeSetViewportMetrics::systemGestureInsetTop : %{public}ld", systemGestureInsetTop); int64_t systemGestureInsetRight; - ret = napi_get_value_int64(env, args[13], &systemGestureInsetRight); + ret = napi_get_value_int64(env, args[THIRTEENTH], &systemGestureInsetRight); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -808,7 +804,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( systemGestureInsetRight); int64_t systemGestureInsetBottom; - ret = napi_get_value_int64(env, args[14], &systemGestureInsetBottom); + ret = napi_get_value_int64(env, args[FOURTEENTH], &systemGestureInsetBottom); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -816,7 +812,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( LOGD("nativeSetViewportMetrics::systemGestureInsetBottom : %{public}ld", systemGestureInsetBottom); int64_t systemGestureInsetLeft; - ret = napi_get_value_int64(env, args[15], &systemGestureInsetLeft); + ret = napi_get_value_int64(env, args[FIFTEENTH], &systemGestureInsetLeft); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -825,7 +821,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( systemGestureInsetLeft); int64_t physicalTouchSlop; - ret = napi_get_value_int64(env, args[16], &physicalTouchSlop); + ret = napi_get_value_int64(env, args[SIXTEENTH], &physicalTouchSlop); if (ret != napi_ok) { LOGE("nativeSetViewportMetrics napi_get_value_int64 error"); return nullptr; @@ -834,7 +830,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( physicalTouchSlop); std::vector displayFeaturesBounds; - napi_value array = args[17]; + napi_value array = args[SEVENTEENTH]; uint32_t length; napi_get_array_length(env, array, &length); displayFeaturesBounds.resize(length); @@ -850,7 +846,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( } std::vector displayFeaturesType; - array = args[18]; + array = args[EIGHTEENTH]; napi_get_array_length(env, array, &length); displayFeaturesType.resize(length); for (uint32_t i = 0; i < length; ++i) { @@ -865,7 +861,7 @@ napi_value PlatformViewOHOSNapi::nativeSetViewportMetrics( } std::vector displayFeaturesState; - array = args[19]; + array = args[NINETEENTH]; napi_get_array_length(env, array, &length); displayFeaturesState.resize(length); for (uint32_t i = 0; i < length; ++i) { @@ -1102,7 +1098,7 @@ napi_value PlatformViewOHOSNapi::nativeDeferredComponentInstallFailure( LOGD("nativeSetAccessibilityFeatures loadingUnitId: %s", error.c_str()); bool isTransient; - ret = napi_get_value_bool(env, args[2], &isTransient); + ret = napi_get_value_bool(env, args[SECOND], &isTransient); if (ret != napi_ok) { LOGE("nativeDeferredComponentInstallFailure napi_get_value_bool error"); return nullptr; @@ -1370,7 +1366,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 8e698dc6e57f70335e85e85e5e3409f7b0338d9a..d32a6fe996af7bfc8c75556cda66321e12f13f51 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 1783f071818ed634ea98f148a14dbf68a47209ea..43b2b3cbef7ebbd12ede9ccaf7509bc208e12d96 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 3947b457d1452d90ac8ae87b100f91e4dc92047e..9be28a018c788ccd7f27c9a811bd16169257c5e4 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 32feddb2c3ad863179afd0be83d663c35a49b18e..3f23e95b007803dcf71befb620d0a0043e46a6ba 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 b416d1269fec3993de31982af9e70c868477c55c..b277c825b79c894b1aaaced63a97098df8d08ea0 100755 --- a/shell/platform/ohos/ohos_egl_surface.cpp +++ b/shell/platform/ohos/ohos_egl_surface.cpp @@ -21,6 +21,7 @@ #include #include "flutter/fml/trace_event.h" +#include "types.h" namespace flutter { @@ -30,28 +31,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); @@ -155,14 +150,14 @@ class OhosEGLSurfaceDamage { } private: - std::array static RectToInts(EGLDisplay display, - EGLSurface surface, - const SkIRect& rect) { + std::array static RectToInts(EGLDisplay display, + EGLSurface surface, + const SkIRect& rect) { EGLint height; eglQuerySurface(display, surface, EGL_HEIGHT, &height); - std::array res{rect.left(), height - rect.bottom(), rect.width(), - rect.height()}; + std::array res{rect.left(), height - rect.bottom(), + rect.width(), rect.height()}; return res; } diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 8c5c6a68260abcef0f49c15799cc9b299a8bece3..f2ffccbaa8168fda70c7f6cd5afdfa12b56767cc 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 0e0e525f60bb746cb2dec7bf77ab98a1858e6881..e5b029afe640807f1353b9956712b7fb30f298ab 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -20,6 +20,7 @@ #include #include "third_party/skia/include/codec/SkCodecAnimation.h" +#include "types.h" namespace flutter { @@ -151,7 +152,6 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( size_t argc = 4; - // width, height, OHOSImageGenerator this, pixmap; napi_value args[4] = {nullptr}; napi_status status = @@ -161,7 +161,7 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( return nullptr; } - if (argc != 4) { + if (argc != FOUR) { FML_LOG(ERROR) << "argc is error"; return nullptr; } @@ -171,17 +171,17 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( int64_t height = 0; OHOSImageGenerator* generator = nullptr; - status = napi_get_value_int64(env, args[0], &width); + status = napi_get_value_int64(env, args[ZEROTH], &width); if (status != napi_ok) { FML_LOG(ERROR) << "napi_get_value_int32 width error"; } - status = napi_get_value_int64(env, args[1], &height); + status = napi_get_value_int64(env, args[FIRST], &height); if (status != napi_ok) { FML_LOG(ERROR) << "napi_get_value_int32 height error"; } - status = napi_get_value_int64(env, args[2], (int64_t*)&generator); + status = napi_get_value_int64(env, args[SECOND], (int64_t*)&generator); if (status != napi_ok) { FML_LOG(ERROR) << "napi_get_value_int64 this error"; } @@ -195,7 +195,8 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( void* pixel_lock; - int ret = OHOS::Media::OH_AccessPixels(g_env, args[3], (void**)&pixel_lock); + int ret = + OHOS::Media::OH_AccessPixels(g_env, args[THIRD], (void**)&pixel_lock); if (ret != 0) { FML_DLOG(ERROR) << "Failed to lock pixels, error=" << ret; return nullptr; @@ -211,7 +212,7 @@ napi_value OHOSImageGenerator::NativeImageDecodeCallback( ReleaseCtx* ctx = new ReleaseCtx(); ctx->env_ = env; ctx->buf = (char*)pixel_lock; - napi_create_reference(env, args[3], 1, &(ctx->ref)); + napi_create_reference(env, args[THIRD], ONE, &(ctx->ref)); SkData::ReleaseProc on_release = [](const void* ptr, void* context) -> void { ReleaseCtx* ctx = reinterpret_cast(context); diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index 041de2e1803178e48372fe4c57e45fc5bb940ec2..35496196afdbeb133338518b5d7575a183111d85 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -31,6 +31,7 @@ #include "flutter/shell/common/switches.h" #include "third_party/dart/runtime/include/dart_tools_api.h" #include "third_party/skia/include/core/SkFontMgr.h" +#include "types.h" namespace flutter { @@ -95,14 +96,13 @@ 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); - napi_get_value_int64(env, param[5], &initTimeMillis); - fml::napi::GetString(env, param[2], kernelPath); - fml::napi::GetString(env, param[3], appStoragePath); - fml::napi::GetString(env, param[4], engineCachesPath); + napi_get_value_int64(env, param[FIFTH], &initTimeMillis); + fml::napi::GetString(env, param[SECOND], kernelPath); + fml::napi::GetString(env, param[THIRD], appStoragePath); + fml::napi::GetString(env, param[FOURTH], engineCachesPath); FML_DLOG(INFO) << "INIT kernelPath:" << kernelPath; FML_DLOG(INFO) << "appStoragePath:" << appStoragePath; FML_DLOG(INFO) << "engineCachesPath:" << engineCachesPath; @@ -119,8 +119,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; diff --git a/shell/platform/ohos/ohos_shell_holder.cpp b/shell/platform/ohos/ohos_shell_holder.cpp index 7024a36a260b338ab63b679f377f40b34bdc6328..c8a0817aebddfcb08e710c6907e2558dc048d7d1 100644 --- a/shell/platform/ohos/ohos_shell_holder.cpp +++ b/shell/platform/ohos/ohos_shell_holder.cpp @@ -24,6 +24,7 @@ #include #include +#include "types.h" namespace flutter { @@ -33,13 +34,13 @@ static void OHOSPlatformThreadConfigSetter( // set thread priority switch (config.priority) { case fml::Thread::ThreadPriority::BACKGROUND: { - if (::setpriority(PRIO_PROCESS, 0, 10) != 0) { + if (::setpriority(PRIO_PROCESS, 0, TEN) != 0) { FML_DLOG(ERROR) << "Failed to set IO task runner priority"; } break; } case fml::Thread::ThreadPriority::DISPLAY: { - if (::setpriority(PRIO_PROCESS, 0, -1) != 0) { + if (::setpriority(PRIO_PROCESS, 0, NEGATIVE_ONE) != 0) { FML_DLOG(ERROR) << "Failed to set UI task runner priority"; } break; @@ -48,17 +49,17 @@ static void OHOSPlatformThreadConfigSetter( // Android describes -8 as "most important display threads, for // compositing the screen and retrieving input events". Conservatively // set the raster thread to slightly lower priority than it. - if (::setpriority(PRIO_PROCESS, 0, -5) != 0) { + if (::setpriority(PRIO_PROCESS, 0, NEGATIVE_FIVE) != 0) { // Defensive fallback. Depending on the OEM, it may not be possible // to set priority to -5. - if (::setpriority(PRIO_PROCESS, 0, -2) != 0) { + if (::setpriority(PRIO_PROCESS, 0, NEGATIVE_TWO) != 0) { FML_DLOG(ERROR) << "Failed to set raster task runner priority"; } } break; } default: - if (::setpriority(PRIO_PROCESS, 0, 0) != 0) { + if (::setpriority(PRIO_PROCESS, 0, ZERO) != 0) { FML_DLOG(ERROR) << "Failed to set priority"; } } diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 7d5fb0d64a5b5605e5223f310cd9431a72baa74d..760cc6f15e911f91deadede1f2eb672a4e7f0e00 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 6579e8f1fecdaa5235a12d5ddca97f5a38f49e0a..b50e8c8d7b6e812216114ea2e2af98041967a319 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 dfd1ee7ac37f844aa1c66d1fed34e1b7a15d09dd..87b2fa4bf601f51700c3c24c6829518f035cbec4 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 bcc08639aadde79761013bab7431ece44275f19d..22efe4871e5ea971631161187c17fcdd24da088a 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" @@ -154,8 +153,9 @@ SurfaceFrame::FramebufferInfo OhosSurfaceGLSkia::GLContextFramebufferInfo() // otherwise there are glitches // (https://github.com/flutter/flutter/issues/97482#) // Larger alignment might also be beneficial for tile base renderers. - res.horizontal_clip_alignment = 32; - res.vertical_clip_alignment = 32; + constexpr int clip_alignment = 32; + res.horizontal_clip_alignment = clip_alignment; + res.vertical_clip_alignment = clip_alignment; return res; } diff --git a/shell/platform/ohos/ohos_surface_software.cpp b/shell/platform/ohos/ohos_surface_software.cpp index cebb31fd1e0d38829b5e404dbc172f497ecdb716..b5c9271596b959574ed4d01d1d78df0d6e5d03a7 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 45938c990ac8d8bcc892ae3ef17ed8f9a875a5d5..202f07ddb92fbb714cf6725cb8cd6e4aa1d41e12 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 b55625845fd459a82a7e17e0be3cb41b5ae88a3b..21fa8c51fdb83c768d051bda033b3f24a7b1cbf1 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 5d24283f791c8d86b3e4dafe2f37c8e1458cd8a9..75954cd0aceffc90a03028c4963b67f23e4d33bd 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 3e81fc44a78057b8215a46aab74829ec04f9ee7c..1debe9617e8bd956acd053b5995ca99ebc607ad6 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 0000000000000000000000000000000000000000..be3893380a447b8a8d4120d0e3fbedf43f14090b --- /dev/null +++ b/shell/platform/ohos/types.h @@ -0,0 +1,68 @@ +/* + * 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, +}; + +enum Number { + NEGATIVE_FIVE = -5, + NEGATIVE_FOUR = -4, + NEGATIVE_THREE = -3, + NEGATIVE_TWO = -2, + NEGATIVE_ONE = -1, + ZERO = 0, + ONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, + TEN, +}; + +enum Range { + ZEROTH = 0, + FIRST = 1, + SECOND = 2, + THIRD = 3, + FOURTH = 4, + FIFTH = 5, + SIXTH = 6, + SEVENTH = 7, + EIGHTH = 8, + NINTH = 9, + TENTH = 10, + ELEVENTH = 11, + TWELFTH = 12, + THIRTEENTH = 13, + FOURTEENTH = 14, + FIFTEENTH = 15, + SIXTEENTH = 16, + SEVENTEENTH = 17, + EIGHTEENTH = 18, + NINETEENTH = 19, +}; +} // namespace flutter +#endif \ No newline at end of file