Skip to content

Commit c696e5b

Browse files
authored
Fixed ContextEgl construction for eglstreams. Added support for Nvidia Tegra TX1/TX2 (#381)
Signed-off-by: Stanislav Shmarov <[email protected]>
1 parent 311e9f1 commit c696e5b

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ FlafyDev <[email protected]>
1212
Makoto Sato ([email protected])
1313
Yunhao Tian ([email protected])
1414
Luke Howard <[email protected]>
15+
Stanislav Shmarov <[email protected]>

src/flutter/shell/platform/linux_embedded/surface/context_egl_stream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace flutter {
1111

1212
ContextEglStream::ContextEglStream(
1313
std::unique_ptr<EnvironmentEglStream> environment)
14-
: ContextEgl(std::move(environment), EGL_STREAM_BIT_KHR) {
14+
: ContextEgl(std::move(environment), false, EGL_STREAM_BIT_KHR) {
1515
if (!valid_) {
1616
return;
1717
}

src/flutter/shell/platform/linux_embedded/window/elinux_window_drm.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <chrono>
1515
#include <memory>
16+
#include <optional>
1617
#include <string>
1718
#include <unordered_map>
1819
#include <vector>
@@ -262,29 +263,31 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
262263
}
263264

264265
constexpr char kFileNameSeparator[] = "/";
265-
auto pos = device_filename.find_last_of(kFileNameSeparator);
266-
if (pos == std::string::npos) {
267-
ELINUX_LOG(ERROR) << "Failed to get device name position.";
268-
udev_unref(udev);
269-
return false;
270-
}
266+
if (device_filename != "drm-nvdc") {
267+
auto pos = device_filename.find_last_of(kFileNameSeparator);
268+
if (pos == std::string::npos) {
269+
ELINUX_LOG(ERROR) << "Failed to get device name position.";
270+
udev_unref(udev);
271+
return false;
272+
}
271273

272-
auto device_name = device_filename.substr(pos + 1);
273-
auto device = udev_device_new_from_subsystem_sysname(
274-
udev, kUdevMonitorSubsystemDrm, device_name.c_str());
275-
if (!device) {
276-
ELINUX_LOG(ERROR) << "Failed to get device from " << device_name;
277-
udev_unref(udev);
278-
return false;
279-
}
274+
auto device_name = device_filename.substr(pos + 1);
275+
auto device = udev_device_new_from_subsystem_sysname(
276+
udev, kUdevMonitorSubsystemDrm, device_name.c_str());
277+
if (!device) {
278+
ELINUX_LOG(ERROR) << "Failed to get device from " << device_name;
279+
udev_unref(udev);
280+
return false;
281+
}
280282

281-
auto sysnum = udev_device_get_sysnum(device);
282-
if (!sysnum) {
283-
ELINUX_LOG(ERROR) << "Failed to get device id.";
284-
udev_unref(udev);
285-
return false;
283+
auto sysnum = udev_device_get_sysnum(device);
284+
if (!sysnum) {
285+
ELINUX_LOG(ERROR) << "Failed to get device id.";
286+
udev_unref(udev);
287+
return false;
288+
}
289+
drm_device_id_ = std::atoi(sysnum);
286290
}
287-
drm_device_id_ = std::atoi(sysnum);
288291
udev_unref(udev);
289292

290293
if (sd_event_new(&udev_drm_event_loop_) < 0) {
@@ -348,7 +351,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
348351
if (!sysnum) {
349352
ELINUX_LOG(ERROR) << "Failed to get device id.";
350353
return false;
351-
} else if (std::atoi(sysnum) != drm_device_id_) {
354+
} else if (drm_device_id_ && std::atoi(sysnum) != *drm_device_id_) {
352355
ELINUX_LOG(ERROR) << "Not expected device id.";
353356
return false;
354357
}
@@ -721,7 +724,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
721724

722725
sd_event* udev_drm_event_loop_ = nullptr;
723726
udev_monitor* udev_monitor_ = nullptr;
724-
int drm_device_id_;
727+
std::optional<int> drm_device_id_;
725728
};
726729

727730
} // namespace flutter

src/flutter/shell/platform/linux_embedded/window/native_window_drm.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ namespace flutter {
1818
NativeWindowDrm::NativeWindowDrm(const char* device_filename,
1919
const uint16_t rotation,
2020
bool enable_vsync) {
21-
drm_device_ = open(device_filename, O_RDWR | O_CLOEXEC);
21+
if (!strcmp("drm-nvdc", device_filename)) {
22+
drm_device_ = drmOpen(device_filename, nullptr);
23+
} else {
24+
drm_device_ = open(device_filename, O_RDWR | O_CLOEXEC);
25+
}
2226
if (drm_device_ == -1) {
2327
ELINUX_LOG(ERROR) << "Couldn't open " << device_filename;
2428
return;

src/flutter/shell/platform/linux_embedded/window/native_window_drm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <xf86drmMode.h>
99

10+
#include <cstddef>
11+
#include <cstdint>
1012
#include <string>
1113

1214
#include "flutter/shell/platform/linux_embedded/surface/surface_gl.h"

0 commit comments

Comments
 (0)