From 984abe48258082c6a47a8b3b8b82702dd497956c Mon Sep 17 00:00:00 2001 From: tanjiancheng <562575412@qq.com> Date: Wed, 19 Feb 2025 16:34:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?codecheck=E6=89=AB=E6=8F=8F=EF=BC=8Cohos?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=83=A8=E5=88=86=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanjiancheng <562575412@qq.com> --- .../accessibility/ohos_accessibility_bridge.h | 54 ------------------- shell/platform/ohos/napi_common.h | 4 +- shell/platform/ohos/ohos_context_gl_skia.cpp | 28 +++++++--- shell/platform/ohos/ohos_context_gl_skia.h | 30 ----------- shell/platform/ohos/ohos_egl_surface.h | 11 ---- shell/platform/ohos/ohos_environment_gl.cpp | 4 +- shell/platform/ohos/ohos_image_generator.cpp | 8 ++- shell/platform/ohos/ohos_image_generator.h | 6 --- shell/platform/ohos/ohos_shell_holder.cpp | 11 +++- shell/platform/ohos/ohos_shell_holder.h | 1 + shell/platform/ohos/ohos_surface_gl_skia.cpp | 7 ++- .../ohos/platform_message_handler_ohos.cpp | 4 ++ .../ohos/platform_message_response_ohos.h | 3 +- shell/platform/ohos/platform_view_ohos.h | 15 +----- .../ohos/platform_view_ohos_delegate.cpp | 27 +++++++--- 15 files changed, 72 insertions(+), 141 deletions(-) diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h index 6cfb61aab8..d947b14f14 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h @@ -333,59 +333,5 @@ private: void GetSemanticsDebugInfo(); void AccessibiltiyChangesWithXComponentId(); }; - -enum class AccessibilityAction : int32_t { - kTap = 1 << 0, - kLongPress = 1 << 1, - kScrollLeft = 1 << 2, - kScrollRight = 1 << 3, - kScrollUp = 1 << 4, - kScrollDown = 1 << 5, - kIncrease = 1 << 6, - kDecrease = 1 << 7, - kShowOnScreen = 1 << 8, - kMoveCursorForwardByCharacter = 1 << 9, - kMoveCursorBackwardByCharacter = 1 << 10, - kSetSelection = 1 << 11, - kCopy = 1 << 12, - kCut = 1 << 13, - kPaste = 1 << 14, - kDidGainAccessibilityFocus = 1 << 15, - kDidLoseAccessibilityFocus = 1 << 16, - kCustomAction = 1 << 17, - kDismiss = 1 << 18, - kMoveCursorForwardByWord = 1 << 19, - kMoveCursorBackwardByWord = 1 << 20, - kSetText = 1 << 21, -}; -enum class AccessibilityFlags : int32_t { - kHasCheckedState = 1 << 0, - kIsChecked = 1 << 1, - kIsSelected = 1 << 2, - kIsButton = 1 << 3, - kIsTextField = 1 << 4, - kIsFocused = 1 << 5, - kHasEnabledState = 1 << 6, - kIsEnabled = 1 << 7, - kIsInMutuallyExclusiveGroup = 1 << 8, - kIsHeader = 1 << 9, - kIsObscured = 1 << 10, - kScopesRoute = 1 << 11, - kNamesRoute = 1 << 12, - kIsHidden = 1 << 13, - kIsImage = 1 << 14, - kIsLiveRegion = 1 << 15, - kHasToggledState = 1 << 16, - kIsToggled = 1 << 17, - kHasImplicitScrolling = 1 << 18, - kIsMultiline = 1 << 19, - kIsReadOnly = 1 << 20, - kIsFocusable = 1 << 21, - kIsLink = 1 << 22, - kIsSlider = 1 << 23, - kIsKeyboardKey = 1 << 24, - kIsCheckStateMixed = 1 << 25, -}; - } // namespace flutter #endif // OHOS_ACCESSIBILITY_BRIDGE_H diff --git a/shell/platform/ohos/napi_common.h b/shell/platform/ohos/napi_common.h index c6e468d80b..0cc32aab99 100644 --- a/shell/platform/ohos/napi_common.h +++ b/shell/platform/ohos/napi_common.h @@ -16,7 +16,7 @@ #define NAPI_RETVAL_NOTHING #define GET_AND_THROW_LAST_ERROR(env) \ - do { \ + do { /*get throw last error */ \ const napi_extended_error_info* errorInfo = nullptr; \ napi_get_last_error_info((env), &errorInfo); \ bool isPending = false; \ @@ -45,7 +45,7 @@ NAPI_ASSERT_BASE(env, assertion, message, NAPI_RETVAL_NOTHING) #define NAPI_CALL_BASE(env, theCall, retVal) \ - do { \ + do { /* NAPI_CALL_BAS */ \ if ((theCall) != napi_ok) { \ GET_AND_THROW_LAST_ERROR((env)); \ return retVal; \ diff --git a/shell/platform/ohos/ohos_context_gl_skia.cpp b/shell/platform/ohos/ohos_context_gl_skia.cpp index 43ecdd1612..75b33edcc5 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.cpp +++ b/shell/platform/ohos/ohos_context_gl_skia.cpp @@ -21,7 +21,7 @@ static EGLResult CreateContext(EGLDisplay display, EGLConfig config, EGLContext share = EGL_NO_CONTEXT) { EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; - + /*CreateContex*/ EGLContext context = eglCreateContext(display, config, share, attributes); return {context != EGL_NO_CONTEXT, context}; @@ -31,12 +31,13 @@ static EGLResult ChooseEGLConfiguration(EGLDisplay display, uint8_t msaa_samples) { EGLint sample_buffers = msaa_samples > 1 ? 1 : 0; EGLint attributes[] = { - // clang-format off + // clang-format off ChooseEGLConfiguration EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + // EGLCongfig EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 0, @@ -46,21 +47,23 @@ static EGLResult ChooseEGLConfiguration(EGLDisplay display, // clang-format on }; + // EGLCongfig EGLint config_count = 0; EGLConfig egl_config = nullptr; if (eglChooseConfig(display, attributes, &egl_config, 1, &config_count) != EGL_TRUE) { + // EGLCongfig return {false, nullptr}; } - + // EGLCongfig bool success = config_count > 0 && egl_config != nullptr; return {success, success ? egl_config : nullptr}; } static bool TeardownContext(EGLDisplay display, EGLContext context) { - if (context != EGL_NO_CONTEXT) { + if (context != EGL_NO_CONTEXT) { // TeardownContext return eglDestroyContext(display, context) == EGL_TRUE; } @@ -91,20 +94,24 @@ OhosContextGLSkia::OhosContextGLSkia(OHOSRenderingAPI rendering_api, return; } + //configuration // Create a context for the configuration. std::tie(success, context_) = CreateContext(environment_->Display(), config_, EGL_NO_CONTEXT); + //configuration if (!success) { FML_LOG(ERROR) << "Could not create an EGL context"; LogLastEGLError(); return; } - + //configuration std::tie(success, resource_context_) = CreateContext(environment_->Display(), config_, context_); + //configuration if (!success) { FML_LOG(ERROR) << "Could not create an EGL resource context"; LogLastEGLError(); + //configuration return; } @@ -113,12 +120,15 @@ OhosContextGLSkia::OhosContextGLSkia(OHOSRenderingAPI rendering_api, } OhosContextGLSkia::~OhosContextGLSkia() { + //~OhosContextGLSkia FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); sk_sp main_context = GetMainSkiaContext(); + //~OhosContextGLSkia SetMainSkiaContext(nullptr); fml::AutoResetWaitableEvent latch; // This context needs to be deallocated from the raster thread in order to // keep a coherent usage of egl from a single thread. + //~OhosContextGLSkia fml::TaskRunner::RunNowOrPostTask(task_runners_.GetRasterTaskRunner(), [&] { if (main_context) { std::unique_ptr pbuffer_surface = CreatePbufferSurface(); @@ -130,6 +140,7 @@ OhosContextGLSkia::~OhosContextGLSkia() { } } latch.Signal(); + //~OhosContextGLSkia }); latch.Wait(); @@ -138,7 +149,7 @@ OhosContextGLSkia::~OhosContextGLSkia() { << "Could not tear down the EGL context. Possible resource leak."; LogLastEGLError(); } - + //~OhosContextGLSkia if (!TeardownContext(environment_->Display(), resource_context_)) { FML_LOG(ERROR) << "Could not tear down the EGL resource context. Possible " "resource leak."; @@ -154,7 +165,7 @@ std::unique_ptr OhosContextGLSkia::CreateOnscreenSurface( EGLDisplay display = environment_->Display(); const EGLint attribs[] = {EGL_NONE}; - + //CreateOnscreenSurface EGLSurface surface = eglCreateWindowSurface( display, config_, reinterpret_cast(window->handle()), attribs); @@ -204,11 +215,13 @@ bool OhosContextGLSkia::ClearCurrent() const { if (eglGetCurrentContext() != context_) { return true; } + // ClearCurrent if (eglMakeCurrent(environment_->Display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE) { FML_LOG(ERROR) << "Could not clear the current context"; LogLastEGLError(); return false; + // ClearCurrent } return true; } @@ -216,6 +229,7 @@ bool OhosContextGLSkia::ClearCurrent() const { EGLContext OhosContextGLSkia::CreateNewContext() const { bool success; EGLContext context; + // CreateNewContext std::tie(success, context) = CreateContext(environment_->Display(), config_, EGL_NO_CONTEXT); return success ? context : EGL_NO_CONTEXT; diff --git a/shell/platform/ohos/ohos_context_gl_skia.h b/shell/platform/ohos/ohos_context_gl_skia.h index cb80b66045..29d2086b78 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.h +++ b/shell/platform/ohos/ohos_context_gl_skia.h @@ -37,29 +37,11 @@ class OhosContextGLSkia : public OHOSContext { ~OhosContextGLSkia(); - //---------------------------------------------------------------------------- - /// @brief Allocates an new EGL window surface that is used for on-screen - /// pixels. - /// - /// @return The window surface. - /// std::unique_ptr CreateOnscreenSurface( const fml::RefPtr& window) const; - //---------------------------------------------------------------------------- - /// @brief Allocates an 1x1 pbuffer surface that is used for making the - /// offscreen current for texture uploads. - /// - /// @return The pbuffer surface. - /// std::unique_ptr CreateOffscreenSurface() const; - //---------------------------------------------------------------------------- - /// @brief Allocates an 1x1 pbuffer surface that is used for making the - /// onscreen context current for snapshotting. - /// - /// @return The pbuffer surface. - /// std::unique_ptr CreatePbufferSurface() const; //---------------------------------------------------------------------------- @@ -68,22 +50,10 @@ class OhosContextGLSkia : public OHOSContext { /// fml::RefPtr Environment() const; - //---------------------------------------------------------------------------- - /// @return Whether the current context is valid. That is, if the EGL - /// contexts were successfully created. - /// bool IsValid() const override; - //---------------------------------------------------------------------------- - /// @return Whether the current context was successfully clear. - /// bool ClearCurrent() const; - //---------------------------------------------------------------------------- - /// @brief Create a new EGLContext using the same EGLConfig. - /// - /// @return The EGLContext. - /// EGLContext CreateNewContext() const; //---------------------------------------------------------------------------- diff --git a/shell/platform/ohos/ohos_egl_surface.h b/shell/platform/ohos/ohos_egl_surface.h index dd1cb98e25..37cf87ca53 100755 --- a/shell/platform/ohos/ohos_egl_surface.h +++ b/shell/platform/ohos/ohos_egl_surface.h @@ -47,19 +47,8 @@ class OhosEGLSurface { ~OhosEGLSurface(); - //---------------------------------------------------------------------------- - /// @return Whether the current `EGLSurface` reference is valid. That is, - /// if - /// the surface doesn't point to `EGL_NO_SURFACE`. - /// bool IsValid() const; - //---------------------------------------------------------------------------- - /// @brief Binds the EGLContext context to the current rendering thread - /// and to the draw and read surface. - /// - /// @return Whether the surface was made current. - /// OhosEGLSurfaceMakeCurrentStatus MakeCurrent() const; //---------------------------------------------------------------------------- diff --git a/shell/platform/ohos/ohos_environment_gl.cpp b/shell/platform/ohos/ohos_environment_gl.cpp index 545b7037b2..1c7977b4d8 100755 --- a/shell/platform/ohos/ohos_environment_gl.cpp +++ b/shell/platform/ohos/ohos_environment_gl.cpp @@ -14,11 +14,11 @@ OhosEnvironmentGL::OhosEnvironmentGL() : display_(EGL_NO_DISPLAY), valid_(false) { // Get the display. display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - + // OhosEnvironmentGL if (display_ == EGL_NO_DISPLAY) { return; } - + // OhosEnvironmentGL // Initialize the display connection. if (eglInitialize(display_, nullptr, nullptr) != EGL_TRUE) { return; diff --git a/shell/platform/ohos/ohos_image_generator.cpp b/shell/platform/ohos/ohos_image_generator.cpp index c00ffd88b3..874fe001e8 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -75,17 +75,19 @@ bool OHOSImageGenerator::GetPixels(const SkImageInfo& info, if (!software_decoded_data_) { return false; } - + // kRGBA_8888_SkColorType if (kRGBA_8888_SkColorType != info.colorType()) { return false; } - + // info.alphaType switch (info.alphaType()) { case kOpaque_SkAlphaType: if (kOpaque_SkAlphaType != GetInfo().alphaType()) { return false; + // kOpaque_SkAlphaTyp } break; + // kPremul_SkAlphaType case kPremul_SkAlphaType: break; default: @@ -94,6 +96,7 @@ bool OHOSImageGenerator::GetPixels(const SkImageInfo& info, // TODO(bdero): Override `GetImage()` to use `SkImage::FromAHardwareBuffer` on // API level 30+ once it's updated to do symbol lookups and not get + // memcpy // preprocessed out in Skia. This will allow for avoiding this copy in // cases where the result image doesn't need to be resized. memcpy(pixels, software_decoded_data_->data(), @@ -143,6 +146,7 @@ void OHOSImageGenerator::DoDecodeImage() { bool OHOSImageGenerator::IsValidImageData() { // The generator kicks off an IO task to decode everything, and calls to // "GetInfo()" block until either the header has been decoded or decoding has + // IsValidImageData // failed, whichever is sooner. The decoder is initialized with a width and // height of -1 and will update the dimensions if the image is able to be // decoded. diff --git a/shell/platform/ohos/ohos_image_generator.h b/shell/platform/ohos/ohos_image_generator.h index f21ddfeabd..cd677e20cc 100755 --- a/shell/platform/ohos/ohos_image_generator.h +++ b/shell/platform/ohos/ohos_image_generator.h @@ -36,23 +36,17 @@ class OHOSImageGenerator : public ImageGenerator { ~OHOSImageGenerator(); - // |ImageGenerator| const SkImageInfo& GetInfo() override; - // |ImageGenerator| unsigned int GetFrameCount() const override; - // |ImageGenerator| unsigned int GetPlayCount() const override; - // |ImageGenerator| const ImageGenerator::FrameInfo GetFrameInfo( unsigned int frame_index) const override; - // |ImageGenerator| SkISize GetScaledDimensions(float desired_scale) override; - // |ImageGenerator| bool GetPixels(const SkImageInfo& info, void* pixels, size_t row_bytes, diff --git a/shell/platform/ohos/ohos_shell_holder.cpp b/shell/platform/ohos/ohos_shell_holder.cpp index 35970f42a1..8ae091e172 100644 --- a/shell/platform/ohos/ohos_shell_holder.cpp +++ b/shell/platform/ohos/ohos_shell_holder.cpp @@ -111,13 +111,15 @@ OHOSShellHolder::OHOSShellHolder( fml::MessageLoop::EnsureInitializedForCurrentThread(platform_loop); fml::RefPtr raster_runner; fml::RefPtr ui_runner; + // Initialized Current Thread fml::RefPtr io_runner; fml::RefPtr platform_runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); + // Initialized Current Thread raster_runner = thread_host_->raster_thread->GetTaskRunner(); ui_runner = thread_host_->ui_thread->GetTaskRunner(); io_runner = thread_host_->io_thread->GetTaskRunner(); - + // Initialized Current Thread flutter::TaskRunners task_runners(thread_label, // label platform_runner, // platform raster_runner, // raster @@ -127,10 +129,11 @@ OHOSShellHolder::OHOSShellHolder( napi_facade_->SetPlatformTaskRunner(platform_runner); FML_DLOG(INFO) << "before shell create"; + // shell shell_ = Shell::Create(GetDefaultPlatformData(), // window data task_runners, // task runners - settings_, // settings + settings_, on_create_platform_view, // platform view create callback on_create_rasterizer // rasterizer create callback ); @@ -240,9 +243,11 @@ std::unique_ptr OHOSShellHolder::Spawn( if (!config) { // If the RunConfiguration was null, the kernel blob wasn't readable. // Fail the whole thing. + // config return nullptr; } + // on_create_platform_view std::unique_ptr shell = shell_->Spawn(std::move(config.value()), initial_route, on_create_platform_view, on_create_rasterizer); @@ -297,10 +302,12 @@ std::optional OHOSShellHolder::BuildRunConfiguration( if (flutter::DartVM::IsRunningPrecompiledCode()) { FML_LOG(INFO) << "isolate_configuration."; isolate_configuration = IsolateConfiguration::CreateForAppSnapshot(); + // isolate_configuration } else { std::unique_ptr kernel_blob = fml::FileMapping::CreateReadOnly( GetSettings().application_kernel_asset); + // isolate_configuration if (!kernel_blob) { FML_DLOG(ERROR) << "Unable to load the kernel blob asset."; return std::nullopt; diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 1fadd18a3d..9d0f69c9b3 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -11,6 +11,7 @@ #include "flutter/assets/asset_manager.h" #include "flutter/fml/macros.h" #include "flutter/fml/unique_fd.h" +// flutter lib ui in window #include "flutter/lib/ui/window/viewport_metrics.h" #include "flutter/runtime/platform_data.h" #include "flutter/shell/common/run_configuration.h" diff --git a/shell/platform/ohos/ohos_surface_gl_skia.cpp b/shell/platform/ohos/ohos_surface_gl_skia.cpp index 7298179925..05bb475631 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.cpp +++ b/shell/platform/ohos/ohos_surface_gl_skia.cpp @@ -117,9 +117,9 @@ bool OhosSurfaceGLSkia::SetNativeWindow(fml::RefPtr window) { FML_DCHECK(window); native_window_ = window; // Ensure the destructor is called since it destroys the `EGLSurface` before - // creating a new onscreen surface. + // creating a new onscreen surface SetNativeWindow. onscreen_surface_ = nullptr; - // Create the onscreen surface. + // Create the onscreen surface SetNativeWindow. onscreen_surface_ = GLContextPtr()->CreateOnscreenSurface(window); if (!onscreen_surface_->IsValid()) { return false; @@ -189,8 +189,10 @@ sk_sp OhosSurfaceGLSkia::GetGLInterface() const { // implementation. Some versions of the emulator will not update the // GL version string when the process switches to a new EGL context // unless the EGL context is being made current for the first time. + // GetGLInterface // The inaccurate version string will be rejected by Skia when it // tries to build the GrGLInterface. Flutter can work around this + // GetGLInterface // by creating a new context, making it current to force an update // of the version, and then reverting to the previous context. const char* gl_renderer = @@ -212,6 +214,7 @@ sk_sp OhosSurfaceGLSkia::GetGLInterface() const { FML_DCHECK(result == EGL_TRUE); result = eglMakeCurrent(display, draw_surface, read_surface, old_context); FML_DCHECK(result == EGL_TRUE); + // eglDestroyContext result = eglDestroyContext(display, new_context); FML_DCHECK(result == EGL_TRUE); } diff --git a/shell/platform/ohos/platform_message_handler_ohos.cpp b/shell/platform/ohos/platform_message_handler_ohos.cpp index 3e6b8b3d8e..cd05e19e7c 100644 --- a/shell/platform/ohos/platform_message_handler_ohos.cpp +++ b/shell/platform/ohos/platform_message_handler_ohos.cpp @@ -41,11 +41,13 @@ void PlatformMessageHandlerOHOS::InvokePlatformMessageResponseCallback( // PlatformMessageResponseDart so we won't need to use a mutex anymore. fml::RefPtr message_response; { + // message_response std::lock_guard lock(pending_responses_mutex_); auto it = pending_responses_.find(response_id); if (it == pending_responses_.end()) { return; } + // message_response message_response = std::move(it->second); pending_responses_.erase(it); } @@ -60,11 +62,13 @@ void PlatformMessageHandlerOHOS::InvokePlatformMessageEmptyResponseCallback( } fml::RefPtr message_response; { + // InvokePlatformMessageEmptyResponseCallback std::lock_guard lock(pending_responses_mutex_); auto it = pending_responses_.find(response_id); if (it == pending_responses_.end()) { return; } + // InvokePlatformMessageEmptyResponseCallback message_response = std::move(it->second); pending_responses_.erase(it); } diff --git a/shell/platform/ohos/platform_message_response_ohos.h b/shell/platform/ohos/platform_message_response_ohos.h index ad38f75f0b..b113f4ac22 100644 --- a/shell/platform/ohos/platform_message_response_ohos.h +++ b/shell/platform/ohos/platform_message_response_ohos.h @@ -19,10 +19,9 @@ namespace flutter { class PlatformMessageResponseOHOS : public flutter::PlatformMessageResponse { public: - // |flutter::PlatformMessageResponse| + void Complete(std::unique_ptr data) override; - // |flutter::PlatformMessageResponse| void CompleteEmpty() override; private: diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index 7185fbfd6d..75e49c12c4 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -107,17 +107,16 @@ class PlatformViewOHOS final : public PlatformView { // |PlatformView| PointerDataDispatcherMaker GetDispatcherMaker() override; - // |PlatformView| void LoadDartDeferredLibrary( intptr_t loading_unit_id, std::unique_ptr snapshot_data, std::unique_ptr snapshot_instructions) override; + // |PlatformView| void LoadDartDeferredLibraryError(intptr_t loading_unit_id, const std::string error_message, bool transient) override; - // |PlatformView| void UpdateAssetResolverByType( std::unique_ptr updated_asset_resolver, AssetResolver::AssetResolverType type) override; @@ -154,45 +153,33 @@ class PlatformViewOHOS final : public PlatformView { void SetDestroyed(bool isDestroyed_); - // |PlatformView| void UpdateSemantics( flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) override; - // |PlatformView| void HandlePlatformMessage( std::unique_ptr message) override; - // |PlatformView| void OnPreEngineRestart() const override; - // |PlatformView| std::unique_ptr CreateVSyncWaiter() override; - // |PlatformView| std::unique_ptr CreateRenderingSurface() override; - // |PlatformView| std::shared_ptr CreateExternalViewEmbedder() override; - // |PlatformView| std::unique_ptr CreateSnapshotSurfaceProducer() override; - // |PlatformView| sk_sp CreateResourceContext() const override; - // |PlatformView| void ReleaseResourceContext() const override; - // |PlatformView| std::shared_ptr GetImpellerContext() const override; - // |PlatformView| std::unique_ptr> ComputePlatformResolvedLocales( const std::vector& supported_locale_data) override; - // |PlatformView| void RequestDartDeferredLibrary(intptr_t loading_unit_id) override; void InstallFirstFrameCallback(); diff --git a/shell/platform/ohos/platform_view_ohos_delegate.cpp b/shell/platform/ohos/platform_view_ohos_delegate.cpp index 07746a4c7d..1028f2e68a 100644 --- a/shell/platform/ohos/platform_view_ohos_delegate.cpp +++ b/shell/platform/ohos/platform_view_ohos_delegate.cpp @@ -48,6 +48,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( const flutter::CustomAccessibilityActionUpdates& actions) { constexpr size_t kBytesPerNode = 47 * sizeof(int32_t); constexpr size_t kBytesPerChild = sizeof(int32_t); + // UpdateSemantics constexpr size_t kBytesPerCustomAction = sizeof(int32_t); constexpr size_t kBytesPerAction = 4 * sizeof(int32_t); constexpr size_t kBytesPerStringAttribute = 4 * sizeof(int32_t); @@ -58,6 +59,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( num_bytes += kBytesPerNode; num_bytes += value.second.childrenInTraversalOrder.size() * kBytesPerChild; + //kBytesPer num_bytes += value.second.childrenInHitTestOrder.size() * kBytesPerChild; num_bytes += value.second.customAccessibilityActions.size() * kBytesPerCustomAction; @@ -67,6 +69,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( value.second.valueAttributes.size() * kBytesPerStringAttribute; num_bytes += value.second.increasedValueAttributes.size() * kBytesPerStringAttribute; + // decreasedValueAttributes num_bytes += value.second.decreasedValueAttributes.size() * kBytesPerStringAttribute; num_bytes += @@ -88,13 +91,16 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = node.id; buffer_int32[position++] = node.flags; buffer_int32[position++] = node.actions; + // buffer_int32 config buffer_int32[position++] = node.maxValueLength; buffer_int32[position++] = node.currentValueLength; buffer_int32[position++] = node.textSelectionBase; + // buffer_int32 config buffer_int32[position++] = node.textSelectionExtent; buffer_int32[position++] = node.platformViewId; buffer_int32[position++] = node.scrollChildren; buffer_int32[position++] = node.scrollIndex; + // buffer_int32 config buffer_float32[position++] = static_cast(node.scrollPosition); buffer_float32[position++] = static_cast(node.scrollExtentMax); buffer_float32[position++] = static_cast(node.scrollExtentMin); @@ -104,7 +110,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.label); } - + // buffer_int32 config putStringAttributesIntoBuffer(node.labelAttributes, buffer_int32, position, string_attribute_args); if (node.value.empty()) { @@ -113,7 +119,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.value); } - + // buffer_int32 config putStringAttributesIntoBuffer(node.valueAttributes, buffer_int32, position, string_attribute_args); if (node.increasedValue.empty()) { @@ -122,7 +128,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.increasedValue); } - + // buffer_int32 config putStringAttributesIntoBuffer(node.increasedValueAttributes, buffer_int32, position, string_attribute_args); if (node.decreasedValue.empty()) { @@ -131,7 +137,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.decreasedValue); } - + // buffer_int32 config putStringAttributesIntoBuffer(node.decreasedValueAttributes, buffer_int32, position, string_attribute_args); @@ -141,7 +147,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.hint); } - + // buffer_int32 config putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position, string_attribute_args); @@ -159,27 +165,32 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_float32[position++] = node.rect.bottom(); node.transform.getColMajor(&buffer_float32[position]); position += 16; - + + // buffer_int32 config buffer_int32[position++] = node.childrenInTraversalOrder.size(); for (int32_t child : node.childrenInTraversalOrder) { buffer_int32[position++] = child; } + // buffer_int32 config for (int32_t child : node.childrenInHitTestOrder) { buffer_int32[position++] = child; } + // buffer_int32 config buffer_int32[position++] = node.customAccessibilityActions.size(); for (int32_t child : node.customAccessibilityActions) { buffer_int32[position++] = child; } } + // num_action_bytes // custom accessibility actions. size_t num_action_bytes = actions.size() * kBytesPerAction; std::vector actions_buffer(num_action_bytes); int32_t* actions_buffer_int32 = reinterpret_cast(&actions_buffer[0]); + // num_action_bytes std::vector action_strings; size_t actions_position = 0; @@ -189,12 +200,14 @@ void PlatformViewOHOSDelegate::UpdateSemantics( const flutter::CustomAccessibilityAction& action = value.second; actions_buffer_int32[actions_position++] = action.id; actions_buffer_int32[actions_position++] = action.overrideId; + // actions_buffer if (action.label.empty()) { actions_buffer_int32[actions_position++] = -1; } else { + // actions_buffer actions_buffer_int32[actions_position++] = action_strings.size(); action_strings.push_back(action.label); - } + } // actions_buffer if (action.hint.empty()) { actions_buffer_int32[actions_position++] = -1; } else { -- Gitee From c690b7c8a32090253aebf10311b18de69845c6e4 Mon Sep 17 00:00:00 2001 From: tanjiancheng <562575412@qq.com> Date: Wed, 19 Feb 2025 17:43:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?codecheck=E6=89=AB=E6=8F=8F=EF=BC=8Cohos?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=83=A8=E5=88=86=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanjiancheng <562575412@qq.com> --- shell/platform/ohos/napi_common.h | 4 +-- shell/platform/ohos/ohos_context_gl_skia.cpp | 28 +++++------------ shell/platform/ohos/ohos_context_gl_skia.h | 30 +++++++++++++++++++ shell/platform/ohos/ohos_egl_surface.h | 11 +++++++ shell/platform/ohos/ohos_environment_gl.cpp | 4 +-- shell/platform/ohos/ohos_image_generator.cpp | 8 ++--- shell/platform/ohos/ohos_shell_holder.cpp | 11 ++----- shell/platform/ohos/ohos_shell_holder.h | 1 - shell/platform/ohos/ohos_surface_gl_skia.cpp | 7 ++--- .../ohos/platform_message_handler_ohos.cpp | 4 --- .../ohos/platform_view_ohos_delegate.cpp | 27 +++++------------ 11 files changed, 65 insertions(+), 70 deletions(-) diff --git a/shell/platform/ohos/napi_common.h b/shell/platform/ohos/napi_common.h index 0cc32aab99..c6e468d80b 100644 --- a/shell/platform/ohos/napi_common.h +++ b/shell/platform/ohos/napi_common.h @@ -16,7 +16,7 @@ #define NAPI_RETVAL_NOTHING #define GET_AND_THROW_LAST_ERROR(env) \ - do { /*get throw last error */ \ + do { \ const napi_extended_error_info* errorInfo = nullptr; \ napi_get_last_error_info((env), &errorInfo); \ bool isPending = false; \ @@ -45,7 +45,7 @@ NAPI_ASSERT_BASE(env, assertion, message, NAPI_RETVAL_NOTHING) #define NAPI_CALL_BASE(env, theCall, retVal) \ - do { /* NAPI_CALL_BAS */ \ + do { \ if ((theCall) != napi_ok) { \ GET_AND_THROW_LAST_ERROR((env)); \ return retVal; \ diff --git a/shell/platform/ohos/ohos_context_gl_skia.cpp b/shell/platform/ohos/ohos_context_gl_skia.cpp index 75b33edcc5..43ecdd1612 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.cpp +++ b/shell/platform/ohos/ohos_context_gl_skia.cpp @@ -21,7 +21,7 @@ static EGLResult CreateContext(EGLDisplay display, EGLConfig config, EGLContext share = EGL_NO_CONTEXT) { EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; - /*CreateContex*/ + EGLContext context = eglCreateContext(display, config, share, attributes); return {context != EGL_NO_CONTEXT, context}; @@ -31,13 +31,12 @@ static EGLResult ChooseEGLConfiguration(EGLDisplay display, uint8_t msaa_samples) { EGLint sample_buffers = msaa_samples > 1 ? 1 : 0; EGLint attributes[] = { - // clang-format off ChooseEGLConfiguration + // clang-format off EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, - // EGLCongfig EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 0, @@ -47,23 +46,21 @@ static EGLResult ChooseEGLConfiguration(EGLDisplay display, // clang-format on }; - // EGLCongfig EGLint config_count = 0; EGLConfig egl_config = nullptr; if (eglChooseConfig(display, attributes, &egl_config, 1, &config_count) != EGL_TRUE) { - // EGLCongfig return {false, nullptr}; } - // EGLCongfig + bool success = config_count > 0 && egl_config != nullptr; return {success, success ? egl_config : nullptr}; } static bool TeardownContext(EGLDisplay display, EGLContext context) { - if (context != EGL_NO_CONTEXT) { // TeardownContext + if (context != EGL_NO_CONTEXT) { return eglDestroyContext(display, context) == EGL_TRUE; } @@ -94,24 +91,20 @@ OhosContextGLSkia::OhosContextGLSkia(OHOSRenderingAPI rendering_api, return; } - //configuration // Create a context for the configuration. std::tie(success, context_) = CreateContext(environment_->Display(), config_, EGL_NO_CONTEXT); - //configuration if (!success) { FML_LOG(ERROR) << "Could not create an EGL context"; LogLastEGLError(); return; } - //configuration + std::tie(success, resource_context_) = CreateContext(environment_->Display(), config_, context_); - //configuration if (!success) { FML_LOG(ERROR) << "Could not create an EGL resource context"; LogLastEGLError(); - //configuration return; } @@ -120,15 +113,12 @@ OhosContextGLSkia::OhosContextGLSkia(OHOSRenderingAPI rendering_api, } OhosContextGLSkia::~OhosContextGLSkia() { - //~OhosContextGLSkia FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); sk_sp main_context = GetMainSkiaContext(); - //~OhosContextGLSkia SetMainSkiaContext(nullptr); fml::AutoResetWaitableEvent latch; // This context needs to be deallocated from the raster thread in order to // keep a coherent usage of egl from a single thread. - //~OhosContextGLSkia fml::TaskRunner::RunNowOrPostTask(task_runners_.GetRasterTaskRunner(), [&] { if (main_context) { std::unique_ptr pbuffer_surface = CreatePbufferSurface(); @@ -140,7 +130,6 @@ OhosContextGLSkia::~OhosContextGLSkia() { } } latch.Signal(); - //~OhosContextGLSkia }); latch.Wait(); @@ -149,7 +138,7 @@ OhosContextGLSkia::~OhosContextGLSkia() { << "Could not tear down the EGL context. Possible resource leak."; LogLastEGLError(); } - //~OhosContextGLSkia + if (!TeardownContext(environment_->Display(), resource_context_)) { FML_LOG(ERROR) << "Could not tear down the EGL resource context. Possible " "resource leak."; @@ -165,7 +154,7 @@ std::unique_ptr OhosContextGLSkia::CreateOnscreenSurface( EGLDisplay display = environment_->Display(); const EGLint attribs[] = {EGL_NONE}; - //CreateOnscreenSurface + EGLSurface surface = eglCreateWindowSurface( display, config_, reinterpret_cast(window->handle()), attribs); @@ -215,13 +204,11 @@ bool OhosContextGLSkia::ClearCurrent() const { if (eglGetCurrentContext() != context_) { return true; } - // ClearCurrent if (eglMakeCurrent(environment_->Display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE) { FML_LOG(ERROR) << "Could not clear the current context"; LogLastEGLError(); return false; - // ClearCurrent } return true; } @@ -229,7 +216,6 @@ bool OhosContextGLSkia::ClearCurrent() const { EGLContext OhosContextGLSkia::CreateNewContext() const { bool success; EGLContext context; - // CreateNewContext std::tie(success, context) = CreateContext(environment_->Display(), config_, EGL_NO_CONTEXT); return success ? context : EGL_NO_CONTEXT; diff --git a/shell/platform/ohos/ohos_context_gl_skia.h b/shell/platform/ohos/ohos_context_gl_skia.h index 29d2086b78..cb80b66045 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.h +++ b/shell/platform/ohos/ohos_context_gl_skia.h @@ -37,11 +37,29 @@ class OhosContextGLSkia : public OHOSContext { ~OhosContextGLSkia(); + //---------------------------------------------------------------------------- + /// @brief Allocates an new EGL window surface that is used for on-screen + /// pixels. + /// + /// @return The window surface. + /// std::unique_ptr CreateOnscreenSurface( const fml::RefPtr& window) const; + //---------------------------------------------------------------------------- + /// @brief Allocates an 1x1 pbuffer surface that is used for making the + /// offscreen current for texture uploads. + /// + /// @return The pbuffer surface. + /// std::unique_ptr CreateOffscreenSurface() const; + //---------------------------------------------------------------------------- + /// @brief Allocates an 1x1 pbuffer surface that is used for making the + /// onscreen context current for snapshotting. + /// + /// @return The pbuffer surface. + /// std::unique_ptr CreatePbufferSurface() const; //---------------------------------------------------------------------------- @@ -50,10 +68,22 @@ class OhosContextGLSkia : public OHOSContext { /// fml::RefPtr Environment() const; + //---------------------------------------------------------------------------- + /// @return Whether the current context is valid. That is, if the EGL + /// contexts were successfully created. + /// bool IsValid() const override; + //---------------------------------------------------------------------------- + /// @return Whether the current context was successfully clear. + /// bool ClearCurrent() const; + //---------------------------------------------------------------------------- + /// @brief Create a new EGLContext using the same EGLConfig. + /// + /// @return The EGLContext. + /// EGLContext CreateNewContext() const; //---------------------------------------------------------------------------- diff --git a/shell/platform/ohos/ohos_egl_surface.h b/shell/platform/ohos/ohos_egl_surface.h index 37cf87ca53..dd1cb98e25 100755 --- a/shell/platform/ohos/ohos_egl_surface.h +++ b/shell/platform/ohos/ohos_egl_surface.h @@ -47,8 +47,19 @@ class OhosEGLSurface { ~OhosEGLSurface(); + //---------------------------------------------------------------------------- + /// @return Whether the current `EGLSurface` reference is valid. That is, + /// if + /// the surface doesn't point to `EGL_NO_SURFACE`. + /// bool IsValid() const; + //---------------------------------------------------------------------------- + /// @brief Binds the EGLContext context to the current rendering thread + /// and to the draw and read surface. + /// + /// @return Whether the surface was made current. + /// OhosEGLSurfaceMakeCurrentStatus MakeCurrent() const; //---------------------------------------------------------------------------- diff --git a/shell/platform/ohos/ohos_environment_gl.cpp b/shell/platform/ohos/ohos_environment_gl.cpp index 1c7977b4d8..545b7037b2 100755 --- a/shell/platform/ohos/ohos_environment_gl.cpp +++ b/shell/platform/ohos/ohos_environment_gl.cpp @@ -14,11 +14,11 @@ OhosEnvironmentGL::OhosEnvironmentGL() : display_(EGL_NO_DISPLAY), valid_(false) { // Get the display. display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - // OhosEnvironmentGL + if (display_ == EGL_NO_DISPLAY) { return; } - // OhosEnvironmentGL + // Initialize the display connection. if (eglInitialize(display_, nullptr, nullptr) != EGL_TRUE) { return; diff --git a/shell/platform/ohos/ohos_image_generator.cpp b/shell/platform/ohos/ohos_image_generator.cpp index 874fe001e8..c00ffd88b3 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -75,19 +75,17 @@ bool OHOSImageGenerator::GetPixels(const SkImageInfo& info, if (!software_decoded_data_) { return false; } - // kRGBA_8888_SkColorType + if (kRGBA_8888_SkColorType != info.colorType()) { return false; } - // info.alphaType + switch (info.alphaType()) { case kOpaque_SkAlphaType: if (kOpaque_SkAlphaType != GetInfo().alphaType()) { return false; - // kOpaque_SkAlphaTyp } break; - // kPremul_SkAlphaType case kPremul_SkAlphaType: break; default: @@ -96,7 +94,6 @@ bool OHOSImageGenerator::GetPixels(const SkImageInfo& info, // TODO(bdero): Override `GetImage()` to use `SkImage::FromAHardwareBuffer` on // API level 30+ once it's updated to do symbol lookups and not get - // memcpy // preprocessed out in Skia. This will allow for avoiding this copy in // cases where the result image doesn't need to be resized. memcpy(pixels, software_decoded_data_->data(), @@ -146,7 +143,6 @@ void OHOSImageGenerator::DoDecodeImage() { bool OHOSImageGenerator::IsValidImageData() { // The generator kicks off an IO task to decode everything, and calls to // "GetInfo()" block until either the header has been decoded or decoding has - // IsValidImageData // failed, whichever is sooner. The decoder is initialized with a width and // height of -1 and will update the dimensions if the image is able to be // decoded. diff --git a/shell/platform/ohos/ohos_shell_holder.cpp b/shell/platform/ohos/ohos_shell_holder.cpp index 8ae091e172..35970f42a1 100644 --- a/shell/platform/ohos/ohos_shell_holder.cpp +++ b/shell/platform/ohos/ohos_shell_holder.cpp @@ -111,15 +111,13 @@ OHOSShellHolder::OHOSShellHolder( fml::MessageLoop::EnsureInitializedForCurrentThread(platform_loop); fml::RefPtr raster_runner; fml::RefPtr ui_runner; - // Initialized Current Thread fml::RefPtr io_runner; fml::RefPtr platform_runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); - // Initialized Current Thread raster_runner = thread_host_->raster_thread->GetTaskRunner(); ui_runner = thread_host_->ui_thread->GetTaskRunner(); io_runner = thread_host_->io_thread->GetTaskRunner(); - // Initialized Current Thread + flutter::TaskRunners task_runners(thread_label, // label platform_runner, // platform raster_runner, // raster @@ -129,11 +127,10 @@ OHOSShellHolder::OHOSShellHolder( napi_facade_->SetPlatformTaskRunner(platform_runner); FML_DLOG(INFO) << "before shell create"; - // shell shell_ = Shell::Create(GetDefaultPlatformData(), // window data task_runners, // task runners - settings_, + settings_, // settings on_create_platform_view, // platform view create callback on_create_rasterizer // rasterizer create callback ); @@ -243,11 +240,9 @@ std::unique_ptr OHOSShellHolder::Spawn( if (!config) { // If the RunConfiguration was null, the kernel blob wasn't readable. // Fail the whole thing. - // config return nullptr; } - // on_create_platform_view std::unique_ptr shell = shell_->Spawn(std::move(config.value()), initial_route, on_create_platform_view, on_create_rasterizer); @@ -302,12 +297,10 @@ std::optional OHOSShellHolder::BuildRunConfiguration( if (flutter::DartVM::IsRunningPrecompiledCode()) { FML_LOG(INFO) << "isolate_configuration."; isolate_configuration = IsolateConfiguration::CreateForAppSnapshot(); - // isolate_configuration } else { std::unique_ptr kernel_blob = fml::FileMapping::CreateReadOnly( GetSettings().application_kernel_asset); - // isolate_configuration if (!kernel_blob) { FML_DLOG(ERROR) << "Unable to load the kernel blob asset."; return std::nullopt; diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 9d0f69c9b3..1fadd18a3d 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -11,7 +11,6 @@ #include "flutter/assets/asset_manager.h" #include "flutter/fml/macros.h" #include "flutter/fml/unique_fd.h" -// flutter lib ui in window #include "flutter/lib/ui/window/viewport_metrics.h" #include "flutter/runtime/platform_data.h" #include "flutter/shell/common/run_configuration.h" diff --git a/shell/platform/ohos/ohos_surface_gl_skia.cpp b/shell/platform/ohos/ohos_surface_gl_skia.cpp index 05bb475631..7298179925 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.cpp +++ b/shell/platform/ohos/ohos_surface_gl_skia.cpp @@ -117,9 +117,9 @@ bool OhosSurfaceGLSkia::SetNativeWindow(fml::RefPtr window) { FML_DCHECK(window); native_window_ = window; // Ensure the destructor is called since it destroys the `EGLSurface` before - // creating a new onscreen surface SetNativeWindow. + // creating a new onscreen surface. onscreen_surface_ = nullptr; - // Create the onscreen surface SetNativeWindow. + // Create the onscreen surface. onscreen_surface_ = GLContextPtr()->CreateOnscreenSurface(window); if (!onscreen_surface_->IsValid()) { return false; @@ -189,10 +189,8 @@ sk_sp OhosSurfaceGLSkia::GetGLInterface() const { // implementation. Some versions of the emulator will not update the // GL version string when the process switches to a new EGL context // unless the EGL context is being made current for the first time. - // GetGLInterface // The inaccurate version string will be rejected by Skia when it // tries to build the GrGLInterface. Flutter can work around this - // GetGLInterface // by creating a new context, making it current to force an update // of the version, and then reverting to the previous context. const char* gl_renderer = @@ -214,7 +212,6 @@ sk_sp OhosSurfaceGLSkia::GetGLInterface() const { FML_DCHECK(result == EGL_TRUE); result = eglMakeCurrent(display, draw_surface, read_surface, old_context); FML_DCHECK(result == EGL_TRUE); - // eglDestroyContext result = eglDestroyContext(display, new_context); FML_DCHECK(result == EGL_TRUE); } diff --git a/shell/platform/ohos/platform_message_handler_ohos.cpp b/shell/platform/ohos/platform_message_handler_ohos.cpp index cd05e19e7c..3e6b8b3d8e 100644 --- a/shell/platform/ohos/platform_message_handler_ohos.cpp +++ b/shell/platform/ohos/platform_message_handler_ohos.cpp @@ -41,13 +41,11 @@ void PlatformMessageHandlerOHOS::InvokePlatformMessageResponseCallback( // PlatformMessageResponseDart so we won't need to use a mutex anymore. fml::RefPtr message_response; { - // message_response std::lock_guard lock(pending_responses_mutex_); auto it = pending_responses_.find(response_id); if (it == pending_responses_.end()) { return; } - // message_response message_response = std::move(it->second); pending_responses_.erase(it); } @@ -62,13 +60,11 @@ void PlatformMessageHandlerOHOS::InvokePlatformMessageEmptyResponseCallback( } fml::RefPtr message_response; { - // InvokePlatformMessageEmptyResponseCallback std::lock_guard lock(pending_responses_mutex_); auto it = pending_responses_.find(response_id); if (it == pending_responses_.end()) { return; } - // InvokePlatformMessageEmptyResponseCallback message_response = std::move(it->second); pending_responses_.erase(it); } diff --git a/shell/platform/ohos/platform_view_ohos_delegate.cpp b/shell/platform/ohos/platform_view_ohos_delegate.cpp index 1028f2e68a..07746a4c7d 100644 --- a/shell/platform/ohos/platform_view_ohos_delegate.cpp +++ b/shell/platform/ohos/platform_view_ohos_delegate.cpp @@ -48,7 +48,6 @@ void PlatformViewOHOSDelegate::UpdateSemantics( const flutter::CustomAccessibilityActionUpdates& actions) { constexpr size_t kBytesPerNode = 47 * sizeof(int32_t); constexpr size_t kBytesPerChild = sizeof(int32_t); - // UpdateSemantics constexpr size_t kBytesPerCustomAction = sizeof(int32_t); constexpr size_t kBytesPerAction = 4 * sizeof(int32_t); constexpr size_t kBytesPerStringAttribute = 4 * sizeof(int32_t); @@ -59,7 +58,6 @@ void PlatformViewOHOSDelegate::UpdateSemantics( num_bytes += kBytesPerNode; num_bytes += value.second.childrenInTraversalOrder.size() * kBytesPerChild; - //kBytesPer num_bytes += value.second.childrenInHitTestOrder.size() * kBytesPerChild; num_bytes += value.second.customAccessibilityActions.size() * kBytesPerCustomAction; @@ -69,7 +67,6 @@ void PlatformViewOHOSDelegate::UpdateSemantics( value.second.valueAttributes.size() * kBytesPerStringAttribute; num_bytes += value.second.increasedValueAttributes.size() * kBytesPerStringAttribute; - // decreasedValueAttributes num_bytes += value.second.decreasedValueAttributes.size() * kBytesPerStringAttribute; num_bytes += @@ -91,16 +88,13 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = node.id; buffer_int32[position++] = node.flags; buffer_int32[position++] = node.actions; - // buffer_int32 config buffer_int32[position++] = node.maxValueLength; buffer_int32[position++] = node.currentValueLength; buffer_int32[position++] = node.textSelectionBase; - // buffer_int32 config buffer_int32[position++] = node.textSelectionExtent; buffer_int32[position++] = node.platformViewId; buffer_int32[position++] = node.scrollChildren; buffer_int32[position++] = node.scrollIndex; - // buffer_int32 config buffer_float32[position++] = static_cast(node.scrollPosition); buffer_float32[position++] = static_cast(node.scrollExtentMax); buffer_float32[position++] = static_cast(node.scrollExtentMin); @@ -110,7 +104,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.label); } - // buffer_int32 config + putStringAttributesIntoBuffer(node.labelAttributes, buffer_int32, position, string_attribute_args); if (node.value.empty()) { @@ -119,7 +113,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.value); } - // buffer_int32 config + putStringAttributesIntoBuffer(node.valueAttributes, buffer_int32, position, string_attribute_args); if (node.increasedValue.empty()) { @@ -128,7 +122,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.increasedValue); } - // buffer_int32 config + putStringAttributesIntoBuffer(node.increasedValueAttributes, buffer_int32, position, string_attribute_args); if (node.decreasedValue.empty()) { @@ -137,7 +131,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.decreasedValue); } - // buffer_int32 config + putStringAttributesIntoBuffer(node.decreasedValueAttributes, buffer_int32, position, string_attribute_args); @@ -147,7 +141,7 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_int32[position++] = strings.size(); strings.push_back(node.hint); } - // buffer_int32 config + putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position, string_attribute_args); @@ -165,32 +159,27 @@ void PlatformViewOHOSDelegate::UpdateSemantics( buffer_float32[position++] = node.rect.bottom(); node.transform.getColMajor(&buffer_float32[position]); position += 16; - - // buffer_int32 config + buffer_int32[position++] = node.childrenInTraversalOrder.size(); for (int32_t child : node.childrenInTraversalOrder) { buffer_int32[position++] = child; } - // buffer_int32 config for (int32_t child : node.childrenInHitTestOrder) { buffer_int32[position++] = child; } - // buffer_int32 config buffer_int32[position++] = node.customAccessibilityActions.size(); for (int32_t child : node.customAccessibilityActions) { buffer_int32[position++] = child; } } - // num_action_bytes // custom accessibility actions. size_t num_action_bytes = actions.size() * kBytesPerAction; std::vector actions_buffer(num_action_bytes); int32_t* actions_buffer_int32 = reinterpret_cast(&actions_buffer[0]); - // num_action_bytes std::vector action_strings; size_t actions_position = 0; @@ -200,14 +189,12 @@ void PlatformViewOHOSDelegate::UpdateSemantics( const flutter::CustomAccessibilityAction& action = value.second; actions_buffer_int32[actions_position++] = action.id; actions_buffer_int32[actions_position++] = action.overrideId; - // actions_buffer if (action.label.empty()) { actions_buffer_int32[actions_position++] = -1; } else { - // actions_buffer actions_buffer_int32[actions_position++] = action_strings.size(); action_strings.push_back(action.label); - } // actions_buffer + } if (action.hint.empty()) { actions_buffer_int32[actions_position++] = -1; } else { -- Gitee