Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tizen 4.0 #23

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//flutter/shell/platform/tizen/config.gni")

_public_headers = [ "public/flutter_tizen.h" ]

Expand Down Expand Up @@ -43,10 +44,8 @@ source_set("flutter_tizen") {
"key_event_handler.cc",
"tizen_embedder_engine.cc",
"tizen_event_loop.cc",
"tizen_surface.cc",
"tizen_surface_gl.cc",
"tizen_renderer.cc",
"tizen_vsync_waiter.cc",
"tizen_native_window.cc",
"touch_event_handler.cc",
]

Expand All @@ -72,6 +71,7 @@ source_set("flutter_tizen") {
"$custom_sysroot/usr/include/ecore-imf-1",
"$custom_sysroot/usr/include/ecore-imf-evas-1",
"$custom_sysroot/usr/include/ecore-input-1",
"$custom_sysroot/usr/include/ecore-wayland-1",
"$custom_sysroot/usr/include/ecore-wl2-1",
"$custom_sysroot/usr/include/efl-1",
"$custom_sysroot/usr/include/eina-1",
Expand All @@ -80,6 +80,7 @@ source_set("flutter_tizen") {
"$custom_sysroot/usr/include/eo-1",
"$custom_sysroot/usr/include/evas-1",
"$custom_sysroot/usr/include/system",
"$custom_sysroot/usr/include/wayland-extension"
]

lib_dirs = [ "$custom_sysroot/usr/lib" ]
Expand All @@ -98,14 +99,22 @@ source_set("flutter_tizen") {
"ecore",
"ecore_imf",
"ecore_input",
"ecore_wl2",
"EGL",
"evas",
"GLESv2",
"tbm",
"tdm-client",
"wayland-client",
]

if (tizen_sdk_4) {
sources += [ "tizen_renderer_ecore_wl.cc" ]
libs += [ "ecore_wayland", "wayland-egl" ]
defines = [ "FLUTTER_TIZEN_4" ]
} else {
sources += [ "tizen_renderer_ecore_wl2.cc" ]
libs += [ "ecore_wl2" ]
}
}

copy("publish_headers_tizen") {
Expand Down
18 changes: 9 additions & 9 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ void TextInputChannel::InputPanelStateChangedCallback(
[](void* data) -> Eina_Bool {
TextInputChannel* self = (TextInputChannel*)data;
auto window_geometry =
self->engine_->tizen_native_window->GetGeometry();
self->engine_->tizen_renderer->GetGeometry();
int32_t surface_w = window_geometry.w;
int32_t surface_h =
window_geometry.h - self->current_keyboard_geometry_.h;

self->engine_->tizen_native_window->GetTizenNativeEGLWindow()
->ResizeWithRotation(0, 0, surface_w, surface_h, 0);
self->engine_->tizen_renderer->ResizeWithRotation(0, 0, surface_w,
surface_h, 0);
if (self->rotation == 90 || self->rotation == 270) {
self->engine_->SendWindowMetrics(surface_h, surface_w, 0);
} else {
Expand Down Expand Up @@ -298,10 +298,8 @@ TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger,
imf_context_ = ecore_imf_context_add(GetImfMethod());
}
if (imf_context_) {
Ecore_Wl2_Window* ecoreWindow =
engine_->tizen_native_window->GetWindowHandle();
ecore_imf_context_client_window_set(
imf_context_, (void*)ecore_wl2_window_id_get(ecoreWindow));
imf_context_, (void*)engine_->tizen_renderer->GetEcoreWindowId());
RegisterIMFCallback();
} else {
FT_LOGE("Failed to create imfContext");
Expand Down Expand Up @@ -456,7 +454,9 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
ecore_device_class_get(keyDownEvent->dev));
ecoreKeyDownEvent.dev_subclass = EoreDeviceSubClassToEcoreIMFDeviceSubClass(
ecore_device_subclass_get(keyDownEvent->dev));
#ifndef FLUTTER_TIZEN_4
ecoreKeyDownEvent.keycode = keyDownEvent->keycode;
#endif

bool isIME = strcmp(device, "ime") == 0;
if (isIME && strcmp(keyDownEvent->key, "Select") == 0) {
Expand Down Expand Up @@ -612,15 +612,15 @@ void TextInputChannel::HideSoftwareKeyboard() {

if (engine_->device_profile ==
"mobile") { // FIXME : Needs improvement on other devices.
auto window_geometry = engine_->tizen_native_window->GetGeometry();
auto window_geometry = engine_->tizen_renderer->GetGeometry();

if (rotation == 90 || rotation == 270) {
engine_->SendWindowMetrics(window_geometry.h, window_geometry.w, 0);
} else {
engine_->SendWindowMetrics(window_geometry.w, window_geometry.h, 0);
}
engine_->tizen_native_window->GetTizenNativeEGLWindow()
->ResizeWithRotation(0, 0, window_geometry.w, window_geometry.h, 0);
engine_->tizen_renderer->ResizeWithRotation(0, 0, window_geometry.w,
window_geometry.h, 0);
ecore_timer_add(
0.05,
[](void* data) -> Eina_Bool {
Expand Down
1 change: 0 additions & 1 deletion shell/platform/tizen/channels/text_input_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define EFL_BETA_API_SUPPORT
#include <Ecore_IMF.h>
#include <Ecore_Input.h>
#include <Ecore_Wl2.h>

#include <string>

Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ declare_args() {
# as an extra build artifact with this flag. The native toolkit shell will
# still be built as well.
build_tizen_shell = false
tizen_sdk_4 = false
}
1 change: 1 addition & 0 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "public/flutter_tizen.h"

#include <inttypes.h>
#include <unistd.h>

#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h"
Expand Down
36 changes: 18 additions & 18 deletions shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ static double GetDeviceDpi() {
TizenEmbedderEngine::TizenEmbedderEngine(
const FlutterWindowProperties& window_properties)
: device_profile(GetDeviceProfile()), device_dpi(GetDeviceDpi()) {
tizen_native_window = std::make_shared<TizenNativeWindow>(
#ifdef FLUTTER_TIZEN_4
tizen_renderer = std::make_unique<TizenRendererEcoreWl>(
window_properties.x, window_properties.y, window_properties.width,
window_properties.height);
tizen_surface = std::make_unique<TizenSurfaceGL>(tizen_native_window);
#else
tizen_renderer = std::make_unique<TizenRendererEcoreWl2>(
window_properties.x, window_properties.y, window_properties.width,
window_properties.height);
#endif

// Run flutter task on Tizen main loop.
// Tizen engine has four threads (GPU thread, UI thread, IO thread, platform
Expand All @@ -61,8 +66,7 @@ TizenEmbedderEngine::TizenEmbedderEngine(

TizenEmbedderEngine::~TizenEmbedderEngine() {
FT_LOGD("Destroy");
tizen_surface = nullptr;
tizen_native_window = nullptr;
tizen_renderer = nullptr;
}

// Attempts to load AOT data from the given path, which must be absolute and
Expand Down Expand Up @@ -92,7 +96,7 @@ UniqueAotDataPtr LoadAotData(std::string aot_data_path) {

bool TizenEmbedderEngine::RunEngine(
const FlutterEngineProperties& engine_properties) {
if (!tizen_surface->IsValid()) {
if (!tizen_renderer->IsValid()) {
FT_LOGE("The display was not valid.");
return false;
}
Expand Down Expand Up @@ -262,13 +266,13 @@ void TizenEmbedderEngine::SendWindowMetrics(int32_t width, int32_t height,
// This must be called at least once in order to initialize the value of
// transformation_.
void TizenEmbedderEngine::SetWindowOrientation(int32_t degree) {
if (!tizen_surface) {
if (!tizen_renderer) {
return;
}

// Compute renderer transformation based on the angle of rotation.
double rad = (360 - degree) * M_PI / 180;
auto geometry = tizen_native_window->GetGeometry();
auto geometry = tizen_renderer->GetGeometry();
double width = geometry.w;
double height = geometry.h;

Expand Down Expand Up @@ -331,11 +335,7 @@ void TizenEmbedderEngine::OnFlutterPlatformMessage(
void TizenEmbedderEngine::OnVsyncCallback(void* user_data, intptr_t baton) {
TizenEmbedderEngine* tizen_embedder_engine =
reinterpret_cast<TizenEmbedderEngine*>(user_data);
if (tizen_embedder_engine->tizen_vsync_waiter_->IsValid()) {
tizen_embedder_engine->tizen_vsync_waiter_->AsyncWaitForVsync(baton);
return;
}
FT_ASSERT_NOT_REACHED();
tizen_embedder_engine->tizen_vsync_waiter_->AsyncWaitForVsync(baton);
}

// Converts a FlutterPlatformMessage to an equivalent FlutterDesktopMessage.
Expand All @@ -352,27 +352,27 @@ FlutterDesktopMessage TizenEmbedderEngine::ConvertToDesktopMessage(

bool TizenEmbedderEngine::MakeContextCurrent(void* user_data) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnMakeCurrent();
->tizen_renderer->OnMakeCurrent();
}

bool TizenEmbedderEngine::ClearContext(void* user_data) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnClearCurrent();
->tizen_renderer->OnClearCurrent();
}

bool TizenEmbedderEngine::Present(void* user_data) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnPresent();
->tizen_renderer->OnPresent();
}

bool TizenEmbedderEngine::MakeResourceCurrent(void* user_data) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnMakeResourceCurrent();
->tizen_renderer->OnMakeResourceCurrent();
}

uint32_t TizenEmbedderEngine::GetActiveFbo(void* user_data) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnGetFBO();
->tizen_renderer->OnGetFBO();
}

FlutterTransformation TizenEmbedderEngine::Transformation(void* user_data) {
Expand All @@ -381,5 +381,5 @@ FlutterTransformation TizenEmbedderEngine::Transformation(void* user_data) {

void* TizenEmbedderEngine::GlProcResolver(void* user_data, const char* name) {
return reinterpret_cast<TizenEmbedderEngine*>(user_data)
->tizen_surface->OnProcResolver(name);
->tizen_renderer->OnProcResolver(name);
}
11 changes: 7 additions & 4 deletions shell/platform/tizen/tizen_embedder_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
#include "flutter/shell/platform/tizen/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
#include "flutter/shell/platform/tizen/tizen_event_loop.h"
#include "flutter/shell/platform/tizen/tizen_surface.h"
#include "flutter/shell/platform/tizen/tizen_surface_gl.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#ifdef FLUTTER_TIZEN_4
#include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl.h"
#else
#include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h"
#endif
#include "flutter/shell/platform/tizen/tizen_vsync_waiter.h"
#include "flutter/shell/platform/tizen/touch_event_handler.h"

Expand Down Expand Up @@ -94,8 +98,7 @@ class TizenEmbedderEngine {
std::unique_ptr<flutter::IncomingMessageDispatcher> message_dispatcher;

// The interface between the Flutter rasterizer and the platform.
std::unique_ptr<TizenSurface> tizen_surface;
std::shared_ptr<TizenNativeWindow> tizen_native_window;
std::unique_ptr<TizenRenderer> tizen_renderer;

// The system channels for communicating between Flutter and the platform.
std::unique_ptr<KeyEventChannel> key_event_channel;
Expand Down
Loading