From 42b904169df6ede5dfdd979e2ae92e1efa99c2a5 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Fri, 16 Apr 2021 22:00:26 +0900 Subject: [PATCH 01/19] Separate binaries --- shell/platform/tizen/BUILD.gn | 58 ++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 5cdac760a2ac3..c36d0bcbf03c3 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -4,20 +4,6 @@ # found in the LICENSE file. import("//flutter/shell/platform/tizen/config.gni") -group("tizen") { - deps = [ ":flutter_tizen_library" ] -} - -shared_library("flutter_tizen_library") { - output_name = "flutter_tizen" - - ldflags = [ "-Wl,-rpath,\$ORIGIN" ] - - deps = [ ":flutter_tizen" ] - - public_configs = [ "//flutter:config" ] -} - source_set("flutter_tizen_headers") { public = [ "public/flutter_platform_view.h", @@ -35,6 +21,10 @@ source_set("flutter_tizen_headers") { [ "//flutter/shell/platform/common/cpp:relative_flutter_library_headers" ] } +config("flutter_tizen_config") { + ldflags = [ "-Wl,-rpath,\$ORIGIN" ] +} + source_set("flutter_tizen") { sources = [ "channels/key_event_channel.cc", @@ -59,6 +49,11 @@ source_set("flutter_tizen") { configs += [ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ] + public_configs = [ + ":flutter_tizen_config", + "//flutter:config" + ] + deps = [ ":flutter_tizen_headers", "//flutter/shell/platform/common/cpp:common_cpp", @@ -89,7 +84,7 @@ source_set("flutter_tizen") { "$custom_sysroot/usr/include/system", "$custom_sysroot/usr/include/wayland-extension" ] - + lib_dirs = [ root_out_dir, "$custom_sysroot/usr/lib" ] cflags_cc = [ @@ -125,3 +120,36 @@ source_set("flutter_tizen") { libs += [ "ecore_wl2" ] } } + +shared_library("flutter_tizen_mobile") { + defines = [ "MOBILE_PROFILE" ] + + deps = [ ":flutter_tizen" ] +} + +shared_library("flutter_tizen_wearable") { + defines = [ "WEARABLE_PROFILE" ] + + deps = [ ":flutter_tizen" ] +} + +shared_library("flutter_tizen_tv") { + defines = [ "TV_PROFILE" ] + + deps = [ ":flutter_tizen" ] +} + +shared_library("flutter_tizen_common") { + defines = [ "COMMON_PROFILE" ] + + deps = [ ":flutter_tizen" ] +} + +group("tizen") { + deps = [ + ":flutter_tizen_mobile", + ":flutter_tizen_wearable", + ":flutter_tizen_tv", + ":flutter_tizen_common", + ] +} From b8251fa170c1034f978e8248f5ff8a4721a90a18 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 00:17:39 +0900 Subject: [PATCH 02/19] Clean up the build script --- shell/platform/tizen/BUILD.gn | 128 ++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index c36d0bcbf03c3..9d4f76423b669 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -1,68 +1,31 @@ # Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -# 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") -source_set("flutter_tizen_headers") { - public = [ - "public/flutter_platform_view.h", - "public/flutter_tizen_texture_registrar.h", - "public/flutter_tizen.h", - ] - - public_deps = - [ "//flutter/shell/platform/common/cpp:common_cpp_library_headers" ] - - configs += - [ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ] - - public_configs = - [ "//flutter/shell/platform/common/cpp:relative_flutter_library_headers" ] -} - -config("flutter_tizen_config") { +# Sets the rpath of dependent targets (shared libs) to $ORIGIN. +# This assumes that the flutter_engine library exists next to the embedder +# library when they are deployed on Tizen devices. +config("tizen_embedder_rpath") { ldflags = [ "-Wl,-rpath,\$ORIGIN" ] } -source_set("flutter_tizen") { - sources = [ - "channels/key_event_channel.cc", - "channels/lifecycle_channel.cc", - "channels/localization_channel.cc", - "channels/navigation_channel.cc", - "channels/platform_channel.cc", - "channels/platform_view_channel.cc", - "channels/settings_channel.cc", - "channels/text_input_channel.cc", - "external_texture_gl.cc", - "flutter_tizen.cc", - "key_event_handler.cc", - "tizen_embedder_engine.cc", - "tizen_event_loop.cc", - "tizen_log.cc", - "tizen_renderer.cc", - "tizen_vsync_waiter.cc", - "touch_event_handler.cc", - ] +source_set("flutter_engine") { + visibility = [ ":*" ] - configs += - [ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ] + libs = [ "flutter_engine" ] - public_configs = [ - ":flutter_tizen_config", - "//flutter:config" - ] + lib_dirs = [ root_out_dir ] - deps = [ - ":flutter_tizen_headers", - "//flutter/shell/platform/common/cpp:common_cpp", - "//flutter/shell/platform/common/cpp:common_cpp_input", - "//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper", - "//flutter/shell/platform/embedder:flutter_engine", - "//third_party/rapidjson", - ] + public_configs = [ ":tizen_embedder_rpath" ] + deps = [ "//flutter/shell/platform/embedder:flutter_engine" ] +} + +# Tizen native headers assume that the following include dirs are already +# added to the compiler's search paths. Since we are not using the Tizen CLI +# builder, we have to add them manually. +config("tizen_rootstrap_include_dirs") { include_dirs = [ "$custom_sysroot/usr/include", "$custom_sysroot/usr/include/appfw", @@ -85,11 +48,34 @@ source_set("flutter_tizen") { "$custom_sysroot/usr/include/wayland-extension" ] - lib_dirs = [ root_out_dir, "$custom_sysroot/usr/lib" ] + lib_dirs = [ "$custom_sysroot/usr/lib" ] +} - cflags_cc = [ - "-Wno-newline-eof", - "-Wno-macro-redefined", +source_set("flutter_tizen") { + public = [ + "public/flutter_platform_view.h", + "public/flutter_tizen_texture_registrar.h", + "public/flutter_tizen.h", + ] + + sources = [ + "channels/key_event_channel.cc", + "channels/lifecycle_channel.cc", + "channels/localization_channel.cc", + "channels/navigation_channel.cc", + "channels/platform_channel.cc", + "channels/platform_view_channel.cc", + "channels/settings_channel.cc", + "channels/text_input_channel.cc", + "external_texture_gl.cc", + "flutter_tizen.cc", + "key_event_handler.cc", + "tizen_embedder_engine.cc", + "tizen_event_loop.cc", + "tizen_log.cc", + "tizen_renderer.cc", + "tizen_vsync_waiter.cc", + "touch_event_handler.cc", ] libs = [ @@ -102,21 +88,45 @@ source_set("flutter_tizen") { "ecore_imf", "ecore_input", "eina", - "EGL", "evas", - "flutter_engine", + "EGL", "GLESv2", "tbm", "tdm-client", "wayland-client", ] + cflags_cc = [ + "-Wno-newline-eof", + "-Wno-macro-redefined", + ] + + configs += [ + ":tizen_rootstrap_include_dirs", + "//flutter/shell/platform/common/cpp:desktop_library_implementation" + ] + + public_configs = [ "//flutter:config" ] + + public_deps = [ ":flutter_engine" ] + + deps = [ + "//flutter/shell/platform/common/cpp:common_cpp", + "//flutter/shell/platform/common/cpp:common_cpp_input", + "//flutter/shell/platform/common/cpp:common_cpp_library_headers", + "//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper", + "//third_party/rapidjson", + ] + 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" ] } } From 19b8bb8c3359a05de345d4e2d5aefa414971ef38 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 01:18:06 +0900 Subject: [PATCH 03/19] Use templates --- shell/platform/tizen/BUILD.gn | 180 +++++++++++++++++----------------- 1 file changed, 89 insertions(+), 91 deletions(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 9d4f76423b669..0e516c8d2736b 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -4,8 +4,8 @@ import("//flutter/shell/platform/tizen/config.gni") # Sets the rpath of dependent targets (shared libs) to $ORIGIN. -# This assumes that the flutter_engine library exists next to the embedder -# library when they are deployed on Tizen devices. +# We assume that the flutter_engine library exists next to the embedder library +# when they are deployed on Tizen devices. config("tizen_embedder_rpath") { ldflags = [ "-Wl,-rpath,\$ORIGIN" ] } @@ -51,108 +51,106 @@ config("tizen_rootstrap_include_dirs") { lib_dirs = [ "$custom_sysroot/usr/lib" ] } -source_set("flutter_tizen") { - public = [ - "public/flutter_platform_view.h", - "public/flutter_tizen_texture_registrar.h", - "public/flutter_tizen.h", - ] - - sources = [ - "channels/key_event_channel.cc", - "channels/lifecycle_channel.cc", - "channels/localization_channel.cc", - "channels/navigation_channel.cc", - "channels/platform_channel.cc", - "channels/platform_view_channel.cc", - "channels/settings_channel.cc", - "channels/text_input_channel.cc", - "external_texture_gl.cc", - "flutter_tizen.cc", - "key_event_handler.cc", - "tizen_embedder_engine.cc", - "tizen_event_loop.cc", - "tizen_log.cc", - "tizen_renderer.cc", - "tizen_vsync_waiter.cc", - "touch_event_handler.cc", - ] - - libs = [ - "base-utils-i18n", - "capi-appfw-application", - "capi-system-info", - "capi-system-system-settings", - "dlog", - "ecore", - "ecore_imf", - "ecore_input", - "eina", - "evas", - "EGL", - "GLESv2", - "tbm", - "tdm-client", - "wayland-client", - ] - - cflags_cc = [ - "-Wno-newline-eof", - "-Wno-macro-redefined", - ] - - configs += [ - ":tizen_rootstrap_include_dirs", - "//flutter/shell/platform/common/cpp:desktop_library_implementation" - ] - - public_configs = [ "//flutter:config" ] - - public_deps = [ ":flutter_engine" ] - - deps = [ - "//flutter/shell/platform/common/cpp:common_cpp", - "//flutter/shell/platform/common/cpp:common_cpp_input", - "//flutter/shell/platform/common/cpp:common_cpp_library_headers", - "//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper", - "//third_party/rapidjson", - ] - - 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" ] +# Template for the embedder build. Used to generate embedders for different +# device profiles. The output library name is "flutter_tizen_[profile]". +template("embedder_for_profile") { + shared_library("flutter_tizen_${target_name}") { + public = [ + "public/flutter_platform_view.h", + "public/flutter_tizen_texture_registrar.h", + "public/flutter_tizen.h", + ] + + sources = [ + "channels/key_event_channel.cc", + "channels/lifecycle_channel.cc", + "channels/localization_channel.cc", + "channels/navigation_channel.cc", + "channels/platform_channel.cc", + "channels/platform_view_channel.cc", + "channels/settings_channel.cc", + "channels/text_input_channel.cc", + "external_texture_gl.cc", + "flutter_tizen.cc", + "key_event_handler.cc", + "tizen_embedder_engine.cc", + "tizen_event_loop.cc", + "tizen_log.cc", + "tizen_renderer.cc", + "tizen_vsync_waiter.cc", + "touch_event_handler.cc", + ] + + libs = [ + "base-utils-i18n", + "capi-appfw-application", + "capi-system-info", + "capi-system-system-settings", + "dlog", + "ecore", + "ecore_imf", + "ecore_input", + "eina", + "evas", + "EGL", + "GLESv2", + "tbm", + "tdm-client", + "wayland-client", + ] + + defines = invoker.defines + + cflags_cc = [ + "-Wno-newline-eof", + "-Wno-macro-redefined", + ] + + configs += [ + ":tizen_rootstrap_include_dirs", + "//flutter/shell/platform/common/cpp:desktop_library_implementation" + ] + + public_configs = [ "//flutter:config" ] + + public_deps = [ ":flutter_engine" ] + + deps = [ + "//flutter/shell/platform/common/cpp:common_cpp", + "//flutter/shell/platform/common/cpp:common_cpp_input", + "//flutter/shell/platform/common/cpp:common_cpp_library_headers", + "//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper", + "//third_party/rapidjson", + ] + + 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" ] + } } } -shared_library("flutter_tizen_mobile") { +embedder_for_profile("mobile") { defines = [ "MOBILE_PROFILE" ] - - deps = [ ":flutter_tizen" ] } -shared_library("flutter_tizen_wearable") { +embedder_for_profile("wearable") { defines = [ "WEARABLE_PROFILE" ] - - deps = [ ":flutter_tizen" ] } -shared_library("flutter_tizen_tv") { +embedder_for_profile("tv") { defines = [ "TV_PROFILE" ] - - deps = [ ":flutter_tizen" ] } -shared_library("flutter_tizen_common") { +embedder_for_profile("common") { defines = [ "COMMON_PROFILE" ] - - deps = [ ":flutter_tizen" ] } group("tizen") { From 0de970f7aef14cf9b7b40da583026479e7cc058e Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 18:19:19 +0900 Subject: [PATCH 04/19] Use __dlog_print() only on TV --- shell/platform/tizen/tizen_log.cc | 4 ++-- shell/platform/tizen/tizen_log.h | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/tizen_log.cc b/shell/platform/tizen/tizen_log.cc index 83ec8af0c0425..0439dfefa204e 100644 --- a/shell/platform/tizen/tizen_log.cc +++ b/shell/platform/tizen/tizen_log.cc @@ -15,14 +15,14 @@ static bool is_running = false; static void* LoggingFunction(void* arg) { int* pipe = (int*)arg; - int priority = pipe == stdout_pipe ? DLOG_INFO : DLOG_ERROR; + auto priority = pipe == stdout_pipe ? DLOG_INFO : DLOG_ERROR; ssize_t size; char buffer[1024]; while ((size = read(pipe[0], buffer, sizeof(buffer) - 1)) > 0) { buffer[size] = 0; - __dlog_print(LOG_ID_MAIN, priority, LOG_TAG, "%s", buffer); + __LOG(priority, "%s", buffer); } close(pipe[0]); diff --git a/shell/platform/tizen/tizen_log.h b/shell/platform/tizen/tizen_log.h index 61b3aba45b809..7e543b435ab23 100644 --- a/shell/platform/tizen/tizen_log.h +++ b/shell/platform/tizen/tizen_log.h @@ -10,22 +10,29 @@ #include #include -// Start logging threads which constantly redirect stdout/stderr to dlog. +// Starts logging threads which constantly redirect stdout/stderr to dlog. // The threads can be started only once per process. void StartLogging(); #ifdef LOG_TAG #undef LOG_TAG #endif +// This is the only valid log tag that TV devices can understand. #define LOG_TAG "ConsoleMessage" #undef __LOG -#define __LOG(id, prio, tag, fmt, arg...) \ - __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, \ - __LINE__, ##arg); +#ifdef TV_PROFILE +// dlog_print() cannot be used because it implicitly passes LOG_ID_APPS as +// a log id, which is ignored by TV devices. Instead, an internal function +// __dlog_print() that takes a log id as a parameter is used. +#define __LOG(prio, fmt, args...) \ + __dlog_print(LOG_ID_MAIN, prio, LOG_TAG, fmt, ##args) +#else +#define __LOG(prio, fmt, args...) dlog_print(prio, LOG_TAG, fmt, ##args) +#endif #define __FT_LOG(prio, fmt, args...) \ - __LOG(LOG_ID_MAIN, prio, LOG_TAG, fmt, ##args) + __LOG(prio, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##args) #define FT_LOGD(fmt, args...) __FT_LOG(DLOG_DEBUG, fmt, ##args) #define FT_LOGI(fmt, args...) __FT_LOG(DLOG_INFO, fmt, ##args) From 00bf7acd0afae6fb0d979c26d488aaf4a106d576 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 23:01:38 +0900 Subject: [PATCH 05/19] Copy headers and icudata --- shell/platform/tizen/BUILD.gn | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 0e516c8d2736b..a8096591cf16c 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -1,6 +1,7 @@ # Copyright 2020 Samsung Electronics Co., Ltd. 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/common/cpp/client_wrapper/publish.gni") import("//flutter/shell/platform/tizen/config.gni") # Sets the rpath of dependent targets (shared libs) to $ORIGIN. @@ -22,6 +23,12 @@ source_set("flutter_engine") { deps = [ "//flutter/shell/platform/embedder:flutter_engine" ] } +_public_headers = [ + "public/flutter_platform_view.h", + "public/flutter_tizen_texture_registrar.h", + "public/flutter_tizen.h", +] + # Tizen native headers assume that the following include dirs are already # added to the compiler's search paths. Since we are not using the Tizen CLI # builder, we have to add them manually. @@ -55,11 +62,7 @@ config("tizen_rootstrap_include_dirs") { # device profiles. The output library name is "flutter_tizen_[profile]". template("embedder_for_profile") { shared_library("flutter_tizen_${target_name}") { - public = [ - "public/flutter_platform_view.h", - "public/flutter_tizen_texture_registrar.h", - "public/flutter_tizen.h", - ] + public = _public_headers sources = [ "channels/key_event_channel.cc", @@ -153,11 +156,39 @@ embedder_for_profile("common") { defines = [ "COMMON_PROFILE" ] } +publish_client_wrapper_core("publish_cpp_client_wrapper") { + visibility = [ ":*" ] +} + +_common_cpp_public_headers = [ + "//flutter/shell/platform/common/cpp/public/flutter_export.h", + "//flutter/shell/platform/common/cpp/public/flutter_messenger.h", + "//flutter/shell/platform/common/cpp/public/flutter_plugin_registrar.h", + "//flutter/shell/platform/common/cpp/public/flutter_texture_registrar.h", +] + +copy("publish_headers_tizen") { + sources = _public_headers + _common_cpp_public_headers + + outputs = [ "$root_out_dir/public/{{source_file_part}}" ] +} + +copy("copy_icu") { + visibility = [ ":*" ] + + sources = [ "//third_party/icu/flutter/icudtl.dat" ] + + outputs = [ "$root_out_dir/icu/{{source_file_part}}" ] +} + group("tizen") { deps = [ ":flutter_tizen_mobile", ":flutter_tizen_wearable", ":flutter_tizen_tv", ":flutter_tizen_common", + ":publish_cpp_client_wrapper", + ":publish_headers_tizen", + ":copy_icu" ] } From 30223bc413aff42bc3b082434b2b9e9d4dcf6035 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 23:02:06 +0900 Subject: [PATCH 06/19] Partially update azure-pipelines.yml --- azure-pipelines.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b8ed161045e70..aaa59f830806f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -99,6 +99,10 @@ jobs: if [[ "$(arch)" != "arm64" ]]; then cp tizen40/out/linux_$(mode)_$(arch)/libflutter_tizen.so $OUTDIR/libflutter_tizen40.so fi + if [[ $(System.JobName) == "tizen-arm-release" ]]; then + mkdir $OUTDIR/common + cp default/out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common + fi displayName: Copy artifacts workingDirectory: $(buildroot)/output failOnStderr: true @@ -119,19 +123,12 @@ jobs: path: src/flutter - download: current - bash: | - mkdir -p common/client_wrapper - ROOT=$(Pipeline.Workspace)/src/flutter/shell/platform - cp $ROOT/common/cpp/client_wrapper/*.{h,cc} common/client_wrapper - rm common/client_wrapper/{*_unittests.*,engine_method_result.cc} - cp -r $ROOT/common/cpp/public common - cp -r $ROOT/common/cpp/client_wrapper/include common/client_wrapper - cp $ROOT/tizen/public/*.h common/public - cp $ROOT/tizen/LICENSE . - displayName: Copy headers + mv $(Pipeline.Workspace)/tizen-arm-release/common . + rm common/client_wrapper/engine_method_result.cc + displayName: Copy common files workingDirectory: $(Build.BinariesDirectory) failOnStderr: true - bash: | - cp $(Pipeline.Workspace)/src/third_party/icu/flutter/icudtl.dat common mv $(Pipeline.Workspace)/tizen-* . for platform in linux windows darwin; do for arch in arm arm64; do From 4a4181a7c677899bcf450739d325416623772f5c Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sat, 17 Apr 2021 23:11:22 +0900 Subject: [PATCH 07/19] Temporarily unsupport Tizen 4.0 and use only ecore_wl2 --- azure-pipelines.yml | 33 +---- shell/platform/tizen/BUILD.gn | 12 +- .../tizen/channels/text_input_channel.cc | 2 - shell/platform/tizen/tizen_embedder_engine.cc | 6 - shell/platform/tizen/tizen_embedder_engine.h | 4 - .../platform/tizen/tizen_renderer_ecore_wl.cc | 133 ------------------ .../platform/tizen/tizen_renderer_ecore_wl.h | 46 ------ tools/gn | 2 - 8 files changed, 7 insertions(+), 231 deletions(-) delete mode 100644 shell/platform/tizen/tizen_renderer_ecore_wl.cc delete mode 100644 shell/platform/tizen/tizen_renderer_ecore_wl.h diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aaa59f830806f..4538ec590b735 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -68,43 +68,20 @@ jobs: --runtime-mode $(mode) \ --embedder-for-target \ --disable-desktop-embeddings \ - --build-tizen-shell \ - --out-dir output/default - ninja -C output/default/out/linux_$(mode)_$(arch) + --build-tizen-shell + ninja -C out/linux_$(mode)_$(arch) displayName: Build workingDirectory: $(buildroot) failOnStderr: true - - bash: | - flutter/tools/gn \ - --target-os linux \ - --linux-cpu $(arch) \ - --target-toolchain `pwd`/tizen_tools/toolchains \ - --target-sysroot `pwd`/tizen_tools/sysroot/$(arch)_40 \ - --target-triple $(targetTriple) \ - --runtime-mode $(mode) \ - --embedder-for-target \ - --disable-desktop-embeddings \ - --build-tizen-shell \ - --tizen-sdk-4 \ - --out-dir output/tizen40 - ninja -C output/tizen40/out/linux_$(mode)_$(arch) - displayName: Build for Tizen 4.0 - workingDirectory: $(buildroot) - condition: ne(variables['arch'], 'arm64') - failOnStderr: true - bash: | OUTDIR=$(Build.StagingDirectory) - cp default/out/linux_$(mode)_$(arch)/libflutter_engine.so $OUTDIR - cp default/out/linux_$(mode)_$(arch)/libflutter_tizen.so $OUTDIR - if [[ "$(arch)" != "arm64" ]]; then - cp tizen40/out/linux_$(mode)_$(arch)/libflutter_tizen.so $OUTDIR/libflutter_tizen40.so - fi + cp out/linux_$(mode)_$(arch)/libflutter_*.so $OUTDIR if [[ $(System.JobName) == "tizen-arm-release" ]]; then mkdir $OUTDIR/common - cp default/out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common + cp out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common fi displayName: Copy artifacts - workingDirectory: $(buildroot)/output + workingDirectory: $(buildroot) failOnStderr: true - publish: $(Build.StagingDirectory) artifact: $(System.JobName) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index a8096591cf16c..ae5831b04138c 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -126,17 +126,9 @@ template("embedder_for_profile") { "//third_party/rapidjson", ] - if (tizen_sdk_4) { - sources += [ "tizen_renderer_ecore_wl.cc" ] + sources += [ "tizen_renderer_ecore_wl2.cc" ] - libs += [ "ecore_wayland", "wayland-egl" ] - - defines = [ "FLUTTER_TIZEN_4" ] - } else { - sources += [ "tizen_renderer_ecore_wl2.cc" ] - - libs += [ "ecore_wl2" ] - } + libs += [ "ecore_wl2" ] } } diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 5692ba3726356..b5883a5109089 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -435,9 +435,7 @@ 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; diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index 4d4c5105905b1..3ee512d784f0a 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -46,15 +46,9 @@ static double GetDeviceDpi() { TizenEmbedderEngine::TizenEmbedderEngine( const FlutterWindowProperties& window_properties) : device_profile(GetDeviceProfile()), device_dpi(GetDeviceDpi()) { -#ifdef FLUTTER_TIZEN_4 - tizen_renderer = std::make_unique( - *this, window_properties.x, window_properties.y, window_properties.width, - window_properties.height); -#else tizen_renderer = std::make_unique( *this, 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 diff --git a/shell/platform/tizen/tizen_embedder_engine.h b/shell/platform/tizen/tizen_embedder_engine.h index 93d19fa266263..3bf9b924b4fe1 100644 --- a/shell/platform/tizen/tizen_embedder_engine.h +++ b/shell/platform/tizen/tizen_embedder_engine.h @@ -24,11 +24,7 @@ #include "flutter/shell/platform/tizen/public/flutter_tizen_texture_registrar.h" #include "flutter/shell/platform/tizen/tizen_event_loop.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" diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl.cc b/shell/platform/tizen/tizen_renderer_ecore_wl.cc deleted file mode 100644 index 997163d52550e..0000000000000 --- a/shell/platform/tizen/tizen_renderer_ecore_wl.cc +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "tizen_renderer_ecore_wl.h" - -#include "flutter/shell/platform/tizen/tizen_log.h" - -TizenRendererEcoreWl::TizenRendererEcoreWl(TizenRenderer::Delegate &delegate, - int32_t x, int32_t y, int32_t w, - int32_t h) - : TizenRenderer(delegate) { - InitializeRenderer(x, y, w, h); -} - -TizenRendererEcoreWl::~TizenRendererEcoreWl() { DestoryRenderer(); } - -bool TizenRendererEcoreWl::SetupDisplay() { - // ecore_wl INIT - if (!ecore_wl_init(NULL)) { - FT_LOGE("Could not initialize ecore_wl"); - return false; - } - wl_display_ = ecore_wl_display_get(); - if (nullptr == wl_display_) { - FT_LOGE("ecore_wl_display_get failed"); - return false; - } - return true; -} - -bool TizenRendererEcoreWl::SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, - int32_t h) { - if (w == 0 || h == 0) { - FT_LOGE("Failed to create because of the wrong size"); - return false; - } - - ecore_wl_window_ = ecore_wl_window_new( - nullptr, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW); - FT_LOGD("ecore_wl_window_: %p", ecore_wl_window_); - if (ecore_wl_window_ == nullptr) { - FT_LOGE("ecore_wl_window_new fail"); - return false; - } - ecore_wl_window_type_set(ecore_wl_window_, ECORE_WL_WINDOW_TYPE_TOPLEVEL); - // ecore_wl_window_alpha_set(ecore_wl_window_, EINA_FALSE); - ecore_wl_window_aux_hint_add(ecore_wl_window_, 0, - "wm.policy.win.user.geometry", "1"); - ecore_wl_window_show(ecore_wl_window_); - int rotations[4] = {0, 90, 180, 270}; - ecore_wl_window_rotation_available_rotations_set( - ecore_wl_window_, rotations, sizeof(rotations) / sizeof(int)); - ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE, RotationEventCb, this); - return true; -} - -Eina_Bool TizenRendererEcoreWl::RotationEventCb(void *data, int type, - void *event) { - auto *self = reinterpret_cast(data); - Ecore_Wl_Event_Window_Rotate *ev = - reinterpret_cast(event); - self->delegate_.OnRotationChange(ev->angle); - return ECORE_CALLBACK_PASS_ON; -} - -void TizenRendererEcoreWl::Show() { ecore_wl_window_show(ecore_wl_window_); } - -void TizenRendererEcoreWl::SetRotate(int degree) { - ecore_wl_window_rotation_set(ecore_wl_window_, degree); - received_rotation = true; -} - -void TizenRendererEcoreWl::ResizeWithRotation(int32_t x, int32_t y, - int32_t width, int32_t height, - int32_t degree) { - wl_egl_window_set_buffer_transform(wl_egl_window_, degree / 90); - wl_egl_window_set_window_transform(wl_egl_window_, degree / 90); - - if ((degree == 90) || (degree == 270)) - wl_egl_window_resize(wl_egl_window_, height, width, x, y); - else - wl_egl_window_resize(wl_egl_window_, width, height, x, y); -} - -void TizenRendererEcoreWl::SendRotationChangeDone() { - ecore_wl_window_rotation_change_done_send(ecore_wl_window_); -} - -bool TizenRendererEcoreWl::SetupEglWindow(int32_t w, int32_t h) { - wl_egl_window_ = - wl_egl_window_create(ecore_wl_window_surface_get(ecore_wl_window_), w, h); - if (nullptr == wl_egl_window_) { - FT_LOGE("wl_egl_window_create is Failed"); - return false; - } - return true; -} - -EGLDisplay TizenRendererEcoreWl::GetEGLDisplay() { - return eglGetDisplay((EGLNativeDisplayType)wl_display_); -} - -EGLNativeWindowType TizenRendererEcoreWl::GetEGLNativeWindowType() { - return (EGLNativeWindowType)wl_egl_window_; -} - -void TizenRendererEcoreWl::DestoryEglWindow() { - if (wl_egl_window_) { - wl_egl_window_destroy(wl_egl_window_); - wl_egl_window_ = nullptr; - } -} - -void TizenRendererEcoreWl::DestoryEcoreWlWindow() { - if (ecore_wl_window_) { - ecore_wl_window_free(ecore_wl_window_); - ecore_wl_window_ = nullptr; - } -} - -void TizenRendererEcoreWl::ShutdownDisplay() { ecore_wl_shutdown(); } - -TizenRenderer::TizenWindowGeometry TizenRendererEcoreWl::GetGeometry() { - TizenWindowGeometry result; - ecore_wl_window_geometry_get(ecore_wl_window_, &result.x, &result.y, - &result.w, &result.h); - return result; -} - -int TizenRendererEcoreWl::GetEcoreWindowId() { - return ecore_wl_window_id_get(ecore_wl_window_); -} diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl.h b/shell/platform/tizen/tizen_renderer_ecore_wl.h deleted file mode 100644 index 7e9c6f1fb0bbf..0000000000000 --- a/shell/platform/tizen/tizen_renderer_ecore_wl.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef EMBEDDER_TIZEN_RENDERER_ECORE_WL_H -#define EMBEDDER_TIZEN_RENDERER_ECORE_WL_H - -#include -#include - -#define EFL_BETA_API_SUPPORT -#include - -#include "flutter/shell/platform/tizen/tizen_renderer.h" - -class TizenRendererEcoreWl : public TizenRenderer { - public: - TizenRendererEcoreWl(TizenRenderer::Delegate& delegate, int32_t x, int32_t y, - int32_t w, int32_t h); - ~TizenRendererEcoreWl(); - TizenRenderer::TizenWindowGeometry GetGeometry() override; - void Show() override; - void SetRotate(int angle) override; - void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, - int32_t degree) override; - int GetEcoreWindowId() override; - - protected: - void DestoryEglWindow() override; - void DestoryEcoreWlWindow() override; - EGLDisplay GetEGLDisplay() override; - EGLNativeWindowType GetEGLNativeWindowType() override; - bool SetupDisplay() override; - bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, int32_t h) override; - bool SetupEglWindow(int32_t w, int32_t h) override; - void ShutdownDisplay() override; - void SendRotationChangeDone() override; - - private: - Ecore_Wl_Window* ecore_wl_window_ = nullptr; - wl_egl_window* wl_egl_window_ = nullptr; - wl_display* wl_display_ = nullptr; - static Eina_Bool RotationEventCb(void* data, int type, void* event); -}; - -#endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL_H diff --git a/tools/gn b/tools/gn index 5bd2ae9fa35c5..f77f8ee31d6b6 100755 --- a/tools/gn +++ b/tools/gn @@ -129,7 +129,6 @@ def to_gn_args(args): gn_args['embedder_for_target'] = args.embedder_for_target gn_args['build_tizen_shell'] = args.build_tizen_shell - gn_args['tizen_sdk_4'] = args.tizen_sdk_4 gn_args['enable_coverage'] = args.coverage @@ -404,7 +403,6 @@ def parse_args(args): parser.add_argument('--embedder-for-target', dest='embedder_for_target', action='store_true', default=False) parser.add_argument('--build-tizen-shell', dest='build_tizen_shell', action='store_true', default=False) - parser.add_argument('--tizen-sdk-4', dest='tizen_sdk_4', action='store_true', default=False) parser.add_argument('--coverage', default=False, action='store_true') From b12b8d4a6d5a99556ef2657e153ec1742fc79b87 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Sun, 18 Apr 2021 20:14:49 +0900 Subject: [PATCH 08/19] Cherry-pick "Enable Evas GL direct mode (#54)" - Cherry-pick the commit from flutter-2.0.1-tizen-dev - Rename FLUTTER_TIZEN_EVASGL with TIZEN_RENDERER_EVAS_GL - Add missing switches and fix build errors Co-authored-by: Boram Bae Co-authored-by: MuHong Byun --- shell/common/animator.cc | 13 +- shell/platform/tizen/BUILD.gn | 49 +- .../tizen/channels/text_input_channel.cc | 70 +- shell/platform/tizen/external_texture_gl.cc | 63 +- shell/platform/tizen/tizen_embedder_engine.cc | 50 +- shell/platform/tizen/tizen_embedder_engine.h | 14 +- shell/platform/tizen/tizen_event_loop.cc | 75 ++- shell/platform/tizen/tizen_event_loop.h | 37 +- shell/platform/tizen/tizen_renderer.cc | 611 ++++++++++++++++++ shell/platform/tizen/tizen_renderer.h | 46 +- .../platform/tizen/tizen_renderer_evas_gl.cc | 102 +++ shell/platform/tizen/tizen_renderer_evas_gl.h | 38 ++ 12 files changed, 1065 insertions(+), 103 deletions(-) create mode 100644 shell/platform/tizen/tizen_renderer_evas_gl.cc create mode 100644 shell/platform/tizen/tizen_renderer_evas_gl.h diff --git a/shell/common/animator.cc b/shell/common/animator.cc index cacac38c12063..3f27cb40dc775 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -35,11 +35,14 @@ Animator::Animator(Delegate& delegate, // 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. - layer_tree_pipeline_(fml::MakeRefCounted( - task_runners.GetPlatformTaskRunner() == - task_runners.GetRasterTaskRunner() - ? 1 - : 2)), + // layer_tree_pipeline_(fml::MakeRefCounted( + // task_runners.GetPlatformTaskRunner() == + // task_runners.GetRasterTaskRunner() + // ? 1 + // : 2)), + // FIXME(bbrto21): This is a workaround to avoid flickering that occurs + // in evas gl direct mode. + layer_tree_pipeline_(fml::MakeRefCounted(1)), #endif // SHELL_ENABLE_METAL pending_frame_semaphore_(1), frame_number_(1), diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index ae5831b04138c..1ea9bcf30bb00 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -1,6 +1,7 @@ # Copyright 2020 Samsung Electronics Co., Ltd. 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/common/cpp/client_wrapper/publish.gni") import("//flutter/shell/platform/tizen/config.gni") @@ -52,7 +53,17 @@ config("tizen_rootstrap_include_dirs") { "$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", + # For Evas_GL. + "$custom_sysroot/usr/include/ecore-con-1", + "$custom_sysroot/usr/include/ecore-file-1", + "$custom_sysroot/usr/include/edje-1", + "$custom_sysroot/usr/include/eet-1", + "$custom_sysroot/usr/include/efl-1/interfaces", + "$custom_sysroot/usr/include/efreet-1", + "$custom_sysroot/usr/include/elementary-1", + "$custom_sysroot/usr/include/ethumb-1", + "$custom_sysroot/usr/include/ethumb-client-1", ] lib_dirs = [ "$custom_sysroot/usr/lib" ] @@ -60,7 +71,16 @@ config("tizen_rootstrap_include_dirs") { # Template for the embedder build. Used to generate embedders for different # device profiles. The output library name is "flutter_tizen_[profile]". +# +# If use_evas_gl_renderer is provided as true, the Evas_GL renderer is used, +# otherwise the Ecore_Wl2 renderer is used. template("embedder_for_profile") { + forward_variables_from(invoker, [ "use_evas_gl_renderer" ]) + + if (!defined(use_evas_gl_renderer)) { + use_evas_gl_renderer = false + } + shared_library("flutter_tizen_${target_name}") { public = _public_headers @@ -80,7 +100,6 @@ template("embedder_for_profile") { "tizen_event_loop.cc", "tizen_log.cc", "tizen_renderer.cc", - "tizen_vsync_waiter.cc", "touch_event_handler.cc", ] @@ -104,6 +123,24 @@ template("embedder_for_profile") { defines = invoker.defines + if (use_evas_gl_renderer) { + sources += [ "tizen_renderer_evas_gl.cc" ] + + libs += [ + "ecore_evas", + "elementary", + ] + + defines += [ "TIZEN_RENDERER_EVAS_GL" ] + } else { + sources += [ + "tizen_renderer_ecore_wl2.cc", + "tizen_vsync_waiter.cc", + ] + + libs += [ "ecore_wl2" ] + } + cflags_cc = [ "-Wno-newline-eof", "-Wno-macro-redefined", @@ -125,10 +162,6 @@ template("embedder_for_profile") { "//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper", "//third_party/rapidjson", ] - - sources += [ "tizen_renderer_ecore_wl2.cc" ] - - libs += [ "ecore_wl2" ] } } @@ -138,6 +171,8 @@ embedder_for_profile("mobile") { embedder_for_profile("wearable") { defines = [ "WEARABLE_PROFILE" ] + + use_evas_gl_renderer = true } embedder_for_profile("tv") { @@ -181,6 +216,6 @@ group("tizen") { ":flutter_tizen_common", ":publish_cpp_client_wrapper", ":publish_headers_tizen", - ":copy_icu" + ":copy_icu", ] } diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index b5883a5109089..f90288405327d 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -202,61 +202,6 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( return static_cast(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>( @@ -418,7 +363,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; @@ -430,15 +376,13 @@ 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 = ""; + } ecoreKeyDownEvent.keycode = keyDownEvent->keycode; - bool isIME = strcmp(device, "ime") == 0; - if (isIME && strcmp(keyDownEvent->key, "Select") == 0) { if (engine_->device_profile == DeviceProfile::kWearable) { // FIXME: for wearable diff --git a/shell/platform/tizen/external_texture_gl.cc b/shell/platform/tizen/external_texture_gl.cc index d7078978f5685..3586109c52a1b 100644 --- a/shell/platform/tizen/external_texture_gl.cc +++ b/shell/platform/tizen/external_texture_gl.cc @@ -4,11 +4,20 @@ #include "external_texture_gl.h" +#ifdef TIZEN_RENDERER_EVAS_GL +#undef EFL_BETA_API_SUPPORT +#include +#include +#include +extern Evas_GL* g_evas_gl; +EVAS_GL_GLOBAL_GLES3_DECLARE(); +#else #include #include #include #include #include +#endif #include #include @@ -48,13 +57,13 @@ 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; } @@ -67,22 +76,54 @@ 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; } +#ifdef TIZEN_RENDERER_EVAS_GL + 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); + } +#else 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; } @@ -103,12 +144,14 @@ 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); } +#endif + opengl_texture->target = GL_TEXTURE_EXTERNAL_OES; opengl_texture->name = state_->gl_texture; opengl_texture->format = GL_RGBA8; @@ -131,7 +174,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; } diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index 3ee512d784f0a..a4bfccababc15 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -15,6 +15,9 @@ // Unique number associated with platform tasks. static constexpr size_t kPlatformTaskRunnerIdentifier = 1; +#ifdef TIZEN_RENDERER_EVAS_GL +static constexpr size_t kRenderTaskRunnerIdentifier = 2; +#endif static DeviceProfile GetDeviceProfile() { char* feature_profile; @@ -46,14 +49,24 @@ static double GetDeviceDpi() { TizenEmbedderEngine::TizenEmbedderEngine( const FlutterWindowProperties& window_properties) : device_profile(GetDeviceProfile()), device_dpi(GetDeviceDpi()) { +#ifdef TIZEN_RENDERER_EVAS_GL + tizen_renderer = std::make_unique( + *this, window_properties.x, window_properties.y, window_properties.width, + window_properties.height); + // clear once to remove noise + tizen_renderer->OnMakeCurrent(); + tizen_renderer->ClearColor(0, 0, 0, 0); + tizen_renderer->OnPresent(); +#else tizen_renderer = std::make_unique( *this, 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 // thread). UI threads need to send flutter task to platform thread. - event_loop_ = std::make_unique( + event_loop_ = std::make_unique( std::this_thread::get_id(), // main thread [this](const auto* task) { if (FlutterEngineRunTask(this->flutter_engine, task) != kSuccess) { @@ -61,12 +74,25 @@ TizenEmbedderEngine::TizenEmbedderEngine( } }); +#ifdef TIZEN_RENDERER_EVAS_GL + render_loop_ = std::make_unique( + std::this_thread::get_id(), // main thread + [this](const auto* task) { + if (FlutterEngineRunTask(this->flutter_engine, task) != kSuccess) { + FT_LOGE("Could not post an engine task."); + } + }, + tizen_renderer.get()); +#endif + messenger = std::make_unique(); messenger->engine = this; message_dispatcher = std::make_unique(messenger.get()); +#ifndef TIZEN_RENDERER_EVAS_GL tizen_vsync_waiter_ = std::make_unique(this); +#endif } TizenEmbedderEngine::~TizenEmbedderEngine() { @@ -129,9 +155,27 @@ bool TizenEmbedderEngine::RunEngine( }; platform_task_runner.identifier = kPlatformTaskRunnerIdentifier; +#ifdef TIZEN_RENDERER_EVAS_GL + FlutterTaskRunnerDescription render_task_runner = {}; + render_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription); + render_task_runner.user_data = render_loop_.get(); + render_task_runner.runs_task_on_current_thread_callback = + [](void* data) -> bool { + return static_cast(data)->RunsTasksOnCurrentThread(); + }; + render_task_runner.post_task_callback = + [](FlutterTask task, uint64_t target_time_nanos, void* data) -> void { + static_cast(data)->PostTask(task, target_time_nanos); + }; + render_task_runner.identifier = kRenderTaskRunnerIdentifier; +#endif + FlutterCustomTaskRunners custom_task_runners = {}; custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners); custom_task_runners.platform_task_runner = &platform_task_runner; +#ifdef TIZEN_RENDERER_EVAS_GL + custom_task_runners.render_task_runner = &render_task_runner; +#endif FlutterRendererConfig config = {}; config.type = kOpenGL; @@ -153,7 +197,9 @@ bool TizenEmbedderEngine::RunEngine( args.command_line_argv = &argv[0]; args.platform_message_callback = OnFlutterPlatformMessage; args.custom_task_runners = &custom_task_runners; +#ifndef TIZEN_RENDERER_EVAS_GL args.vsync_callback = OnVsyncCallback; +#endif if (FlutterEngineRunsAOTCompiledDartCode()) { aot_data_ = LoadAotData(engine_properties.aot_library_path); @@ -343,11 +389,13 @@ void TizenEmbedderEngine::OnFlutterPlatformMessage( tizen_embedder_engine->message_dispatcher->HandleMessage(message); } +#ifndef TIZEN_RENDERER_EVAS_GL void TizenEmbedderEngine::OnVsyncCallback(void* user_data, intptr_t baton) { TizenEmbedderEngine* tizen_embedder_engine = reinterpret_cast(user_data); tizen_embedder_engine->tizen_vsync_waiter_->AsyncWaitForVsync(baton); } +#endif // Converts a FlutterPlatformMessage to an equivalent FlutterDesktopMessage. FlutterDesktopMessage TizenEmbedderEngine::ConvertToDesktopMessage( diff --git a/shell/platform/tizen/tizen_embedder_engine.h b/shell/platform/tizen/tizen_embedder_engine.h index 3bf9b924b4fe1..654d2a76405bf 100644 --- a/shell/platform/tizen/tizen_embedder_engine.h +++ b/shell/platform/tizen/tizen_embedder_engine.h @@ -24,8 +24,12 @@ #include "flutter/shell/platform/tizen/public/flutter_tizen_texture_registrar.h" #include "flutter/shell/platform/tizen/tizen_event_loop.h" #include "flutter/shell/platform/tizen/tizen_renderer.h" +#ifdef TIZEN_RENDERER_EVAS_GL +#include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h" +#else #include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h" #include "flutter/shell/platform/tizen/tizen_vsync_waiter.h" +#endif #include "flutter/shell/platform/tizen/touch_event_handler.h" // State associated with the plugin registrar. @@ -122,7 +126,9 @@ class TizenEmbedderEngine : public TizenRenderer::Delegate { static void* GlProcResolver(void* user_data, const char* name); static void OnFlutterPlatformMessage( const FlutterPlatformMessage* engine_message, void* user_data); +#ifndef TIZEN_RENDERER_EVAS_GL static void OnVsyncCallback(void* user_data, intptr_t baton); +#endif FlutterDesktopMessage ConvertToDesktopMessage( const FlutterPlatformMessage& engine_message); @@ -146,10 +152,16 @@ class TizenEmbedderEngine : public TizenRenderer::Delegate { std::unique_ptr internal_plugin_registrar_; // The event loop for the main thread that allows for delayed task execution. - std::unique_ptr event_loop_; + std::unique_ptr event_loop_; +#ifdef TIZEN_RENDERER_EVAS_GL + std::unique_ptr render_loop_; +#endif + +#ifndef TIZEN_RENDERER_EVAS_GL // The vsync waiter for the embedder. std::unique_ptr tizen_vsync_waiter_; +#endif // AOT data for this engine instance, if applicable. UniqueAotDataPtr aot_data_; diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index 876818f05815d..c1d14365d9cfd 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -8,6 +8,9 @@ #include #include +#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/tizen_renderer.h" + TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id, TaskExpiredCallback on_task_expired) : main_thread_id_(main_thread_id), @@ -27,22 +30,21 @@ bool TizenEventLoop::RunsTasksOnCurrentThread() const { void TizenEventLoop::ExcuteTaskEvents(std::chrono::nanoseconds max_wait) { const auto now = TaskTimePoint::clock::now(); - std::vector expired_tasks; { - std::lock_guard lock(task_queue_mutex_); + std::lock_guard lock1(task_queue_mutex_); + std::lock_guard lock2(expired_tasks_mutex_); while (!task_queue_.empty()) { const auto& top = task_queue_.top(); if (top.fire_time > now) { break; } - expired_tasks.push_back(task_queue_.top().task); + + expired_tasks_.push_back(task_queue_.top().task); task_queue_.pop(); } } - for (const auto& task : expired_tasks) { - on_task_expired_(&task); - } + OnTaskExpired(); } TizenEventLoop::TaskTimePoint TizenEventLoop::TimePointFromFlutterTime( @@ -55,9 +57,8 @@ TizenEventLoop::TaskTimePoint TizenEventLoop::TimePointFromFlutterTime( void TizenEventLoop::PostTask(FlutterTask flutter_task, uint64_t flutter_target_time_nanos) { - static std::atomic sGlobalTaskOrder(0); Task task; - task.order = ++sGlobalTaskOrder; + task.order = ++task_order_; task.fire_time = TimePointFromFlutterTime(flutter_target_time_nanos); task.task = flutter_task; if (ecore_pipe_) { @@ -87,6 +88,62 @@ void TizenEventLoop::ExcuteTaskEvents(void* data, void* buffer, } ecore_timer_add(flutter_duration, TaskTimerCallback, tizenEventLoop); } else { - tizenEventLoop->on_task_expired_(&(p_task->task)); + { + std::lock_guard lock(tizenEventLoop->expired_tasks_mutex_); + tizenEventLoop->expired_tasks_.push_back(p_task->task); + } + tizenEventLoop->OnTaskExpired(); + } +} + +TizenPlatformEventLoop::TizenPlatformEventLoop( + std::thread::id main_thread_id, TaskExpiredCallback on_task_expired) + : TizenEventLoop(main_thread_id, on_task_expired) {} + +TizenPlatformEventLoop::~TizenPlatformEventLoop() {} + +void TizenPlatformEventLoop::OnTaskExpired() { + for (const auto& task : expired_tasks_) { + on_task_expired_(&task); + } + expired_tasks_.clear(); +} + +#ifdef TIZEN_RENDERER_EVAS_GL +TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id, + TaskExpiredCallback on_task_expired, + TizenRenderer* tizen_renderer) + : TizenEventLoop(main_thread_id, on_task_expired), + tizen_renderer_(tizen_renderer) { + evas_object_image_pixels_get_callback_set( + (Evas_Object*)tizen_renderer_->GetImageHandle(), + [](void* data, Evas_Object* o) { // Render call back + TizenRenderEventLoop* self = (TizenRenderEventLoop*)data; + { + std::lock_guard lock(self->expired_tasks_mutex_); + for (const auto& task : self->expired_tasks_) { + self->on_task_expired_(&task); + } + self->expired_tasks_.clear(); + } + self->has_pending_renderer_callback_ = false; + }, + this); +} + +TizenRenderEventLoop::~TizenRenderEventLoop() {} + +void TizenRenderEventLoop::OnTaskExpired() { + size_t expired_tasks_count = 0; + std::lock_guard lock(expired_tasks_mutex_); + expired_tasks_count = expired_tasks_.size(); + if (has_pending_renderer_callback_ == false && expired_tasks_count) { + evas_object_image_pixels_dirty_set( + (Evas_Object*)tizen_renderer_->GetImageHandle(), EINA_TRUE); + has_pending_renderer_callback_ = true; + } else { + // Do nothing + FT_LOGD("Ignore set dirty"); } } +#endif diff --git a/shell/platform/tizen/tizen_event_loop.h b/shell/platform/tizen/tizen_event_loop.h index 56b41fae27e34..15ad7225d8952 100644 --- a/shell/platform/tizen/tizen_event_loop.h +++ b/shell/platform/tizen/tizen_event_loop.h @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -18,12 +19,14 @@ #include "flutter/shell/platform/embedder/embedder.h" +class TizenRenderer; + class TizenEventLoop { public: using TaskExpiredCallback = std::function; TizenEventLoop(std::thread::id main_thread_id, TaskExpiredCallback on_task_expired); - ~TizenEventLoop(); + virtual ~TizenEventLoop(); bool RunsTasksOnCurrentThread() const; void ExcuteTaskEvents( @@ -32,7 +35,9 @@ class TizenEventLoop { // Post a Flutter engine tasks to the event loop for delayed execution. void PostTask(FlutterTask flutter_task, uint64_t flutter_target_time_nanos); - private: + virtual void OnTaskExpired() = 0; + + protected: using TaskTimePoint = std::chrono::steady_clock::time_point; struct Task { uint64_t order; @@ -53,6 +58,11 @@ class TizenEventLoop { std::mutex task_queue_mutex_; std::priority_queue, Task::Comparer> task_queue_; std::condition_variable task_queue_cv_; + std::vector expired_tasks_; + std::mutex expired_tasks_mutex_; + std::atomic task_order_{0}; + + private: Ecore_Pipe* ecore_pipe_; TizenEventLoop(const TizenEventLoop&) = delete; @@ -66,4 +76,27 @@ class TizenEventLoop { uint64_t flutter_target_time_nanos); }; +class TizenPlatformEventLoop : public TizenEventLoop { + public: + TizenPlatformEventLoop(std::thread::id main_thread_id, + TaskExpiredCallback on_task_expired); + virtual ~TizenPlatformEventLoop(); + virtual void OnTaskExpired() override; +}; + +#ifdef TIZEN_RENDERER_EVAS_GL +class TizenRenderEventLoop : public TizenEventLoop { + public: + TizenRenderEventLoop(std::thread::id main_thread_id, + TaskExpiredCallback on_task_expired, + TizenRenderer* tizen_renderer); + virtual ~TizenRenderEventLoop(); + virtual void OnTaskExpired() override; + + private: + TizenRenderer* tizen_renderer_; + std::atomic_bool has_pending_renderer_callback_{false}; +}; +#endif + #endif // TIZEN_EVENT_LOOP_H_ diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index 1354a7648b119..f0472103489e9 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -4,8 +4,14 @@ #include "tizen_renderer.h" +#ifdef TIZEN_RENDERER_EVAS_GL +#include +Evas_GL* g_evas_gl = nullptr; +EVAS_GL_GLOBAL_GLES3_DEFINE(); +#else #include #include +#endif #include "flutter/shell/platform/tizen/tizen_log.h" @@ -14,6 +20,609 @@ TizenRenderer::TizenRenderer(TizenRenderer::Delegate& delegate) TizenRenderer::~TizenRenderer() = default; +#ifdef TIZEN_RENDERER_EVAS_GL + +void TizenRenderer::ClearColor(float r, float g, float b, float a) { + glClearColor(r, g, b, a); + glClear(GL_COLOR_BUFFER_BIT); +} + +bool TizenRenderer::OnMakeCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, gl_surface_, gl_context_) != EINA_TRUE) { + return false; + } + + return true; +} + +bool TizenRenderer::OnClearCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, NULL, NULL) != EINA_TRUE) { + return false; + } + return true; +} + +bool TizenRenderer::OnMakeResourceCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, gl_resource_surface_, + gl_resource_context_) != EINA_TRUE) { + return false; + } + return true; +} + +bool TizenRenderer::OnPresent() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (received_rotation) { + SendRotationChangeDone(); + received_rotation = false; + } + + return true; +} + +uint32_t TizenRenderer::OnGetFBO() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return 999; + } + FT_LOGD("OnGetFBO"); + return 0; +} + +#define GL_FUNC(FunctionName) \ + else if (strcmp(name, #FunctionName) == 0) { \ + return reinterpret_cast(FunctionName); \ + } +void* TizenRenderer::OnProcResolver(const char* name) { + auto address = evas_gl_proc_address_get(evas_gl_, name); + if (address != nullptr) { + return reinterpret_cast(address); + } + GL_FUNC(glActiveTexture) + GL_FUNC(glAttachShader) + GL_FUNC(glBindAttribLocation) + GL_FUNC(glBindBuffer) + GL_FUNC(glBindFramebuffer) + GL_FUNC(glBindRenderbuffer) + GL_FUNC(glBindTexture) + GL_FUNC(glBlendColor) + GL_FUNC(glBlendEquation) + GL_FUNC(glBlendEquationSeparate) + GL_FUNC(glBlendFunc) + GL_FUNC(glBlendFuncSeparate) + GL_FUNC(glBufferData) + GL_FUNC(glBufferSubData) + GL_FUNC(glCheckFramebufferStatus) + GL_FUNC(glClear) + GL_FUNC(glClearColor) + GL_FUNC(glClearDepthf) + GL_FUNC(glClearStencil) + GL_FUNC(glColorMask) + GL_FUNC(glCompileShader) + GL_FUNC(glCompressedTexImage2D) + GL_FUNC(glCompressedTexSubImage2D) + GL_FUNC(glCopyTexImage2D) + GL_FUNC(glCopyTexSubImage2D) + GL_FUNC(glCreateProgram) + GL_FUNC(glCreateShader) + GL_FUNC(glCullFace) + GL_FUNC(glDeleteBuffers) + GL_FUNC(glDeleteFramebuffers) + GL_FUNC(glDeleteProgram) + GL_FUNC(glDeleteRenderbuffers) + GL_FUNC(glDeleteShader) + GL_FUNC(glDeleteTextures) + GL_FUNC(glDepthFunc) + GL_FUNC(glDepthMask) + GL_FUNC(glDepthRangef) + GL_FUNC(glDetachShader) + GL_FUNC(glDisable) + GL_FUNC(glDisableVertexAttribArray) + GL_FUNC(glDrawArrays) + GL_FUNC(glDrawElements) + GL_FUNC(glEnable) + GL_FUNC(glEnableVertexAttribArray) + GL_FUNC(glFinish) + GL_FUNC(glFlush) + GL_FUNC(glFramebufferRenderbuffer) + GL_FUNC(glFramebufferTexture2D) + GL_FUNC(glFrontFace) + GL_FUNC(glGenBuffers) + GL_FUNC(glGenerateMipmap) + GL_FUNC(glGenFramebuffers) + GL_FUNC(glGenRenderbuffers) + GL_FUNC(glGenTextures) + GL_FUNC(glGetActiveAttrib) + GL_FUNC(glGetActiveUniform) + GL_FUNC(glGetAttachedShaders) + GL_FUNC(glGetAttribLocation) + GL_FUNC(glGetBooleanv) + GL_FUNC(glGetBufferParameteriv) + GL_FUNC(glGetError) + GL_FUNC(glGetFloatv) + GL_FUNC(glGetFramebufferAttachmentParameteriv) + GL_FUNC(glGetIntegerv) + GL_FUNC(glGetProgramiv) + GL_FUNC(glGetProgramInfoLog) + GL_FUNC(glGetRenderbufferParameteriv) + GL_FUNC(glGetShaderiv) + GL_FUNC(glGetShaderInfoLog) + GL_FUNC(glGetShaderPrecisionFormat) + GL_FUNC(glGetShaderSource) + GL_FUNC(glGetString) + GL_FUNC(glGetTexParameterfv) + GL_FUNC(glGetTexParameteriv) + GL_FUNC(glGetUniformfv) + GL_FUNC(glGetUniformiv) + GL_FUNC(glGetUniformLocation) + GL_FUNC(glGetVertexAttribfv) + GL_FUNC(glGetVertexAttribiv) + GL_FUNC(glGetVertexAttribPointerv) + GL_FUNC(glHint) + GL_FUNC(glIsBuffer) + GL_FUNC(glIsEnabled) + GL_FUNC(glIsFramebuffer) + GL_FUNC(glIsProgram) + GL_FUNC(glIsRenderbuffer) + GL_FUNC(glIsShader) + GL_FUNC(glIsTexture) + GL_FUNC(glLineWidth) + GL_FUNC(glLinkProgram) + GL_FUNC(glPixelStorei) + GL_FUNC(glPolygonOffset) + GL_FUNC(glReadPixels) + GL_FUNC(glReleaseShaderCompiler) + GL_FUNC(glRenderbufferStorage) + GL_FUNC(glSampleCoverage) + GL_FUNC(glScissor) + GL_FUNC(glShaderBinary) + GL_FUNC(glShaderSource) + GL_FUNC(glStencilFunc) + GL_FUNC(glStencilFuncSeparate) + GL_FUNC(glStencilMask) + GL_FUNC(glStencilMaskSeparate) + GL_FUNC(glStencilOp) + GL_FUNC(glStencilOpSeparate) + GL_FUNC(glTexImage2D) + GL_FUNC(glTexParameterf) + GL_FUNC(glTexParameterfv) + GL_FUNC(glTexParameteri) + GL_FUNC(glTexParameteriv) + GL_FUNC(glTexSubImage2D) + GL_FUNC(glUniform1f) + GL_FUNC(glUniform1fv) + GL_FUNC(glUniform1i) + GL_FUNC(glUniform1iv) + GL_FUNC(glUniform2f) + GL_FUNC(glUniform2fv) + GL_FUNC(glUniform2i) + GL_FUNC(glUniform2iv) + GL_FUNC(glUniform3f) + GL_FUNC(glUniform3fv) + GL_FUNC(glUniform3i) + GL_FUNC(glUniform3iv) + GL_FUNC(glUniform4f) + GL_FUNC(glUniform4fv) + GL_FUNC(glUniform4i) + GL_FUNC(glUniform4iv) + GL_FUNC(glUniformMatrix2fv) + GL_FUNC(glUniformMatrix3fv) + GL_FUNC(glUniformMatrix4fv) + GL_FUNC(glUseProgram) + GL_FUNC(glValidateProgram) + GL_FUNC(glVertexAttrib1f) + GL_FUNC(glVertexAttrib1fv) + GL_FUNC(glVertexAttrib2f) + GL_FUNC(glVertexAttrib2fv) + GL_FUNC(glVertexAttrib3f) + GL_FUNC(glVertexAttrib3fv) + GL_FUNC(glVertexAttrib4f) + GL_FUNC(glVertexAttrib4fv) + GL_FUNC(glVertexAttribPointer) + GL_FUNC(glViewport) + GL_FUNC(glGetProgramBinaryOES) + GL_FUNC(glProgramBinaryOES) + GL_FUNC(glMapBufferOES) + GL_FUNC(glUnmapBufferOES) + GL_FUNC(glGetBufferPointervOES) + GL_FUNC(glTexImage3DOES) + GL_FUNC(glTexSubImage3DOES) + GL_FUNC(glCopyTexSubImage3DOES) + GL_FUNC(glCompressedTexImage3DOES) + GL_FUNC(glCompressedTexSubImage3DOES) + GL_FUNC(glFramebufferTexture3DOES) + GL_FUNC(glBindVertexArrayOES) + GL_FUNC(glDeleteVertexArraysOES) + GL_FUNC(glGenVertexArraysOES) + GL_FUNC(glIsVertexArrayOES) + GL_FUNC(glGetPerfMonitorGroupsAMD) + GL_FUNC(glGetPerfMonitorCountersAMD) + GL_FUNC(glGetPerfMonitorGroupStringAMD) + GL_FUNC(glGetPerfMonitorCounterStringAMD) + GL_FUNC(glGetPerfMonitorCounterInfoAMD) + GL_FUNC(glGenPerfMonitorsAMD) + GL_FUNC(glDeletePerfMonitorsAMD) + GL_FUNC(glSelectPerfMonitorCountersAMD) + GL_FUNC(glBeginPerfMonitorAMD) + GL_FUNC(glEndPerfMonitorAMD) + GL_FUNC(glGetPerfMonitorCounterDataAMD) + GL_FUNC(glCopyTextureLevelsAPPLE) + GL_FUNC(glRenderbufferStorageMultisampleAPPLE) + GL_FUNC(glResolveMultisampleFramebufferAPPLE) + GL_FUNC(glFenceSyncAPPLE) + GL_FUNC(glIsSyncAPPLE) + GL_FUNC(glDeleteSyncAPPLE) + GL_FUNC(glClientWaitSyncAPPLE) + GL_FUNC(glWaitSyncAPPLE) + GL_FUNC(glGetInteger64vAPPLE) + GL_FUNC(glGetSyncivAPPLE) + GL_FUNC(glDiscardFramebufferEXT) + GL_FUNC(glMapBufferRangeEXT) + GL_FUNC(glFlushMappedBufferRangeEXT) + GL_FUNC(glMultiDrawArraysEXT) + GL_FUNC(glMultiDrawElementsEXT) + GL_FUNC(glRenderbufferStorageMultisampleEXT) + GL_FUNC(glFramebufferTexture2DMultisampleEXT) + GL_FUNC(glGetGraphicsResetStatusEXT) + GL_FUNC(glReadnPixelsEXT) + GL_FUNC(glGetnUniformfvEXT) + GL_FUNC(glGetnUniformivEXT) + GL_FUNC(glTexStorage1DEXT) + GL_FUNC(glTexStorage2DEXT) + GL_FUNC(glTexStorage3DEXT) + GL_FUNC(glTextureStorage1DEXT) + GL_FUNC(glTextureStorage2DEXT) + GL_FUNC(glTextureStorage3DEXT) + GL_FUNC(glRenderbufferStorageMultisampleIMG) + GL_FUNC(glFramebufferTexture2DMultisampleIMG) + GL_FUNC(glDeleteFencesNV) + GL_FUNC(glGenFencesNV) + GL_FUNC(glIsFenceNV) + GL_FUNC(glTestFenceNV) + GL_FUNC(glGetFenceivNV) + GL_FUNC(glFinishFenceNV) + GL_FUNC(glSetFenceNV) + GL_FUNC(glGetDriverControlsQCOM) + GL_FUNC(glGetDriverControlStringQCOM) + GL_FUNC(glEnableDriverControlQCOM) + GL_FUNC(glDisableDriverControlQCOM) + GL_FUNC(glExtGetTexturesQCOM) + GL_FUNC(glExtGetBuffersQCOM) + GL_FUNC(glExtGetRenderbuffersQCOM) + GL_FUNC(glExtGetFramebuffersQCOM) + GL_FUNC(glExtGetTexLevelParameterivQCOM) + GL_FUNC(glExtTexObjectStateOverrideiQCOM) + GL_FUNC(glExtGetTexSubImageQCOM) + GL_FUNC(glExtGetBufferPointervQCOM) + GL_FUNC(glExtGetShadersQCOM) + GL_FUNC(glExtGetProgramsQCOM) + GL_FUNC(glExtIsProgramBinaryQCOM) + GL_FUNC(glExtGetProgramBinarySourceQCOM) + GL_FUNC(glStartTilingQCOM) + GL_FUNC(glEndTilingQCOM) + GL_FUNC(glEvasGLImageTargetTexture2DOES) + GL_FUNC(glEvasGLImageTargetRenderbufferStorageOES) + GL_FUNC(glBeginQuery) + GL_FUNC(glBeginTransformFeedback) + GL_FUNC(glBindBufferBase) + GL_FUNC(glBindBufferRange) + GL_FUNC(glBindSampler) + GL_FUNC(glBindTransformFeedback) + GL_FUNC(glBindVertexArray) + GL_FUNC(glBlitFramebuffer) + GL_FUNC(glClearBufferfi) + GL_FUNC(glClearBufferfv) + GL_FUNC(glClearBufferiv) + GL_FUNC(glClearBufferuiv) + GL_FUNC(glClientWaitSync) + GL_FUNC(glCompressedTexImage3D) + GL_FUNC(glCompressedTexSubImage3D) + GL_FUNC(glCopyBufferSubData) + GL_FUNC(glCopyTexSubImage3D) + GL_FUNC(glDeleteQueries) + GL_FUNC(glDeleteSamplers) + GL_FUNC(glDeleteSync) + GL_FUNC(glDeleteTransformFeedbacks) + GL_FUNC(glDeleteVertexArrays) + GL_FUNC(glDrawArraysInstanced) + GL_FUNC(glDrawBuffers) + GL_FUNC(glDrawElementsInstanced) + GL_FUNC(glDrawRangeElements) + GL_FUNC(glEndQuery) + GL_FUNC(glEndTransformFeedback) + GL_FUNC(glFenceSync) + GL_FUNC(glFlushMappedBufferRange) + GL_FUNC(glFramebufferTextureLayer) + GL_FUNC(glGenQueries) + GL_FUNC(glGenSamplers) + GL_FUNC(glGenTransformFeedbacks) + GL_FUNC(glGenVertexArrays) + GL_FUNC(glGetActiveUniformBlockiv) + GL_FUNC(glGetActiveUniformBlockName) + GL_FUNC(glGetActiveUniformsiv) + GL_FUNC(glGetBufferParameteri64v) + GL_FUNC(glGetBufferPointerv) + GL_FUNC(glGetFragDataLocation) + GL_FUNC(glGetInteger64i_v) + GL_FUNC(glGetInteger64v) + GL_FUNC(glGetIntegeri_v) + GL_FUNC(glGetInternalformativ) + GL_FUNC(glGetProgramBinary) + GL_FUNC(glGetQueryiv) + GL_FUNC(glGetQueryObjectuiv) + GL_FUNC(glGetSamplerParameterfv) + GL_FUNC(glGetSamplerParameteriv) + GL_FUNC(glGetStringi) + GL_FUNC(glGetSynciv) + GL_FUNC(glGetTransformFeedbackVarying) + GL_FUNC(glGetUniformBlockIndex) + GL_FUNC(glGetUniformIndices) + GL_FUNC(glGetUniformuiv) + GL_FUNC(glGetVertexAttribIiv) + GL_FUNC(glGetVertexAttribIuiv) + GL_FUNC(glInvalidateFramebuffer) + GL_FUNC(glInvalidateSubFramebuffer) + GL_FUNC(glIsQuery) + GL_FUNC(glIsSampler) + GL_FUNC(glIsSync) + GL_FUNC(glIsTransformFeedback) + GL_FUNC(glIsVertexArray) + GL_FUNC(glMapBufferRange) + GL_FUNC(glPauseTransformFeedback) + GL_FUNC(glProgramBinary) + GL_FUNC(glProgramParameteri) + GL_FUNC(glReadBuffer) + GL_FUNC(glRenderbufferStorageMultisample) + GL_FUNC(glResumeTransformFeedback) + GL_FUNC(glSamplerParameterf) + GL_FUNC(glSamplerParameterfv) + GL_FUNC(glSamplerParameteri) + GL_FUNC(glSamplerParameteriv) + GL_FUNC(glTexImage3D) + GL_FUNC(glTexStorage2D) + GL_FUNC(glTexStorage3D) + GL_FUNC(glTexSubImage3D) + GL_FUNC(glTransformFeedbackVaryings) + GL_FUNC(glUniform1ui) + GL_FUNC(glUniform1uiv) + GL_FUNC(glUniform2ui) + GL_FUNC(glUniform2uiv) + GL_FUNC(glUniform3ui) + GL_FUNC(glUniform3uiv) + GL_FUNC(glUniform4ui) + GL_FUNC(glUniform4uiv) + GL_FUNC(glUniformBlockBinding) + GL_FUNC(glUniformMatrix2x3fv) + GL_FUNC(glUniformMatrix3x2fv) + GL_FUNC(glUniformMatrix2x4fv) + GL_FUNC(glUniformMatrix4x2fv) + GL_FUNC(glUniformMatrix3x4fv) + GL_FUNC(glUniformMatrix4x3fv) + GL_FUNC(glUnmapBuffer) + GL_FUNC(glVertexAttribDivisor) + GL_FUNC(glVertexAttribI4i) + GL_FUNC(glVertexAttribI4iv) + GL_FUNC(glVertexAttribI4ui) + GL_FUNC(glVertexAttribI4uiv) + GL_FUNC(glVertexAttribIPointer) + GL_FUNC(glWaitSync) + GL_FUNC(glDispatchCompute) + GL_FUNC(glDispatchComputeIndirect) + GL_FUNC(glDrawArraysIndirect) + GL_FUNC(glDrawElementsIndirect) + GL_FUNC(glFramebufferParameteri) + GL_FUNC(glGetFramebufferParameteriv) + GL_FUNC(glGetProgramInterfaceiv) + GL_FUNC(glGetProgramResourceIndex) + GL_FUNC(glGetProgramResourceName) + GL_FUNC(glGetProgramResourceiv) + GL_FUNC(glGetProgramResourceLocation) + GL_FUNC(glUseProgramStages) + GL_FUNC(glActiveShaderProgram) + GL_FUNC(glCreateShaderProgramv) + GL_FUNC(glBindProgramPipeline) + GL_FUNC(glDeleteProgramPipelines) + GL_FUNC(glGenProgramPipelines) + GL_FUNC(glIsProgramPipeline) + GL_FUNC(glGetProgramPipelineiv) + GL_FUNC(glProgramUniform1i) + GL_FUNC(glProgramUniform2i) + GL_FUNC(glProgramUniform3i) + GL_FUNC(glProgramUniform4i) + GL_FUNC(glProgramUniform1ui) + GL_FUNC(glProgramUniform2ui) + GL_FUNC(glProgramUniform3ui) + GL_FUNC(glProgramUniform4ui) + GL_FUNC(glProgramUniform1f) + GL_FUNC(glProgramUniform2f) + GL_FUNC(glProgramUniform3f) + GL_FUNC(glProgramUniform4f) + GL_FUNC(glProgramUniform1iv) + GL_FUNC(glProgramUniform2iv) + GL_FUNC(glProgramUniform3iv) + GL_FUNC(glProgramUniform4iv) + GL_FUNC(glProgramUniform1uiv) + GL_FUNC(glProgramUniform2uiv) + GL_FUNC(glProgramUniform3uiv) + GL_FUNC(glProgramUniform4uiv) + GL_FUNC(glProgramUniform1fv) + GL_FUNC(glProgramUniform2fv) + GL_FUNC(glProgramUniform3fv) + GL_FUNC(glProgramUniform4fv) + GL_FUNC(glProgramUniformMatrix2fv) + GL_FUNC(glProgramUniformMatrix3fv) + GL_FUNC(glProgramUniformMatrix4fv) + GL_FUNC(glProgramUniformMatrix2x3fv) + GL_FUNC(glProgramUniformMatrix3x2fv) + GL_FUNC(glProgramUniformMatrix2x4fv) + GL_FUNC(glProgramUniformMatrix4x2fv) + GL_FUNC(glProgramUniformMatrix3x4fv) + GL_FUNC(glProgramUniformMatrix4x3fv) + GL_FUNC(glValidateProgramPipeline) + GL_FUNC(glGetProgramPipelineInfoLog) + GL_FUNC(glBindImageTexture) + GL_FUNC(glGetBooleani_v) + GL_FUNC(glMemoryBarrier) + GL_FUNC(glMemoryBarrierByRegion) + GL_FUNC(glTexStorage2DMultisample) + GL_FUNC(glGetMultisamplefv) + GL_FUNC(glSampleMaski) + GL_FUNC(glGetTexLevelParameteriv) + GL_FUNC(glGetTexLevelParameterfv) + GL_FUNC(glBindVertexBuffer) + GL_FUNC(glVertexAttribFormat) + GL_FUNC(glVertexAttribIFormat) + GL_FUNC(glVertexAttribBinding) + GL_FUNC(glVertexBindingDivisor) + GL_FUNC(glBlendBarrier) + GL_FUNC(glCopyImageSubData) + GL_FUNC(glDebugMessageControl) + GL_FUNC(glDebugMessageInsert) + GL_FUNC(glDebugMessageCallback) + GL_FUNC(glGetDebugMessageLog) + GL_FUNC(glPushDebugGroup) + GL_FUNC(glPopDebugGroup) + GL_FUNC(glObjectLabel) + GL_FUNC(glGetObjectLabel) + GL_FUNC(glObjectPtrLabel) + GL_FUNC(glGetObjectPtrLabel) + GL_FUNC(glGetPointerv) + GL_FUNC(glEnablei) + GL_FUNC(glDisablei) + GL_FUNC(glBlendEquationi) + GL_FUNC(glBlendEquationSeparatei) + GL_FUNC(glBlendFunci) + GL_FUNC(glBlendFuncSeparatei) + GL_FUNC(glColorMaski) + GL_FUNC(glIsEnabledi) + GL_FUNC(glDrawElementsBaseVertex) + GL_FUNC(glDrawRangeElementsBaseVertex) + GL_FUNC(glDrawElementsInstancedBaseVertex) + GL_FUNC(glFramebufferTexture) + GL_FUNC(glPrimitiveBoundingBox) + GL_FUNC(glGetGraphicsResetStatus) + GL_FUNC(glReadnPixels) + GL_FUNC(glGetnUniformfv) + GL_FUNC(glGetnUniformiv) + GL_FUNC(glGetnUniformuiv) + GL_FUNC(glMinSampleShading) + GL_FUNC(glPatchParameteri) + GL_FUNC(glTexParameterIiv) + GL_FUNC(glTexParameterIuiv) + GL_FUNC(glGetTexParameterIiv) + GL_FUNC(glGetTexParameterIuiv) + GL_FUNC(glSamplerParameterIiv) + GL_FUNC(glSamplerParameterIuiv) + GL_FUNC(glGetSamplerParameterIiv) + GL_FUNC(glGetSamplerParameterIuiv) + GL_FUNC(glTexBuffer) + GL_FUNC(glTexBufferRange) + GL_FUNC(glTexStorage3DMultisample) + FT_LOGD("Could not resolve: %s", name); + return nullptr; +} +#undef GL_FUNC + +bool TizenRenderer::InitializeRenderer(int32_t x, int32_t y, int32_t w, + int32_t h) { + if (!SetupEvasGL(x, y, w, h)) { + FT_LOGE("SetupEvasGL fail"); + return false; + } + Show(); + is_valid_ = true; + return true; +} + +bool TizenRenderer::IsValid() { return is_valid_; } + +void TizenRenderer::flush() { glFlush(); } + +bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { + evas_gl_ = evas_gl_new( + evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); + + if (!evas_gl_) { + FT_LOGE("SetupEvasWindow fail"); + return false; + } + + g_evas_gl = evas_gl_; + gl_config_ = evas_gl_config_new(); + gl_config_->color_format = EVAS_GL_RGBA_8888; + gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; + gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; +#define EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE (1 << 12) +#define EVAS_GL_OPTIONS_DIRECT_OVERRIDE (1 << 13) + gl_config_->options_bits = (Evas_GL_Options_Bits)( + EVAS_GL_OPTIONS_DIRECT | EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE | + EVAS_GL_OPTIONS_DIRECT_OVERRIDE | EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION); + + gl_context_ = + evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_3_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); + + if (gl_context_ == nullptr) { + FT_LOGW( + "Failed to create evas gl context with EVAS_GL_GLES_3_X, try to use " + "EVAS_GL_GLES_2_X,"); + gl_context_ = + evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); + } + if (gl_context_ == nullptr) { + FT_LOGE("Failed to create evas gl context!"); + FT_RELEASE_ASSERT_NOT_REACHED(); + } + + EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); + gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, w, h); + + gl_resource_surface_ = + evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, w, h, NULL); + + Evas_Native_Surface ns; + evas_gl_native_surface_get(evas_gl_, gl_surface_, &ns); + evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), &ns); + + return true; +} + +void TizenRenderer::DestoryRenderer() { + DestoryEvasGL(); + DestoryEvasWindow(); +} + +void TizenRenderer::DestoryEvasGL() { + evas_gl_surface_destroy(evas_gl_, gl_surface_); + evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); + + evas_gl_context_destroy(evas_gl_, gl_context_); + evas_gl_context_destroy(evas_gl_, gl_resource_context_); + + evas_gl_config_free(gl_config_); + evas_gl_free(evas_gl_); +} + +#else // TIZEN_RENDERER_EVAS_GL + bool TizenRenderer::OnMakeCurrent() { if (!IsValid()) { FT_LOGE("Invalid TizenRenderer"); @@ -458,3 +1067,5 @@ void TizenRenderer::DestoryEglSurface() { egl_display_ = EGL_NO_DISPLAY; } } + +#endif // TIZEN_RENDERER_EVAS_GL diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index d4cddfe4a2b4d..a29ee13442514 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -5,7 +5,13 @@ #ifndef EMBEDDER_TIZEN_RENDERER_H #define EMBEDDER_TIZEN_RENDERER_H +#ifdef TIZEN_RENDERER_EVAS_GL +#undef EFL_BETA_API_SUPPORT +#include +#include +#else #include +#endif class TizenRenderer { public: @@ -20,12 +26,17 @@ class TizenRenderer { TizenRenderer(TizenRenderer::Delegate& deleget); virtual ~TizenRenderer(); + +#ifdef TIZEN_RENDERER_EVAS_GL + void ClearColor(float r, float g, float b, float a); +#endif bool OnMakeCurrent(); bool OnClearCurrent(); bool OnMakeResourceCurrent(); bool OnPresent(); uint32_t OnGetFBO(); void* OnProcResolver(const char* name); + void flush(); virtual TizenWindowGeometry GetGeometry() = 0; bool IsValid(); virtual void Show() = 0; @@ -38,30 +49,55 @@ class TizenRenderer { bool received_rotation{false}; TizenRenderer::Delegate& delegate_; bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h); +#ifdef TIZEN_RENDERER_EVAS_GL + virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h) = 0; + virtual void DestoryEvasWindow() = 0; + + public: + virtual void* GetImageHandle() = 0; + + protected: + bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); + void DestoryEvasGL(); +#else virtual bool SetupDisplay() = 0; virtual bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, int32_t h) = 0; virtual bool SetupEglWindow(int32_t w, int32_t h) = 0; - bool SetupEglSurface(); virtual EGLDisplay GetEGLDisplay() = 0; virtual EGLNativeWindowType GetEGLNativeWindowType() = 0; - void DestoryRenderer(); - void DestoryEglSurface(); virtual void DestoryEglWindow() = 0; virtual void DestoryEcoreWlWindow() = 0; virtual void ShutdownDisplay() = 0; + + void DestoryEglSurface(); + bool SetupEglSurface(); +#endif + void DestoryRenderer(); virtual void SendRotationChangeDone() = 0; private: bool is_valid_ = false; +#ifdef TIZEN_RENDERER_EVAS_GL + Evas_GL_Config* gl_config_; + Evas_GL* evas_gl_{nullptr}; + + Evas_GL_Context* gl_context_; + Evas_GL_Context* gl_resource_context_; + + Evas_GL_Surface* gl_surface_{nullptr}; + Evas_GL_Surface* gl_resource_surface_{nullptr}; +#else + bool ChooseEGLConfiguration(); + void PrintEGLError(); + EGLConfig egl_config_; EGLDisplay egl_display_ = EGL_NO_DISPLAY; EGLContext egl_context_ = EGL_NO_CONTEXT; EGLSurface egl_surface_ = EGL_NO_SURFACE; EGLContext egl_resource_context_ = EGL_NO_CONTEXT; EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; - bool ChooseEGLConfiguration(); - void PrintEGLError(); +#endif }; #endif // EMBEDDER_TIZEN_RENDERER_H diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc new file mode 100644 index 0000000000000..902eb600ec91d --- /dev/null +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -0,0 +1,102 @@ +// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tizen_renderer_evas_gl.h" + +#include "flutter/shell/platform/tizen/tizen_log.h" + +TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate, + int32_t x, int32_t y, int32_t w, + int32_t h) + : TizenRenderer(delegate) { + InitializeRenderer(x, y, w, h); +} + +TizenRendererEvasGL::~TizenRendererEvasGL() { DestoryRenderer(); } + +void* TizenRendererEvasGL::SetupEvasWindow(int32_t x, int32_t y, int32_t w, + int32_t h) { + if (w == 0 || h == 0) { + FT_LOGE("Failed to create because of the wrong size"); + return nullptr; + } + elm_config_accel_preference_set("hw:opengl"); + + evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC); + elm_win_alpha_set(evas_window_, EINA_FALSE); + elm_win_aux_hint_add(evas_window_, "wm.policy.win.user.geometry", "1"); + evas_object_move(evas_window_, x, y); + evas_object_resize(evas_window_, w, h); + evas_object_raise(evas_window_); + + Evas_Object* bg = elm_bg_add(evas_window_); + evas_object_color_set(bg, 0x00, 0x00, 0x00, 0x00); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(evas_window_, bg); + + graphics_adapter_ = + evas_object_image_filled_add(evas_object_evas_get(evas_window_)); + evas_object_resize(graphics_adapter_, w, h); + evas_object_move(graphics_adapter_, x, y); + evas_object_image_size_set(graphics_adapter_, w, h); + evas_object_image_alpha_set(graphics_adapter_, EINA_TRUE); + elm_win_resize_object_add(evas_window_, graphics_adapter_); + + int rotations[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(evas_window_, + (const int*)(&rotations), 4); + evas_object_smart_callback_add(evas_window_, "rotation,changed", + RotationEventCb, this); + return (void*)evas_window_; +} + +void TizenRendererEvasGL::RotationEventCb(void* data, Evas_Object* obj, + void* event_info) { + auto* self = reinterpret_cast(data); + // TODO : Use current window rotation degree + FT_UNIMPLEMENTED(); + self->delegate_.OnRotationChange(0); +} + +void TizenRendererEvasGL::Show() { + evas_object_show((Evas_Object*)GetImageHandle()); + evas_object_show(evas_window_); +} + +void TizenRendererEvasGL::SetRotate(int angle) { + elm_win_rotation_set(evas_window_, angle); + received_rotation = true; +} + +void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; } + +void TizenRendererEvasGL::ResizeWithRotation(int32_t x, int32_t y, + int32_t width, int32_t height, + int32_t angle) { + evas_object_move(evas_window_, x, y); + evas_object_resize(evas_window_, width, height); + SetRotate(angle); +} + +void TizenRendererEvasGL::SendRotationChangeDone() { + elm_win_wm_rotation_manual_rotation_done(evas_window_); +} + +void TizenRendererEvasGL::DestoryEvasWindow() { + evas_object_del(evas_window_); + evas_object_del(graphics_adapter_); +} + +TizenRenderer::TizenWindowGeometry TizenRendererEvasGL::GetGeometry() { + TizenWindowGeometry result; + evas_object_geometry_get(evas_window_, &result.x, &result.y, &result.w, + &result.h); + return result; +} + +int TizenRendererEvasGL::GetEcoreWindowId() { + return (int)ecore_evas_window_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(graphics_adapter_))); +} diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h new file mode 100644 index 0000000000000..a47347375430f --- /dev/null +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -0,0 +1,38 @@ +// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_TIZEN_RENDERER_EVAS_GL_H +#define EMBEDDER_TIZEN_RENDERER_EVAS_GL_H + +#include +#include + +#include "tizen_renderer.h" + +class TizenRendererEvasGL : public TizenRenderer { + public: + TizenRendererEvasGL(TizenRenderer::Delegate& delegate, int32_t x, int32_t y, + int32_t w, int32_t h); + ~TizenRendererEvasGL(); + TizenWindowGeometry GetGeometry() override; + int GetEcoreWindowId() override; + void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, + int32_t angle) override; + void Show() override; + void SetRotate(int angle) override; + + void* GetImageHandle() override; + + protected: + virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, + int32_t h) override; + virtual void DestoryEvasWindow() override; + void SendRotationChangeDone() override; + + private: + Evas_Object* evas_window_{nullptr}; + Evas_Object* graphics_adapter_{nullptr}; + static void RotationEventCb(void* data, Evas_Object* obj, void* event_info); +}; +#endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H From 217caf3e1158571fc3e2820e44901d1d29a98d00 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 19 Apr 2021 16:08:13 +0900 Subject: [PATCH 09/19] Fix CI build --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4538ec590b735..15791095bdac0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,7 +78,7 @@ jobs: cp out/linux_$(mode)_$(arch)/libflutter_*.so $OUTDIR if [[ $(System.JobName) == "tizen-arm-release" ]]; then mkdir $OUTDIR/common - cp out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common + cp -r out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common fi displayName: Copy artifacts workingDirectory: $(buildroot) From 6d44714fcfe592aa6edf59d808c74f943843d6ca Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 19 Apr 2021 16:08:58 +0900 Subject: [PATCH 10/19] Disable Evas GL direct mode and remove use of elm_win_aux_hint_add --- shell/common/animator.cc | 13 +++++-------- shell/platform/tizen/tizen_renderer.cc | 5 ----- shell/platform/tizen/tizen_renderer_evas_gl.cc | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/shell/common/animator.cc b/shell/common/animator.cc index 3f27cb40dc775..cacac38c12063 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -35,14 +35,11 @@ Animator::Animator(Delegate& delegate, // 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. - // layer_tree_pipeline_(fml::MakeRefCounted( - // task_runners.GetPlatformTaskRunner() == - // task_runners.GetRasterTaskRunner() - // ? 1 - // : 2)), - // FIXME(bbrto21): This is a workaround to avoid flickering that occurs - // in evas gl direct mode. - layer_tree_pipeline_(fml::MakeRefCounted(1)), + layer_tree_pipeline_(fml::MakeRefCounted( + task_runners.GetPlatformTaskRunner() == + task_runners.GetRasterTaskRunner() + ? 1 + : 2)), #endif // SHELL_ENABLE_METAL pending_frame_semaphore_(1), frame_number_(1), diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index f0472103489e9..025f5c5a69e53 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -567,11 +567,6 @@ bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { gl_config_->color_format = EVAS_GL_RGBA_8888; gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; -#define EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE (1 << 12) -#define EVAS_GL_OPTIONS_DIRECT_OVERRIDE (1 << 13) - gl_config_->options_bits = (Evas_GL_Options_Bits)( - EVAS_GL_OPTIONS_DIRECT | EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE | - EVAS_GL_OPTIONS_DIRECT_OVERRIDE | EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION); gl_context_ = evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_3_X); diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 902eb600ec91d..afa0cf475b492 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -25,7 +25,6 @@ void* TizenRendererEvasGL::SetupEvasWindow(int32_t x, int32_t y, int32_t w, evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC); elm_win_alpha_set(evas_window_, EINA_FALSE); - elm_win_aux_hint_add(evas_window_, "wm.policy.win.user.geometry", "1"); evas_object_move(evas_window_, x, y); evas_object_resize(evas_window_, w, h); evas_object_raise(evas_window_); From 6cfaab924d8d6591771edab371797f0b5f125034 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 19 Apr 2021 16:38:19 +0900 Subject: [PATCH 11/19] Simplify the CI job --- azure-pipelines.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 15791095bdac0..8e8e683d1acf5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -79,6 +79,7 @@ jobs: if [[ $(System.JobName) == "tizen-arm-release" ]]; then mkdir $OUTDIR/common cp -r out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common + rm $OUTDIR/common/cpp_client_wrapper/engine_method_result.cc fi displayName: Copy artifacts workingDirectory: $(buildroot) @@ -101,11 +102,6 @@ jobs: - download: current - bash: | mv $(Pipeline.Workspace)/tizen-arm-release/common . - rm common/client_wrapper/engine_method_result.cc - displayName: Copy common files - workingDirectory: $(Build.BinariesDirectory) - failOnStderr: true - - bash: | mv $(Pipeline.Workspace)/tizen-* . for platform in linux windows darwin; do for arch in arm arm64; do From 26f4fa56ab097a48bcc26877158237a9e30b7a49 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 19 Apr 2021 16:50:10 +0900 Subject: [PATCH 12/19] A workaround for isIME in Evas GL mode --- .../platform/tizen/channels/text_input_channel.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index f90288405327d..2f62e8c7cdf85 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -363,8 +363,14 @@ void TextInputChannel::SendStateUpdate(const flutter::TextInputModel& model) { bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) { bool handled = false; + +#ifdef TIZEN_RENDERER_EVAS_GL + // It is assumed that no hardware keyboard can be attached in Evas GL mode. + bool isIME = true; +#else bool isIME = ecore_imf_context_keyboard_mode_get(imf_context_) == - ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE; + ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE; +#endif Ecore_IMF_Event_Key_Down ecoreKeyDownEvent; ecoreKeyDownEvent.keyname = keyDownEvent->keyname; @@ -376,11 +382,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) { EcoreInputModifierToEcoreIMFModifier(keyDownEvent->modifiers); ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock(keyDownEvent->modifiers); - if (isIME) { - ecoreKeyDownEvent.dev_name = "ime"; - } else { - ecoreKeyDownEvent.dev_name = ""; - } + ecoreKeyDownEvent.dev_name = isIME ? "ime" : ""; ecoreKeyDownEvent.keycode = keyDownEvent->keycode; if (isIME && strcmp(keyDownEvent->key, "Select") == 0) { From d2ec02fb872e473406f71f610a84d6aeb7573e62 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Wed, 21 Apr 2021 17:45:09 +0900 Subject: [PATCH 13/19] Refactor: Clean up tizen_renderer.h and re-order functions --- shell/platform/tizen/external_texture_gl.cc | 4 +- shell/platform/tizen/tizen_event_loop.cc | 4 + shell/platform/tizen/tizen_renderer.cc | 1056 ----------------- shell/platform/tizen/tizen_renderer.h | 92 +- .../tizen/tizen_renderer_ecore_wl2.cc | 528 ++++++++- .../platform/tizen/tizen_renderer_ecore_wl2.h | 53 +- .../platform/tizen/tizen_renderer_evas_gl.cc | 646 +++++++++- shell/platform/tizen/tizen_renderer_evas_gl.h | 46 +- shell/platform/tizen/tizen_vsync_waiter.cc | 6 +- shell/platform/tizen/tizen_vsync_waiter.h | 2 +- 10 files changed, 1219 insertions(+), 1218 deletions(-) diff --git a/shell/platform/tizen/external_texture_gl.cc b/shell/platform/tizen/external_texture_gl.cc index 3586109c52a1b..bc52739267ce5 100644 --- a/shell/platform/tizen/external_texture_gl.cc +++ b/shell/platform/tizen/external_texture_gl.cc @@ -146,9 +146,9 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( "glEGLImageTargetTexture2DOES"); glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image); if (egl_src_image) { - PFNEGLDESTROYIMAGEKHRPROC n_eglDestoryImageKHR = + PFNEGLDESTROYIMAGEKHRPROC n_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - n_eglDestoryImageKHR(eglGetCurrentDisplay(), egl_src_image); + n_eglDestroyImageKHR(eglGetCurrentDisplay(), egl_src_image); } #endif diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index c1d14365d9cfd..605bea99ae958 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -8,6 +8,10 @@ #include #include +#ifdef TIZEN_RENDERER_EVAS_GL +#include +#endif + #include "flutter/shell/platform/tizen/tizen_log.h" #include "flutter/shell/platform/tizen/tizen_renderer.h" diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index 025f5c5a69e53..5c47b9c5a9ea8 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -4,1063 +4,7 @@ #include "tizen_renderer.h" -#ifdef TIZEN_RENDERER_EVAS_GL -#include -Evas_GL* g_evas_gl = nullptr; -EVAS_GL_GLOBAL_GLES3_DEFINE(); -#else -#include -#include -#endif - -#include "flutter/shell/platform/tizen/tizen_log.h" - TizenRenderer::TizenRenderer(TizenRenderer::Delegate& delegate) : delegate_(delegate) {} TizenRenderer::~TizenRenderer() = default; - -#ifdef TIZEN_RENDERER_EVAS_GL - -void TizenRenderer::ClearColor(float r, float g, float b, float a) { - glClearColor(r, g, b, a); - glClear(GL_COLOR_BUFFER_BIT); -} - -bool TizenRenderer::OnMakeCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (evas_gl_make_current(evas_gl_, gl_surface_, gl_context_) != EINA_TRUE) { - return false; - } - - return true; -} - -bool TizenRenderer::OnClearCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (evas_gl_make_current(evas_gl_, NULL, NULL) != EINA_TRUE) { - return false; - } - return true; -} - -bool TizenRenderer::OnMakeResourceCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (evas_gl_make_current(evas_gl_, gl_resource_surface_, - gl_resource_context_) != EINA_TRUE) { - return false; - } - return true; -} - -bool TizenRenderer::OnPresent() { - if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (received_rotation) { - SendRotationChangeDone(); - received_rotation = false; - } - - return true; -} - -uint32_t TizenRenderer::OnGetFBO() { - if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); - return 999; - } - FT_LOGD("OnGetFBO"); - return 0; -} - -#define GL_FUNC(FunctionName) \ - else if (strcmp(name, #FunctionName) == 0) { \ - return reinterpret_cast(FunctionName); \ - } -void* TizenRenderer::OnProcResolver(const char* name) { - auto address = evas_gl_proc_address_get(evas_gl_, name); - if (address != nullptr) { - return reinterpret_cast(address); - } - GL_FUNC(glActiveTexture) - GL_FUNC(glAttachShader) - GL_FUNC(glBindAttribLocation) - GL_FUNC(glBindBuffer) - GL_FUNC(glBindFramebuffer) - GL_FUNC(glBindRenderbuffer) - GL_FUNC(glBindTexture) - GL_FUNC(glBlendColor) - GL_FUNC(glBlendEquation) - GL_FUNC(glBlendEquationSeparate) - GL_FUNC(glBlendFunc) - GL_FUNC(glBlendFuncSeparate) - GL_FUNC(glBufferData) - GL_FUNC(glBufferSubData) - GL_FUNC(glCheckFramebufferStatus) - GL_FUNC(glClear) - GL_FUNC(glClearColor) - GL_FUNC(glClearDepthf) - GL_FUNC(glClearStencil) - GL_FUNC(glColorMask) - GL_FUNC(glCompileShader) - GL_FUNC(glCompressedTexImage2D) - GL_FUNC(glCompressedTexSubImage2D) - GL_FUNC(glCopyTexImage2D) - GL_FUNC(glCopyTexSubImage2D) - GL_FUNC(glCreateProgram) - GL_FUNC(glCreateShader) - GL_FUNC(glCullFace) - GL_FUNC(glDeleteBuffers) - GL_FUNC(glDeleteFramebuffers) - GL_FUNC(glDeleteProgram) - GL_FUNC(glDeleteRenderbuffers) - GL_FUNC(glDeleteShader) - GL_FUNC(glDeleteTextures) - GL_FUNC(glDepthFunc) - GL_FUNC(glDepthMask) - GL_FUNC(glDepthRangef) - GL_FUNC(glDetachShader) - GL_FUNC(glDisable) - GL_FUNC(glDisableVertexAttribArray) - GL_FUNC(glDrawArrays) - GL_FUNC(glDrawElements) - GL_FUNC(glEnable) - GL_FUNC(glEnableVertexAttribArray) - GL_FUNC(glFinish) - GL_FUNC(glFlush) - GL_FUNC(glFramebufferRenderbuffer) - GL_FUNC(glFramebufferTexture2D) - GL_FUNC(glFrontFace) - GL_FUNC(glGenBuffers) - GL_FUNC(glGenerateMipmap) - GL_FUNC(glGenFramebuffers) - GL_FUNC(glGenRenderbuffers) - GL_FUNC(glGenTextures) - GL_FUNC(glGetActiveAttrib) - GL_FUNC(glGetActiveUniform) - GL_FUNC(glGetAttachedShaders) - GL_FUNC(glGetAttribLocation) - GL_FUNC(glGetBooleanv) - GL_FUNC(glGetBufferParameteriv) - GL_FUNC(glGetError) - GL_FUNC(glGetFloatv) - GL_FUNC(glGetFramebufferAttachmentParameteriv) - GL_FUNC(glGetIntegerv) - GL_FUNC(glGetProgramiv) - GL_FUNC(glGetProgramInfoLog) - GL_FUNC(glGetRenderbufferParameteriv) - GL_FUNC(glGetShaderiv) - GL_FUNC(glGetShaderInfoLog) - GL_FUNC(glGetShaderPrecisionFormat) - GL_FUNC(glGetShaderSource) - GL_FUNC(glGetString) - GL_FUNC(glGetTexParameterfv) - GL_FUNC(glGetTexParameteriv) - GL_FUNC(glGetUniformfv) - GL_FUNC(glGetUniformiv) - GL_FUNC(glGetUniformLocation) - GL_FUNC(glGetVertexAttribfv) - GL_FUNC(glGetVertexAttribiv) - GL_FUNC(glGetVertexAttribPointerv) - GL_FUNC(glHint) - GL_FUNC(glIsBuffer) - GL_FUNC(glIsEnabled) - GL_FUNC(glIsFramebuffer) - GL_FUNC(glIsProgram) - GL_FUNC(glIsRenderbuffer) - GL_FUNC(glIsShader) - GL_FUNC(glIsTexture) - GL_FUNC(glLineWidth) - GL_FUNC(glLinkProgram) - GL_FUNC(glPixelStorei) - GL_FUNC(glPolygonOffset) - GL_FUNC(glReadPixels) - GL_FUNC(glReleaseShaderCompiler) - GL_FUNC(glRenderbufferStorage) - GL_FUNC(glSampleCoverage) - GL_FUNC(glScissor) - GL_FUNC(glShaderBinary) - GL_FUNC(glShaderSource) - GL_FUNC(glStencilFunc) - GL_FUNC(glStencilFuncSeparate) - GL_FUNC(glStencilMask) - GL_FUNC(glStencilMaskSeparate) - GL_FUNC(glStencilOp) - GL_FUNC(glStencilOpSeparate) - GL_FUNC(glTexImage2D) - GL_FUNC(glTexParameterf) - GL_FUNC(glTexParameterfv) - GL_FUNC(glTexParameteri) - GL_FUNC(glTexParameteriv) - GL_FUNC(glTexSubImage2D) - GL_FUNC(glUniform1f) - GL_FUNC(glUniform1fv) - GL_FUNC(glUniform1i) - GL_FUNC(glUniform1iv) - GL_FUNC(glUniform2f) - GL_FUNC(glUniform2fv) - GL_FUNC(glUniform2i) - GL_FUNC(glUniform2iv) - GL_FUNC(glUniform3f) - GL_FUNC(glUniform3fv) - GL_FUNC(glUniform3i) - GL_FUNC(glUniform3iv) - GL_FUNC(glUniform4f) - GL_FUNC(glUniform4fv) - GL_FUNC(glUniform4i) - GL_FUNC(glUniform4iv) - GL_FUNC(glUniformMatrix2fv) - GL_FUNC(glUniformMatrix3fv) - GL_FUNC(glUniformMatrix4fv) - GL_FUNC(glUseProgram) - GL_FUNC(glValidateProgram) - GL_FUNC(glVertexAttrib1f) - GL_FUNC(glVertexAttrib1fv) - GL_FUNC(glVertexAttrib2f) - GL_FUNC(glVertexAttrib2fv) - GL_FUNC(glVertexAttrib3f) - GL_FUNC(glVertexAttrib3fv) - GL_FUNC(glVertexAttrib4f) - GL_FUNC(glVertexAttrib4fv) - GL_FUNC(glVertexAttribPointer) - GL_FUNC(glViewport) - GL_FUNC(glGetProgramBinaryOES) - GL_FUNC(glProgramBinaryOES) - GL_FUNC(glMapBufferOES) - GL_FUNC(glUnmapBufferOES) - GL_FUNC(glGetBufferPointervOES) - GL_FUNC(glTexImage3DOES) - GL_FUNC(glTexSubImage3DOES) - GL_FUNC(glCopyTexSubImage3DOES) - GL_FUNC(glCompressedTexImage3DOES) - GL_FUNC(glCompressedTexSubImage3DOES) - GL_FUNC(glFramebufferTexture3DOES) - GL_FUNC(glBindVertexArrayOES) - GL_FUNC(glDeleteVertexArraysOES) - GL_FUNC(glGenVertexArraysOES) - GL_FUNC(glIsVertexArrayOES) - GL_FUNC(glGetPerfMonitorGroupsAMD) - GL_FUNC(glGetPerfMonitorCountersAMD) - GL_FUNC(glGetPerfMonitorGroupStringAMD) - GL_FUNC(glGetPerfMonitorCounterStringAMD) - GL_FUNC(glGetPerfMonitorCounterInfoAMD) - GL_FUNC(glGenPerfMonitorsAMD) - GL_FUNC(glDeletePerfMonitorsAMD) - GL_FUNC(glSelectPerfMonitorCountersAMD) - GL_FUNC(glBeginPerfMonitorAMD) - GL_FUNC(glEndPerfMonitorAMD) - GL_FUNC(glGetPerfMonitorCounterDataAMD) - GL_FUNC(glCopyTextureLevelsAPPLE) - GL_FUNC(glRenderbufferStorageMultisampleAPPLE) - GL_FUNC(glResolveMultisampleFramebufferAPPLE) - GL_FUNC(glFenceSyncAPPLE) - GL_FUNC(glIsSyncAPPLE) - GL_FUNC(glDeleteSyncAPPLE) - GL_FUNC(glClientWaitSyncAPPLE) - GL_FUNC(glWaitSyncAPPLE) - GL_FUNC(glGetInteger64vAPPLE) - GL_FUNC(glGetSyncivAPPLE) - GL_FUNC(glDiscardFramebufferEXT) - GL_FUNC(glMapBufferRangeEXT) - GL_FUNC(glFlushMappedBufferRangeEXT) - GL_FUNC(glMultiDrawArraysEXT) - GL_FUNC(glMultiDrawElementsEXT) - GL_FUNC(glRenderbufferStorageMultisampleEXT) - GL_FUNC(glFramebufferTexture2DMultisampleEXT) - GL_FUNC(glGetGraphicsResetStatusEXT) - GL_FUNC(glReadnPixelsEXT) - GL_FUNC(glGetnUniformfvEXT) - GL_FUNC(glGetnUniformivEXT) - GL_FUNC(glTexStorage1DEXT) - GL_FUNC(glTexStorage2DEXT) - GL_FUNC(glTexStorage3DEXT) - GL_FUNC(glTextureStorage1DEXT) - GL_FUNC(glTextureStorage2DEXT) - GL_FUNC(glTextureStorage3DEXT) - GL_FUNC(glRenderbufferStorageMultisampleIMG) - GL_FUNC(glFramebufferTexture2DMultisampleIMG) - GL_FUNC(glDeleteFencesNV) - GL_FUNC(glGenFencesNV) - GL_FUNC(glIsFenceNV) - GL_FUNC(glTestFenceNV) - GL_FUNC(glGetFenceivNV) - GL_FUNC(glFinishFenceNV) - GL_FUNC(glSetFenceNV) - GL_FUNC(glGetDriverControlsQCOM) - GL_FUNC(glGetDriverControlStringQCOM) - GL_FUNC(glEnableDriverControlQCOM) - GL_FUNC(glDisableDriverControlQCOM) - GL_FUNC(glExtGetTexturesQCOM) - GL_FUNC(glExtGetBuffersQCOM) - GL_FUNC(glExtGetRenderbuffersQCOM) - GL_FUNC(glExtGetFramebuffersQCOM) - GL_FUNC(glExtGetTexLevelParameterivQCOM) - GL_FUNC(glExtTexObjectStateOverrideiQCOM) - GL_FUNC(glExtGetTexSubImageQCOM) - GL_FUNC(glExtGetBufferPointervQCOM) - GL_FUNC(glExtGetShadersQCOM) - GL_FUNC(glExtGetProgramsQCOM) - GL_FUNC(glExtIsProgramBinaryQCOM) - GL_FUNC(glExtGetProgramBinarySourceQCOM) - GL_FUNC(glStartTilingQCOM) - GL_FUNC(glEndTilingQCOM) - GL_FUNC(glEvasGLImageTargetTexture2DOES) - GL_FUNC(glEvasGLImageTargetRenderbufferStorageOES) - GL_FUNC(glBeginQuery) - GL_FUNC(glBeginTransformFeedback) - GL_FUNC(glBindBufferBase) - GL_FUNC(glBindBufferRange) - GL_FUNC(glBindSampler) - GL_FUNC(glBindTransformFeedback) - GL_FUNC(glBindVertexArray) - GL_FUNC(glBlitFramebuffer) - GL_FUNC(glClearBufferfi) - GL_FUNC(glClearBufferfv) - GL_FUNC(glClearBufferiv) - GL_FUNC(glClearBufferuiv) - GL_FUNC(glClientWaitSync) - GL_FUNC(glCompressedTexImage3D) - GL_FUNC(glCompressedTexSubImage3D) - GL_FUNC(glCopyBufferSubData) - GL_FUNC(glCopyTexSubImage3D) - GL_FUNC(glDeleteQueries) - GL_FUNC(glDeleteSamplers) - GL_FUNC(glDeleteSync) - GL_FUNC(glDeleteTransformFeedbacks) - GL_FUNC(glDeleteVertexArrays) - GL_FUNC(glDrawArraysInstanced) - GL_FUNC(glDrawBuffers) - GL_FUNC(glDrawElementsInstanced) - GL_FUNC(glDrawRangeElements) - GL_FUNC(glEndQuery) - GL_FUNC(glEndTransformFeedback) - GL_FUNC(glFenceSync) - GL_FUNC(glFlushMappedBufferRange) - GL_FUNC(glFramebufferTextureLayer) - GL_FUNC(glGenQueries) - GL_FUNC(glGenSamplers) - GL_FUNC(glGenTransformFeedbacks) - GL_FUNC(glGenVertexArrays) - GL_FUNC(glGetActiveUniformBlockiv) - GL_FUNC(glGetActiveUniformBlockName) - GL_FUNC(glGetActiveUniformsiv) - GL_FUNC(glGetBufferParameteri64v) - GL_FUNC(glGetBufferPointerv) - GL_FUNC(glGetFragDataLocation) - GL_FUNC(glGetInteger64i_v) - GL_FUNC(glGetInteger64v) - GL_FUNC(glGetIntegeri_v) - GL_FUNC(glGetInternalformativ) - GL_FUNC(glGetProgramBinary) - GL_FUNC(glGetQueryiv) - GL_FUNC(glGetQueryObjectuiv) - GL_FUNC(glGetSamplerParameterfv) - GL_FUNC(glGetSamplerParameteriv) - GL_FUNC(glGetStringi) - GL_FUNC(glGetSynciv) - GL_FUNC(glGetTransformFeedbackVarying) - GL_FUNC(glGetUniformBlockIndex) - GL_FUNC(glGetUniformIndices) - GL_FUNC(glGetUniformuiv) - GL_FUNC(glGetVertexAttribIiv) - GL_FUNC(glGetVertexAttribIuiv) - GL_FUNC(glInvalidateFramebuffer) - GL_FUNC(glInvalidateSubFramebuffer) - GL_FUNC(glIsQuery) - GL_FUNC(glIsSampler) - GL_FUNC(glIsSync) - GL_FUNC(glIsTransformFeedback) - GL_FUNC(glIsVertexArray) - GL_FUNC(glMapBufferRange) - GL_FUNC(glPauseTransformFeedback) - GL_FUNC(glProgramBinary) - GL_FUNC(glProgramParameteri) - GL_FUNC(glReadBuffer) - GL_FUNC(glRenderbufferStorageMultisample) - GL_FUNC(glResumeTransformFeedback) - GL_FUNC(glSamplerParameterf) - GL_FUNC(glSamplerParameterfv) - GL_FUNC(glSamplerParameteri) - GL_FUNC(glSamplerParameteriv) - GL_FUNC(glTexImage3D) - GL_FUNC(glTexStorage2D) - GL_FUNC(glTexStorage3D) - GL_FUNC(glTexSubImage3D) - GL_FUNC(glTransformFeedbackVaryings) - GL_FUNC(glUniform1ui) - GL_FUNC(glUniform1uiv) - GL_FUNC(glUniform2ui) - GL_FUNC(glUniform2uiv) - GL_FUNC(glUniform3ui) - GL_FUNC(glUniform3uiv) - GL_FUNC(glUniform4ui) - GL_FUNC(glUniform4uiv) - GL_FUNC(glUniformBlockBinding) - GL_FUNC(glUniformMatrix2x3fv) - GL_FUNC(glUniformMatrix3x2fv) - GL_FUNC(glUniformMatrix2x4fv) - GL_FUNC(glUniformMatrix4x2fv) - GL_FUNC(glUniformMatrix3x4fv) - GL_FUNC(glUniformMatrix4x3fv) - GL_FUNC(glUnmapBuffer) - GL_FUNC(glVertexAttribDivisor) - GL_FUNC(glVertexAttribI4i) - GL_FUNC(glVertexAttribI4iv) - GL_FUNC(glVertexAttribI4ui) - GL_FUNC(glVertexAttribI4uiv) - GL_FUNC(glVertexAttribIPointer) - GL_FUNC(glWaitSync) - GL_FUNC(glDispatchCompute) - GL_FUNC(glDispatchComputeIndirect) - GL_FUNC(glDrawArraysIndirect) - GL_FUNC(glDrawElementsIndirect) - GL_FUNC(glFramebufferParameteri) - GL_FUNC(glGetFramebufferParameteriv) - GL_FUNC(glGetProgramInterfaceiv) - GL_FUNC(glGetProgramResourceIndex) - GL_FUNC(glGetProgramResourceName) - GL_FUNC(glGetProgramResourceiv) - GL_FUNC(glGetProgramResourceLocation) - GL_FUNC(glUseProgramStages) - GL_FUNC(glActiveShaderProgram) - GL_FUNC(glCreateShaderProgramv) - GL_FUNC(glBindProgramPipeline) - GL_FUNC(glDeleteProgramPipelines) - GL_FUNC(glGenProgramPipelines) - GL_FUNC(glIsProgramPipeline) - GL_FUNC(glGetProgramPipelineiv) - GL_FUNC(glProgramUniform1i) - GL_FUNC(glProgramUniform2i) - GL_FUNC(glProgramUniform3i) - GL_FUNC(glProgramUniform4i) - GL_FUNC(glProgramUniform1ui) - GL_FUNC(glProgramUniform2ui) - GL_FUNC(glProgramUniform3ui) - GL_FUNC(glProgramUniform4ui) - GL_FUNC(glProgramUniform1f) - GL_FUNC(glProgramUniform2f) - GL_FUNC(glProgramUniform3f) - GL_FUNC(glProgramUniform4f) - GL_FUNC(glProgramUniform1iv) - GL_FUNC(glProgramUniform2iv) - GL_FUNC(glProgramUniform3iv) - GL_FUNC(glProgramUniform4iv) - GL_FUNC(glProgramUniform1uiv) - GL_FUNC(glProgramUniform2uiv) - GL_FUNC(glProgramUniform3uiv) - GL_FUNC(glProgramUniform4uiv) - GL_FUNC(glProgramUniform1fv) - GL_FUNC(glProgramUniform2fv) - GL_FUNC(glProgramUniform3fv) - GL_FUNC(glProgramUniform4fv) - GL_FUNC(glProgramUniformMatrix2fv) - GL_FUNC(glProgramUniformMatrix3fv) - GL_FUNC(glProgramUniformMatrix4fv) - GL_FUNC(glProgramUniformMatrix2x3fv) - GL_FUNC(glProgramUniformMatrix3x2fv) - GL_FUNC(glProgramUniformMatrix2x4fv) - GL_FUNC(glProgramUniformMatrix4x2fv) - GL_FUNC(glProgramUniformMatrix3x4fv) - GL_FUNC(glProgramUniformMatrix4x3fv) - GL_FUNC(glValidateProgramPipeline) - GL_FUNC(glGetProgramPipelineInfoLog) - GL_FUNC(glBindImageTexture) - GL_FUNC(glGetBooleani_v) - GL_FUNC(glMemoryBarrier) - GL_FUNC(glMemoryBarrierByRegion) - GL_FUNC(glTexStorage2DMultisample) - GL_FUNC(glGetMultisamplefv) - GL_FUNC(glSampleMaski) - GL_FUNC(glGetTexLevelParameteriv) - GL_FUNC(glGetTexLevelParameterfv) - GL_FUNC(glBindVertexBuffer) - GL_FUNC(glVertexAttribFormat) - GL_FUNC(glVertexAttribIFormat) - GL_FUNC(glVertexAttribBinding) - GL_FUNC(glVertexBindingDivisor) - GL_FUNC(glBlendBarrier) - GL_FUNC(glCopyImageSubData) - GL_FUNC(glDebugMessageControl) - GL_FUNC(glDebugMessageInsert) - GL_FUNC(glDebugMessageCallback) - GL_FUNC(glGetDebugMessageLog) - GL_FUNC(glPushDebugGroup) - GL_FUNC(glPopDebugGroup) - GL_FUNC(glObjectLabel) - GL_FUNC(glGetObjectLabel) - GL_FUNC(glObjectPtrLabel) - GL_FUNC(glGetObjectPtrLabel) - GL_FUNC(glGetPointerv) - GL_FUNC(glEnablei) - GL_FUNC(glDisablei) - GL_FUNC(glBlendEquationi) - GL_FUNC(glBlendEquationSeparatei) - GL_FUNC(glBlendFunci) - GL_FUNC(glBlendFuncSeparatei) - GL_FUNC(glColorMaski) - GL_FUNC(glIsEnabledi) - GL_FUNC(glDrawElementsBaseVertex) - GL_FUNC(glDrawRangeElementsBaseVertex) - GL_FUNC(glDrawElementsInstancedBaseVertex) - GL_FUNC(glFramebufferTexture) - GL_FUNC(glPrimitiveBoundingBox) - GL_FUNC(glGetGraphicsResetStatus) - GL_FUNC(glReadnPixels) - GL_FUNC(glGetnUniformfv) - GL_FUNC(glGetnUniformiv) - GL_FUNC(glGetnUniformuiv) - GL_FUNC(glMinSampleShading) - GL_FUNC(glPatchParameteri) - GL_FUNC(glTexParameterIiv) - GL_FUNC(glTexParameterIuiv) - GL_FUNC(glGetTexParameterIiv) - GL_FUNC(glGetTexParameterIuiv) - GL_FUNC(glSamplerParameterIiv) - GL_FUNC(glSamplerParameterIuiv) - GL_FUNC(glGetSamplerParameterIiv) - GL_FUNC(glGetSamplerParameterIuiv) - GL_FUNC(glTexBuffer) - GL_FUNC(glTexBufferRange) - GL_FUNC(glTexStorage3DMultisample) - FT_LOGD("Could not resolve: %s", name); - return nullptr; -} -#undef GL_FUNC - -bool TizenRenderer::InitializeRenderer(int32_t x, int32_t y, int32_t w, - int32_t h) { - if (!SetupEvasGL(x, y, w, h)) { - FT_LOGE("SetupEvasGL fail"); - return false; - } - Show(); - is_valid_ = true; - return true; -} - -bool TizenRenderer::IsValid() { return is_valid_; } - -void TizenRenderer::flush() { glFlush(); } - -bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { - evas_gl_ = evas_gl_new( - evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); - - if (!evas_gl_) { - FT_LOGE("SetupEvasWindow fail"); - return false; - } - - g_evas_gl = evas_gl_; - gl_config_ = evas_gl_config_new(); - gl_config_->color_format = EVAS_GL_RGBA_8888; - gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; - gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; - - gl_context_ = - evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_3_X); - gl_resource_context_ = - evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); - - if (gl_context_ == nullptr) { - FT_LOGW( - "Failed to create evas gl context with EVAS_GL_GLES_3_X, try to use " - "EVAS_GL_GLES_2_X,"); - gl_context_ = - evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); - gl_resource_context_ = - evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); - } - if (gl_context_ == nullptr) { - FT_LOGE("Failed to create evas gl context!"); - FT_RELEASE_ASSERT_NOT_REACHED(); - } - - EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); - gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, w, h); - - gl_resource_surface_ = - evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, w, h, NULL); - - Evas_Native_Surface ns; - evas_gl_native_surface_get(evas_gl_, gl_surface_, &ns); - evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), &ns); - - return true; -} - -void TizenRenderer::DestoryRenderer() { - DestoryEvasGL(); - DestoryEvasWindow(); -} - -void TizenRenderer::DestoryEvasGL() { - evas_gl_surface_destroy(evas_gl_, gl_surface_); - evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); - - evas_gl_context_destroy(evas_gl_, gl_context_); - evas_gl_context_destroy(evas_gl_, gl_resource_context_); - - evas_gl_config_free(gl_config_); - evas_gl_free(evas_gl_); -} - -#else // TIZEN_RENDERER_EVAS_GL - -bool TizenRenderer::OnMakeCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (eglMakeCurrent(egl_display_, egl_surface_, egl_surface_, egl_context_) != - EGL_TRUE) { - FT_LOGE("Could not make the onscreen context current"); - PrintEGLError(); - return false; - } - return true; -} - -bool TizenRenderer::OnClearCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT) != EGL_TRUE) { - FT_LOGE("Could not clear context"); - PrintEGLError(); - return false; - } - return true; -} - -bool TizenRenderer::OnMakeResourceCurrent() { - if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - if (eglMakeCurrent(egl_display_, egl_resource_surface_, egl_resource_surface_, - egl_resource_context_) != EGL_TRUE) { - FT_LOGE("Could not make the offscreen context current"); - PrintEGLError(); - return false; - } - return true; -} - -bool TizenRenderer::OnPresent() { - if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); - return false; - } - - if (received_rotation) { - SendRotationChangeDone(); - received_rotation = false; - } - - if (eglSwapBuffers(egl_display_, egl_surface_) != EGL_TRUE) { - FT_LOGE("Could not swap EGl buffer"); - PrintEGLError(); - return false; - } - return true; -} - -uint32_t TizenRenderer::OnGetFBO() { - if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); - return 999; - } - FT_LOGD("OnGetFBO"); - return 0; -} - -#define GL_FUNC(FunctionName) \ - else if (strcmp(name, #FunctionName) == 0) { \ - return reinterpret_cast(FunctionName); \ - } -void* TizenRenderer::OnProcResolver(const char* name) { - auto address = eglGetProcAddress(name); - if (address != nullptr) { - return reinterpret_cast(address); - } - GL_FUNC(eglGetCurrentDisplay) - GL_FUNC(eglQueryString) - GL_FUNC(glActiveTexture) - GL_FUNC(glAttachShader) - GL_FUNC(glBindAttribLocation) - GL_FUNC(glBindBuffer) - GL_FUNC(glBindFramebuffer) - GL_FUNC(glBindRenderbuffer) - GL_FUNC(glBindTexture) - GL_FUNC(glBlendColor) - GL_FUNC(glBlendEquation) - GL_FUNC(glBlendFunc) - GL_FUNC(glBufferData) - GL_FUNC(glBufferSubData) - GL_FUNC(glCheckFramebufferStatus) - GL_FUNC(glClear) - GL_FUNC(glClearColor) - GL_FUNC(glClearStencil) - GL_FUNC(glColorMask) - GL_FUNC(glCompileShader) - GL_FUNC(glCompressedTexImage2D) - GL_FUNC(glCompressedTexSubImage2D) - GL_FUNC(glCopyTexSubImage2D) - GL_FUNC(glCreateProgram) - GL_FUNC(glCreateShader) - GL_FUNC(glCullFace) - GL_FUNC(glDeleteBuffers) - GL_FUNC(glDeleteFramebuffers) - GL_FUNC(glDeleteProgram) - GL_FUNC(glDeleteRenderbuffers) - GL_FUNC(glDeleteShader) - GL_FUNC(glDeleteTextures) - GL_FUNC(glDepthMask) - GL_FUNC(glDisable) - GL_FUNC(glDisableVertexAttribArray) - GL_FUNC(glDrawArrays) - GL_FUNC(glDrawElements) - GL_FUNC(glEnable) - GL_FUNC(glEnableVertexAttribArray) - GL_FUNC(glFinish) - GL_FUNC(glFlush) - GL_FUNC(glFramebufferRenderbuffer) - GL_FUNC(glFramebufferTexture2D) - GL_FUNC(glFrontFace) - GL_FUNC(glGenBuffers) - GL_FUNC(glGenerateMipmap) - GL_FUNC(glGenFramebuffers) - GL_FUNC(glGenRenderbuffers) - GL_FUNC(glGenTextures) - GL_FUNC(glGetBufferParameteriv) - GL_FUNC(glGetError) - GL_FUNC(glGetFramebufferAttachmentParameteriv) - GL_FUNC(glGetIntegerv) - GL_FUNC(glGetProgramInfoLog) - GL_FUNC(glGetProgramiv) - GL_FUNC(glGetRenderbufferParameteriv) - GL_FUNC(glGetShaderInfoLog) - GL_FUNC(glGetShaderiv) - GL_FUNC(glGetShaderPrecisionFormat) - GL_FUNC(glGetString) - GL_FUNC(glGetUniformLocation) - GL_FUNC(glIsTexture) - GL_FUNC(glLineWidth) - GL_FUNC(glLinkProgram) - GL_FUNC(glPixelStorei) - GL_FUNC(glReadPixels) - GL_FUNC(glRenderbufferStorage) - GL_FUNC(glScissor) - GL_FUNC(glShaderSource) - GL_FUNC(glStencilFunc) - GL_FUNC(glStencilFuncSeparate) - GL_FUNC(glStencilMask) - GL_FUNC(glStencilMaskSeparate) - GL_FUNC(glStencilOp) - GL_FUNC(glStencilOpSeparate) - GL_FUNC(glTexImage2D) - GL_FUNC(glTexParameterf) - GL_FUNC(glTexParameterfv) - GL_FUNC(glTexParameteri) - GL_FUNC(glTexParameteriv) - GL_FUNC(glTexSubImage2D) - GL_FUNC(glUniform1f) - GL_FUNC(glUniform1fv) - GL_FUNC(glUniform1i) - GL_FUNC(glUniform1iv) - GL_FUNC(glUniform2f) - GL_FUNC(glUniform2fv) - GL_FUNC(glUniform2i) - GL_FUNC(glUniform2iv) - GL_FUNC(glUniform3f) - GL_FUNC(glUniform3fv) - GL_FUNC(glUniform3i) - GL_FUNC(glUniform3iv) - GL_FUNC(glUniform4f) - GL_FUNC(glUniform4fv) - GL_FUNC(glUniform4i) - GL_FUNC(glUniform4iv) - GL_FUNC(glUniformMatrix2fv) - GL_FUNC(glUniformMatrix3fv) - GL_FUNC(glUniformMatrix4fv) - GL_FUNC(glUseProgram) - GL_FUNC(glVertexAttrib1f) - GL_FUNC(glVertexAttrib2fv) - GL_FUNC(glVertexAttrib3fv) - GL_FUNC(glVertexAttrib4fv) - GL_FUNC(glVertexAttribPointer) - GL_FUNC(glViewport) - - FT_LOGW("Could not resolve: %s", name); - return nullptr; -} -#undef GL_FUNC - -bool TizenRenderer::InitializeRenderer(int32_t x, int32_t y, int32_t w, - int32_t h) { - if (!SetupDisplay()) { - FT_LOGE("setupDisplay fail"); - return false; - } - if (!SetupEcoreWlWindow(x, y, w, h)) { - FT_LOGE("SetupEcoreWlWindow fail"); - return false; - } - - if (!SetupEglWindow(w, h)) { - FT_LOGE("SetupEglWindow fail"); - return false; - } - - if (!SetupEglSurface()) { - FT_LOGE("setupEglSurface fail"); - return false; - } - Show(); - is_valid_ = true; - return true; -} - -bool TizenRenderer::IsValid() { return is_valid_; } - -bool TizenRenderer::SetupEglSurface() { - if (!ChooseEGLConfiguration()) { - FT_LOGE("ChooseEGLConfiguration fail"); - return false; - } - const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; - egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, - contextAttribs); - if (EGL_NO_CONTEXT == egl_context_) { - PrintEGLError(); - return false; - } - - egl_resource_context_ = - eglCreateContext(egl_display_, egl_config_, egl_context_, contextAttribs); - if (EGL_NO_CONTEXT == egl_resource_context_) { - PrintEGLError(); - return false; - } - EGLint* ptr = nullptr; - const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; - egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, - GetEGLNativeWindowType(), ptr); - if (egl_surface_ == EGL_NO_SURFACE) { - FT_LOGE("eglCreateWindowSurface failed"); - return false; - } - egl_resource_surface_ = - eglCreatePbufferSurface(egl_display_, egl_config_, attribs); - if (egl_resource_surface_ == EGL_NO_SURFACE) { - FT_LOGE("eglCreatePbufferSurface is Failed"); - return false; - } - return true; -} - -bool TizenRenderer::ChooseEGLConfiguration() { - // egl CONTEXT - EGLint configAttribs[] = { - // clang-format off - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, - EGL_SAMPLES, EGL_DONT_CARE, - EGL_NONE - // clang-format on - }; - - EGLint major = 0; - EGLint minor = 0; - int bufferSize = 32; - egl_display_ = GetEGLDisplay(); - if (EGL_NO_DISPLAY == egl_display_) { - FT_LOGE("EGL Get Display is failed"); - return false; - } - - if (!eglInitialize(egl_display_, &major, &minor)) { - FT_LOGE("EGL Intialize is Failed major [%d] minor [%d]", major, minor); - PrintEGLError(); - return false; - } - - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - PrintEGLError(); - return false; - } - - EGLint numOfConfig = 0; - // Query all framebuffer configurations - if (!eglGetConfigs(egl_display_, NULL, 0, &numOfConfig)) { - FT_LOGE("eglGetConfigs is Failed!!"); - PrintEGLError(); - return false; - } - EGLConfig* configs = (EGLConfig*)calloc(numOfConfig, sizeof(EGLConfig)); - EGLint n; - // Get the List of EGL framebuffer configuration matches with configAttribs in - // list "configs" - if (!eglChooseConfig(egl_display_, configAttribs, configs, numOfConfig, &n)) { - free(configs); - configs = NULL; - PrintEGLError(); - return false; - } - - EGLint size; - for (int i = 0; i < n; i++) { - eglGetConfigAttrib(egl_display_, configs[i], EGL_BUFFER_SIZE, &size); - if (bufferSize == size) { - egl_config_ = configs[i]; - break; - } - } - free(configs); - configs = NULL; - return true; -} - -void TizenRenderer::PrintEGLError() { - EGLint error = eglGetError(); - switch (error) { - case EGL_BAD_DISPLAY: { - FT_LOGE("EGL_BAD_DISPLAY : Display is not an EGL display connection"); - break; - } - case EGL_NOT_INITIALIZED: { - FT_LOGE("EGL_NOT_INITIALIZED : Display has not been initialized"); - break; - } - case EGL_BAD_SURFACE: { - FT_LOGE("EGL_BAD_SURFACE : Draw or read is not an EGL surface"); - break; - } - case EGL_BAD_CONTEXT: { - FT_LOGE("EGL_BAD_CONTEXT : Context is not an EGL rendering context"); - break; - } - case EGL_BAD_CONFIG: { - FT_LOGE( - "EGL_BAD_CONFIG : Config is not an EGL frame buffer configuration"); - break; - } - case EGL_BAD_MATCH: { - FT_LOGE( - "EGL_BAD_MATCH : Draw or read are not compatible with context, or if " - "context is set to EGL_NO_CONTEXT and draw or read are not set to " - "EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and " - "context is not set to EGL_NO_CONTEXT\n"); - break; - } - case EGL_BAD_ACCESS: { - FT_LOGE("EGL_BAD_ACCESS : Context is current to some other thread"); - break; - } - case EGL_BAD_NATIVE_PIXMAP: { - FT_LOGE( - "EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or " - "read is no longer valid"); - break; - } - case EGL_BAD_NATIVE_WINDOW: { - FT_LOGE( - "EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or " - "read is no longer valid"); - break; - } - case EGL_BAD_CURRENT_SURFACE: { - FT_LOGE( - "EGL_BAD_CURRENT_SURFACE : The previous context has unflushed " - "commands and the previous surface is no longer valid"); - break; - } - case EGL_BAD_ALLOC: { - FT_LOGE( - "EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read " - "were delayed until eglMakeCurrent is called, and there are not " - "enough resources to allocate them"); - break; - } - case EGL_CONTEXT_LOST: { - FT_LOGE( - "EGL_CONTEXT_LOST : A power management event has occurred. The " - "application must destroy all contexts and reinitialise OpenGL ES " - "state and objects to continue rendering"); - break; - } - case EGL_BAD_PARAMETER: { - FT_LOGE("Invalid parameter is passed"); - break; - } - case EGL_BAD_ATTRIBUTE: { - FT_LOGE( - "The parameter configAttribs contains an invalid frame buffer " - "configuration attribute or an attribute value that is unrecognized " - "or out of range"); - break; - } - default: { - FT_LOGE("Unknown error with code: %d", error); - break; - } - } -} - -void TizenRenderer::DestoryRenderer() { - DestoryEglSurface(); - DestoryEglWindow(); - DestoryEcoreWlWindow(); - ShutdownDisplay(); -} - -void TizenRenderer::DestoryEglSurface() { - if (EGL_NO_DISPLAY != egl_display_) { - eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - - if (EGL_NO_SURFACE != egl_surface_) { - eglDestroySurface(egl_display_, egl_surface_); - egl_surface_ = EGL_NO_SURFACE; - } - - if (EGL_NO_CONTEXT != egl_context_) { - eglDestroyContext(egl_display_, egl_context_); - egl_context_ = EGL_NO_CONTEXT; - } - - if (EGL_NO_SURFACE != egl_resource_surface_) { - eglDestroySurface(egl_display_, egl_resource_surface_); - egl_resource_surface_ = EGL_NO_SURFACE; - } - - if (EGL_NO_CONTEXT != egl_resource_context_) { - eglDestroyContext(egl_display_, egl_resource_context_); - egl_resource_context_ = EGL_NO_CONTEXT; - } - - eglTerminate(egl_display_); - egl_display_ = EGL_NO_DISPLAY; - } -} - -#endif // TIZEN_RENDERER_EVAS_GL diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index a29ee13442514..b0b08f422e574 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -5,13 +5,7 @@ #ifndef EMBEDDER_TIZEN_RENDERER_H #define EMBEDDER_TIZEN_RENDERER_H -#ifdef TIZEN_RENDERER_EVAS_GL -#undef EFL_BETA_API_SUPPORT -#include -#include -#else -#include -#endif +#include class TizenRenderer { public: @@ -24,80 +18,42 @@ class TizenRenderer { virtual void OnRotationChange(int angle) = 0; }; - TizenRenderer(TizenRenderer::Delegate& deleget); virtual ~TizenRenderer(); -#ifdef TIZEN_RENDERER_EVAS_GL - void ClearColor(float r, float g, float b, float a); -#endif - bool OnMakeCurrent(); - bool OnClearCurrent(); - bool OnMakeResourceCurrent(); - bool OnPresent(); - uint32_t OnGetFBO(); - void* OnProcResolver(const char* name); - void flush(); + bool IsValid() { return is_valid_; } + + virtual bool OnMakeCurrent() = 0; + virtual bool OnClearCurrent() = 0; + virtual bool OnMakeResourceCurrent() = 0; + virtual bool OnPresent() = 0; + virtual uint32_t OnGetFBO() = 0; + virtual void* OnProcResolver(const char* name) = 0; + virtual TizenWindowGeometry GetGeometry() = 0; - bool IsValid(); - virtual void Show() = 0; - virtual void SetRotate(int angle) = 0; virtual int GetEcoreWindowId() = 0; + + // TODO: For Evas GL only. + virtual void* GetImageHandle() { return nullptr; }; + virtual void ClearColor(float r, float g, float b, float a){}; + + virtual void SetRotate(int angle) = 0; virtual void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t degree) = 0; protected: - bool received_rotation{false}; - TizenRenderer::Delegate& delegate_; - bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h); -#ifdef TIZEN_RENDERER_EVAS_GL - virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h) = 0; - virtual void DestoryEvasWindow() = 0; + explicit TizenRenderer(TizenRenderer::Delegate& delegate); - public: - virtual void* GetImageHandle() = 0; - - protected: - bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); - void DestoryEvasGL(); -#else - virtual bool SetupDisplay() = 0; - virtual bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, + virtual bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) = 0; - virtual bool SetupEglWindow(int32_t w, int32_t h) = 0; - virtual EGLDisplay GetEGLDisplay() = 0; - virtual EGLNativeWindowType GetEGLNativeWindowType() = 0; - virtual void DestoryEglWindow() = 0; - virtual void DestoryEcoreWlWindow() = 0; - virtual void ShutdownDisplay() = 0; - - void DestoryEglSurface(); - bool SetupEglSurface(); -#endif - void DestoryRenderer(); + virtual void Show() = 0; + virtual void DestroyRenderer() = 0; + virtual void SendRotationChangeDone() = 0; - private: bool is_valid_ = false; -#ifdef TIZEN_RENDERER_EVAS_GL - Evas_GL_Config* gl_config_; - Evas_GL* evas_gl_{nullptr}; - - Evas_GL_Context* gl_context_; - Evas_GL_Context* gl_resource_context_; - - Evas_GL_Surface* gl_surface_{nullptr}; - Evas_GL_Surface* gl_resource_surface_{nullptr}; -#else - bool ChooseEGLConfiguration(); - void PrintEGLError(); - - EGLConfig egl_config_; - EGLDisplay egl_display_ = EGL_NO_DISPLAY; - EGLContext egl_context_ = EGL_NO_CONTEXT; - EGLSurface egl_surface_ = EGL_NO_SURFACE; - EGLContext egl_resource_context_ = EGL_NO_CONTEXT; - EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; -#endif + + bool received_rotation{false}; + TizenRenderer::Delegate& delegate_; }; #endif // EMBEDDER_TIZEN_RENDERER_H diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 4d99b1ca5312e..09f959b1a789c 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -4,6 +4,9 @@ #include "tizen_renderer_ecore_wl2.h" +#include +#include + #include "flutter/shell/platform/tizen/tizen_log.h" TizenRendererEcoreWl2::TizenRendererEcoreWl2(TizenRenderer::Delegate &delegate, @@ -13,7 +16,244 @@ TizenRendererEcoreWl2::TizenRendererEcoreWl2(TizenRenderer::Delegate &delegate, InitializeRenderer(x, y, w, h); } -TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { DestoryRenderer(); } +TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { DestroyRenderer(); } + +bool TizenRendererEcoreWl2::OnMakeCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (eglMakeCurrent(egl_display_, egl_surface_, egl_surface_, egl_context_) != + EGL_TRUE) { + FT_LOGE("Could not make the onscreen context current"); + PrintEGLError(); + return false; + } + return true; +} + +bool TizenRendererEcoreWl2::OnClearCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT) != EGL_TRUE) { + FT_LOGE("Could not clear context"); + PrintEGLError(); + return false; + } + return true; +} + +bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (eglMakeCurrent(egl_display_, egl_resource_surface_, egl_resource_surface_, + egl_resource_context_) != EGL_TRUE) { + FT_LOGE("Could not make the offscreen context current"); + PrintEGLError(); + return false; + } + return true; +} + +bool TizenRendererEcoreWl2::OnPresent() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + + if (received_rotation) { + SendRotationChangeDone(); + received_rotation = false; + } + + if (eglSwapBuffers(egl_display_, egl_surface_) != EGL_TRUE) { + FT_LOGE("Could not swap EGl buffer"); + PrintEGLError(); + return false; + } + return true; +} + +uint32_t TizenRendererEcoreWl2::OnGetFBO() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return 999; + } + FT_LOGD("OnGetFBO"); + return 0; +} + +void *TizenRendererEcoreWl2::OnProcResolver(const char *name) { + auto address = eglGetProcAddress(name); + if (address != nullptr) { + return reinterpret_cast(address); + } +#define GL_FUNC(FunctionName) \ + else if (strcmp(name, #FunctionName) == 0) { \ + return reinterpret_cast(FunctionName); \ + } + GL_FUNC(eglGetCurrentDisplay) + GL_FUNC(eglQueryString) + GL_FUNC(glActiveTexture) + GL_FUNC(glAttachShader) + GL_FUNC(glBindAttribLocation) + GL_FUNC(glBindBuffer) + GL_FUNC(glBindFramebuffer) + GL_FUNC(glBindRenderbuffer) + GL_FUNC(glBindTexture) + GL_FUNC(glBlendColor) + GL_FUNC(glBlendEquation) + GL_FUNC(glBlendFunc) + GL_FUNC(glBufferData) + GL_FUNC(glBufferSubData) + GL_FUNC(glCheckFramebufferStatus) + GL_FUNC(glClear) + GL_FUNC(glClearColor) + GL_FUNC(glClearStencil) + GL_FUNC(glColorMask) + GL_FUNC(glCompileShader) + GL_FUNC(glCompressedTexImage2D) + GL_FUNC(glCompressedTexSubImage2D) + GL_FUNC(glCopyTexSubImage2D) + GL_FUNC(glCreateProgram) + GL_FUNC(glCreateShader) + GL_FUNC(glCullFace) + GL_FUNC(glDeleteBuffers) + GL_FUNC(glDeleteFramebuffers) + GL_FUNC(glDeleteProgram) + GL_FUNC(glDeleteRenderbuffers) + GL_FUNC(glDeleteShader) + GL_FUNC(glDeleteTextures) + GL_FUNC(glDepthMask) + GL_FUNC(glDisable) + GL_FUNC(glDisableVertexAttribArray) + GL_FUNC(glDrawArrays) + GL_FUNC(glDrawElements) + GL_FUNC(glEnable) + GL_FUNC(glEnableVertexAttribArray) + GL_FUNC(glFinish) + GL_FUNC(glFlush) + GL_FUNC(glFramebufferRenderbuffer) + GL_FUNC(glFramebufferTexture2D) + GL_FUNC(glFrontFace) + GL_FUNC(glGenBuffers) + GL_FUNC(glGenerateMipmap) + GL_FUNC(glGenFramebuffers) + GL_FUNC(glGenRenderbuffers) + GL_FUNC(glGenTextures) + GL_FUNC(glGetBufferParameteriv) + GL_FUNC(glGetError) + GL_FUNC(glGetFramebufferAttachmentParameteriv) + GL_FUNC(glGetIntegerv) + GL_FUNC(glGetProgramInfoLog) + GL_FUNC(glGetProgramiv) + GL_FUNC(glGetRenderbufferParameteriv) + GL_FUNC(glGetShaderInfoLog) + GL_FUNC(glGetShaderiv) + GL_FUNC(glGetShaderPrecisionFormat) + GL_FUNC(glGetString) + GL_FUNC(glGetUniformLocation) + GL_FUNC(glIsTexture) + GL_FUNC(glLineWidth) + GL_FUNC(glLinkProgram) + GL_FUNC(glPixelStorei) + GL_FUNC(glReadPixels) + GL_FUNC(glRenderbufferStorage) + GL_FUNC(glScissor) + GL_FUNC(glShaderSource) + GL_FUNC(glStencilFunc) + GL_FUNC(glStencilFuncSeparate) + GL_FUNC(glStencilMask) + GL_FUNC(glStencilMaskSeparate) + GL_FUNC(glStencilOp) + GL_FUNC(glStencilOpSeparate) + GL_FUNC(glTexImage2D) + GL_FUNC(glTexParameterf) + GL_FUNC(glTexParameterfv) + GL_FUNC(glTexParameteri) + GL_FUNC(glTexParameteriv) + GL_FUNC(glTexSubImage2D) + GL_FUNC(glUniform1f) + GL_FUNC(glUniform1fv) + GL_FUNC(glUniform1i) + GL_FUNC(glUniform1iv) + GL_FUNC(glUniform2f) + GL_FUNC(glUniform2fv) + GL_FUNC(glUniform2i) + GL_FUNC(glUniform2iv) + GL_FUNC(glUniform3f) + GL_FUNC(glUniform3fv) + GL_FUNC(glUniform3i) + GL_FUNC(glUniform3iv) + GL_FUNC(glUniform4f) + GL_FUNC(glUniform4fv) + GL_FUNC(glUniform4i) + GL_FUNC(glUniform4iv) + GL_FUNC(glUniformMatrix2fv) + GL_FUNC(glUniformMatrix3fv) + GL_FUNC(glUniformMatrix4fv) + GL_FUNC(glUseProgram) + GL_FUNC(glVertexAttrib1f) + GL_FUNC(glVertexAttrib2fv) + GL_FUNC(glVertexAttrib3fv) + GL_FUNC(glVertexAttrib4fv) + GL_FUNC(glVertexAttribPointer) + GL_FUNC(glViewport) +#undef GL_FUNC + + FT_LOGW("Could not resolve: %s", name); + return nullptr; +} + +TizenRenderer::TizenWindowGeometry TizenRendererEcoreWl2::GetGeometry() { + TizenWindowGeometry result; + ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.x, &result.y, + &result.w, &result.h); + return result; +} + +int TizenRendererEcoreWl2::GetEcoreWindowId() { + return ecore_wl2_window_id_get(ecore_wl2_window_); +} + +bool TizenRendererEcoreWl2::InitializeRenderer(int32_t x, int32_t y, int32_t w, + int32_t h) { + if (!SetupDisplay()) { + FT_LOGE("setupDisplay fail"); + return false; + } + if (!SetupEcoreWlWindow(x, y, w, h)) { + FT_LOGE("SetupEcoreWlWindow fail"); + return false; + } + + if (!SetupEglWindow(w, h)) { + FT_LOGE("SetupEglWindow fail"); + return false; + } + + if (!SetupEglSurface()) { + FT_LOGE("setupEglSurface fail"); + return false; + } + Show(); + is_valid_ = true; + return true; +} + +void TizenRendererEcoreWl2::Show() { ecore_wl2_window_show(ecore_wl2_window_); } + +void TizenRendererEcoreWl2::DestroyRenderer() { + DestroyEglSurface(); + DestroyEglWindow(); + DestroyEcoreWlWindow(); + ShutdownDisplay(); +} bool TizenRendererEcoreWl2::SetupDisplay() { if (!ecore_wl2_init()) { @@ -50,37 +290,6 @@ bool TizenRendererEcoreWl2::SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, return true; } -Eina_Bool TizenRendererEcoreWl2::RotationEventCb(void *data, int type, - void *event) { - auto *self = reinterpret_cast(data); - Ecore_Wl2_Event_Window_Rotation *ev = - reinterpret_cast(event); - self->delegate_.OnRotationChange(ev->angle); - return ECORE_CALLBACK_PASS_ON; -} - -void TizenRendererEcoreWl2::Show() { ecore_wl2_window_show(ecore_wl2_window_); } - -void TizenRendererEcoreWl2::SetRotate(int angle) { - ecore_wl2_window_rotation_set(ecore_wl2_window_, angle); - received_rotation = true; -} - -void TizenRendererEcoreWl2::ResizeWithRotation(int32_t x, int32_t y, - int32_t width, int32_t height, - int32_t angle) { - ecore_wl2_egl_window_resize_with_rotation(ecore_wl2_egl_window_, x, y, width, - height, angle); -} - -void TizenRendererEcoreWl2::SendRotationChangeDone() { - int x, y, w, h; - ecore_wl2_window_geometry_get(ecore_wl2_window_, &x, &y, &w, &h); - ecore_wl2_window_rotation_change_done_send( - ecore_wl2_window_, ecore_wl2_window_rotation_get(ecore_wl2_window_), w, - h); -} - bool TizenRendererEcoreWl2::SetupEglWindow(int32_t w, int32_t h) { ecore_wl2_egl_window_ = ecore_wl2_egl_window_create(ecore_wl2_window_, w, h); return ecore_wl2_egl_window_ != nullptr; @@ -96,14 +305,14 @@ EGLNativeWindowType TizenRendererEcoreWl2::GetEGLNativeWindowType() { ecore_wl2_egl_window_); } -void TizenRendererEcoreWl2::DestoryEglWindow() { +void TizenRendererEcoreWl2::DestroyEglWindow() { if (ecore_wl2_egl_window_) { ecore_wl2_egl_window_destroy(ecore_wl2_egl_window_); ecore_wl2_egl_window_ = nullptr; } } -void TizenRendererEcoreWl2::DestoryEcoreWlWindow() { +void TizenRendererEcoreWl2::DestroyEcoreWlWindow() { if (ecore_wl2_window_) { ecore_wl2_window_free(ecore_wl2_window_); ecore_wl2_window_ = nullptr; @@ -118,13 +327,250 @@ void TizenRendererEcoreWl2::ShutdownDisplay() { ecore_wl2_shutdown(); } -TizenRenderer::TizenWindowGeometry TizenRendererEcoreWl2::GetGeometry() { - TizenWindowGeometry result; - ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.x, &result.y, - &result.w, &result.h); - return result; +bool TizenRendererEcoreWl2::SetupEglSurface() { + if (!ChooseEGLConfiguration()) { + FT_LOGE("ChooseEGLConfiguration fail"); + return false; + } + const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, + contextAttribs); + if (EGL_NO_CONTEXT == egl_context_) { + PrintEGLError(); + return false; + } + + egl_resource_context_ = + eglCreateContext(egl_display_, egl_config_, egl_context_, contextAttribs); + if (EGL_NO_CONTEXT == egl_resource_context_) { + PrintEGLError(); + return false; + } + EGLint *ptr = nullptr; + const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; + egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, + GetEGLNativeWindowType(), ptr); + if (egl_surface_ == EGL_NO_SURFACE) { + FT_LOGE("eglCreateWindowSurface failed"); + return false; + } + egl_resource_surface_ = + eglCreatePbufferSurface(egl_display_, egl_config_, attribs); + if (egl_resource_surface_ == EGL_NO_SURFACE) { + FT_LOGE("eglCreatePbufferSurface is Failed"); + return false; + } + return true; } -int TizenRendererEcoreWl2::GetEcoreWindowId() { - return ecore_wl2_window_id_get(ecore_wl2_window_); +bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { + // egl CONTEXT + EGLint configAttribs[] = { + // clang-format off + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, EGL_DONT_CARE, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, + EGL_SAMPLES, EGL_DONT_CARE, + EGL_NONE + // clang-format on + }; + + EGLint major = 0; + EGLint minor = 0; + int bufferSize = 32; + egl_display_ = GetEGLDisplay(); + if (EGL_NO_DISPLAY == egl_display_) { + FT_LOGE("EGL Get Display is failed"); + return false; + } + + if (!eglInitialize(egl_display_, &major, &minor)) { + FT_LOGE("EGL Intialize is Failed major [%d] minor [%d]", major, minor); + PrintEGLError(); + return false; + } + + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + PrintEGLError(); + return false; + } + + EGLint numOfConfig = 0; + // Query all framebuffer configurations + if (!eglGetConfigs(egl_display_, NULL, 0, &numOfConfig)) { + FT_LOGE("eglGetConfigs is Failed!!"); + PrintEGLError(); + return false; + } + EGLConfig *configs = (EGLConfig *)calloc(numOfConfig, sizeof(EGLConfig)); + EGLint n; + // Get the List of EGL framebuffer configuration matches with configAttribs in + // list "configs" + if (!eglChooseConfig(egl_display_, configAttribs, configs, numOfConfig, &n)) { + free(configs); + configs = NULL; + PrintEGLError(); + return false; + } + + EGLint size; + for (int i = 0; i < n; i++) { + eglGetConfigAttrib(egl_display_, configs[i], EGL_BUFFER_SIZE, &size); + if (bufferSize == size) { + egl_config_ = configs[i]; + break; + } + } + free(configs); + configs = NULL; + return true; +} + +void TizenRendererEcoreWl2::PrintEGLError() { + EGLint error = eglGetError(); + switch (error) { + case EGL_BAD_DISPLAY: { + FT_LOGE("EGL_BAD_DISPLAY : Display is not an EGL display connection"); + break; + } + case EGL_NOT_INITIALIZED: { + FT_LOGE("EGL_NOT_INITIALIZED : Display has not been initialized"); + break; + } + case EGL_BAD_SURFACE: { + FT_LOGE("EGL_BAD_SURFACE : Draw or read is not an EGL surface"); + break; + } + case EGL_BAD_CONTEXT: { + FT_LOGE("EGL_BAD_CONTEXT : Context is not an EGL rendering context"); + break; + } + case EGL_BAD_CONFIG: { + FT_LOGE( + "EGL_BAD_CONFIG : Config is not an EGL frame buffer configuration"); + break; + } + case EGL_BAD_MATCH: { + FT_LOGE( + "EGL_BAD_MATCH : Draw or read are not compatible with context, or if " + "context is set to EGL_NO_CONTEXT and draw or read are not set to " + "EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and " + "context is not set to EGL_NO_CONTEXT\n"); + break; + } + case EGL_BAD_ACCESS: { + FT_LOGE("EGL_BAD_ACCESS : Context is current to some other thread"); + break; + } + case EGL_BAD_NATIVE_PIXMAP: { + FT_LOGE( + "EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or " + "read is no longer valid"); + break; + } + case EGL_BAD_NATIVE_WINDOW: { + FT_LOGE( + "EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or " + "read is no longer valid"); + break; + } + case EGL_BAD_CURRENT_SURFACE: { + FT_LOGE( + "EGL_BAD_CURRENT_SURFACE : The previous context has unflushed " + "commands and the previous surface is no longer valid"); + break; + } + case EGL_BAD_ALLOC: { + FT_LOGE( + "EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read " + "were delayed until eglMakeCurrent is called, and there are not " + "enough resources to allocate them"); + break; + } + case EGL_CONTEXT_LOST: { + FT_LOGE( + "EGL_CONTEXT_LOST : A power management event has occurred. The " + "application must destroy all contexts and reinitialise OpenGL ES " + "state and objects to continue rendering"); + break; + } + case EGL_BAD_PARAMETER: { + FT_LOGE("Invalid parameter is passed"); + break; + } + case EGL_BAD_ATTRIBUTE: { + FT_LOGE( + "The parameter configAttribs contains an invalid frame buffer " + "configuration attribute or an attribute value that is unrecognized " + "or out of range"); + break; + } + default: { + FT_LOGE("Unknown error with code: %d", error); + break; + } + } +} + +void TizenRendererEcoreWl2::DestroyEglSurface() { + if (EGL_NO_DISPLAY != egl_display_) { + eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT); + + if (EGL_NO_SURFACE != egl_surface_) { + eglDestroySurface(egl_display_, egl_surface_); + egl_surface_ = EGL_NO_SURFACE; + } + + if (EGL_NO_CONTEXT != egl_context_) { + eglDestroyContext(egl_display_, egl_context_); + egl_context_ = EGL_NO_CONTEXT; + } + + if (EGL_NO_SURFACE != egl_resource_surface_) { + eglDestroySurface(egl_display_, egl_resource_surface_); + egl_resource_surface_ = EGL_NO_SURFACE; + } + + if (EGL_NO_CONTEXT != egl_resource_context_) { + eglDestroyContext(egl_display_, egl_resource_context_); + egl_resource_context_ = EGL_NO_CONTEXT; + } + + eglTerminate(egl_display_); + egl_display_ = EGL_NO_DISPLAY; + } +} + +Eina_Bool TizenRendererEcoreWl2::RotationEventCb(void *data, int type, + void *event) { + auto *self = reinterpret_cast(data); + Ecore_Wl2_Event_Window_Rotation *ev = + reinterpret_cast(event); + self->delegate_.OnRotationChange(ev->angle); + return ECORE_CALLBACK_PASS_ON; +} + +void TizenRendererEcoreWl2::SetRotate(int angle) { + ecore_wl2_window_rotation_set(ecore_wl2_window_, angle); + received_rotation = true; +} + +void TizenRendererEcoreWl2::ResizeWithRotation(int32_t x, int32_t y, + int32_t width, int32_t height, + int32_t angle) { + ecore_wl2_egl_window_resize_with_rotation(ecore_wl2_egl_window_, x, y, width, + height, angle); +} + +void TizenRendererEcoreWl2::SendRotationChangeDone() { + int x, y, w, h; + ecore_wl2_window_geometry_get(ecore_wl2_window_, &x, &y, &w, &h); + ecore_wl2_window_rotation_change_done_send( + ecore_wl2_window_, ecore_wl2_window_rotation_get(ecore_wl2_window_), w, + h); } diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index 42803086ea184..b6faad584f849 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -6,38 +6,65 @@ #define EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H #define EFL_BETA_API_SUPPORT +#include #include #include "flutter/shell/platform/tizen/tizen_renderer.h" class TizenRendererEcoreWl2 : public TizenRenderer { public: - TizenRendererEcoreWl2(TizenRenderer::Delegate &delegate, int32_t x, int32_t y, - int32_t w, int32_t h); - ~TizenRendererEcoreWl2(); + explicit TizenRendererEcoreWl2(TizenRenderer::Delegate &delegate, int32_t x, + int32_t y, int32_t w, int32_t h); + virtual ~TizenRendererEcoreWl2(); + + bool OnMakeCurrent() override; + bool OnClearCurrent() override; + bool OnMakeResourceCurrent() override; + bool OnPresent() override; + uint32_t OnGetFBO() override; + void *OnProcResolver(const char *name) override; + TizenWindowGeometry GetGeometry() override; int GetEcoreWindowId() override; + void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) override; - void Show() override; void SetRotate(int angle) override; protected: - void DestoryEglWindow() override; - void DestoryEcoreWlWindow() override; - EGLDisplay GetEGLDisplay() override; - EGLNativeWindowType GetEGLNativeWindowType() override; - bool SetupDisplay() override; - bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, int32_t h) override; - bool SetupEglWindow(int32_t w, int32_t h) override; - void ShutdownDisplay() override; + bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override; + void Show() override; + void DestroyRenderer() override; + void SendRotationChangeDone() override; private: + bool SetupDisplay(); + bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, int32_t h); + bool SetupEglWindow(int32_t w, int32_t h); + EGLDisplay GetEGLDisplay(); + EGLNativeWindowType GetEGLNativeWindowType(); + void DestroyEglWindow(); + void DestroyEcoreWlWindow(); + void ShutdownDisplay(); + + bool SetupEglSurface(); + bool ChooseEGLConfiguration(); + void PrintEGLError(); + void DestroyEglSurface(); + + static Eina_Bool RotationEventCb(void *data, int type, void *event); + Ecore_Wl2_Display *ecore_wl2_display_ = nullptr; Ecore_Wl2_Window *ecore_wl2_window_ = nullptr; Ecore_Wl2_Egl_Window *ecore_wl2_egl_window_ = nullptr; - static Eina_Bool RotationEventCb(void *data, int type, void *event); + + EGLConfig egl_config_; + EGLDisplay egl_display_ = EGL_NO_DISPLAY; + EGLContext egl_context_ = EGL_NO_CONTEXT; + EGLSurface egl_surface_ = EGL_NO_SURFACE; + EGLContext egl_resource_context_ = EGL_NO_CONTEXT; + EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; }; #endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index afa0cf475b492..89ec9c0f1824f 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -4,6 +4,10 @@ #include "tizen_renderer_evas_gl.h" +#include +Evas_GL* g_evas_gl = nullptr; +EVAS_GL_GLOBAL_GLES3_DEFINE(); + #include "flutter/shell/platform/tizen/tizen_log.h" TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate, @@ -13,7 +17,607 @@ TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate, InitializeRenderer(x, y, w, h); } -TizenRendererEvasGL::~TizenRendererEvasGL() { DestoryRenderer(); } +TizenRendererEvasGL::~TizenRendererEvasGL() { DestroyRenderer(); } + +bool TizenRendererEvasGL::OnMakeCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, gl_surface_, gl_context_) != EINA_TRUE) { + return false; + } + + return true; +} + +bool TizenRendererEvasGL::OnClearCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, NULL, NULL) != EINA_TRUE) { + return false; + } + return true; +} + +bool TizenRendererEvasGL::OnMakeResourceCurrent() { + if (!IsValid()) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (evas_gl_make_current(evas_gl_, gl_resource_surface_, + gl_resource_context_) != EINA_TRUE) { + return false; + } + return true; +} + +bool TizenRendererEvasGL::OnPresent() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return false; + } + if (received_rotation) { + SendRotationChangeDone(); + received_rotation = false; + } + + return true; +} + +uint32_t TizenRendererEvasGL::OnGetFBO() { + if (!is_valid_) { + FT_LOGE("Invalid TizenRenderer"); + return 999; + } + FT_LOGD("OnGetFBO"); + return 0; +} + +void* TizenRendererEvasGL::OnProcResolver(const char* name) { + auto address = evas_gl_proc_address_get(evas_gl_, name); + if (address != nullptr) { + return reinterpret_cast(address); + } +#define GL_FUNC(FunctionName) \ + else if (strcmp(name, #FunctionName) == 0) { \ + return reinterpret_cast(FunctionName); \ + } + GL_FUNC(glActiveTexture) + GL_FUNC(glAttachShader) + GL_FUNC(glBindAttribLocation) + GL_FUNC(glBindBuffer) + GL_FUNC(glBindFramebuffer) + GL_FUNC(glBindRenderbuffer) + GL_FUNC(glBindTexture) + GL_FUNC(glBlendColor) + GL_FUNC(glBlendEquation) + GL_FUNC(glBlendEquationSeparate) + GL_FUNC(glBlendFunc) + GL_FUNC(glBlendFuncSeparate) + GL_FUNC(glBufferData) + GL_FUNC(glBufferSubData) + GL_FUNC(glCheckFramebufferStatus) + GL_FUNC(glClear) + GL_FUNC(glClearColor) + GL_FUNC(glClearDepthf) + GL_FUNC(glClearStencil) + GL_FUNC(glColorMask) + GL_FUNC(glCompileShader) + GL_FUNC(glCompressedTexImage2D) + GL_FUNC(glCompressedTexSubImage2D) + GL_FUNC(glCopyTexImage2D) + GL_FUNC(glCopyTexSubImage2D) + GL_FUNC(glCreateProgram) + GL_FUNC(glCreateShader) + GL_FUNC(glCullFace) + GL_FUNC(glDeleteBuffers) + GL_FUNC(glDeleteFramebuffers) + GL_FUNC(glDeleteProgram) + GL_FUNC(glDeleteRenderbuffers) + GL_FUNC(glDeleteShader) + GL_FUNC(glDeleteTextures) + GL_FUNC(glDepthFunc) + GL_FUNC(glDepthMask) + GL_FUNC(glDepthRangef) + GL_FUNC(glDetachShader) + GL_FUNC(glDisable) + GL_FUNC(glDisableVertexAttribArray) + GL_FUNC(glDrawArrays) + GL_FUNC(glDrawElements) + GL_FUNC(glEnable) + GL_FUNC(glEnableVertexAttribArray) + GL_FUNC(glFinish) + GL_FUNC(glFlush) + GL_FUNC(glFramebufferRenderbuffer) + GL_FUNC(glFramebufferTexture2D) + GL_FUNC(glFrontFace) + GL_FUNC(glGenBuffers) + GL_FUNC(glGenerateMipmap) + GL_FUNC(glGenFramebuffers) + GL_FUNC(glGenRenderbuffers) + GL_FUNC(glGenTextures) + GL_FUNC(glGetActiveAttrib) + GL_FUNC(glGetActiveUniform) + GL_FUNC(glGetAttachedShaders) + GL_FUNC(glGetAttribLocation) + GL_FUNC(glGetBooleanv) + GL_FUNC(glGetBufferParameteriv) + GL_FUNC(glGetError) + GL_FUNC(glGetFloatv) + GL_FUNC(glGetFramebufferAttachmentParameteriv) + GL_FUNC(glGetIntegerv) + GL_FUNC(glGetProgramiv) + GL_FUNC(glGetProgramInfoLog) + GL_FUNC(glGetRenderbufferParameteriv) + GL_FUNC(glGetShaderiv) + GL_FUNC(glGetShaderInfoLog) + GL_FUNC(glGetShaderPrecisionFormat) + GL_FUNC(glGetShaderSource) + GL_FUNC(glGetString) + GL_FUNC(glGetTexParameterfv) + GL_FUNC(glGetTexParameteriv) + GL_FUNC(glGetUniformfv) + GL_FUNC(glGetUniformiv) + GL_FUNC(glGetUniformLocation) + GL_FUNC(glGetVertexAttribfv) + GL_FUNC(glGetVertexAttribiv) + GL_FUNC(glGetVertexAttribPointerv) + GL_FUNC(glHint) + GL_FUNC(glIsBuffer) + GL_FUNC(glIsEnabled) + GL_FUNC(glIsFramebuffer) + GL_FUNC(glIsProgram) + GL_FUNC(glIsRenderbuffer) + GL_FUNC(glIsShader) + GL_FUNC(glIsTexture) + GL_FUNC(glLineWidth) + GL_FUNC(glLinkProgram) + GL_FUNC(glPixelStorei) + GL_FUNC(glPolygonOffset) + GL_FUNC(glReadPixels) + GL_FUNC(glReleaseShaderCompiler) + GL_FUNC(glRenderbufferStorage) + GL_FUNC(glSampleCoverage) + GL_FUNC(glScissor) + GL_FUNC(glShaderBinary) + GL_FUNC(glShaderSource) + GL_FUNC(glStencilFunc) + GL_FUNC(glStencilFuncSeparate) + GL_FUNC(glStencilMask) + GL_FUNC(glStencilMaskSeparate) + GL_FUNC(glStencilOp) + GL_FUNC(glStencilOpSeparate) + GL_FUNC(glTexImage2D) + GL_FUNC(glTexParameterf) + GL_FUNC(glTexParameterfv) + GL_FUNC(glTexParameteri) + GL_FUNC(glTexParameteriv) + GL_FUNC(glTexSubImage2D) + GL_FUNC(glUniform1f) + GL_FUNC(glUniform1fv) + GL_FUNC(glUniform1i) + GL_FUNC(glUniform1iv) + GL_FUNC(glUniform2f) + GL_FUNC(glUniform2fv) + GL_FUNC(glUniform2i) + GL_FUNC(glUniform2iv) + GL_FUNC(glUniform3f) + GL_FUNC(glUniform3fv) + GL_FUNC(glUniform3i) + GL_FUNC(glUniform3iv) + GL_FUNC(glUniform4f) + GL_FUNC(glUniform4fv) + GL_FUNC(glUniform4i) + GL_FUNC(glUniform4iv) + GL_FUNC(glUniformMatrix2fv) + GL_FUNC(glUniformMatrix3fv) + GL_FUNC(glUniformMatrix4fv) + GL_FUNC(glUseProgram) + GL_FUNC(glValidateProgram) + GL_FUNC(glVertexAttrib1f) + GL_FUNC(glVertexAttrib1fv) + GL_FUNC(glVertexAttrib2f) + GL_FUNC(glVertexAttrib2fv) + GL_FUNC(glVertexAttrib3f) + GL_FUNC(glVertexAttrib3fv) + GL_FUNC(glVertexAttrib4f) + GL_FUNC(glVertexAttrib4fv) + GL_FUNC(glVertexAttribPointer) + GL_FUNC(glViewport) + GL_FUNC(glGetProgramBinaryOES) + GL_FUNC(glProgramBinaryOES) + GL_FUNC(glMapBufferOES) + GL_FUNC(glUnmapBufferOES) + GL_FUNC(glGetBufferPointervOES) + GL_FUNC(glTexImage3DOES) + GL_FUNC(glTexSubImage3DOES) + GL_FUNC(glCopyTexSubImage3DOES) + GL_FUNC(glCompressedTexImage3DOES) + GL_FUNC(glCompressedTexSubImage3DOES) + GL_FUNC(glFramebufferTexture3DOES) + GL_FUNC(glBindVertexArrayOES) + GL_FUNC(glDeleteVertexArraysOES) + GL_FUNC(glGenVertexArraysOES) + GL_FUNC(glIsVertexArrayOES) + GL_FUNC(glGetPerfMonitorGroupsAMD) + GL_FUNC(glGetPerfMonitorCountersAMD) + GL_FUNC(glGetPerfMonitorGroupStringAMD) + GL_FUNC(glGetPerfMonitorCounterStringAMD) + GL_FUNC(glGetPerfMonitorCounterInfoAMD) + GL_FUNC(glGenPerfMonitorsAMD) + GL_FUNC(glDeletePerfMonitorsAMD) + GL_FUNC(glSelectPerfMonitorCountersAMD) + GL_FUNC(glBeginPerfMonitorAMD) + GL_FUNC(glEndPerfMonitorAMD) + GL_FUNC(glGetPerfMonitorCounterDataAMD) + GL_FUNC(glCopyTextureLevelsAPPLE) + GL_FUNC(glRenderbufferStorageMultisampleAPPLE) + GL_FUNC(glResolveMultisampleFramebufferAPPLE) + GL_FUNC(glFenceSyncAPPLE) + GL_FUNC(glIsSyncAPPLE) + GL_FUNC(glDeleteSyncAPPLE) + GL_FUNC(glClientWaitSyncAPPLE) + GL_FUNC(glWaitSyncAPPLE) + GL_FUNC(glGetInteger64vAPPLE) + GL_FUNC(glGetSyncivAPPLE) + GL_FUNC(glDiscardFramebufferEXT) + GL_FUNC(glMapBufferRangeEXT) + GL_FUNC(glFlushMappedBufferRangeEXT) + GL_FUNC(glMultiDrawArraysEXT) + GL_FUNC(glMultiDrawElementsEXT) + GL_FUNC(glRenderbufferStorageMultisampleEXT) + GL_FUNC(glFramebufferTexture2DMultisampleEXT) + GL_FUNC(glGetGraphicsResetStatusEXT) + GL_FUNC(glReadnPixelsEXT) + GL_FUNC(glGetnUniformfvEXT) + GL_FUNC(glGetnUniformivEXT) + GL_FUNC(glTexStorage1DEXT) + GL_FUNC(glTexStorage2DEXT) + GL_FUNC(glTexStorage3DEXT) + GL_FUNC(glTextureStorage1DEXT) + GL_FUNC(glTextureStorage2DEXT) + GL_FUNC(glTextureStorage3DEXT) + GL_FUNC(glRenderbufferStorageMultisampleIMG) + GL_FUNC(glFramebufferTexture2DMultisampleIMG) + GL_FUNC(glDeleteFencesNV) + GL_FUNC(glGenFencesNV) + GL_FUNC(glIsFenceNV) + GL_FUNC(glTestFenceNV) + GL_FUNC(glGetFenceivNV) + GL_FUNC(glFinishFenceNV) + GL_FUNC(glSetFenceNV) + GL_FUNC(glGetDriverControlsQCOM) + GL_FUNC(glGetDriverControlStringQCOM) + GL_FUNC(glEnableDriverControlQCOM) + GL_FUNC(glDisableDriverControlQCOM) + GL_FUNC(glExtGetTexturesQCOM) + GL_FUNC(glExtGetBuffersQCOM) + GL_FUNC(glExtGetRenderbuffersQCOM) + GL_FUNC(glExtGetFramebuffersQCOM) + GL_FUNC(glExtGetTexLevelParameterivQCOM) + GL_FUNC(glExtTexObjectStateOverrideiQCOM) + GL_FUNC(glExtGetTexSubImageQCOM) + GL_FUNC(glExtGetBufferPointervQCOM) + GL_FUNC(glExtGetShadersQCOM) + GL_FUNC(glExtGetProgramsQCOM) + GL_FUNC(glExtIsProgramBinaryQCOM) + GL_FUNC(glExtGetProgramBinarySourceQCOM) + GL_FUNC(glStartTilingQCOM) + GL_FUNC(glEndTilingQCOM) + GL_FUNC(glEvasGLImageTargetTexture2DOES) + GL_FUNC(glEvasGLImageTargetRenderbufferStorageOES) + GL_FUNC(glBeginQuery) + GL_FUNC(glBeginTransformFeedback) + GL_FUNC(glBindBufferBase) + GL_FUNC(glBindBufferRange) + GL_FUNC(glBindSampler) + GL_FUNC(glBindTransformFeedback) + GL_FUNC(glBindVertexArray) + GL_FUNC(glBlitFramebuffer) + GL_FUNC(glClearBufferfi) + GL_FUNC(glClearBufferfv) + GL_FUNC(glClearBufferiv) + GL_FUNC(glClearBufferuiv) + GL_FUNC(glClientWaitSync) + GL_FUNC(glCompressedTexImage3D) + GL_FUNC(glCompressedTexSubImage3D) + GL_FUNC(glCopyBufferSubData) + GL_FUNC(glCopyTexSubImage3D) + GL_FUNC(glDeleteQueries) + GL_FUNC(glDeleteSamplers) + GL_FUNC(glDeleteSync) + GL_FUNC(glDeleteTransformFeedbacks) + GL_FUNC(glDeleteVertexArrays) + GL_FUNC(glDrawArraysInstanced) + GL_FUNC(glDrawBuffers) + GL_FUNC(glDrawElementsInstanced) + GL_FUNC(glDrawRangeElements) + GL_FUNC(glEndQuery) + GL_FUNC(glEndTransformFeedback) + GL_FUNC(glFenceSync) + GL_FUNC(glFlushMappedBufferRange) + GL_FUNC(glFramebufferTextureLayer) + GL_FUNC(glGenQueries) + GL_FUNC(glGenSamplers) + GL_FUNC(glGenTransformFeedbacks) + GL_FUNC(glGenVertexArrays) + GL_FUNC(glGetActiveUniformBlockiv) + GL_FUNC(glGetActiveUniformBlockName) + GL_FUNC(glGetActiveUniformsiv) + GL_FUNC(glGetBufferParameteri64v) + GL_FUNC(glGetBufferPointerv) + GL_FUNC(glGetFragDataLocation) + GL_FUNC(glGetInteger64i_v) + GL_FUNC(glGetInteger64v) + GL_FUNC(glGetIntegeri_v) + GL_FUNC(glGetInternalformativ) + GL_FUNC(glGetProgramBinary) + GL_FUNC(glGetQueryiv) + GL_FUNC(glGetQueryObjectuiv) + GL_FUNC(glGetSamplerParameterfv) + GL_FUNC(glGetSamplerParameteriv) + GL_FUNC(glGetStringi) + GL_FUNC(glGetSynciv) + GL_FUNC(glGetTransformFeedbackVarying) + GL_FUNC(glGetUniformBlockIndex) + GL_FUNC(glGetUniformIndices) + GL_FUNC(glGetUniformuiv) + GL_FUNC(glGetVertexAttribIiv) + GL_FUNC(glGetVertexAttribIuiv) + GL_FUNC(glInvalidateFramebuffer) + GL_FUNC(glInvalidateSubFramebuffer) + GL_FUNC(glIsQuery) + GL_FUNC(glIsSampler) + GL_FUNC(glIsSync) + GL_FUNC(glIsTransformFeedback) + GL_FUNC(glIsVertexArray) + GL_FUNC(glMapBufferRange) + GL_FUNC(glPauseTransformFeedback) + GL_FUNC(glProgramBinary) + GL_FUNC(glProgramParameteri) + GL_FUNC(glReadBuffer) + GL_FUNC(glRenderbufferStorageMultisample) + GL_FUNC(glResumeTransformFeedback) + GL_FUNC(glSamplerParameterf) + GL_FUNC(glSamplerParameterfv) + GL_FUNC(glSamplerParameteri) + GL_FUNC(glSamplerParameteriv) + GL_FUNC(glTexImage3D) + GL_FUNC(glTexStorage2D) + GL_FUNC(glTexStorage3D) + GL_FUNC(glTexSubImage3D) + GL_FUNC(glTransformFeedbackVaryings) + GL_FUNC(glUniform1ui) + GL_FUNC(glUniform1uiv) + GL_FUNC(glUniform2ui) + GL_FUNC(glUniform2uiv) + GL_FUNC(glUniform3ui) + GL_FUNC(glUniform3uiv) + GL_FUNC(glUniform4ui) + GL_FUNC(glUniform4uiv) + GL_FUNC(glUniformBlockBinding) + GL_FUNC(glUniformMatrix2x3fv) + GL_FUNC(glUniformMatrix3x2fv) + GL_FUNC(glUniformMatrix2x4fv) + GL_FUNC(glUniformMatrix4x2fv) + GL_FUNC(glUniformMatrix3x4fv) + GL_FUNC(glUniformMatrix4x3fv) + GL_FUNC(glUnmapBuffer) + GL_FUNC(glVertexAttribDivisor) + GL_FUNC(glVertexAttribI4i) + GL_FUNC(glVertexAttribI4iv) + GL_FUNC(glVertexAttribI4ui) + GL_FUNC(glVertexAttribI4uiv) + GL_FUNC(glVertexAttribIPointer) + GL_FUNC(glWaitSync) + GL_FUNC(glDispatchCompute) + GL_FUNC(glDispatchComputeIndirect) + GL_FUNC(glDrawArraysIndirect) + GL_FUNC(glDrawElementsIndirect) + GL_FUNC(glFramebufferParameteri) + GL_FUNC(glGetFramebufferParameteriv) + GL_FUNC(glGetProgramInterfaceiv) + GL_FUNC(glGetProgramResourceIndex) + GL_FUNC(glGetProgramResourceName) + GL_FUNC(glGetProgramResourceiv) + GL_FUNC(glGetProgramResourceLocation) + GL_FUNC(glUseProgramStages) + GL_FUNC(glActiveShaderProgram) + GL_FUNC(glCreateShaderProgramv) + GL_FUNC(glBindProgramPipeline) + GL_FUNC(glDeleteProgramPipelines) + GL_FUNC(glGenProgramPipelines) + GL_FUNC(glIsProgramPipeline) + GL_FUNC(glGetProgramPipelineiv) + GL_FUNC(glProgramUniform1i) + GL_FUNC(glProgramUniform2i) + GL_FUNC(glProgramUniform3i) + GL_FUNC(glProgramUniform4i) + GL_FUNC(glProgramUniform1ui) + GL_FUNC(glProgramUniform2ui) + GL_FUNC(glProgramUniform3ui) + GL_FUNC(glProgramUniform4ui) + GL_FUNC(glProgramUniform1f) + GL_FUNC(glProgramUniform2f) + GL_FUNC(glProgramUniform3f) + GL_FUNC(glProgramUniform4f) + GL_FUNC(glProgramUniform1iv) + GL_FUNC(glProgramUniform2iv) + GL_FUNC(glProgramUniform3iv) + GL_FUNC(glProgramUniform4iv) + GL_FUNC(glProgramUniform1uiv) + GL_FUNC(glProgramUniform2uiv) + GL_FUNC(glProgramUniform3uiv) + GL_FUNC(glProgramUniform4uiv) + GL_FUNC(glProgramUniform1fv) + GL_FUNC(glProgramUniform2fv) + GL_FUNC(glProgramUniform3fv) + GL_FUNC(glProgramUniform4fv) + GL_FUNC(glProgramUniformMatrix2fv) + GL_FUNC(glProgramUniformMatrix3fv) + GL_FUNC(glProgramUniformMatrix4fv) + GL_FUNC(glProgramUniformMatrix2x3fv) + GL_FUNC(glProgramUniformMatrix3x2fv) + GL_FUNC(glProgramUniformMatrix2x4fv) + GL_FUNC(glProgramUniformMatrix4x2fv) + GL_FUNC(glProgramUniformMatrix3x4fv) + GL_FUNC(glProgramUniformMatrix4x3fv) + GL_FUNC(glValidateProgramPipeline) + GL_FUNC(glGetProgramPipelineInfoLog) + GL_FUNC(glBindImageTexture) + GL_FUNC(glGetBooleani_v) + GL_FUNC(glMemoryBarrier) + GL_FUNC(glMemoryBarrierByRegion) + GL_FUNC(glTexStorage2DMultisample) + GL_FUNC(glGetMultisamplefv) + GL_FUNC(glSampleMaski) + GL_FUNC(glGetTexLevelParameteriv) + GL_FUNC(glGetTexLevelParameterfv) + GL_FUNC(glBindVertexBuffer) + GL_FUNC(glVertexAttribFormat) + GL_FUNC(glVertexAttribIFormat) + GL_FUNC(glVertexAttribBinding) + GL_FUNC(glVertexBindingDivisor) + GL_FUNC(glBlendBarrier) + GL_FUNC(glCopyImageSubData) + GL_FUNC(glDebugMessageControl) + GL_FUNC(glDebugMessageInsert) + GL_FUNC(glDebugMessageCallback) + GL_FUNC(glGetDebugMessageLog) + GL_FUNC(glPushDebugGroup) + GL_FUNC(glPopDebugGroup) + GL_FUNC(glObjectLabel) + GL_FUNC(glGetObjectLabel) + GL_FUNC(glObjectPtrLabel) + GL_FUNC(glGetObjectPtrLabel) + GL_FUNC(glGetPointerv) + GL_FUNC(glEnablei) + GL_FUNC(glDisablei) + GL_FUNC(glBlendEquationi) + GL_FUNC(glBlendEquationSeparatei) + GL_FUNC(glBlendFunci) + GL_FUNC(glBlendFuncSeparatei) + GL_FUNC(glColorMaski) + GL_FUNC(glIsEnabledi) + GL_FUNC(glDrawElementsBaseVertex) + GL_FUNC(glDrawRangeElementsBaseVertex) + GL_FUNC(glDrawElementsInstancedBaseVertex) + GL_FUNC(glFramebufferTexture) + GL_FUNC(glPrimitiveBoundingBox) + GL_FUNC(glGetGraphicsResetStatus) + GL_FUNC(glReadnPixels) + GL_FUNC(glGetnUniformfv) + GL_FUNC(glGetnUniformiv) + GL_FUNC(glGetnUniformuiv) + GL_FUNC(glMinSampleShading) + GL_FUNC(glPatchParameteri) + GL_FUNC(glTexParameterIiv) + GL_FUNC(glTexParameterIuiv) + GL_FUNC(glGetTexParameterIiv) + GL_FUNC(glGetTexParameterIuiv) + GL_FUNC(glSamplerParameterIiv) + GL_FUNC(glSamplerParameterIuiv) + GL_FUNC(glGetSamplerParameterIiv) + GL_FUNC(glGetSamplerParameterIuiv) + GL_FUNC(glTexBuffer) + GL_FUNC(glTexBufferRange) + GL_FUNC(glTexStorage3DMultisample) +#undef GL_FUNC + + FT_LOGD("Could not resolve: %s", name); + return nullptr; +} + +TizenRenderer::TizenWindowGeometry TizenRendererEvasGL::GetGeometry() { + TizenWindowGeometry result; + evas_object_geometry_get(evas_window_, &result.x, &result.y, &result.w, + &result.h); + return result; +} + +int TizenRendererEvasGL::GetEcoreWindowId() { + return (int)ecore_evas_window_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(graphics_adapter_))); +} + +void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; } + +void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) { + glClearColor(r, g, b, a); + glClear(GL_COLOR_BUFFER_BIT); +} + +bool TizenRendererEvasGL::InitializeRenderer(int32_t x, int32_t y, int32_t w, + int32_t h) { + if (!SetupEvasGL(x, y, w, h)) { + FT_LOGE("SetupEvasGL fail"); + return false; + } + Show(); + is_valid_ = true; + return true; +} + +void TizenRendererEvasGL::Show() { + evas_object_show((Evas_Object*)GetImageHandle()); + evas_object_show(evas_window_); +} + +void TizenRendererEvasGL::DestroyRenderer() { + DestroyEvasGL(); + DestroyEvasWindow(); +} + +bool TizenRendererEvasGL::SetupEvasGL(int32_t x, int32_t y, int32_t w, + int32_t h) { + evas_gl_ = evas_gl_new( + evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); + + if (!evas_gl_) { + FT_LOGE("SetupEvasWindow fail"); + return false; + } + + g_evas_gl = evas_gl_; + gl_config_ = evas_gl_config_new(); + gl_config_->color_format = EVAS_GL_RGBA_8888; + gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; + gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; + + gl_context_ = + evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_3_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); + + if (gl_context_ == nullptr) { + FT_LOGW( + "Failed to create evas gl context with EVAS_GL_GLES_3_X, try to use " + "EVAS_GL_GLES_2_X,"); + gl_context_ = + evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); + gl_resource_context_ = + evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); + } + if (gl_context_ == nullptr) { + FT_LOGE("Failed to create evas gl context!"); + FT_RELEASE_ASSERT_NOT_REACHED(); + } + + EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); + gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, w, h); + + gl_resource_surface_ = + evas_gl_pbuffer_surface_create(evas_gl_, gl_config_, w, h, NULL); + + Evas_Native_Surface ns; + evas_gl_native_surface_get(evas_gl_, gl_surface_, &ns); + evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), &ns); + + return true; +} void* TizenRendererEvasGL::SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h) { @@ -51,6 +655,22 @@ void* TizenRendererEvasGL::SetupEvasWindow(int32_t x, int32_t y, int32_t w, return (void*)evas_window_; } +void TizenRendererEvasGL::DestroyEvasGL() { + evas_gl_surface_destroy(evas_gl_, gl_surface_); + evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); + + evas_gl_context_destroy(evas_gl_, gl_context_); + evas_gl_context_destroy(evas_gl_, gl_resource_context_); + + evas_gl_config_free(gl_config_); + evas_gl_free(evas_gl_); +} + +void TizenRendererEvasGL::DestroyEvasWindow() { + evas_object_del(evas_window_); + evas_object_del(graphics_adapter_); +} + void TizenRendererEvasGL::RotationEventCb(void* data, Evas_Object* obj, void* event_info) { auto* self = reinterpret_cast(data); @@ -59,18 +679,11 @@ void TizenRendererEvasGL::RotationEventCb(void* data, Evas_Object* obj, self->delegate_.OnRotationChange(0); } -void TizenRendererEvasGL::Show() { - evas_object_show((Evas_Object*)GetImageHandle()); - evas_object_show(evas_window_); -} - void TizenRendererEvasGL::SetRotate(int angle) { elm_win_rotation_set(evas_window_, angle); received_rotation = true; } -void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; } - void TizenRendererEvasGL::ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) { @@ -82,20 +695,3 @@ void TizenRendererEvasGL::ResizeWithRotation(int32_t x, int32_t y, void TizenRendererEvasGL::SendRotationChangeDone() { elm_win_wm_rotation_manual_rotation_done(evas_window_); } - -void TizenRendererEvasGL::DestoryEvasWindow() { - evas_object_del(evas_window_); - evas_object_del(graphics_adapter_); -} - -TizenRenderer::TizenWindowGeometry TizenRendererEvasGL::GetGeometry() { - TizenWindowGeometry result; - evas_object_geometry_get(evas_window_, &result.x, &result.y, &result.w, - &result.h); - return result; -} - -int TizenRendererEvasGL::GetEcoreWindowId() { - return (int)ecore_evas_window_get( - ecore_evas_ecore_evas_get(evas_object_evas_get(graphics_adapter_))); -} diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index a47347375430f..c1cec894eb624 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -5,6 +5,8 @@ #ifndef EMBEDDER_TIZEN_RENDERER_EVAS_GL_H #define EMBEDDER_TIZEN_RENDERER_EVAS_GL_H +#undef EFL_BETA_API_SUPPORT +#include #include #include @@ -12,27 +14,53 @@ class TizenRendererEvasGL : public TizenRenderer { public: - TizenRendererEvasGL(TizenRenderer::Delegate& delegate, int32_t x, int32_t y, - int32_t w, int32_t h); - ~TizenRendererEvasGL(); + explicit TizenRendererEvasGL(TizenRenderer::Delegate& delegate, int32_t x, + int32_t y, int32_t w, int32_t h); + virtual ~TizenRendererEvasGL(); + + bool OnMakeCurrent() override; + bool OnClearCurrent() override; + bool OnMakeResourceCurrent() override; + bool OnPresent() override; + uint32_t OnGetFBO() override; + void* OnProcResolver(const char* name) override; + TizenWindowGeometry GetGeometry() override; int GetEcoreWindowId() override; + void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) override; - void Show() override; void SetRotate(int angle) override; - + void* GetImageHandle() override; + void ClearColor(float r, float g, float b, float a) override; protected: - virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, - int32_t h) override; - virtual void DestoryEvasWindow() override; + bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override; + void Show() override; + void DestroyRenderer() override; + void SendRotationChangeDone() override; private: + bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); + void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h); + void DestroyEvasGL(); + void DestroyEvasWindow(); + + static void RotationEventCb(void* data, Evas_Object* obj, void* event_info); + Evas_Object* evas_window_{nullptr}; Evas_Object* graphics_adapter_{nullptr}; - static void RotationEventCb(void* data, Evas_Object* obj, void* event_info); + + Evas_GL_Config* gl_config_; + Evas_GL* evas_gl_{nullptr}; + + Evas_GL_Context* gl_context_; + Evas_GL_Context* gl_resource_context_; + + Evas_GL_Surface* gl_surface_{nullptr}; + Evas_GL_Surface* gl_resource_surface_{nullptr}; }; + #endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index bb88d0fe09180..5dc73529262c2 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -23,7 +23,7 @@ TizenVsyncWaiter::TizenVsyncWaiter(TizenEmbedderEngine* engine) : engine_(engine) { if (!CreateTDMVblank()) { FT_LOGE("Failed to create TDM vblank"); - DestoryTDMVblank(); + DestroyTDMVblank(); } else { vblank_thread_queue = eina_thread_queue_new(); vblank_thread_ = @@ -38,7 +38,7 @@ TizenVsyncWaiter::~TizenVsyncWaiter() { ecore_thread_cancel(vblank_thread_); vblank_thread_ = nullptr; } - DestoryTDMVblank(); + DestroyTDMVblank(); } void TizenVsyncWaiter::AsyncWaitForVsync(intptr_t baton) { @@ -127,7 +127,7 @@ bool TizenVsyncWaiter::CreateTDMVblank() { return true; } -void TizenVsyncWaiter::DestoryTDMVblank() { +void TizenVsyncWaiter::DestroyTDMVblank() { if (vblank_) { tdm_client_vblank_destroy(vblank_); vblank_ = nullptr; diff --git a/shell/platform/tizen/tizen_vsync_waiter.h b/shell/platform/tizen/tizen_vsync_waiter.h index eb4826d4e7feb..ae1a8e6b94f65 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.h +++ b/shell/platform/tizen/tizen_vsync_waiter.h @@ -20,7 +20,7 @@ class TizenVsyncWaiter { private: bool CreateTDMVblank(); - void DestoryTDMVblank(); + void DestroyTDMVblank(); bool TDMValid(); void SendMessage(int val); static void TdmClientVblankCallback(tdm_client_vblank* vblank, From 22101725b5cff0f2904ab7ee8b7969e41615e038 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Wed, 21 Apr 2021 18:27:23 +0900 Subject: [PATCH 14/19] Refactor: Rename GetEcoreWindowId and change its return type to uintptr_t --- shell/platform/tizen/channels/text_input_channel.cc | 4 +--- shell/platform/tizen/tizen_renderer.h | 2 +- shell/platform/tizen/tizen_renderer_ecore_wl2.cc | 4 ++-- shell/platform/tizen/tizen_renderer_ecore_wl2.h | 2 +- shell/platform/tizen/tizen_renderer_evas_gl.cc | 4 ++-- shell/platform/tizen/tizen_renderer_evas_gl.h | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 2f62e8c7cdf85..663d8340fc0d9 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -222,10 +222,8 @@ TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger, imf_context_ = ecore_imf_context_add(GetImfMethod()); } if (imf_context_) { - // Caution: Conversion between incompatible types (int to void*). ecore_imf_context_client_window_set( - imf_context_, - (void*)(intptr_t)(engine_->tizen_renderer->GetEcoreWindowId())); + imf_context_, (void*)engine_->tizen_renderer->GetWindowId()); RegisterIMFCallback(); } else { FT_LOGE("Failed to create imfContext"); diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index b0b08f422e574..8b29f20246b08 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -30,7 +30,7 @@ class TizenRenderer { virtual void* OnProcResolver(const char* name) = 0; virtual TizenWindowGeometry GetGeometry() = 0; - virtual int GetEcoreWindowId() = 0; + virtual uintptr_t GetWindowId() = 0; // TODO: For Evas GL only. virtual void* GetImageHandle() { return nullptr; }; diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 09f959b1a789c..614b80e8ceb87 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -217,8 +217,8 @@ TizenRenderer::TizenWindowGeometry TizenRendererEcoreWl2::GetGeometry() { return result; } -int TizenRendererEcoreWl2::GetEcoreWindowId() { - return ecore_wl2_window_id_get(ecore_wl2_window_); +uintptr_t TizenRendererEcoreWl2::GetWindowId() { + return (uintptr_t)ecore_wl2_window_id_get(ecore_wl2_window_); } bool TizenRendererEcoreWl2::InitializeRenderer(int32_t x, int32_t y, int32_t w, diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index b6faad584f849..d4a133ade139b 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -25,7 +25,7 @@ class TizenRendererEcoreWl2 : public TizenRenderer { void *OnProcResolver(const char *name) override; TizenWindowGeometry GetGeometry() override; - int GetEcoreWindowId() override; + uintptr_t GetWindowId() override; void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) override; diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 89ec9c0f1824f..96fcd1a81191c 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -538,8 +538,8 @@ TizenRenderer::TizenWindowGeometry TizenRendererEvasGL::GetGeometry() { return result; } -int TizenRendererEvasGL::GetEcoreWindowId() { - return (int)ecore_evas_window_get( +uintptr_t TizenRendererEvasGL::GetWindowId() { + return ecore_evas_window_get( ecore_evas_ecore_evas_get(evas_object_evas_get(graphics_adapter_))); } diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index c1cec894eb624..92af716dc6701 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -26,7 +26,7 @@ class TizenRendererEvasGL : public TizenRenderer { void* OnProcResolver(const char* name) override; TizenWindowGeometry GetGeometry() override; - int GetEcoreWindowId() override; + uintptr_t GetWindowId() override; void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) override; From 66fcc5fec5a7b44ea87d496c469c3fa3b642803d Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Thu, 22 Apr 2021 10:34:04 +0900 Subject: [PATCH 15/19] Refactor: Make GetImageHandle() Evas GL-only --- shell/platform/tizen/tizen_embedder_engine.cc | 4 ---- shell/platform/tizen/tizen_event_loop.cc | 18 ++++++++++-------- shell/platform/tizen/tizen_renderer.h | 4 ---- shell/platform/tizen/tizen_renderer_evas_gl.cc | 15 ++++++++++----- shell/platform/tizen/tizen_renderer_evas_gl.h | 7 ++++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index a4bfccababc15..aaaa4946c7337 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -53,10 +53,6 @@ TizenEmbedderEngine::TizenEmbedderEngine( tizen_renderer = std::make_unique( *this, window_properties.x, window_properties.y, window_properties.width, window_properties.height); - // clear once to remove noise - tizen_renderer->OnMakeCurrent(); - tizen_renderer->ClearColor(0, 0, 0, 0); - tizen_renderer->OnPresent(); #else tizen_renderer = std::make_unique( *this, window_properties.x, window_properties.y, window_properties.width, diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index 605bea99ae958..f9e29b9de1381 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -8,12 +8,11 @@ #include #include -#ifdef TIZEN_RENDERER_EVAS_GL -#include -#endif - #include "flutter/shell/platform/tizen/tizen_log.h" #include "flutter/shell/platform/tizen/tizen_renderer.h" +#ifdef TIZEN_RENDERER_EVAS_GL +#include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h" +#endif TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id, TaskExpiredCallback on_task_expired) @@ -120,8 +119,9 @@ TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id, : TizenEventLoop(main_thread_id, on_task_expired), tizen_renderer_(tizen_renderer) { evas_object_image_pixels_get_callback_set( - (Evas_Object*)tizen_renderer_->GetImageHandle(), - [](void* data, Evas_Object* o) { // Render call back + (Evas_Object*)static_cast(tizen_renderer_) + ->GetImageHandle(), + [](void* data, Evas_Object* o) { // Render callback TizenRenderEventLoop* self = (TizenRenderEventLoop*)data; { std::lock_guard lock(self->expired_tasks_mutex_); @@ -141,9 +141,11 @@ void TizenRenderEventLoop::OnTaskExpired() { size_t expired_tasks_count = 0; std::lock_guard lock(expired_tasks_mutex_); expired_tasks_count = expired_tasks_.size(); - if (has_pending_renderer_callback_ == false && expired_tasks_count) { + if (!has_pending_renderer_callback_ && expired_tasks_count) { evas_object_image_pixels_dirty_set( - (Evas_Object*)tizen_renderer_->GetImageHandle(), EINA_TRUE); + (Evas_Object*)static_cast(tizen_renderer_) + ->GetImageHandle(), + EINA_TRUE); has_pending_renderer_callback_ = true; } else { // Do nothing diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 8b29f20246b08..f5c9de1b217e1 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -32,10 +32,6 @@ class TizenRenderer { virtual TizenWindowGeometry GetGeometry() = 0; virtual uintptr_t GetWindowId() = 0; - // TODO: For Evas GL only. - virtual void* GetImageHandle() { return nullptr; }; - virtual void ClearColor(float r, float g, float b, float a){}; - virtual void SetRotate(int angle) = 0; virtual void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t degree) = 0; diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 96fcd1a81191c..5181384cf6742 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -15,10 +15,20 @@ TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate, int32_t h) : TizenRenderer(delegate) { InitializeRenderer(x, y, w, h); + + // Clear once to remove noise. + OnMakeCurrent(); + ClearColor(0, 0, 0, 0); + OnPresent(); } TizenRendererEvasGL::~TizenRendererEvasGL() { DestroyRenderer(); } +void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) { + glClearColor(r, g, b, a); + glClear(GL_COLOR_BUFFER_BIT); +} + bool TizenRendererEvasGL::OnMakeCurrent() { if (!IsValid()) { FT_LOGE("Invalid TizenRenderer"); @@ -545,11 +555,6 @@ uintptr_t TizenRendererEvasGL::GetWindowId() { void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; } -void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) { - glClearColor(r, g, b, a); - glClear(GL_COLOR_BUFFER_BIT); -} - bool TizenRendererEvasGL::InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) { if (!SetupEvasGL(x, y, w, h)) { diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 92af716dc6701..33a26e1d19a73 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -31,9 +31,8 @@ class TizenRendererEvasGL : public TizenRenderer { void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height, int32_t angle) override; void SetRotate(int angle) override; - - void* GetImageHandle() override; - void ClearColor(float r, float g, float b, float a) override; + + void* GetImageHandle(); protected: bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override; @@ -43,6 +42,8 @@ class TizenRendererEvasGL : public TizenRenderer { void SendRotationChangeDone() override; private: + void ClearColor(float r, float g, float b, float a); + bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h); void DestroyEvasGL(); From ba4c936a9eeae8d823da88f5564443a61172a10e Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Thu, 22 Apr 2021 11:33:57 +0900 Subject: [PATCH 16/19] Refactor: Additional clean ups --- .../tizen/channels/text_input_channel.cc | 2 +- shell/platform/tizen/external_texture_gl.cc | 11 ++-- shell/platform/tizen/tizen_event_loop.cc | 3 - shell/platform/tizen/tizen_renderer.h | 9 +-- .../tizen/tizen_renderer_ecore_wl2.cc | 55 ++++++++++--------- .../platform/tizen/tizen_renderer_ecore_wl2.h | 12 ++-- .../platform/tizen/tizen_renderer_evas_gl.cc | 10 ++-- shell/platform/tizen/tizen_renderer_evas_gl.h | 12 ++-- 8 files changed, 51 insertions(+), 63 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 663d8340fc0d9..663722b184a4e 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -363,7 +363,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) { bool handled = false; #ifdef TIZEN_RENDERER_EVAS_GL - // It is assumed that no hardware keyboard can be attached in Evas GL mode. + // TODO: Hardware keyboard not supported when running in Evas GL mode. bool isIME = true; #else bool isIME = ecore_imf_context_keyboard_mode_get(imf_context_) == diff --git a/shell/platform/tizen/external_texture_gl.cc b/shell/platform/tizen/external_texture_gl.cc index bc52739267ce5..2bf6784f7969d 100644 --- a/shell/platform/tizen/external_texture_gl.cc +++ b/shell/platform/tizen/external_texture_gl.cc @@ -86,13 +86,12 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( } #ifdef TIZEN_RENDERER_EVAS_GL - int eglImgAttr[] = {EVAS_GL_IMAGE_PRESERVED, GL_TRUE, 0}; + int attribs[] = {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); + attribs); if (!egl_src_image) { - // FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError()); mutex_.unlock(); return false; } @@ -117,11 +116,11 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( #else PFNEGLCREATEIMAGEKHRPROC n_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - const EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, - EGL_NONE}; + const EGLint attribs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, + EGL_NONE}; EGLImageKHR egl_src_image = n_eglCreateImageKHR( eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, - (EGLClientBuffer)texture_tbm_surface_, attrs); + (EGLClientBuffer)texture_tbm_surface_, attribs); if (!egl_src_image) { FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError()); mutex_.unlock(); diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index f9e29b9de1381..3c3c700db171f 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -8,8 +8,6 @@ #include #include -#include "flutter/shell/platform/tizen/tizen_log.h" -#include "flutter/shell/platform/tizen/tizen_renderer.h" #ifdef TIZEN_RENDERER_EVAS_GL #include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h" #endif @@ -149,7 +147,6 @@ void TizenRenderEventLoop::OnTaskExpired() { has_pending_renderer_callback_ = true; } else { // Do nothing - FT_LOGD("Ignore set dirty"); } } #endif diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index f5c9de1b217e1..d100495a110af 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -39,16 +39,9 @@ class TizenRenderer { protected: explicit TizenRenderer(TizenRenderer::Delegate& delegate); - virtual bool InitializeRenderer(int32_t x, int32_t y, int32_t w, - int32_t h) = 0; - virtual void Show() = 0; - virtual void DestroyRenderer() = 0; - - virtual void SendRotationChangeDone() = 0; - bool is_valid_ = false; - bool received_rotation{false}; + bool received_rotation_{false}; TizenRenderer::Delegate& delegate_; }; diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 614b80e8ceb87..4b0140450fcd2 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -61,14 +61,14 @@ bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { } bool TizenRendererEcoreWl2::OnPresent() { - if (!is_valid_) { + if (!IsValid()) { FT_LOGE("Invalid TizenRenderer"); return false; } - if (received_rotation) { + if (received_rotation_) { SendRotationChangeDone(); - received_rotation = false; + received_rotation_ = false; } if (eglSwapBuffers(egl_display_, egl_surface_) != EGL_TRUE) { @@ -224,21 +224,19 @@ uintptr_t TizenRendererEcoreWl2::GetWindowId() { bool TizenRendererEcoreWl2::InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) { if (!SetupDisplay()) { - FT_LOGE("setupDisplay fail"); + FT_LOGE("SetupDisplay fail"); return false; } if (!SetupEcoreWlWindow(x, y, w, h)) { FT_LOGE("SetupEcoreWlWindow fail"); return false; } - if (!SetupEglWindow(w, h)) { FT_LOGE("SetupEglWindow fail"); return false; } - if (!SetupEglSurface()) { - FT_LOGE("setupEglSurface fail"); + FT_LOGE("SetupEglSurface fail"); return false; } Show(); @@ -262,7 +260,7 @@ bool TizenRendererEcoreWl2::SetupDisplay() { } ecore_wl2_display_ = ecore_wl2_display_connect(nullptr); if (ecore_wl2_display_ == nullptr) { - FT_LOGE("Disyplay not found"); + FT_LOGE("Display not found"); return false; } FT_LOGD("ecore_wl2_display_: %p", ecore_wl2_display_); @@ -332,40 +330,44 @@ bool TizenRendererEcoreWl2::SetupEglSurface() { FT_LOGE("ChooseEGLConfiguration fail"); return false; } - const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + + const EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, - contextAttribs); + context_attribs); if (EGL_NO_CONTEXT == egl_context_) { PrintEGLError(); return false; } - egl_resource_context_ = - eglCreateContext(egl_display_, egl_config_, egl_context_, contextAttribs); + egl_resource_context_ = eglCreateContext(egl_display_, egl_config_, + egl_context_, context_attribs); if (EGL_NO_CONTEXT == egl_resource_context_) { PrintEGLError(); return false; } + EGLint *ptr = nullptr; - const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, GetEGLNativeWindowType(), ptr); if (egl_surface_ == EGL_NO_SURFACE) { FT_LOGE("eglCreateWindowSurface failed"); return false; } + + const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; egl_resource_surface_ = eglCreatePbufferSurface(egl_display_, egl_config_, attribs); if (egl_resource_surface_ == EGL_NO_SURFACE) { FT_LOGE("eglCreatePbufferSurface is Failed"); return false; } + return true; } bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { // egl CONTEXT - EGLint configAttribs[] = { + EGLint config_attribs[] = { // clang-format off EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, @@ -381,7 +383,7 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { EGLint major = 0; EGLint minor = 0; - int bufferSize = 32; + int buffer_size = 32; egl_display_ = GetEGLDisplay(); if (EGL_NO_DISPLAY == egl_display_) { FT_LOGE("EGL Get Display is failed"); @@ -399,18 +401,19 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { return false; } - EGLint numOfConfig = 0; + EGLint num_config = 0; // Query all framebuffer configurations - if (!eglGetConfigs(egl_display_, NULL, 0, &numOfConfig)) { + if (!eglGetConfigs(egl_display_, NULL, 0, &num_config)) { FT_LOGE("eglGetConfigs is Failed!!"); PrintEGLError(); return false; } - EGLConfig *configs = (EGLConfig *)calloc(numOfConfig, sizeof(EGLConfig)); - EGLint n; - // Get the List of EGL framebuffer configuration matches with configAttribs in - // list "configs" - if (!eglChooseConfig(egl_display_, configAttribs, configs, numOfConfig, &n)) { + EGLConfig *configs = (EGLConfig *)calloc(num_config, sizeof(EGLConfig)); + EGLint num; + // Get the List of EGL framebuffer configuration matches with config_attribs + // in list "configs" + if (!eglChooseConfig(egl_display_, config_attribs, configs, num_config, + &num)) { free(configs); configs = NULL; PrintEGLError(); @@ -418,9 +421,9 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { } EGLint size; - for (int i = 0; i < n; i++) { + for (int i = 0; i < num; i++) { eglGetConfigAttrib(egl_display_, configs[i], EGL_BUFFER_SIZE, &size); - if (bufferSize == size) { + if (buffer_size == size) { egl_config_ = configs[i]; break; } @@ -459,7 +462,7 @@ void TizenRendererEcoreWl2::PrintEGLError() { "EGL_BAD_MATCH : Draw or read are not compatible with context, or if " "context is set to EGL_NO_CONTEXT and draw or read are not set to " "EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and " - "context is not set to EGL_NO_CONTEXT\n"); + "context is not set to EGL_NO_CONTEXT"); break; } case EGL_BAD_ACCESS: { @@ -557,7 +560,7 @@ Eina_Bool TizenRendererEcoreWl2::RotationEventCb(void *data, int type, void TizenRendererEcoreWl2::SetRotate(int angle) { ecore_wl2_window_rotation_set(ecore_wl2_window_, angle); - received_rotation = true; + received_rotation_ = true; } void TizenRendererEcoreWl2::ResizeWithRotation(int32_t x, int32_t y, diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index d4a133ade139b..1f885c49f77ec 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -31,14 +31,11 @@ class TizenRendererEcoreWl2 : public TizenRenderer { int32_t angle) override; void SetRotate(int angle) override; - protected: - bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override; - void Show() override; - void DestroyRenderer() override; - - void SendRotationChangeDone() override; - private: + bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h); + void Show(); + void DestroyRenderer(); + bool SetupDisplay(); bool SetupEcoreWlWindow(int32_t x, int32_t y, int32_t w, int32_t h); bool SetupEglWindow(int32_t w, int32_t h); @@ -54,6 +51,7 @@ class TizenRendererEcoreWl2 : public TizenRenderer { void DestroyEglSurface(); static Eina_Bool RotationEventCb(void *data, int type, void *event); + void SendRotationChangeDone(); Ecore_Wl2_Display *ecore_wl2_display_ = nullptr; Ecore_Wl2_Window *ecore_wl2_window_ = nullptr; diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 5181384cf6742..9913f97c23a45 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -65,13 +65,14 @@ bool TizenRendererEvasGL::OnMakeResourceCurrent() { } bool TizenRendererEvasGL::OnPresent() { - if (!is_valid_) { + if (!IsValid()) { FT_LOGE("Invalid TizenRenderer"); return false; } - if (received_rotation) { + + if (received_rotation_) { SendRotationChangeDone(); - received_rotation = false; + received_rotation_ = false; } return true; @@ -580,7 +581,6 @@ bool TizenRendererEvasGL::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { evas_gl_ = evas_gl_new( evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); - if (!evas_gl_) { FT_LOGE("SetupEvasWindow fail"); return false; @@ -686,7 +686,7 @@ void TizenRendererEvasGL::RotationEventCb(void* data, Evas_Object* obj, void TizenRendererEvasGL::SetRotate(int angle) { elm_win_rotation_set(evas_window_, angle); - received_rotation = true; + received_rotation_ = true; } void TizenRendererEvasGL::ResizeWithRotation(int32_t x, int32_t y, diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 33a26e1d19a73..f83da7f5b4af2 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -34,22 +34,20 @@ class TizenRendererEvasGL : public TizenRenderer { void* GetImageHandle(); - protected: - bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override; - void Show() override; - void DestroyRenderer() override; - - void SendRotationChangeDone() override; - private: void ClearColor(float r, float g, float b, float a); + bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h); + void Show(); + void DestroyRenderer(); + bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h); void DestroyEvasGL(); void DestroyEvasWindow(); static void RotationEventCb(void* data, Evas_Object* obj, void* event_info); + void SendRotationChangeDone(); Evas_Object* evas_window_{nullptr}; Evas_Object* graphics_adapter_{nullptr}; From 97ef634c5141fcd636b4c929e5780924e7389674 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Thu, 22 Apr 2021 16:06:48 +0900 Subject: [PATCH 17/19] Initialize members properly --- shell/platform/tizen/tizen_event_loop.h | 2 +- shell/platform/tizen/tizen_renderer_evas_gl.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/tizen/tizen_event_loop.h b/shell/platform/tizen/tizen_event_loop.h index 15ad7225d8952..9aaf58ff12a61 100644 --- a/shell/platform/tizen/tizen_event_loop.h +++ b/shell/platform/tizen/tizen_event_loop.h @@ -94,7 +94,7 @@ class TizenRenderEventLoop : public TizenEventLoop { virtual void OnTaskExpired() override; private: - TizenRenderer* tizen_renderer_; + TizenRenderer* tizen_renderer_{nullptr}; std::atomic_bool has_pending_renderer_callback_{false}; }; #endif diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index f83da7f5b4af2..186c5acff0260 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -52,11 +52,11 @@ class TizenRendererEvasGL : public TizenRenderer { Evas_Object* evas_window_{nullptr}; Evas_Object* graphics_adapter_{nullptr}; - Evas_GL_Config* gl_config_; + Evas_GL_Config* gl_config_{nullptr}; Evas_GL* evas_gl_{nullptr}; - Evas_GL_Context* gl_context_; - Evas_GL_Context* gl_resource_context_; + Evas_GL_Context* gl_context_{nullptr}; + Evas_GL_Context* gl_resource_context_{nullptr}; Evas_GL_Surface* gl_surface_{nullptr}; Evas_GL_Surface* gl_resource_surface_{nullptr}; From f4c250f160d79791b70cb15a609ec0b4767b6d11 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 26 Apr 2021 15:31:47 +0900 Subject: [PATCH 18/19] Get window id from evas_window_ --- shell/platform/tizen/tizen_renderer_evas_gl.cc | 2 +- shell/platform/tizen/tizen_renderer_evas_gl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 9913f97c23a45..8d2910e471283 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -551,7 +551,7 @@ TizenRenderer::TizenWindowGeometry TizenRendererEvasGL::GetGeometry() { uintptr_t TizenRendererEvasGL::GetWindowId() { return ecore_evas_window_get( - ecore_evas_ecore_evas_get(evas_object_evas_get(graphics_adapter_))); + ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_))); } void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; } diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 186c5acff0260..fe30fe8cb0b86 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -10,7 +10,7 @@ #include #include -#include "tizen_renderer.h" +#include "flutter/shell/platform/tizen/tizen_renderer.h" class TizenRendererEvasGL : public TizenRenderer { public: From 0113bff9bb961d7b8578fafa109c485c6e9b757a Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 26 Apr 2021 15:52:44 +0900 Subject: [PATCH 19/19] Re-format code --- shell/platform/tizen/tizen_event_loop.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index 3c3c700db171f..ec69bb61c1580 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -68,15 +68,15 @@ void TizenEventLoop::PostTask(FlutterTask flutter_task, } Eina_Bool TizenEventLoop::TaskTimerCallback(void* data) { - TizenEventLoop* tizenEventLoop = reinterpret_cast(data); - tizenEventLoop->ExcuteTaskEvents(); + auto* self = reinterpret_cast(data); + self->ExcuteTaskEvents(); return EINA_FALSE; } void TizenEventLoop::ExcuteTaskEvents(void* data, void* buffer, unsigned int nbyte) { - TizenEventLoop* tizenEventLoop = reinterpret_cast(data); - Task* p_task = reinterpret_cast(buffer); + auto* self = reinterpret_cast(data); + auto* p_task = reinterpret_cast(buffer); const double flutter_duration = ((double)(p_task->fire_time.time_since_epoch().count()) - @@ -84,16 +84,16 @@ void TizenEventLoop::ExcuteTaskEvents(void* data, void* buffer, 1000000000.0; if (flutter_duration > 0) { { - std::lock_guard lock(tizenEventLoop->task_queue_mutex_); - tizenEventLoop->task_queue_.push(*p_task); + std::lock_guard lock(self->task_queue_mutex_); + self->task_queue_.push(*p_task); } - ecore_timer_add(flutter_duration, TaskTimerCallback, tizenEventLoop); + ecore_timer_add(flutter_duration, TaskTimerCallback, self); } else { { - std::lock_guard lock(tizenEventLoop->expired_tasks_mutex_); - tizenEventLoop->expired_tasks_.push_back(p_task->task); + std::lock_guard lock(self->expired_tasks_mutex_); + self->expired_tasks_.push_back(p_task->task); } - tizenEventLoop->OnTaskExpired(); + self->OnTaskExpired(); } }