Skip to content

Commit 1b27461

Browse files
committed
Add basic shell for test
Signed-off-by: MuHong Byun <[email protected]>
1 parent 803d7d5 commit 1b27461

File tree

3 files changed

+176
-4
lines changed

3 files changed

+176
-4
lines changed

shell/platform/tizen/BUILD.gn

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
4-
54
import("//flutter/shell/platform/common/client_wrapper/publish.gni")
65
import("//flutter/shell/platform/config.gni")
76
import("//flutter/shell/platform/tizen/config.gni")
@@ -14,6 +13,10 @@ config("tizen_embedder_rpath") {
1413
ldflags = [ "-Wl,-rpath,\$ORIGIN" ]
1514
}
1615

16+
config("relative_angle_headers") {
17+
include_dirs = [ "//third_party/angle/include" ]
18+
}
19+
1720
source_set("flutter_engine") {
1821
visibility = [ ":*" ]
1922

@@ -53,8 +56,6 @@ _libs_minimum = [
5356
"ecore_input",
5457
"eina",
5558
"evas",
56-
"EGL",
57-
"GLESv2",
5859
"wayland-client",
5960
]
6061

@@ -138,6 +139,8 @@ template("embedder_for_profile") {
138139
"feedback",
139140
"tbm",
140141
"tdm-client",
142+
"EGL",
143+
"GLESv2",
141144
]
142145
}
143146

@@ -236,6 +239,7 @@ executable("flutter_tizen_unittests") {
236239
]
237240

238241
public_configs = [ "//flutter:config" ]
242+
239243
configs += [
240244
":tizen_rootstrap_include_dirs",
241245
"//flutter/shell/platform/common:desktop_library_implementation",
@@ -258,6 +262,40 @@ executable("flutter_tizen_unittests") {
258262
]
259263
}
260264

265+
executable("flutter_tizen_shell") {
266+
public = _public_headers
267+
sources = _flutter_tizen_source
268+
sources += [ "tizen_renderer_evas_gl.cc" ]
269+
sources += [ "flutter_tizen_shell.cc" ]
270+
libs = _libs_minimum
271+
libs += [
272+
"ecore_evas",
273+
"elementary",
274+
]
275+
276+
defines = [ "TIZEN_RENDERER_EVAS_GL" ]
277+
cflags_cc = [
278+
"-Wno-newline-eof",
279+
"-Wno-macro-redefined",
280+
]
281+
282+
public_configs = [ "//flutter:config" ]
283+
configs += [
284+
":tizen_rootstrap_include_dirs",
285+
"//flutter/shell/platform/common:desktop_library_implementation",
286+
]
287+
public_deps = [ ":flutter_engine" ]
288+
deps = [
289+
"//flutter/runtime:libdart",
290+
"//flutter/shell/platform/common:common_cpp",
291+
"//flutter/shell/platform/common:common_cpp_input",
292+
"//flutter/shell/platform/common:common_cpp_library_headers",
293+
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
294+
"//flutter/shell/platform/embedder:embedder_headers",
295+
"//third_party/rapidjson",
296+
]
297+
}
298+
261299
publish_client_wrapper_core("publish_cpp_client_wrapper") {
262300
visibility = [ ":*" ]
263301
}
@@ -293,4 +331,7 @@ group("tizen") {
293331
":publish_cpp_client_wrapper",
294332
":publish_headers_tizen",
295333
]
334+
if (enable_desktop_embeddings) {
335+
deps += [ ":flutter_tizen_shell" ]
336+
}
296337
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#include <assert.h>
2+
#include <unistd.h>
3+
#include <chrono>
4+
#include <iostream>
5+
#include <thread>
6+
7+
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
8+
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
9+
10+
extern int gApp_width;
11+
extern int gApp_height;
12+
13+
std::string TPK_ROOT_PATH = "/tpkroot";
14+
std::string LIB_PATH = "/lib";
15+
std::string RES_PATH = "/res";
16+
17+
class FlutterApp {
18+
public:
19+
explicit FlutterApp() {}
20+
virtual ~FlutterApp() {}
21+
22+
bool OnCreate() {
23+
printf("Launching a Flutter application...\n");
24+
25+
std::string assets_path;
26+
std::string icu_data_path;
27+
std::string aot_lib_path;
28+
FlutterDesktopEngineProperties engine_prop = {};
29+
std::vector<const char*> switches;
30+
31+
std::string tpk_root;
32+
if (app_path_.empty()) {
33+
char path[256];
34+
getcwd(path, sizeof(path));
35+
tpk_root = path + TPK_ROOT_PATH;
36+
} else {
37+
tpk_root = app_path_;
38+
}
39+
40+
assets_path = tpk_root + RES_PATH + "/flutter_assets";
41+
icu_data_path = tpk_root + RES_PATH + "/icudtl.dat";
42+
aot_lib_path = tpk_root + LIB_PATH + "/libapp.so";
43+
44+
switches.push_back("--disable-observatory");
45+
switches.push_back("--verbose-logging");
46+
switches.push_back("--enable-dart-profiling");
47+
switches.push_back("--enable-checked-mode");
48+
49+
engine_prop.assets_path = assets_path.c_str();
50+
engine_prop.icu_data_path = icu_data_path.c_str();
51+
engine_prop.aot_library_path = aot_lib_path.c_str();
52+
engine_prop.switches = switches.data();
53+
engine_prop.switches_count = switches.size();
54+
engine_ = reinterpret_cast<flutter::FlutterTizenEngine*>(
55+
FlutterDesktopRunEngine(engine_prop, true));
56+
57+
if (!engine_) {
58+
printf("Could not launch a Flutter application.\n");
59+
return false;
60+
}
61+
// RegisterPlugins(this);
62+
return true;
63+
}
64+
void OnResume() {}
65+
void OnPause() {}
66+
void OnTerminate() {
67+
printf("Shutting down the application...");
68+
69+
FlutterDesktopShutdownEngine(
70+
reinterpret_cast<FlutterDesktopEngineRef>(engine_));
71+
delete engine_;
72+
engine_ = nullptr;
73+
74+
ecore_shutdown();
75+
}
76+
int Run(int argc, char** argv) {
77+
ecore_init();
78+
elm_init(0, 0);
79+
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
80+
elm_config_accel_preference_set("opengl");
81+
82+
for (int i = 1; i < argc; i++) {
83+
if (strstr(argv[i], "--width=") == argv[i]) {
84+
gApp_width = std::atoi(argv[i] + strlen("--width="));
85+
} else if (strstr(argv[i], "--height=") == argv[i]) {
86+
gApp_height = std::atoi(argv[i] + strlen("--height="));
87+
} else if (strstr(argv[i], "--tpkroot=") == argv[i]) {
88+
app_path_ = argv[i] + strlen("--tpkroot=");
89+
}
90+
}
91+
92+
ecore_idler_add(
93+
[](void* data) -> Eina_Bool {
94+
FlutterApp* app = (FlutterApp*)data;
95+
app->OnCreate();
96+
return ECORE_CALLBACK_CANCEL;
97+
},
98+
this);
99+
ecore_main_loop_begin();
100+
return 0;
101+
}
102+
103+
FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin(
104+
const std::string& plugin_name) {
105+
if (engine_) {
106+
return FlutterDesktopGetPluginRegistrar(
107+
reinterpret_cast<FlutterDesktopEngineRef>(engine_),
108+
plugin_name.c_str());
109+
}
110+
return nullptr;
111+
}
112+
113+
private:
114+
std::string app_path_ = {};
115+
flutter::FlutterTizenEngine* engine_ = nullptr;
116+
};
117+
118+
int main(int argc, char* argv[]) {
119+
auto app = new FlutterApp();
120+
return app->Run(argc, argv);
121+
}

shell/platform/tizen/tizen_renderer_evas_gl.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
Evas_GL* g_evas_gl = nullptr;
99
EVAS_GL_GLOBAL_GLES3_DEFINE();
1010

11+
#ifdef __X64_SHELL__
12+
int gApp_width = 800;
13+
int gApp_height = 600;
14+
#endif
15+
1116
#include "flutter/shell/platform/tizen/tizen_log.h"
1217

1318
namespace flutter {
@@ -601,11 +606,12 @@ bool TizenRendererEvasGL::SetupEvasGL() {
601606
gl_config_->depth_bits = EVAS_GL_DEPTH_NONE;
602607
gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE;
603608

609+
#ifndef __X64_SHELL__
604610
gl_context_ =
605611
evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_3_X);
606612
gl_resource_context_ =
607613
evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X);
608-
614+
#endif
609615
if (gl_context_ == nullptr) {
610616
FT_LOGW(
611617
"Failed to create evas gl context with EVAS_GL_GLES_3_X, try to use "
@@ -647,6 +653,10 @@ Evas_Object* TizenRendererEvasGL::SetupEvasWindow(int32_t& width,
647653
return nullptr;
648654
}
649655

656+
#ifdef __X64_SHELL__
657+
width = gApp_width;
658+
height = gApp_height;
659+
#endif
650660
elm_win_alpha_set(evas_window_, EINA_FALSE);
651661
evas_object_move(evas_window_, 0, 0);
652662
evas_object_resize(evas_window_, width, height);

0 commit comments

Comments
 (0)