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:"< #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 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..1621f11855dddfea3ca0f7a3b9c7a8c9c4bfa54f 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 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..b44acf24a8732273614fc0eb822e2658c882fceb 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 041de2e1803178e48372fe4c57e45fc5bb940ec2..a367e1114d468f5ea57089f34b47568028dff3b6 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 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..36609d4b63b5e978ad34bc994f9b412cdf01cfeb 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 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..9be037096beb0ab63c0aeacae7d04ff0dd1ba6cd --- /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