From cfc4883c7b7ca9cbcb9c141605e6ac703c7ef974 Mon Sep 17 00:00:00 2001 From: Yilong Li Date: Fri, 2 Oct 2020 02:08:25 +0900 Subject: [PATCH] fuchsia: Remove display device availability check from Flutter. (flutter/engine#21495) When Flutter engine connects to Scenic, Scenic has already checked the display and graphics device availability before Scenic starts; so it is guaranteed that display devices are available and surface is valid when it is created. Thus this change removes the device watching details from flutter surface on Fuchsia so that it doesn't need to do duplicated checks and hides the device-specific details. --- .../shell/platform/fuchsia/flutter/surface.cc | 26 +------------------ .../shell/platform/fuchsia/flutter/surface.h | 3 --- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/surface.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/surface.cc index fdcb42a3c7..61f2d25878 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/surface.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/surface.cc @@ -24,7 +24,7 @@ Surface::~Surface() = default; // |flutter::Surface| bool Surface::IsValid() { - return valid_; + return true; } // |flutter::Surface| @@ -42,30 +42,6 @@ GrDirectContext* Surface::GetContext() { return gr_context_; } -static zx_status_t DriverWatcher(int dirfd, - int event, - const char* fn, - void* cookie) { - if (event == WATCH_EVENT_ADD_FILE && !strcmp(fn, "000")) { - return ZX_ERR_STOP; - } - return ZX_OK; -} - -bool Surface::CanConnectToDisplay() { - constexpr char kGpuDriverClass[] = "/dev/class/gpu"; - fml::UniqueFD fd(open(kGpuDriverClass, O_DIRECTORY | O_RDONLY)); - if (fd.get() < 0) { - FML_DLOG(ERROR) << "Failed to open " << kGpuDriverClass; - return false; - } - - zx_status_t status = fdio_watch_directory( - fd.get(), DriverWatcher, - zx::deadline_after(zx::duration(ZX_SEC(5))).get(), nullptr); - return status == ZX_ERR_STOP; -} - // |flutter::Surface| SkMatrix Surface::GetRootTransformation() const { // This backend does not support delegating to the underlying platform to diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/surface.h b/engine/src/flutter/shell/platform/fuchsia/flutter/surface.h index 8ebb89de0d..96222c0f2d 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/surface.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/surface.h @@ -22,7 +22,6 @@ class Surface final : public flutter::Surface { ~Surface() override; private: - const bool valid_ = CanConnectToDisplay(); const std::string debug_label_; flutter::ExternalViewEmbedder* view_embedder_; GrDirectContext* gr_context_; @@ -43,8 +42,6 @@ class Surface final : public flutter::Surface { // |flutter::Surface| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; - static bool CanConnectToDisplay(); - FML_DISALLOW_COPY_AND_ASSIGN(Surface); };