Skip to content

Commit a1a960d

Browse files
committed
Introduce to 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 1730d83 commit a1a960d

24 files changed

+652
-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: 15 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,17 @@ 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+
}

shell/platform/tizen/flutter_tizen_elementary.cc

Lines changed: 41 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,42 @@ 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+
}

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);

shell/platform/tizen/flutter_tizen_view.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const std::vector<std::string> kBindableSystemKeys = {
4040

4141
namespace flutter {
4242

43-
FlutterTizenView::FlutterTizenView(std::unique_ptr<TizenWindow> window)
44-
: window_(std::move(window)) {
45-
window_->SetView(this);
46-
window_->BindKeys(kBindableSystemKeys);
43+
FlutterTizenView::FlutterTizenView(std::unique_ptr<TizenBaseHandle> handle)
44+
: handle_(std::move(handle)) {
45+
handle_->SetView(this);
46+
handle_->BindKeys(kBindableSystemKeys);
4747
}
4848

4949
FlutterTizenView::~FlutterTizenView() {}
@@ -58,18 +58,18 @@ void FlutterTizenView::SetEngine(std::unique_ptr<FlutterTizenEngine> engine) {
5858
// Set up window dependent channels.
5959
BinaryMessenger* messenger = internal_plugin_registrar_->messenger();
6060
platform_channel_ =
61-
std::make_unique<PlatformChannel>(messenger, window_.get());
62-
window_channel_ = std::make_unique<WindowChannel>(messenger, window_.get());
61+
std::make_unique<PlatformChannel>(messenger, handle_.get());
62+
window_channel_ = std::make_unique<WindowChannel>(messenger, handle_.get());
6363
text_input_channel_ = std::make_unique<TextInputChannel>(
6464
internal_plugin_registrar_->messenger(),
65-
std::make_unique<TizenInputMethodContext>(window_.get()));
65+
std::make_unique<TizenInputMethodContext>(handle_.get()));
6666
}
6767

6868
void FlutterTizenView::CreateRenderSurface() {
6969
if (engine_ && engine_->renderer()) {
70-
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
71-
engine_->renderer()->CreateSurface(window_->GetRenderTarget(),
72-
window_->GetRenderTargetDisplay(),
70+
TizenBaseHandle::Geometry geometry = handle_->GetRenderTargetGeometry();
71+
engine_->renderer()->CreateSurface(handle_->GetRenderTarget(),
72+
handle_->GetRenderTargetDisplay(),
7373
geometry.width, geometry.height);
7474
}
7575
}
@@ -112,7 +112,7 @@ void FlutterTizenView::OnResize(int32_t left,
112112
std::swap(width, height);
113113
}
114114

115-
window_->ResizeRenderTargetWithRotation({left, top, width, height},
115+
handle_->ResizeRenderTargetWithRotation({left, top, width, height},
116116
rotation_degree_);
117117
SendWindowMetrics(left, top, width, height, 0.0);
118118
}
@@ -121,7 +121,7 @@ void FlutterTizenView::OnRotate(int32_t degree) {
121121
rotation_degree_ = degree;
122122
// Compute renderer transformation based on the angle of rotation.
123123
double rad = (360 - rotation_degree_) * M_PI / 180;
124-
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
124+
TizenBaseHandle::Geometry geometry = handle_->GetRenderTargetGeometry();
125125
int32_t width = geometry.width;
126126
int32_t height = geometry.height;
127127

@@ -145,7 +145,7 @@ void FlutterTizenView::OnRotate(int32_t degree) {
145145
std::swap(width, height);
146146
}
147147

148-
window_->ResizeRenderTargetWithRotation(
148+
handle_->ResizeRenderTargetWithRotation(
149149
{geometry.left, geometry.top, width, height}, rotation_degree_);
150150

151151
// Window position does not change on rotation regardless of its orientation.
@@ -231,7 +231,7 @@ void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) {
231231
}
232232

233233
void FlutterTizenView::SendInitialGeometry() {
234-
OnRotate(window_->GetRotation());
234+
OnRotate(handle_->GetRotation());
235235
}
236236

237237
void FlutterTizenView::SendWindowMetrics(int32_t left,
@@ -247,7 +247,7 @@ void FlutterTizenView::SendWindowMetrics(int32_t left,
247247
#ifdef TV_PROFILE
248248
double dpi = 72.0;
249249
#else
250-
double dpi = static_cast<double>(window_->GetDpi());
250+
double dpi = static_cast<double>(handle_->GetDpi());
251251
#endif
252252
double scale_factor = dpi / 90.0 * kProfileFactor;
253253
computed_pixel_ratio = std::max(scale_factor, 1.0);
@@ -267,7 +267,7 @@ void FlutterTizenView::SendFlutterPointerEvent(
267267
size_t timestamp,
268268
FlutterPointerDeviceKind device_kind,
269269
int device_id) {
270-
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
270+
TizenBaseHandle::Geometry geometry = handle_->GetRenderTargetGeometry();
271271
double new_x = x, new_y = y;
272272

273273
if (rotation_degree_ == 90) {
@@ -284,8 +284,8 @@ void FlutterTizenView::SendFlutterPointerEvent(
284284
FlutterPointerEvent event = {};
285285
event.struct_size = sizeof(event);
286286
event.phase = phase;
287-
event.x = new_x;
288-
event.y = new_y;
287+
event.x = new_x - geometry.left;
288+
event.y = new_y - geometry.top;
289289
if (delta_x != 0 || delta_y != 0) {
290290
event.signal_kind = kFlutterPointerSignalKindScroll;
291291
}

0 commit comments

Comments
 (0)