-
Notifications
You must be signed in to change notification settings - Fork 142
Support eglstream #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f163cb9
Merge remote-tracking branch 'upstream/master'
fc267c1
Merge remote-tracking branch 'upstream/master'
6ad3367
Merge remote-tracking branch 'upstream/master'
0d59e1a
Merge remote-tracking branch 'upstream/master'
497db10
Merge remote-tracking branch 'upstream/master'
6498e88
Merge remote-tracking branch 'upstream/master'
631076a
Merge remote-tracking branch 'upstream/master'
f768b00
Support EGLStream.
da721c6
Fix build error.
f06beaa
Fix for review.
a8fd283
Revert "Support EGLStream."
956b045
Merge remote-tracking branch 'upstream/master'
71b7824
Merge remote-tracking branch 'origin/master' into support-eglstream
b17ff6d
Merge remote-tracking branch 'upstream/master'
076247c
Fix for review.
0cd98a6
Merge remote-tracking branch 'origin/master' into support-eglstream
8c6b973
Fix for review.
9d99dce
Fix for review.
424a534
Fix for review.
9750544
Fix for review.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Overview | ||
|
||
This is the example of DRM backend with EGLStream. | ||
|
||
## Building | ||
|
||
```Shell | ||
$ mkdir build | ||
$ cd build | ||
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend .. | ||
$ cmake --build . | ||
``` | ||
|
||
## Running Flutter app | ||
|
||
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`. | ||
|
||
```Shell | ||
$ Ctrl + Alt + F3 # Switching to CUI | ||
$ FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-eglstream-backend FLUTTER_BUNDLE_PATH | ||
``` | ||
|
||
Note that replace `FLUTTER_BUNDLE_PATH` with the flutter bundle path you want to use like ./sample/build/linux/x64/release/bundle. | ||
|
||
If you want to switch back from CUI to GUI, run `Ctrl + Alt + F2` keys in a terminal. |
25 changes: 25 additions & 0 deletions
25
examples/flutter-drm-eglstream-backend/cmake/user_build.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# user binary name. | ||
set(TARGET flutter-drm-eglstream-backend) | ||
|
||
# source files for user apps. | ||
set(USER_APP_SRCS | ||
examples/flutter-drm-eglstream-backend/main.cc | ||
) | ||
|
||
# header files for user apps. | ||
set(USER_APP_INCLUDE_DIRS | ||
## Public APIs for developers (Don't edit!). | ||
src/client_wrapper/include | ||
src/flutter/shell/platform/common/client_wrapper | ||
src/flutter/shell/platform/common/client_wrapper/include/flutter | ||
src/flutter/shell/platform/common/public | ||
src/flutter/shell/platform/linux_embedded/public | ||
src/public/include | ||
## header file include path for user apps. | ||
examples/flutter-drm-eglstream-backend | ||
) | ||
|
||
# link libraries for user apps. | ||
set(USER_APP_LIBRARIES "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# Flutter embedder configurations. | ||
# See: https://github.com/sony/flutter-embedded-linux#user-configuration-parameters-cmake-options | ||
set(BACKEND_TYPE DRM-GBM) | ||
set(DESKTOP_SHELL OFF) | ||
set(USE_VIRTUAL_KEYBOARD OFF) | ||
set(USE_GLES3 OFF) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2021 Sony Corporation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <flutter/dart_project.h> | ||
#include <flutter/flutter_view_controller.h> | ||
|
||
#include <chrono> | ||
#include <iostream> | ||
#include <memory> | ||
#include <string> | ||
#include <thread> | ||
|
||
static void PrintHelp() { | ||
std::cout << "Usage: ./${execute filename} {Flutter project bundle path}" | ||
<< std::endl; | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
if (argc != 2) { | ||
PrintHelp(); | ||
return 0; | ||
} | ||
|
||
bool show_cursor = true; | ||
std::string str(argv[1]); | ||
std::wstring fl_path(str.begin(), str.end()); | ||
|
||
// The project to run. | ||
flutter::DartProject project(fl_path); | ||
auto command_line_arguments = std::vector<std::string>(); | ||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); | ||
|
||
// The Flutter instance hosted by this window. | ||
int width = 640; | ||
int height = 480; | ||
auto flutter_controller = std::make_unique<flutter::FlutterViewController>( | ||
flutter::FlutterViewController::ViewMode::kFullscreen, width, height, | ||
show_cursor, project); | ||
|
||
// Ensure that basic setup of the controller was successful. | ||
if (!flutter_controller->engine() || !flutter_controller->view()) { | ||
return 0; | ||
} | ||
|
||
// Main loop. | ||
auto next_flutter_event_time = | ||
std::chrono::steady_clock::time_point::clock::now(); | ||
while (flutter_controller->view()->DispatchEvent()) { | ||
// Wait until the next event. | ||
{ | ||
auto wait_duration = | ||
std::max(std::chrono::nanoseconds(0), | ||
next_flutter_event_time - | ||
std::chrono::steady_clock::time_point::clock::now()); | ||
std::this_thread::sleep_for( | ||
std::chrono::duration_cast<std::chrono::milliseconds>(wait_duration)); | ||
} | ||
|
||
// Processes any pending events in the Flutter engine, and returns the | ||
// number of nanoseconds until the next scheduled event (or max, if none). | ||
auto wait_duration = flutter_controller->engine()->ProcessMessages(); | ||
{ | ||
auto next_event_time = std::chrono::steady_clock::time_point::max(); | ||
if (wait_duration != std::chrono::nanoseconds::max()) { | ||
auto next_wakeup = | ||
std::max(std::chrono::steady_clock::time_point::max(), | ||
std::chrono::steady_clock::time_point::clock::now() + | ||
wait_duration); | ||
next_event_time = std::min(next_event_time, next_wakeup); | ||
} else { | ||
// Wait 1/60 [sec] = 13 [msec] if no events. | ||
next_event_time = std::chrono::steady_clock::time_point::clock::now() + | ||
std::chrono::milliseconds(13); | ||
} | ||
next_flutter_event_time = | ||
std::max(next_flutter_event_time, next_event_time); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.