Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8a5e823
Implement FlutterTizenView foundation
bbrto21 Apr 8, 2022
d29bd8f
Add graphics callback to FlutterTizenView
bbrto21 Apr 12, 2022
aaed4a7
Change flutter-tizen API names
bbrto21 Apr 13, 2022
9ebdd2e
Implement FlutterTizenView, FlutterTizenWindow
bbrto21 Apr 18, 2022
638665d
Refactor touch event
bbrto21 Apr 19, 2022
0fdd175
Add GetRotatoin to FlutterTizenWindow
bbrto21 Apr 19, 2022
4377447
Move window dependent channels to FlutterTizenView
bbrto21 Apr 20, 2022
b8a42f0
Refactor key event
bbrto21 Apr 20, 2022
b45925d
Update window related minor things
bbrto21 Apr 20, 2022
b5e3fad
Fix a WindowChannel bug
bbrto21 Apr 20, 2022
bd6632a
Rename TizenWindow
bbrto21 Apr 20, 2022
745212a
Cleanup minor things
bbrto21 Apr 20, 2022
30746fa
Implement TizenWindowElementary
bbrto21 Apr 21, 2022
11aaa65
Fix gn format error
bbrto21 Apr 22, 2022
73ca452
Fix a bug on headless
bbrto21 Apr 22, 2022
8b379af
Fix a custom dart entrypoint bug
bbrto21 Apr 22, 2022
36fecf5
Remove a headed property
bbrto21 Apr 22, 2022
8c26155
Fix a crash on testing
bbrto21 Apr 22, 2022
394fc64
Remove prefix "FlutterXXX"
bbrto21 Apr 26, 2022
2f3ae4c
Adding a trailing comma for readability
bbrto21 Apr 26, 2022
319e5c1
Add null check for custom entrypoint
bbrto21 Apr 26, 2022
7030839
Update based on review
bbrto21 Apr 26, 2022
0fd880d
Change API name based on review
bbrto21 Apr 26, 2022
3c913a3
Update based on review
bbrto21 Apr 28, 2022
4fb0343
Clean up minor things
bbrto21 Apr 28, 2022
6cca9bf
Update based on review
bbrto21 Apr 29, 2022
e7781a9
Remove prefix "FLUTTER" from protection macro
bbrto21 May 2, 2022
b989ba3
Fix a typo
bbrto21 May 2, 2022
2910892
Fix regression changes
bbrto21 May 2, 2022
6d136c4
Call bindKeys when Creating the view
bbrto21 May 3, 2022
5fef421
Updated based on review
bbrto21 May 3, 2022
67324df
Fix a typo
bbrto21 May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ template("embedder") {
"flutter_tizen.cc",
"flutter_tizen_engine.cc",
"flutter_tizen_texture_registrar.cc",
"key_event_handler.cc",
"flutter_tizen_view.cc",
"logger.cc",
"system_utils.cc",
"tizen_event_loop.cc",
"tizen_input_method_context.cc",
"tizen_renderer.cc",
"touch_event_handler.cc",
]

if (target_name != "flutter_tizen_wearable") {
Expand Down Expand Up @@ -185,7 +184,11 @@ template("embedder") {
]

if (use_evas_gl_renderer) {
sources += [ "tizen_renderer_evas_gl.cc" ]
sources += [
"flutter_tizen_elementary.cc",
"tizen_renderer_evas_gl.cc",
"tizen_window_elementary.cc",
]

libs += [
"ecore_evas",
Expand All @@ -196,8 +199,10 @@ template("embedder") {
public_configs += [ ":evas_gl_renderer" ]
} else {
sources += [
"tizen_renderer_ecore_wl2.cc",
"flutter_tizen_ecore.cc",
"tizen_renderer_egl.cc",
"tizen_vsync_waiter.cc",
"tizen_window_ecore_wl2.cc",
]

libs += [
Expand Down
16 changes: 8 additions & 8 deletions shell/platform/tizen/channels/platform_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ std::string text_clipboard = "";
} // namespace

PlatformChannel::PlatformChannel(BinaryMessenger* messenger,
TizenRenderer* renderer)
TizenWindow* window)
: channel_(std::make_unique<MethodChannel<rapidjson::Document>>(
messenger,
kChannelName,
&JsonMethodCodec::GetInstance())),
renderer_(renderer) {
window_(window) {
channel_->SetMethodCallHandler(
[this](const MethodCall<rapidjson::Document>& call,
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
Expand Down Expand Up @@ -164,13 +164,13 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) {
}

void PlatformChannel::RestoreSystemUiOverlays() {
if (!renderer_) {
if (!window_) {
return;
}

#ifdef COMMON_PROFILE
auto& shell = TizenShell::GetInstance();
shell.InitializeSoftkey(renderer_->GetWindowId());
shell.InitializeSoftkey(window_->GetWindowId());

if (shell.IsSoftkeyShown()) {
shell.ShowSoftkey();
Expand All @@ -182,13 +182,13 @@ void PlatformChannel::RestoreSystemUiOverlays() {

void PlatformChannel::SetEnabledSystemUiOverlays(
const std::vector<std::string>& overlays) {
if (!renderer_) {
if (!window_) {
return;
}

#ifdef COMMON_PROFILE
auto& shell = TizenShell::GetInstance();
shell.InitializeSoftkey(renderer_->GetWindowId());
shell.InitializeSoftkey(window_->GetWindowId());

if (std::find(overlays.begin(), overlays.end(), kSystemUiOverlayBottom) !=
overlays.end()) {
Expand All @@ -201,7 +201,7 @@ void PlatformChannel::SetEnabledSystemUiOverlays(

void PlatformChannel::SetPreferredOrientations(
const std::vector<std::string>& orientations) {
if (!renderer_) {
if (!window_) {
return;
}

Expand All @@ -220,7 +220,7 @@ void PlatformChannel::SetPreferredOrientations(
// default.
rotations = {0, 90, 180, 270};
}
renderer_->SetPreferredOrientations(rotations);
window_->SetPreferredOrientations(rotations);
}

} // namespace flutter
8 changes: 4 additions & 4 deletions shell/platform/tizen/channels/platform_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#include "flutter/shell/platform/tizen/tizen_window.h"
#include "rapidjson/document.h"

namespace flutter {

class PlatformChannel {
public:
explicit PlatformChannel(BinaryMessenger* messenger, TizenRenderer* renderer);
explicit PlatformChannel(BinaryMessenger* messenger, TizenWindow* window);
virtual ~PlatformChannel();

private:
Expand All @@ -35,9 +35,9 @@ class PlatformChannel {

std::unique_ptr<MethodChannel<rapidjson::Document>> channel_;

// A reference to the renderer object managed by FlutterTizenEngine.
// A reference to the window object managed by FlutterTizenView.
// This can be nullptr if the engine is running in headless mode.
TizenRenderer* renderer_;
TizenWindow* window_;
};

} // namespace flutter
Expand Down
37 changes: 20 additions & 17 deletions shell/platform/tizen/channels/window_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ constexpr char kChannelName[] = "tizen/internal/window";

} // namespace

WindowChannel::WindowChannel(BinaryMessenger* messenger,
TizenRenderer* renderer,
TizenRenderer::Delegate* delegate)
: renderer_(renderer), delegate_(delegate) {
WindowChannel::WindowChannel(BinaryMessenger* messenger, TizenWindow* window)
: window_(window) {
channel_ = std::make_unique<MethodChannel<EncodableValue>>(
messenger, kChannelName, &StandardMethodCodec::GetInstance());
channel_->SetMethodCallHandler(
Expand All @@ -37,12 +35,12 @@ void WindowChannel::HandleMethodCall(
const std::string& method_name = method_call.method_name();

if (method_name == "getWindowGeometry") {
TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry();
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
EncodableMap map;
map[EncodableValue("x")] = EncodableValue(geometry.x);
map[EncodableValue("y")] = EncodableValue(geometry.y);
map[EncodableValue("width")] = EncodableValue(geometry.w);
map[EncodableValue("height")] = EncodableValue(geometry.h);
map[EncodableValue("x")] = EncodableValue(geometry.left);
map[EncodableValue("y")] = EncodableValue(geometry.top);
map[EncodableValue("width")] = EncodableValue(geometry.width);
map[EncodableValue("height")] = EncodableValue(geometry.height);
result->Success(EncodableValue(map));
} else if (method_name == "setWindowGeometry") {
#ifdef TIZEN_RENDERER_EVAS_GL
Expand All @@ -59,18 +57,23 @@ void WindowChannel::HandleMethodCall(
EncodableValueHolder<int32_t> width(arguments, "width");
EncodableValueHolder<int32_t> height(arguments, "height");

TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry();

delegate_->OnGeometryChange(x ? *x : geometry.x, y ? *y : geometry.y,
width ? *width : geometry.w,
height ? *height : geometry.h);
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
// FIXME: Use SetWindowGeometry() instead of OnGeometryChanged()
// After the SetWindowGeometry was successfully executed, I expected a
// handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't.
window_->OnGeometryChanged({
x ? *x : geometry.left,
y ? *y : geometry.top,
width ? *width : geometry.width,
height ? *height : geometry.height,
});
result->Success();
#endif
} else if (method_name == "getScreenGeometry") {
TizenRenderer::Geometry geometry = renderer_->GetScreenGeometry();
TizenWindow::Geometry geometry = window_->GetScreenGeometry();
EncodableMap map;
map[EncodableValue("width")] = EncodableValue(geometry.w);
map[EncodableValue("height")] = EncodableValue(geometry.h);
map[EncodableValue("width")] = EncodableValue(geometry.width);
map[EncodableValue("height")] = EncodableValue(geometry.height);
result->Success(EncodableValue(map));
} else {
result->NotImplemented();
Expand Down
13 changes: 4 additions & 9 deletions shell/platform/tizen/channels/window_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#include "flutter/shell/platform/tizen/tizen_window.h"

namespace flutter {

// Channel to get/set application's window size and device's screen size.
class WindowChannel {
public:
explicit WindowChannel(BinaryMessenger* messenger,
TizenRenderer* renderer,
TizenRenderer::Delegate* delegate);
explicit WindowChannel(BinaryMessenger* messenger, TizenWindow* window);
virtual ~WindowChannel();

private:
Expand All @@ -28,11 +26,8 @@ class WindowChannel {

std::unique_ptr<MethodChannel<EncodableValue>> channel_;

// A reference to the renderer object managed by FlutterTizenEngine.
// This can be nullptr if the engine is running in headless mode.
TizenRenderer* renderer_;

[[maybe_unused]] TizenRenderer::Delegate* delegate_;
// A reference to the renderer object managed by FlutterTizenView.
TizenWindow* window_;
};

} // namespace flutter
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/tizen/flutter_project_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ FlutterProjectBundle::FlutterProjectBundle(
aot_library_path_ = std::filesystem::path(properties.aot_library_path);
}

if (properties.entrypoint != nullptr) {
custom_dart_entrypoint_ = std::string(properties.entrypoint);
}

for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
dart_entrypoint_arguments_.push_back(
std::string(properties.dart_entrypoint_argv[i]));
Expand Down
8 changes: 8 additions & 0 deletions shell/platform/tizen/flutter_project_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class FlutterProjectBundle {
// Logs and returns nullptr on failure.
UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs);

// Returns custom entrypoint in the Dart project.
const std::string& custom_dart_entrypoint() {
return custom_dart_entrypoint_;
}

// Returns the command line arguments to be passed through to the Dart
// entrypoint.
const std::vector<std::string>& dart_entrypoint_arguments() const {
Expand All @@ -70,6 +75,9 @@ class FlutterProjectBundle {
// Path to the AOT library file, if any.
std::filesystem::path aot_library_path_;

// Custom entrypoint in the Dart project
std::string custom_dart_entrypoint_;
Copy link
Member

@bwikbs bwikbs Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? I mean.. What scenario was it made for? I thought this was necessary for a certain scenario... I wonder what it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A most typical scenario is a multi-packaging app.
this is not a new feature, it has just been refactored. please see this


// Dart entrypoint arguments.
std::vector<std::string> dart_entrypoint_arguments_;
};
Expand Down
45 changes: 21 additions & 24 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
#include "flutter/shell/platform/tizen/flutter_project_bundle.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/flutter_tizen_view.h"
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
#include "flutter/shell/platform/tizen/tizen_window.h"

namespace {

Expand Down Expand Up @@ -39,8 +41,7 @@ FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(

} // namespace

FlutterDesktopEngineRef FlutterDesktopRunEngine(
const FlutterDesktopWindowProperties& window_properties,
FlutterDesktopEngineRef FlutterDesktopEngineCreate(
const FlutterDesktopEngineProperties& engine_properties) {
flutter::FlutterProjectBundle project(engine_properties);
if (project.HasArgument("--verbose-logging")) {
Expand All @@ -53,29 +54,24 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine(
flutter::Logger::Start();

auto engine = std::make_unique<flutter::FlutterTizenEngine>(project);
if (window_properties.headed) {
engine->InitializeRenderer(
window_properties.x, window_properties.y, window_properties.width,
window_properties.height, window_properties.transparent,
window_properties.focusable, window_properties.top_level);
}
if (!engine->RunEngine(engine_properties.entrypoint)) {
FT_LOG(Error) << "Failed to start the Flutter engine.";
return nullptr;
}
return HandleForEngine(engine.release());
}

void FlutterDesktopShutdownEngine(FlutterDesktopEngineRef engine_ref) {
bool FlutterDesktopEngineRun(const FlutterDesktopEngineRef engine) {
return EngineFromHandle(engine)->RunEngine();
}

void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) {
flutter::Logger::Stop();

flutter::FlutterTizenEngine* engine = EngineFromHandle(engine_ref);
engine->StopEngine();
delete engine;
}

void* FlutterDesktopGetWindow(FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->renderer()->GetWindowHandle();
void* FlutterDesktopPluginRegistrarGetNativeWindow(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->view()->window()->GetWindowHandle();
}

void FlutterDesktopPluginRegistrarEnableInputBlocking(
Expand All @@ -85,7 +81,7 @@ void FlutterDesktopPluginRegistrarEnableInputBlocking(
channel);
}

FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar(
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(
FlutterDesktopEngineRef engine,
const char* plugin_name) {
// Currently, one registrar acts as the registrar for all plugins, so the
Expand Down Expand Up @@ -144,33 +140,34 @@ void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger,
user_data);
}

void FlutterDesktopNotifyAppControl(FlutterDesktopEngineRef engine,
void* app_control) {
void FlutterDesktopEngineNotifyAppControl(FlutterDesktopEngineRef engine,
void* app_control) {
EngineFromHandle(engine)->app_control_channel()->NotifyAppControl(
app_control);
}

void FlutterDesktopNotifyLocaleChange(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyLocaleChange(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->SetupLocales();
}

void FlutterDesktopNotifyLowMemoryWarning(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyLowMemoryWarning(
FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->NotifyLowMemoryWarning();
}

void FlutterDesktopNotifyAppIsInactive(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyAppIsInactive(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsInactive();
}

void FlutterDesktopNotifyAppIsResumed(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyAppIsResumed(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsResumed();
}

void FlutterDesktopNotifyAppIsPaused(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyAppIsPaused(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsPaused();
}

void FlutterDesktopNotifyAppIsDetached(FlutterDesktopEngineRef engine) {
void FlutterDesktopEngineNotifyAppIsDetached(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsDetached();
}

Expand Down
Loading