Skip to content

Commit a052911

Browse files
author
Mai-Matsuura
authored
Support eglstream (#52)
1 parent 83227d5 commit a052911

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2006
-1230
lines changed

.github/workflows/build-test.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,22 @@ jobs:
4141
# Execute the build. You can specify a specific target with "--target <NAME>"
4242
run: cmake --build . --config $BUILD_TYPE
4343

44-
- name: Configure CMake for drm backend
44+
- name: Configure CMake for drm backend with GBM
4545
shell: bash
4646
working-directory: ${{github.workspace}}/build
47-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSER_PROJECT_PATH=examples/flutter-drm-backend ..
47+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSER_PROJECT_PATH=examples/flutter-drm-gbm-backend ..
4848

49-
- name: Build for drm backend
49+
- name: Build for drm backend with GBM
50+
working-directory: ${{github.workspace}}/build
51+
shell: bash
52+
run: cmake --build . --config $BUILD_TYPE
53+
54+
- name: Configure CMake for drm backend with EGLStream
55+
shell: bash
56+
working-directory: ${{github.workspace}}/build
57+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend ..
58+
59+
- name: Build for drm backend with EGLStream
5060
working-directory: ${{github.workspace}}/build
5161
shell: bash
5262
run: cmake --build . --config $BUILD_TYPE

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(CMAKE_CXX_COMPILER clang++)
77
set(CMAKE_CXX_STANDARD 17)
88

99
# Build options.
10-
option(USE_DRM "Select WAYLAND or DRM as the display backend type" OFF)
10+
option(BACKEND_TYPE "Select WAYLAND, DRM-GBM, DRM-EGLSTREAM, or X11 as the display backend type" WAYLAND)
1111
option(DESKTOP_SHELL "Work as weston desktop-shell" OFF)
1212
option(USE_VIRTUAL_KEYBOARD "Use virtual keyboard" OFF)
1313
option(USE_GLES3 "Use OpenGL ES3 (default is OpenGL ES2)" OFF)

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ We would be grateful if you could give us feedback on bugs and new feature reque
1616
- [Wayland](https://wayland.freedesktop.org/) backend support
1717
- Direct rendering module ([DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager)) backend support
1818
- [x] Generic Buffer Management ([GBM](https://en.wikipedia.org/wiki/Mesa_(computer_graphics)))
19-
- [ ] [EGLStream](https://docs.nvidia.com/drive/drive_os_5.1.6.1L/nvvib_docs/index.html#page/DRIVE_OS_Linux_SDK_Development_Guide/Graphics/graphics_eglstream_user_guide.html) for NVIDIA devices (coming soon)
19+
- [x] [EGLStream](https://docs.nvidia.com/drive/drive_os_5.1.6.1L/nvvib_docs/index.html#page/DRIVE_OS_Linux_SDK_Development_Guide/Graphics/graphics_eglstream_user_guide.html) for NVIDIA devices
2020
- X11 backend supoort
2121
- This is for the purpose of developing Flutter apps in Linux desktops. It is not intended for use in embedded systems.
2222
- Always single window fullscreen
@@ -39,7 +39,7 @@ This embedder supports x64 and Arm64 (aarch64, ARMv8) architectures on Linux whi
3939
| QEMU (x86_64) | QEMU | [AGL (Automotive Grade Linux)](https://wiki.automotivelinux.org/) koi | Wayland | :heavy_check_mark: |
4040
| QEMU (x86_64) | QEMU | [AGL (Automotive Grade Linux)](https://wiki.automotivelinux.org/) koi | DRM | :heavy_check_mark: |
4141
| [Jetson Nano](https://developer.nvidia.com/embedded/jetson-nano-developer-kit) | NVIDIA | JetPack 4.3 | Wayland | :heavy_check_mark: |
42-
| [Jetson Nano](https://developer.nvidia.com/embedded/jetson-nano-developer-kit) | NVIDIA | JetPack 4.3 | DRM | See: [#1](https://github.com/sony/flutter-embedded-linux/issues/1) |
42+
| [Jetson Nano](https://developer.nvidia.com/embedded/jetson-nano-developer-kit) | NVIDIA | JetPack 4.3 | DRM | :heavy_check_mark: ([#1](https://github.com/sony/flutter-embedded-linux/issues/1))|
4343
| [Raspberry Pi 4 Model B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) | Raspberry Pi Foundation | Ubuntu 20.10 | Wayland | :heavy_check_mark: |
4444
| [Raspberry Pi 4 Model B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) | Raspberry Pi Foundation | Ubuntu 20.10 | DRM | :heavy_check_mark: ([#9](https://github.com/sony/flutter-embedded-linux/issues/9)) |
4545
| [i.MX 8MQuad EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/evaluation-kit-for-the-i-mx-8m-applications-processor:MCIMX8M-EVK) | NXP | Sumo (kernel 4.14.98) | Wayland | :heavy_check_mark: |
@@ -164,10 +164,21 @@ $ cmake --build .
164164

165165
### Build for DRM backend
166166

167+
#### Use GBM
168+
169+
```Shell
170+
$ mkdir build
171+
$ cd build
172+
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-gbm-backend ..
173+
$ cmake --build .
174+
```
175+
176+
#### Use EGLStream
177+
167178
```Shell
168179
$ mkdir build
169180
$ cd build
170-
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-backend ..
181+
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend ..
171182
$ cmake --build .
172183
```
173184

@@ -195,8 +206,7 @@ Please edit `cmake/user_config.cmake` file.
195206

196207
| Option | Description |
197208
| ------------- | ------------- |
198-
| USE_DRM | Use DRM backend instead of Wayland |
199-
| USE_X11 | Use X11 backend instead of Wayland |
209+
| BACKEND_TYPE | Select WAYLAND, DRM-GBM, DRM-EGLSTREAM, or X11 as the display backend type (The default setting is WAYLAND) |
200210
| DESKTOP_SHELL | Work as Weston desktop-shell |
201211
| USE_VIRTUAL_KEYBOARD | Use Virtual Keyboard (only when using `DESKTOP_SHELL`) |
202212
| USE_GLES3 | Use OpenGLES3 instead of OpenGLES2 |
@@ -267,7 +277,7 @@ You need to switch from GUI which is running X11 or Wayland to the Character Use
267277

268278
```Shell
269279
$ Ctrl + Alt + F3 # Switching to CUI
270-
$ sudo FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-backend ./sample/build/linux/x64/release/bundle
280+
$ sudo FLUTTER_DRM_DEVICE="/dev/dri/card1" <binary_file_name> ./sample/build/linux/x64/release/bundle
271281
```
272282

273283
If you want to switch back from CUI to GUI, run `Ctrl + Alt + F2` keys in a terminal.

cmake/build.cmake

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ cmake_minimum_required(VERSION 3.10)
22

33
# display backend type.
44
set(DISPLAY_BACKEND_SRC "")
5-
if(USE_DRM)
6-
add_definitions(-DDISPLAY_BACKEND_TYPE_DRM)
5+
if(${BACKEND_TYPE} STREQUAL "DRM-GBM")
6+
add_definitions(-DDISPLAY_BACKEND_TYPE_DRM_GBM)
77
set(DISPLAY_BACKEND_SRC
8-
src/flutter/shell/platform/linux_embedded/window/linuxes_window_drm.cc
9-
src/flutter/shell/platform/linux_embedded/window/native_window_drm.cc
10-
src/flutter/shell/platform/linux_embedded/surface/linuxes_surface_gl_drm.cc)
11-
elseif(USE_X11)
8+
src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc)
9+
elseif(${BACKEND_TYPE} STREQUAL "DRM-EGLSTREAM")
10+
## Define "EGL_NO_X11" to avoid including x11-related files.
11+
add_definitions(-DDISPLAY_BACKEND_TYPE_DRM_EGLSTREAM -DEGL_NO_X11)
12+
set(DISPLAY_BACKEND_SRC
13+
src/flutter/shell/platform/linux_embedded/surface/context_egl_drm_eglstream.cc
14+
src/flutter/shell/platform/linux_embedded/surface/environment_egl_drm_eglstream.cc
15+
src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc)
16+
elseif(${BACKEND_TYPE} STREQUAL "X11")
1217
add_definitions(-DDISPLAY_BACKEND_TYPE_X11)
1318
set(DISPLAY_BACKEND_SRC
1419
src/flutter/shell/platform/linux_embedded/window/linuxes_window_x11.cc
@@ -42,13 +47,13 @@ else()
4247
endif()
4348

4449
# desktop-shell for weston.
45-
if(NOT USE_DRM AND DESKTOP_SHELL)
50+
if((${BACKEND_TYPE} STREQUAL "WAYLAND") AND DESKTOP_SHELL)
4651
add_definitions(-DDESKTOP_SHELL)
4752
endif()
4853

4954
# wayland & weston protocols.
5055
set(WAYLAND_PROTOCOL_SRC "")
51-
if(NOT USE_DRM AND DESKTOP_SHELL)
56+
if((${BACKEND_TYPE} STREQUAL "WAYLAND") AND DESKTOP_SHELL)
5257
set(WAYLAND_PROTOCOL_SRC ${WAYLAND_PROTOCOL_SRC} src/wayland/protocol/weston-desktop-shell-protocol.c)
5358

5459
if(USE_VIRTUAL_KEYBOARD)
@@ -90,6 +95,7 @@ add_executable(${TARGET}
9095
src/flutter/shell/platform/linux_embedded/plugin/text_input_plugin.cc
9196
src/flutter/shell/platform/linux_embedded/plugin/platform_plugin.cc
9297
src/flutter/shell/platform/linux_embedded/plugin/mouse_cursor_plugin.cc
98+
src/flutter/shell/platform/linux_embedded/surface/context_egl.cc
9399
src/flutter/shell/platform/linux_embedded/surface/egl_utils.cc
94100
${DISPLAY_BACKEND_SRC}
95101
${WAYLAND_PROTOCOL_SRC}
@@ -152,7 +158,7 @@ target_link_libraries(${TARGET}
152158
${USER_APP_LIBRARIES}
153159
)
154160

155-
if(USE_DRM)
161+
if(${BACKEND_TYPE} MATCHES "DRM-(GBM|EGLSTREAM)")
156162
target_link_libraries(${TARGET}
157163
PRIVATE
158164
Threads::Threads

cmake/package.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ pkg_check_modules(EGL REQUIRED egl)
99
pkg_check_modules(XKBCOMMON REQUIRED xkbcommon)
1010

1111
# depends on backend type.
12-
if(USE_DRM)
12+
if(${BACKEND_TYPE} MATCHES "DRM-(GBM|EGLSTREAM)")
1313
# DRM backend
1414
pkg_check_modules(DRM REQUIRED libdrm)
15-
pkg_check_modules(GBM REQUIRED gbm)
1615
pkg_check_modules(LIBINPUT REQUIRED libinput)
1716
pkg_check_modules(LIBUDEV REQUIRED libudev)
1817
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
18+
if(${BACKEND_TYPE} STREQUAL "DRM-GBM")
19+
pkg_check_modules(GBM REQUIRED gbm)
20+
endif()
1921
set(THREADS_PREFER_PTHREAD_FLAG ON)
2022
find_package(Threads REQUIRED)
21-
elseif(USE_X11)
23+
elseif(${BACKEND_TYPE} STREQUAL "X11")
2224
pkg_check_modules(X11 REQUIRED x11)
2325
else()
2426
# Wayland backend

examples/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ These are an example of how to use embedded Linux embedding for Flutter.
77
- [flutter-wayland-client](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-wayland-client): Wayland client app
88
- [flutter-weston-desktop-shell](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-weston-desktop-shell): Works on Weston desktop-shell
99
- [flutter-weston-desktop-shell-virtual-keyboard](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-weston-desktop-shell-virtual-keyboard): Works on Weston desktop-shell with the virtual keyboard
10-
- [flutter-drm-backend](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-drm-backend): Fullscreen app on DRM backend
10+
- [flutter-drm-gbm-backend](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-drm-gbm-backend): Fullscreen app on DRM backend with GBM
11+
- [flutter-drm-eglstream-backend](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-drm-eglstream-backend): Fullscreen app on DRM backend with EGLStream
1112
- [flutter-x11-client](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-x11-client): X11 client app
1213
- [flutter-external-texture-plugin](https://github.com/sony/flutter-embedded-linux/tree/master/examples/flutter-external-texture-plugin): Wayland client app using external texture plugin
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Overview
2+
3+
This is the example of DRM backend with EGLStream.
4+
5+
## Building
6+
7+
```Shell
8+
$ mkdir build
9+
$ cd build
10+
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend ..
11+
$ cmake --build .
12+
```
13+
14+
## Running Flutter app
15+
16+
You need to switch from GUI which is running X11 or Wayland to the Character User Interface (CUI). In addition, `FLUTTER_DRM_DEVICE` must be set properly. The default value is `/dev/dri/card0`.
17+
18+
```Shell
19+
$ Ctrl + Alt + F3 # Switching to CUI
20+
$ FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-eglstream-backend FLUTTER_BUNDLE_PATH
21+
```
22+
23+
Note that replace `FLUTTER_BUNDLE_PATH` with the flutter bundle path you want to use like ./sample/build/linux/x64/release/bundle.
24+
25+
If you want to switch back from CUI to GUI, run `Ctrl + Alt + F2` keys in a terminal.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
# user binary name.
4+
set(TARGET flutter-drm-eglstream-backend)
5+
6+
# source files for user apps.
7+
set(USER_APP_SRCS
8+
examples/flutter-drm-eglstream-backend/main.cc
9+
)
10+
11+
# header files for user apps.
12+
set(USER_APP_INCLUDE_DIRS
13+
## Public APIs for developers (Don't edit!).
14+
src/client_wrapper/include
15+
src/flutter/shell/platform/common/client_wrapper
16+
src/flutter/shell/platform/common/client_wrapper/include/flutter
17+
src/flutter/shell/platform/common/public
18+
src/flutter/shell/platform/linux_embedded/public
19+
src/public/include
20+
## header file include path for user apps.
21+
examples/flutter-drm-eglstream-backend
22+
)
23+
24+
# link libraries for user apps.
25+
set(USER_APP_LIBRARIES "")

examples/flutter-drm-backend/cmake/user_config.cmake renamed to examples/flutter-drm-eglstream-backend/cmake/user_config.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
# Flutter embedder configurations.
44
# See: https://github.com/sony/flutter-embedded-linux#user-configuration-parameters-cmake-options
5-
set(USE_DRM ON)
6-
set(USE_X11 OFF)
5+
set(BACKEND_TYPE DRM-EGLSTREAM)
76
set(DESKTOP_SHELL OFF)
87
set(USE_VIRTUAL_KEYBOARD OFF)
98
set(USE_GLES3 OFF)

0 commit comments

Comments
 (0)