Skip to content

Enable Evas GL direct mode #54

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

Merged
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
5 changes: 5 additions & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/testing/testing.gni")
import("//flutter/shell/platform/tizen/config.gni")

# Template to generate a dart embedder resource.cc file.
# Required invoker inputs:
Expand Down Expand Up @@ -118,6 +119,10 @@ source_set("common") {
"//third_party/dart/runtime:dart_api",
"//third_party/skia",
]

if (build_tizen_shell) {
defines = [ "FLUTTER_TIZEN_SHELL" ]
}
}

template("shell_host_executable") {
Expand Down
6 changes: 5 additions & 1 deletion shell/common/animator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Animator::Animator(Delegate& delegate,
dart_frame_deadline_(0),
#if SHELL_ENABLE_METAL
layer_tree_pipeline_(fml::MakeRefCounted<LayerTreePipeline>(2)),
#else // SHELL_ENABLE_METAL
#elif FLUTTER_TIZEN_SHELL
// FIXME
// This is a workaround to avoid flickering that occurs in evas gl direct mode.
layer_tree_pipeline_(fml::MakeRefCounted<LayerTreePipeline>(1)),
#else // SHELL_ENABLE_METAL
// TODO(dnfield): We should remove this logic and set the pipeline depth
// back to 2 in this case. See
// https://github.com/flutter/engine/pull/9132 for discussion.
Expand Down
22 changes: 17 additions & 5 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ source_set("flutter_tizen") {
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"tizen_vsync_waiter.cc",
"touch_event_handler.cc",
]

Expand Down Expand Up @@ -87,7 +86,16 @@ 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"
"$custom_sysroot/usr/include/wayland-extension",
"$custom_sysroot/usr/include/elementary-1",
"$custom_sysroot/usr/include/eet-1",
"$custom_sysroot/usr/include/ecore-file-1",
"$custom_sysroot/usr/include/ecore-con-1",
"$custom_sysroot/usr/include/edje-1",
"$custom_sysroot/usr/include/efreet-1",
"$custom_sysroot/usr/include/ethumb-1",
"$custom_sysroot/usr/include/ethumb-client-1",
"$custom_sysroot/usr/include/efl-1/interfaces",
]

lib_dirs = [ root_out_dir, "$custom_sysroot/usr/lib" ]
Expand Down Expand Up @@ -119,9 +127,13 @@ source_set("flutter_tizen") {
if (tizen_sdk_4) {
sources += [ "tizen_renderer_ecore_wl.cc" ]
libs += [ "ecore_wayland", "wayland-egl" ]
defines = [ "FLUTTER_TIZEN_4" ]
defines = [ "FLUTTER_TIZEN_EVASGL" ]
} else {
sources += [ "tizen_renderer_ecore_wl2.cc" ]
libs += [ "ecore_wl2" ]
# sources += [ "tizen_renderer_ecore_wl2.cc" ]
# libs += [ "ecore_wl2" ]
#evasgl
sources += [ "tizen_renderer_evas_gl.cc" ]
libs += [ "elementary","ecore_evas" ]
defines = [ "FLUTTER_TIZEN_EVASGL" ]
}
}
71 changes: 7 additions & 64 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,61 +183,6 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock(
return static_cast<Ecore_IMF_Keyboard_Locks>(lock);
}

Ecore_IMF_Device_Class EoreDeviceClassToEcoreIMFDeviceClass(
Ecore_Device_Class ecoreDeviceClass) {
switch (ecoreDeviceClass) {
case ECORE_DEVICE_CLASS_SEAT:
return ECORE_IMF_DEVICE_CLASS_SEAT;
case ECORE_DEVICE_CLASS_KEYBOARD:
return ECORE_IMF_DEVICE_CLASS_KEYBOARD;
case ECORE_DEVICE_CLASS_MOUSE:
return ECORE_IMF_DEVICE_CLASS_MOUSE;
case ECORE_DEVICE_CLASS_TOUCH:
return ECORE_IMF_DEVICE_CLASS_TOUCH;
case ECORE_DEVICE_CLASS_PEN:
return ECORE_IMF_DEVICE_CLASS_PEN;
case ECORE_DEVICE_CLASS_POINTER:
return ECORE_IMF_DEVICE_CLASS_POINTER;
case ECORE_DEVICE_CLASS_GAMEPAD:
return ECORE_IMF_DEVICE_CLASS_GAMEPAD;
case ECORE_DEVICE_CLASS_NONE:
default:
return ECORE_IMF_DEVICE_CLASS_NONE;
}
}

Ecore_IMF_Device_Subclass EoreDeviceSubClassToEcoreIMFDeviceSubClass(
Ecore_Device_Subclass ecoreDeviceSubclass) {
switch (ecoreDeviceSubclass) {
case ECORE_DEVICE_SUBCLASS_FINGER:
return ECORE_IMF_DEVICE_SUBCLASS_FINGER;
case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
return ECORE_IMF_DEVICE_SUBCLASS_FINGERNAIL;
case ECORE_DEVICE_SUBCLASS_KNUCKLE:
return ECORE_IMF_DEVICE_SUBCLASS_KNUCKLE;
case ECORE_DEVICE_SUBCLASS_PALM:
return ECORE_IMF_DEVICE_SUBCLASS_PALM;
case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
return ECORE_IMF_DEVICE_SUBCLASS_HAND_SIZE;
case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
return ECORE_IMF_DEVICE_SUBCLASS_HAND_FLAT;
case ECORE_DEVICE_SUBCLASS_PEN_TIP:
return ECORE_IMF_DEVICE_SUBCLASS_PEN_TIP;
case ECORE_DEVICE_SUBCLASS_TRACKPAD:
return ECORE_IMF_DEVICE_SUBCLASS_TRACKPAD;
case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
return ECORE_IMF_DEVICE_SUBCLASS_TRACKPOINT;
case ECORE_DEVICE_SUBCLASS_TRACKBALL:
return ECORE_IMF_DEVICE_SUBCLASS_TRACKBALL;
case ECORE_DEVICE_SUBCLASS_REMOCON:
case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
// FT_LOGW("There is no corresponding type");
case ECORE_DEVICE_SUBCLASS_NONE:
default:
return ECORE_IMF_DEVICE_SUBCLASS_NONE;
}
}

TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger,
TizenEmbedderEngine* engine)
: channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
Expand Down Expand Up @@ -397,8 +342,8 @@ void TextInputChannel::SendStateUpdate(const flutter::TextInputModel& model) {

bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
bool handled = false;
const char* device = ecore_device_name_get(keyDownEvent->dev);

bool isIME = ecore_imf_context_keyboard_mode_get(imf_context_) ==
ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE;
Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
ecoreKeyDownEvent.keyname = keyDownEvent->keyname;
ecoreKeyDownEvent.key = keyDownEvent->key;
Expand All @@ -409,17 +354,15 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
EcoreInputModifierToEcoreIMFModifier(keyDownEvent->modifiers);
ecoreKeyDownEvent.locks =
EcoreInputModifierToEcoreIMFLock(keyDownEvent->modifiers);
ecoreKeyDownEvent.dev_name = device;
ecoreKeyDownEvent.dev_class = EoreDeviceClassToEcoreIMFDeviceClass(
ecore_device_class_get(keyDownEvent->dev));
ecoreKeyDownEvent.dev_subclass = EoreDeviceSubClassToEcoreIMFDeviceSubClass(
ecore_device_subclass_get(keyDownEvent->dev));
if (isIME) {
ecoreKeyDownEvent.dev_name = "ime";
} else {
ecoreKeyDownEvent.dev_name = "";
}
#ifndef FLUTTER_TIZEN_4
ecoreKeyDownEvent.keycode = keyDownEvent->keycode;
#endif

bool isIME = strcmp(device, "ime") == 0;

if (isIME && strcmp(keyDownEvent->key, "Select") == 0) {
if (engine_->device_profile == DeviceProfile::kWearable) {
// FIXME: for wearable
Expand Down
69 changes: 59 additions & 10 deletions shell/platform/tizen/external_texture_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

#include "external_texture_gl.h"

#ifndef FLUTTER_TIZEN_EVASGL
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES3/gl32.h>
#else
#undef EFL_BETA_API_SUPPORT
#include <Ecore.h>
#include <Elementary.h>
#include <Evas_GL_GLES3_Helpers.h>
extern Evas_GL* g_evas_gl;
EVAS_GL_GLOBAL_GLES3_DECLARE();
#endif

#include <atomic>
#include <iostream>
Expand All @@ -29,7 +38,11 @@ ExternalTextureGL::ExternalTextureGL()
ExternalTextureGL::~ExternalTextureGL() {
mutex_.lock();
if (state_->gl_texture != 0) {
#ifndef FLUTTER_TIZEN_EVASGL
glDeleteTextures(1, &state_->gl_texture);
#else
glDeleteTextures(1, &state_->gl_texture);
#endif
}
state_.release();
DestructionTbmSurface();
Expand All @@ -48,13 +61,14 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) {
mutex_.unlock();
return false;
}
if (!tbm_surface_internal_is_valid(tbm_surface)) {

tbm_surface_info_s info;
if (tbm_surface_get_info(tbm_surface, &info) != TBM_SURFACE_ERROR_NONE) {
FT_LOGD("tbm_surface not valid, pass");
mutex_.unlock();
return false;
}
texture_tbm_surface_ = tbm_surface;
tbm_surface_internal_ref(texture_tbm_surface_);
mutex_.unlock();
return true;
}
Expand All @@ -67,22 +81,26 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
mutex_.unlock();
return false;
}
if (!tbm_surface_internal_is_valid(texture_tbm_surface_)) {
tbm_surface_info_s info;
if (tbm_surface_get_info(texture_tbm_surface_, &info) !=
TBM_SURFACE_ERROR_NONE) {
FT_LOGD("tbm_surface not valid");
DestructionTbmSurface();
mutex_.unlock();
return false;
}

#ifndef FLUTTER_TIZEN_EVASGL
PFNEGLCREATEIMAGEKHRPROC n_eglCreateImageKHR =
(PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
const EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE,
EGL_NONE};
EGLImageKHR eglSrcImage = n_eglCreateImageKHR(
EGLImageKHR egl_src_image = n_eglCreateImageKHR(
eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN,
(EGLClientBuffer)texture_tbm_surface_, attrs);
if (!eglSrcImage) {
FT_LOGE("eglSrcImage create fail!!, errorcode == %d", eglGetError());

if (!egl_src_image) {
FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError());
mutex_.unlock();
return false;
}
Expand All @@ -103,12 +121,43 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES =
(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress(
"glEGLImageTargetTexture2DOES");
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglSrcImage);
if (eglSrcImage) {
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image);
if (egl_src_image) {
PFNEGLDESTROYIMAGEKHRPROC n_eglDestoryImageKHR =
(PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
n_eglDestoryImageKHR(eglGetCurrentDisplay(), eglSrcImage);
n_eglDestoryImageKHR(eglGetCurrentDisplay(), egl_src_image);
}
#else
int eglImgAttr[] = {EVAS_GL_IMAGE_PRESERVED, GL_TRUE, 0};
EvasGLImage egl_src_image = evasglCreateImageForContext(
g_evas_gl, evas_gl_current_context_get(g_evas_gl),
EVAS_GL_NATIVE_SURFACE_TIZEN, (void*)(intptr_t)texture_tbm_surface_,
eglImgAttr);
if (!egl_src_image) {
// FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError());
mutex_.unlock();
return false;
}
if (state_->gl_texture == 0) {
glGenTextures(1, &state_->gl_texture);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture);
// set the texture wrapping parameters
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_BORDER);
// set texture filtering parameters
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture);
}
glEvasGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image);
if (egl_src_image) {
evasglDestroyImage(egl_src_image);
}

#endif
opengl_texture->target = GL_TEXTURE_EXTERNAL_OES;
opengl_texture->name = state_->gl_texture;
opengl_texture->format = GL_RGBA8;
Expand All @@ -131,7 +180,7 @@ void ExternalTextureGL::DestructionTbmSurface() {
FT_LOGE("tbm_surface_h is NULL");
return;
}
tbm_surface_internal_unref(texture_tbm_surface_);
tbm_surface_destroy(texture_tbm_surface_);
texture_tbm_surface_ = NULL;
}

Expand Down
Loading