Skip to content

Commit 2f6ee56

Browse files
JSUYAswift-kim
andauthored
Add external output support (#3)
The eom API only supports elm_win. So TizenWindowElementary supports this. Currently, only HDMI type is available. It can be extended according to the requirements. https://docs.tizen.org/application/native/guides/device/ext-output/ +) How to map input device.(in sdb shell) 1. Check to input event node. $) winfo -input_devices 2. Set to input and output event node $) winfo -input_output_set [input(ex./dev/input/eventX)] [output(ex.HDMIA-1)] related pr : flutter-tizen/flutter-tizen#465 Co-authored-by: Swift Kim <[email protected]>
1 parent b54ad05 commit 2f6ee56

File tree

6 files changed

+113
-12
lines changed

6 files changed

+113
-12
lines changed

flutter/shell/platform/tizen/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config("flutter_tizen_config") {
3838
"${sysroot_path}/usr/include/elementary-1",
3939
"${sysroot_path}/usr/include/emile-1",
4040
"${sysroot_path}/usr/include/eo-1",
41+
"${sysroot_path}/usr/include/eom",
4142
"${sysroot_path}/usr/include/ethumb-1",
4243
"${sysroot_path}/usr/include/ethumb-client-1",
4344
"${sysroot_path}/usr/include/evas-1",
@@ -127,6 +128,7 @@ template("embedder") {
127128
"efl-extension",
128129
"eina",
129130
"elementary",
131+
"eom",
130132
"evas",
131133
"feedback",
132134
"flutter_engine",

flutter/shell/platform/tizen/flutter_tizen.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
204204
if (window_properties.renderer_type == FlutterDesktopRendererType::kEvasGL) {
205205
window = std::make_unique<flutter::TizenWindowElementary>(
206206
window_geometry, window_properties.transparent,
207-
window_properties.focusable, window_properties.top_level);
207+
window_properties.focusable, window_properties.top_level,
208+
window_properties.external_output_type);
208209
} else {
209210
#ifndef WEARABLE_PROFILE
210211
window = std::make_unique<flutter::TizenWindowEcoreWl2>(

flutter/shell/platform/tizen/public/flutter_tizen.h

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ typedef enum {
3838
kMouseMove,
3939
} FlutterDesktopPointerEventType;
4040

41+
typedef enum {
42+
// No external output.
43+
kNone,
44+
// Display to the HDMI external output.
45+
kHDMI,
46+
} FlutterDesktopExternalOutputType;
47+
4148
// Properties for configuring the initial settings of a Flutter window.
4249
typedef struct {
4350
// The x-coordinate of the top left corner of the window.
@@ -56,6 +63,8 @@ typedef struct {
5663
bool top_level;
5764
// The renderer type of the engine.
5865
FlutterDesktopRendererType renderer_type;
66+
// The external output type of the window.
67+
FlutterDesktopExternalOutputType external_output_type;
5968
} FlutterDesktopWindowProperties;
6069

6170
// Properties for configuring the initial settings of a Flutter view.

flutter/shell/platform/tizen/tizen_window_elementary.cc

+85-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "tizen_window_elementary.h"
66

77
#include <efl_extension.h>
8+
#include <eom.h>
89
#include <ui/efl_util.h>
910

1011
#include "flutter/shell/platform/tizen/logger.h"
@@ -34,11 +35,20 @@ uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) {
3435

3536
} // namespace
3637

37-
TizenWindowElementary::TizenWindowElementary(TizenGeometry geometry,
38-
bool transparent,
39-
bool focusable,
40-
bool top_level)
41-
: TizenWindow(geometry, transparent, focusable, top_level) {
38+
TizenWindowElementary::TizenWindowElementary(
39+
TizenGeometry geometry,
40+
bool transparent,
41+
bool focusable,
42+
bool top_level,
43+
FlutterDesktopExternalOutputType external_output_type)
44+
: TizenWindow(geometry, transparent, focusable, top_level),
45+
external_output_type_(external_output_type) {
46+
if (external_output_type_ != FlutterDesktopExternalOutputType::kNone &&
47+
!InitializeExternalOutputManager()) {
48+
FT_LOG(Error) << "Failed to initialize the External Output Manager.";
49+
return;
50+
}
51+
4252
if (!CreateWindow()) {
4353
FT_LOG(Error) << "Failed to create a platform window.";
4454
return;
@@ -51,6 +61,9 @@ TizenWindowElementary::TizenWindowElementary(TizenGeometry geometry,
5161
}
5262

5363
TizenWindowElementary::~TizenWindowElementary() {
64+
if (external_output_type_ != FlutterDesktopExternalOutputType::kNone) {
65+
DestroyExternalOutputManager();
66+
}
5467
UnregisterEventHandlers();
5568
DestroyWindow();
5669
}
@@ -69,11 +82,15 @@ bool TizenWindowElementary::CreateWindow() {
6982
elm_win_aux_hint_add(elm_win_, "wm.policy.win.user.geometry", "1");
7083
#endif
7184

72-
Ecore_Evas* ecore_evas =
73-
ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_));
74-
75-
int32_t width, height;
76-
ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &width, &height);
85+
int32_t width = 0, height = 0;
86+
if (external_output_type_ != FlutterDesktopExternalOutputType::kNone) {
87+
eom_get_output_resolution(external_output_id_, &width, &height);
88+
} else {
89+
Ecore_Evas* ecore_evas =
90+
ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_));
91+
ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &width,
92+
&height);
93+
}
7794
if (width == 0 || height == 0) {
7895
FT_LOG(Error) << "Invalid screen size: " << width << " x " << height;
7996
return false;
@@ -99,6 +116,14 @@ bool TizenWindowElementary::CreateWindow() {
99116
evas_object_image_alpha_set(image_, EINA_TRUE);
100117
elm_win_resize_object_add(elm_win_, image_);
101118

119+
if (external_output_type_ != FlutterDesktopExternalOutputType::kNone) {
120+
if (eom_set_output_window(external_output_id_, elm_win_) !=
121+
EOM_ERROR_NONE) {
122+
FT_LOG(Error) << "eom_set_output_window() failed.";
123+
return false;
124+
}
125+
}
126+
102127
return elm_win_ && image_;
103128
}
104129

@@ -403,4 +428,54 @@ void TizenWindowElementary::PrepareInputMethod() {
403428
[this](std::string str) { view_delegate_->OnCommit(str); });
404429
}
405430

431+
int32_t TizenWindowElementary::GetExternalOutputId() {
432+
int32_t num_ids = 0;
433+
eom_output_id* output_ids = eom_get_eom_output_ids(&num_ids);
434+
if (!output_ids || num_ids == 0) {
435+
FT_LOG(Error) << "No external output found.";
436+
return 0;
437+
}
438+
439+
eom_output_id output_id = 0;
440+
for (int32_t i = 0; i < num_ids; i++) {
441+
eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
442+
eom_get_output_type(output_ids[i], &output_type);
443+
444+
if (external_output_type_ == FlutterDesktopExternalOutputType::kHDMI &&
445+
(output_type == EOM_OUTPUT_TYPE_HDMIA ||
446+
output_type == EOM_OUTPUT_TYPE_HDMIB)) {
447+
output_id = output_ids[i];
448+
break;
449+
}
450+
}
451+
free(output_ids);
452+
return output_id;
453+
}
454+
455+
bool TizenWindowElementary::InitializeExternalOutputManager() {
456+
if (eom_init()) {
457+
FT_LOG(Error) << "eom_init() failed.";
458+
return false;
459+
}
460+
461+
external_output_id_ = GetExternalOutputId();
462+
if (external_output_id_ == 0) {
463+
FT_LOG(Error) << "Invalid external output ID.";
464+
return false;
465+
}
466+
467+
int ret = eom_set_output_attribute(external_output_id_,
468+
EOM_OUTPUT_ATTRIBUTE_NORMAL);
469+
if (ret != EOM_ERROR_NONE) {
470+
FT_LOG(Error)
471+
<< "eom_set_output_attribute() failed. Cannot use external output.";
472+
return false;
473+
}
474+
return true;
475+
}
476+
477+
void TizenWindowElementary::DestroyExternalOutputManager() {
478+
eom_deinit();
479+
}
480+
406481
} // namespace flutter

flutter/shell/platform/tizen/tizen_window_elementary.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <unordered_map>
1313
#include <vector>
1414

15+
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
1516
#include "flutter/shell/platform/tizen/tizen_window.h"
1617

1718
namespace flutter {
@@ -21,7 +22,8 @@ class TizenWindowElementary : public TizenWindow {
2122
TizenWindowElementary(TizenGeometry geometry,
2223
bool transparent,
2324
bool focusable,
24-
bool top_level);
25+
bool top_level,
26+
FlutterDesktopExternalOutputType external_output_type);
2527

2628
~TizenWindowElementary();
2729

@@ -50,6 +52,12 @@ class TizenWindowElementary : public TizenWindow {
5052
void Show() override;
5153

5254
private:
55+
bool InitializeExternalOutputManager();
56+
57+
void DestroyExternalOutputManager();
58+
59+
int GetExternalOutputId();
60+
5361
bool CreateWindow();
5462

5563
void DestroyWindow();
@@ -68,6 +76,10 @@ class TizenWindowElementary : public TizenWindow {
6876
Evas_Smart_Cb rotation_changed_callback_ = nullptr;
6977
std::unordered_map<Evas_Callback_Type, Evas_Object_Event_Cb>
7078
evas_object_callbacks_;
79+
80+
int32_t external_output_id_;
81+
FlutterDesktopExternalOutputType external_output_type_ =
82+
FlutterDesktopExternalOutputType::kNone;
7183
};
7284

7385
} // namespace flutter

tools/generate_sysroot.py

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
'jsoncpp-devel',
8686
'libatk',
8787
'libatk-bridge-2_0-0',
88+
'libeom',
89+
'libeom-devel',
8890
'libfeedback',
8991
'libfeedback-devel',
9092
'libdlog',

0 commit comments

Comments
 (0)