Skip to content

Commit 8886709

Browse files
bbrto21bwikbs
andauthored
Enable Evas GL direct mode (#54)
* Remove unmanaged API - Known issue * Not working at TW3 * Uninitialized buffers are visible at early stage of app running * Call ClearColor once to remove noise (#44) Signed-off-by: Boram Bae <[email protected]> * Update evasgl sync logic (#45) Signed-off-by: MuHong Byun <[email protected]> * Use OpenGL ES 2.1 mode forcely (#46) * Use OpenGL ES 2.1 mode forcely Signed-off-by: MuHong Byun <[email protected]> * Use EvasGLSync for better performance Signed-off-by: MuHong Byun <[email protected]> * Choose OpenGL ES version between 3.x and 2.x (#47) * Add more GL function macros for 3.x * Retry to create evas_gl_context using 2.x when failed to create a context for version 3.x Signed-off-by: Boram Bae <[email protected]> * Enable Evas GL direct mode * Introduce TizenRenderEventLoop using pixel dirty * Add Evas GL config options related to direct mode * Add a workaround to avoid flickering that occurs in Evas GL direct mode Signed-off-by: Boram Bae <[email protected]> Co-authored-by: MuHong Byun <[email protected]>
1 parent 113f51b commit 8886709

13 files changed

+1029
-107
lines changed

shell/common/BUILD.gn

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import("//build/fuchsia/sdk.gni")
66
import("//flutter/common/config.gni")
77
import("//flutter/shell/gpu/gpu.gni")
88
import("//flutter/testing/testing.gni")
9+
import("//flutter/shell/platform/tizen/config.gni")
910

1011
# Template to generate a dart embedder resource.cc file.
1112
# Required invoker inputs:
@@ -118,6 +119,10 @@ source_set("common") {
118119
"//third_party/dart/runtime:dart_api",
119120
"//third_party/skia",
120121
]
122+
123+
if (build_tizen_shell) {
124+
defines = [ "FLUTTER_TIZEN_SHELL" ]
125+
}
121126
}
122127

123128
template("shell_host_executable") {

shell/common/animator.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ Animator::Animator(Delegate& delegate,
3131
dart_frame_deadline_(0),
3232
#if SHELL_ENABLE_METAL
3333
layer_tree_pipeline_(fml::MakeRefCounted<LayerTreePipeline>(2)),
34-
#else // SHELL_ENABLE_METAL
34+
#elif FLUTTER_TIZEN_SHELL
35+
// FIXME
36+
// This is a workaround to avoid flickering that occurs in evas gl direct mode.
37+
layer_tree_pipeline_(fml::MakeRefCounted<LayerTreePipeline>(1)),
38+
#else // SHELL_ENABLE_METAL
3539
// TODO(dnfield): We should remove this logic and set the pipeline depth
3640
// back to 2 in this case. See
3741
// https://github.com/flutter/engine/pull/9132 for discussion.

shell/platform/tizen/BUILD.gn

+17-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ source_set("flutter_tizen") {
5252
"tizen_event_loop.cc",
5353
"tizen_log.cc",
5454
"tizen_renderer.cc",
55-
"tizen_vsync_waiter.cc",
5655
"touch_event_handler.cc",
5756
]
5857

@@ -87,7 +86,16 @@ source_set("flutter_tizen") {
8786
"$custom_sysroot/usr/include/eo-1",
8887
"$custom_sysroot/usr/include/evas-1",
8988
"$custom_sysroot/usr/include/system",
90-
"$custom_sysroot/usr/include/wayland-extension"
89+
"$custom_sysroot/usr/include/wayland-extension",
90+
"$custom_sysroot/usr/include/elementary-1",
91+
"$custom_sysroot/usr/include/eet-1",
92+
"$custom_sysroot/usr/include/ecore-file-1",
93+
"$custom_sysroot/usr/include/ecore-con-1",
94+
"$custom_sysroot/usr/include/edje-1",
95+
"$custom_sysroot/usr/include/efreet-1",
96+
"$custom_sysroot/usr/include/ethumb-1",
97+
"$custom_sysroot/usr/include/ethumb-client-1",
98+
"$custom_sysroot/usr/include/efl-1/interfaces",
9199
]
92100

93101
lib_dirs = [ root_out_dir, "$custom_sysroot/usr/lib" ]
@@ -119,9 +127,13 @@ source_set("flutter_tizen") {
119127
if (tizen_sdk_4) {
120128
sources += [ "tizen_renderer_ecore_wl.cc" ]
121129
libs += [ "ecore_wayland", "wayland-egl" ]
122-
defines = [ "FLUTTER_TIZEN_4" ]
130+
defines = [ "FLUTTER_TIZEN_EVASGL" ]
123131
} else {
124-
sources += [ "tizen_renderer_ecore_wl2.cc" ]
125-
libs += [ "ecore_wl2" ]
132+
# sources += [ "tizen_renderer_ecore_wl2.cc" ]
133+
# libs += [ "ecore_wl2" ]
134+
#evasgl
135+
sources += [ "tizen_renderer_evas_gl.cc" ]
136+
libs += [ "elementary","ecore_evas" ]
137+
defines = [ "FLUTTER_TIZEN_EVASGL" ]
126138
}
127139
}

shell/platform/tizen/channels/text_input_channel.cc

+7-64
Original file line numberDiff line numberDiff line change
@@ -183,61 +183,6 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock(
183183
return static_cast<Ecore_IMF_Keyboard_Locks>(lock);
184184
}
185185

186-
Ecore_IMF_Device_Class EoreDeviceClassToEcoreIMFDeviceClass(
187-
Ecore_Device_Class ecoreDeviceClass) {
188-
switch (ecoreDeviceClass) {
189-
case ECORE_DEVICE_CLASS_SEAT:
190-
return ECORE_IMF_DEVICE_CLASS_SEAT;
191-
case ECORE_DEVICE_CLASS_KEYBOARD:
192-
return ECORE_IMF_DEVICE_CLASS_KEYBOARD;
193-
case ECORE_DEVICE_CLASS_MOUSE:
194-
return ECORE_IMF_DEVICE_CLASS_MOUSE;
195-
case ECORE_DEVICE_CLASS_TOUCH:
196-
return ECORE_IMF_DEVICE_CLASS_TOUCH;
197-
case ECORE_DEVICE_CLASS_PEN:
198-
return ECORE_IMF_DEVICE_CLASS_PEN;
199-
case ECORE_DEVICE_CLASS_POINTER:
200-
return ECORE_IMF_DEVICE_CLASS_POINTER;
201-
case ECORE_DEVICE_CLASS_GAMEPAD:
202-
return ECORE_IMF_DEVICE_CLASS_GAMEPAD;
203-
case ECORE_DEVICE_CLASS_NONE:
204-
default:
205-
return ECORE_IMF_DEVICE_CLASS_NONE;
206-
}
207-
}
208-
209-
Ecore_IMF_Device_Subclass EoreDeviceSubClassToEcoreIMFDeviceSubClass(
210-
Ecore_Device_Subclass ecoreDeviceSubclass) {
211-
switch (ecoreDeviceSubclass) {
212-
case ECORE_DEVICE_SUBCLASS_FINGER:
213-
return ECORE_IMF_DEVICE_SUBCLASS_FINGER;
214-
case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
215-
return ECORE_IMF_DEVICE_SUBCLASS_FINGERNAIL;
216-
case ECORE_DEVICE_SUBCLASS_KNUCKLE:
217-
return ECORE_IMF_DEVICE_SUBCLASS_KNUCKLE;
218-
case ECORE_DEVICE_SUBCLASS_PALM:
219-
return ECORE_IMF_DEVICE_SUBCLASS_PALM;
220-
case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
221-
return ECORE_IMF_DEVICE_SUBCLASS_HAND_SIZE;
222-
case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
223-
return ECORE_IMF_DEVICE_SUBCLASS_HAND_FLAT;
224-
case ECORE_DEVICE_SUBCLASS_PEN_TIP:
225-
return ECORE_IMF_DEVICE_SUBCLASS_PEN_TIP;
226-
case ECORE_DEVICE_SUBCLASS_TRACKPAD:
227-
return ECORE_IMF_DEVICE_SUBCLASS_TRACKPAD;
228-
case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
229-
return ECORE_IMF_DEVICE_SUBCLASS_TRACKPOINT;
230-
case ECORE_DEVICE_SUBCLASS_TRACKBALL:
231-
return ECORE_IMF_DEVICE_SUBCLASS_TRACKBALL;
232-
case ECORE_DEVICE_SUBCLASS_REMOCON:
233-
case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
234-
// FT_LOGW("There is no corresponding type");
235-
case ECORE_DEVICE_SUBCLASS_NONE:
236-
default:
237-
return ECORE_IMF_DEVICE_SUBCLASS_NONE;
238-
}
239-
}
240-
241186
TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger,
242187
TizenEmbedderEngine* engine)
243188
: channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
@@ -397,8 +342,8 @@ void TextInputChannel::SendStateUpdate(const flutter::TextInputModel& model) {
397342

398343
bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
399344
bool handled = false;
400-
const char* device = ecore_device_name_get(keyDownEvent->dev);
401-
345+
bool isIME = ecore_imf_context_keyboard_mode_get(imf_context_) ==
346+
ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE;
402347
Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
403348
ecoreKeyDownEvent.keyname = keyDownEvent->keyname;
404349
ecoreKeyDownEvent.key = keyDownEvent->key;
@@ -409,17 +354,15 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
409354
EcoreInputModifierToEcoreIMFModifier(keyDownEvent->modifiers);
410355
ecoreKeyDownEvent.locks =
411356
EcoreInputModifierToEcoreIMFLock(keyDownEvent->modifiers);
412-
ecoreKeyDownEvent.dev_name = device;
413-
ecoreKeyDownEvent.dev_class = EoreDeviceClassToEcoreIMFDeviceClass(
414-
ecore_device_class_get(keyDownEvent->dev));
415-
ecoreKeyDownEvent.dev_subclass = EoreDeviceSubClassToEcoreIMFDeviceSubClass(
416-
ecore_device_subclass_get(keyDownEvent->dev));
357+
if (isIME) {
358+
ecoreKeyDownEvent.dev_name = "ime";
359+
} else {
360+
ecoreKeyDownEvent.dev_name = "";
361+
}
417362
#ifndef FLUTTER_TIZEN_4
418363
ecoreKeyDownEvent.keycode = keyDownEvent->keycode;
419364
#endif
420365

421-
bool isIME = strcmp(device, "ime") == 0;
422-
423366
if (isIME && strcmp(keyDownEvent->key, "Select") == 0) {
424367
if (engine_->device_profile == DeviceProfile::kWearable) {
425368
// FIXME: for wearable

shell/platform/tizen/external_texture_gl.cc

+59-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
#include "external_texture_gl.h"
66

7+
#ifndef FLUTTER_TIZEN_EVASGL
78
#include <EGL/egl.h>
89
#include <EGL/eglext.h>
910
#include <GLES2/gl2.h>
1011
#include <GLES2/gl2ext.h>
1112
#include <GLES3/gl32.h>
13+
#else
14+
#undef EFL_BETA_API_SUPPORT
15+
#include <Ecore.h>
16+
#include <Elementary.h>
17+
#include <Evas_GL_GLES3_Helpers.h>
18+
extern Evas_GL* g_evas_gl;
19+
EVAS_GL_GLOBAL_GLES3_DECLARE();
20+
#endif
1221

1322
#include <atomic>
1423
#include <iostream>
@@ -29,7 +38,11 @@ ExternalTextureGL::ExternalTextureGL()
2938
ExternalTextureGL::~ExternalTextureGL() {
3039
mutex_.lock();
3140
if (state_->gl_texture != 0) {
41+
#ifndef FLUTTER_TIZEN_EVASGL
3242
glDeleteTextures(1, &state_->gl_texture);
43+
#else
44+
glDeleteTextures(1, &state_->gl_texture);
45+
#endif
3346
}
3447
state_.release();
3548
DestructionTbmSurface();
@@ -48,13 +61,14 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) {
4861
mutex_.unlock();
4962
return false;
5063
}
51-
if (!tbm_surface_internal_is_valid(tbm_surface)) {
64+
65+
tbm_surface_info_s info;
66+
if (tbm_surface_get_info(tbm_surface, &info) != TBM_SURFACE_ERROR_NONE) {
5267
FT_LOGD("tbm_surface not valid, pass");
5368
mutex_.unlock();
5469
return false;
5570
}
5671
texture_tbm_surface_ = tbm_surface;
57-
tbm_surface_internal_ref(texture_tbm_surface_);
5872
mutex_.unlock();
5973
return true;
6074
}
@@ -67,22 +81,26 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
6781
mutex_.unlock();
6882
return false;
6983
}
70-
if (!tbm_surface_internal_is_valid(texture_tbm_surface_)) {
84+
tbm_surface_info_s info;
85+
if (tbm_surface_get_info(texture_tbm_surface_, &info) !=
86+
TBM_SURFACE_ERROR_NONE) {
7187
FT_LOGD("tbm_surface not valid");
7288
DestructionTbmSurface();
7389
mutex_.unlock();
7490
return false;
7591
}
7692

93+
#ifndef FLUTTER_TIZEN_EVASGL
7794
PFNEGLCREATEIMAGEKHRPROC n_eglCreateImageKHR =
7895
(PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
7996
const EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE,
8097
EGL_NONE};
81-
EGLImageKHR eglSrcImage = n_eglCreateImageKHR(
98+
EGLImageKHR egl_src_image = n_eglCreateImageKHR(
8299
eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN,
83100
(EGLClientBuffer)texture_tbm_surface_, attrs);
84-
if (!eglSrcImage) {
85-
FT_LOGE("eglSrcImage create fail!!, errorcode == %d", eglGetError());
101+
102+
if (!egl_src_image) {
103+
FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError());
86104
mutex_.unlock();
87105
return false;
88106
}
@@ -103,12 +121,43 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
103121
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES =
104122
(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress(
105123
"glEGLImageTargetTexture2DOES");
106-
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglSrcImage);
107-
if (eglSrcImage) {
124+
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image);
125+
if (egl_src_image) {
108126
PFNEGLDESTROYIMAGEKHRPROC n_eglDestoryImageKHR =
109127
(PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
110-
n_eglDestoryImageKHR(eglGetCurrentDisplay(), eglSrcImage);
128+
n_eglDestoryImageKHR(eglGetCurrentDisplay(), egl_src_image);
129+
}
130+
#else
131+
int eglImgAttr[] = {EVAS_GL_IMAGE_PRESERVED, GL_TRUE, 0};
132+
EvasGLImage egl_src_image = evasglCreateImageForContext(
133+
g_evas_gl, evas_gl_current_context_get(g_evas_gl),
134+
EVAS_GL_NATIVE_SURFACE_TIZEN, (void*)(intptr_t)texture_tbm_surface_,
135+
eglImgAttr);
136+
if (!egl_src_image) {
137+
// FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError());
138+
mutex_.unlock();
139+
return false;
140+
}
141+
if (state_->gl_texture == 0) {
142+
glGenTextures(1, &state_->gl_texture);
143+
glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture);
144+
// set the texture wrapping parameters
145+
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
146+
GL_CLAMP_TO_BORDER);
147+
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
148+
GL_CLAMP_TO_BORDER);
149+
// set texture filtering parameters
150+
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
151+
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
152+
} else {
153+
glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture);
111154
}
155+
glEvasGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image);
156+
if (egl_src_image) {
157+
evasglDestroyImage(egl_src_image);
158+
}
159+
160+
#endif
112161
opengl_texture->target = GL_TEXTURE_EXTERNAL_OES;
113162
opengl_texture->name = state_->gl_texture;
114163
opengl_texture->format = GL_RGBA8;
@@ -131,7 +180,7 @@ void ExternalTextureGL::DestructionTbmSurface() {
131180
FT_LOGE("tbm_surface_h is NULL");
132181
return;
133182
}
134-
tbm_surface_internal_unref(texture_tbm_surface_);
183+
tbm_surface_destroy(texture_tbm_surface_);
135184
texture_tbm_surface_ = NULL;
136185
}
137186

0 commit comments

Comments
 (0)