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.
This commit is contained in:
Yilong Li
2020-10-02 02:08:25 +09:00
committed by GitHub
parent dd4f9727d6
commit cfc4883c7b
2 changed files with 1 additions and 28 deletions

View File

@@ -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

View File

@@ -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);
};