Skip to content

Commit a38eea4

Browse files
committed
Introduce TizenViewElementary
There are two ways to draw FlutterTizenView in Tizen. (TizenWindowElementary and TizenWindowEcore) Both ways are drawing on Window component(surface). We try to draw FlutterTizenView on the appropriate component provided by Tizen UIFW and support it to be place with other components. To do that, we created a TizenView class on the same level as TizenWindow and abstracted common methods to TizenBaseHandle. we can add FlutterTizenView to other UIFW of Tizen while adding TizenView{?}(maybe Tizen NUI). TizenBaseHandle -> TizenView -> TizenViewElementary -> TizenView{?} -> TizenWindow -> TizenWindowElementary -> TizenWindowEcore There are a few unimplemented things. This is a plan to be added later. - We need to add API related to App Event (Resume, etc..). - The plans for key input are not yet cleared up.
1 parent 70fa036 commit a38eea4

24 files changed

+646
-119
lines changed

shell/platform/tizen/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ template("embedder") {
187187
sources += [
188188
"flutter_tizen_elementary.cc",
189189
"tizen_renderer_evas_gl.cc",
190+
"tizen_view_elementary.cc",
190191
"tizen_window_elementary.cc",
191192
]
192193

shell/platform/tizen/channels/platform_channel.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ std::string text_clipboard = "";
5858
} // namespace
5959

6060
PlatformChannel::PlatformChannel(BinaryMessenger* messenger,
61-
TizenWindow* window)
61+
TizenBaseHandle* handle)
6262
: channel_(std::make_unique<MethodChannel<rapidjson::Document>>(
6363
messenger,
6464
kChannelName,
6565
&JsonMethodCodec::GetInstance())),
66-
window_(window) {
66+
handle_(handle) {
6767
channel_->SetMethodCallHandler(
6868
[this](const MethodCall<rapidjson::Document>& call,
6969
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
@@ -164,13 +164,13 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) {
164164
}
165165

166166
void PlatformChannel::RestoreSystemUiOverlays() {
167-
if (!window_) {
167+
if (!handle_) {
168168
return;
169169
}
170170

171171
#ifdef COMMON_PROFILE
172172
auto& shell = TizenShell::GetInstance();
173-
shell.InitializeSoftkey(window_->GetWindowId());
173+
shell.InitializeSoftkey(handle_->GetWindowId());
174174

175175
if (shell.IsSoftkeyShown()) {
176176
shell.ShowSoftkey();
@@ -182,13 +182,13 @@ void PlatformChannel::RestoreSystemUiOverlays() {
182182

183183
void PlatformChannel::SetEnabledSystemUiOverlays(
184184
const std::vector<std::string>& overlays) {
185-
if (!window_) {
185+
if (!handle_) {
186186
return;
187187
}
188188

189189
#ifdef COMMON_PROFILE
190190
auto& shell = TizenShell::GetInstance();
191-
shell.InitializeSoftkey(window_->GetWindowId());
191+
shell.InitializeSoftkey(handle_->GetWindowId());
192192

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

202202
void PlatformChannel::SetPreferredOrientations(
203203
const std::vector<std::string>& orientations) {
204-
if (!window_) {
204+
if (!handle_) {
205205
return;
206206
}
207207

@@ -220,7 +220,7 @@ void PlatformChannel::SetPreferredOrientations(
220220
// default.
221221
rotations = {0, 90, 180, 270};
222222
}
223-
window_->SetPreferredOrientations(rotations);
223+
handle_->SetPreferredOrientations(rotations);
224224
}
225225

226226
} // namespace flutter

shell/platform/tizen/channels/platform_channel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
1313
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
14-
#include "flutter/shell/platform/tizen/tizen_window.h"
14+
#include "flutter/shell/platform/tizen/tizen_base_handle.h"
1515
#include "rapidjson/document.h"
1616

1717
namespace flutter {
1818

1919
class PlatformChannel {
2020
public:
21-
explicit PlatformChannel(BinaryMessenger* messenger, TizenWindow* window);
21+
explicit PlatformChannel(BinaryMessenger* messenger, TizenBaseHandle* handle);
2222
virtual ~PlatformChannel();
2323

2424
private:
@@ -35,9 +35,9 @@ class PlatformChannel {
3535

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

38-
// A reference to the window object managed by FlutterTizenView.
38+
// A reference to the base handle object managed by FlutterTizenView.
3939
// This can be nullptr if the engine is running in headless mode.
40-
TizenWindow* window_;
40+
TizenBaseHandle* handle_;
4141
};
4242

4343
} // namespace flutter

shell/platform/tizen/channels/window_channel.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ constexpr char kChannelName[] = "tizen/internal/window";
1616

1717
} // namespace
1818

19-
WindowChannel::WindowChannel(BinaryMessenger* messenger, TizenWindow* window)
20-
: window_(window) {
19+
WindowChannel::WindowChannel(BinaryMessenger* messenger,
20+
TizenBaseHandle* handle)
21+
: handle_(handle) {
2122
channel_ = std::make_unique<MethodChannel<EncodableValue>>(
2223
messenger, kChannelName, &StandardMethodCodec::GetInstance());
2324
channel_->SetMethodCallHandler(
@@ -35,7 +36,7 @@ void WindowChannel::HandleMethodCall(
3536
const std::string& method_name = method_call.method_name();
3637

3738
if (method_name == "getWindowGeometry") {
38-
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
39+
TizenBaseHandle::Geometry geometry = handle_->GetRenderTargetGeometry();
3940
EncodableMap map;
4041
map[EncodableValue("x")] = EncodableValue(geometry.left);
4142
map[EncodableValue("y")] = EncodableValue(geometry.top);
@@ -57,11 +58,11 @@ void WindowChannel::HandleMethodCall(
5758
EncodableValueHolder<int32_t> width(arguments, "width");
5859
EncodableValueHolder<int32_t> height(arguments, "height");
5960

60-
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
61+
TizenBaseHandle::Geometry geometry = handle_->GetRenderTargetGeometry();
6162
// FIXME: Use SetWindowGeometry() instead of OnGeometryChanged()
6263
// After the SetWindowGeometry was successfully executed, I expected a
6364
// handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't.
64-
window_->OnGeometryChanged({
65+
handle_->OnGeometryChanged({
6566
x ? *x : geometry.left,
6667
y ? *y : geometry.top,
6768
width ? *width : geometry.width,
@@ -70,7 +71,7 @@ void WindowChannel::HandleMethodCall(
7071
result->Success();
7172
#endif
7273
} else if (method_name == "getScreenGeometry") {
73-
TizenWindow::Geometry geometry = window_->GetScreenGeometry();
74+
TizenBaseHandle::Geometry geometry = handle_->GetScreenGeometry();
7475
EncodableMap map;
7576
map[EncodableValue("width")] = EncodableValue(geometry.width);
7677
map[EncodableValue("height")] = EncodableValue(geometry.height);

shell/platform/tizen/channels/window_channel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
1111
#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h"
1212
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
13-
#include "flutter/shell/platform/tizen/tizen_window.h"
13+
#include "flutter/shell/platform/tizen/tizen_base_handle.h"
1414

1515
namespace flutter {
1616

1717
// Channel to get/set application's window size and device's screen size.
1818
class WindowChannel {
1919
public:
20-
explicit WindowChannel(BinaryMessenger* messenger, TizenWindow* window);
20+
explicit WindowChannel(BinaryMessenger* messenger, TizenBaseHandle* window);
2121
virtual ~WindowChannel();
2222

2323
private:
@@ -27,7 +27,7 @@ class WindowChannel {
2727
std::unique_ptr<MethodChannel<EncodableValue>> channel_;
2828

2929
// A reference to the renderer object managed by FlutterTizenView.
30-
TizenWindow* window_;
30+
TizenBaseHandle* handle_;
3131
};
3232

3333
} // namespace flutter

shell/platform/tizen/flutter_tizen.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) {
7171

7272
void* FlutterDesktopPluginRegistrarGetNativeWindow(
7373
FlutterDesktopPluginRegistrarRef registrar) {
74-
return registrar->engine->view()->window()->GetWindowHandle();
74+
return registrar->engine->view()->handle()->GetWindowHandle();
7575
}
7676

7777
void FlutterDesktopPluginRegistrarEnableInputBlocking(

shell/platform/tizen/flutter_tizen_ecore.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) {
2424
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
2525
const FlutterDesktopWindowProperties& window_properties,
2626
FlutterDesktopEngineRef engine) {
27-
flutter::TizenWindow::Geometry window_geometry = {
27+
flutter::TizenBaseHandle::Geometry window_geometry = {
2828
window_properties.x,
2929
window_properties.y,
3030
window_properties.width,
@@ -52,3 +52,23 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
5252

5353
return HandleForView(view.release());
5454
}
55+
56+
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewView(
57+
const FlutterDesktopViewProperties& view_properties,
58+
FlutterDesktopEngineRef engine,
59+
void* elm_parent) {
60+
// Not supported.
61+
62+
return nullptr;
63+
}
64+
65+
void* FlutterDesktopViewGetEvasImageHandle(FlutterDesktopEngineRef engine) {
66+
// Not supported.
67+
return nullptr;
68+
}
69+
70+
void FlutterDesktopViewResizeView(FlutterDesktopEngineRef engine,
71+
int32_t width,
72+
int32_t height) {
73+
// Not supported.
74+
}

shell/platform/tizen/flutter_tizen_elementary.cc

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
88
#include "flutter/shell/platform/tizen/flutter_tizen_view.h"
9+
#include "flutter/shell/platform/tizen/tizen_view_elementary.h"
910
#include "flutter/shell/platform/tizen/tizen_window_elementary.h"
1011

1112
namespace {
@@ -24,7 +25,7 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) {
2425
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
2526
const FlutterDesktopWindowProperties& window_properties,
2627
FlutterDesktopEngineRef engine) {
27-
flutter::TizenWindow::Geometry window_geometry = {
28+
flutter::TizenBaseHandle::Geometry window_geometry = {
2829
window_properties.x,
2930
window_properties.y,
3031
window_properties.width,
@@ -52,3 +53,56 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
5253

5354
return HandleForView(view.release());
5455
}
56+
57+
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewView(
58+
const FlutterDesktopViewProperties& view_properties,
59+
FlutterDesktopEngineRef engine,
60+
void* elm_parent) {
61+
flutter::TizenBaseHandle::Geometry view_geometry = {
62+
0,
63+
0,
64+
view_properties.width,
65+
view_properties.height,
66+
};
67+
68+
std::unique_ptr<flutter::TizenBaseHandle> view =
69+
std::make_unique<flutter::TizenViewElementary>(
70+
view_geometry, (Evas_Object*)(view_properties.elm_parent));
71+
72+
auto flutter_view =
73+
std::make_unique<flutter::FlutterTizenView>(std::move(view));
74+
75+
// Take ownership of the engine, starting it if necessary.
76+
flutter_view->SetEngine(
77+
std::unique_ptr<flutter::FlutterTizenEngine>(EngineFromHandle(engine)));
78+
flutter_view->CreateRenderSurface();
79+
if (!flutter_view->engine()->IsRunning()) {
80+
if (!flutter_view->engine()->RunEngine()) {
81+
return nullptr;
82+
}
83+
}
84+
85+
flutter_view->SendInitialGeometry();
86+
87+
return HandleForView(flutter_view.release());
88+
}
89+
90+
void* FlutterDesktopViewGetEvasImageHandle(FlutterDesktopEngineRef engine) {
91+
flutter::TizenViewElementary* tizenView =
92+
(flutter::TizenViewElementary*)EngineFromHandle(engine)->view()->handle();
93+
return tizenView->GetRenderTargetDisplay();
94+
}
95+
96+
void FlutterDesktopViewResizeView(FlutterDesktopEngineRef engine,
97+
int32_t width,
98+
int32_t height) {
99+
flutter::TizenViewElementary* tizenView =
100+
(flutter::TizenViewElementary*)EngineFromHandle(engine)->view()->handle();
101+
flutter::TizenBaseHandle::Geometry view_geometry = {
102+
0,
103+
0,
104+
width,
105+
height,
106+
};
107+
tizenView->OnGeometryChanged(view_geometry);
108+
}

shell/platform/tizen/flutter_tizen_engine.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions(
536536
bridge->GetFlutterPlatformNodeDelegateFromID(0);
537537
std::shared_ptr<FlutterPlatformWindowDelegateTizen> window =
538538
FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock();
539-
TizenWindow::Geometry geometry =
540-
engine->view_->window()->GetWindowGeometry();
539+
TizenBaseHandle::Geometry geometry =
540+
engine->view_->handle()->GetRenderTargetGeometry();
541541
window->SetGeometry(geometry.left, geometry.top, geometry.width,
542542
geometry.height);
543543
window->SetRootNode(root);

0 commit comments

Comments
 (0)