From 8d306c817535ea6dcf4f45e9a430042def715560 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 20 Jun 2024 15:56:35 +0900 Subject: [PATCH 1/2] Support imepller in EglRenderer When there is an impeller argument, set egl config to match the impeller. --- .../platform/tizen/flutter_tizen_engine.cc | 3 +- .../platform/tizen/tizen_renderer_egl.cc | 67 +++++++++++++------ .../shell/platform/tizen/tizen_renderer_egl.h | 3 +- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/flutter/shell/platform/tizen/flutter_tizen_engine.cc b/flutter/shell/platform/tizen/flutter_tizen_engine.cc index e2708a4..95e75b8 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_engine.cc +++ b/flutter/shell/platform/tizen/flutter_tizen_engine.cc @@ -91,7 +91,8 @@ void FlutterTizenEngine::CreateRenderer( }, renderer_.get()); } else { - renderer_ = std::make_unique(); + renderer_ = std::make_unique( + project_->HasArgument("--enable-impeller")); } } diff --git a/flutter/shell/platform/tizen/tizen_renderer_egl.cc b/flutter/shell/platform/tizen/tizen_renderer_egl.cc index 618fc94..ab70f17 100644 --- a/flutter/shell/platform/tizen/tizen_renderer_egl.cc +++ b/flutter/shell/platform/tizen/tizen_renderer_egl.cc @@ -19,7 +19,8 @@ namespace flutter { -TizenRendererEgl::TizenRendererEgl() {} +TizenRendererEgl::TizenRendererEgl(bool enable_impeller) + : enable_impeller_(enable_impeller) {} TizenRendererEgl::~TizenRendererEgl() { DestroySurface(); @@ -144,20 +145,6 @@ void TizenRendererEgl::DestroySurface() { } bool TizenRendererEgl::ChooseEGLConfiguration() { - EGLint config_attribs[] = { - // 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 - }; - if (!eglInitialize(egl_display_, nullptr, nullptr)) { PrintEGLError(); FT_LOG(Error) << "Could not initialize the EGL display."; @@ -179,12 +166,50 @@ bool TizenRendererEgl::ChooseEGLConfiguration() { EGLConfig* configs = (EGLConfig*)calloc(config_size, sizeof(EGLConfig)); EGLint num_config; - if (!eglChooseConfig(egl_display_, config_attribs, configs, config_size, - &num_config)) { - free(configs); - PrintEGLError(); - FT_LOG(Error) << "No matching configurations found."; - return false; + if (enable_impeller_) { + EGLint impeller_config_attribs[] = { + // clang-format off + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SAMPLE_BUFFERS, 1, + EGL_SAMPLES, 4, + EGL_STENCIL_SIZE, 8, + EGL_DEPTH_SIZE, 0, + EGL_NONE + // clang-format on + }; + if (!eglChooseConfig(egl_display_, impeller_config_attribs, configs, + config_size, &num_config)) { + free(configs); + PrintEGLError(); + FT_LOG(Error) << "No matching configurations found."; + return false; + } + } else { + EGLint config_attribs[] = { + // 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 + }; + if (!eglChooseConfig(egl_display_, config_attribs, configs, config_size, + &num_config)) { + free(configs); + PrintEGLError(); + FT_LOG(Error) << "No matching configurations found."; + return false; + } } int buffer_size = 32; diff --git a/flutter/shell/platform/tizen/tizen_renderer_egl.h b/flutter/shell/platform/tizen/tizen_renderer_egl.h index 1026f67..cc19ec3 100644 --- a/flutter/shell/platform/tizen/tizen_renderer_egl.h +++ b/flutter/shell/platform/tizen/tizen_renderer_egl.h @@ -15,7 +15,7 @@ namespace flutter { class TizenRendererEgl : public TizenRenderer { public: - explicit TizenRendererEgl(); + explicit TizenRendererEgl(bool enable_impeller); virtual ~TizenRendererEgl(); @@ -55,6 +55,7 @@ class TizenRendererEgl : public TizenRenderer { EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; std::string egl_extension_str_; + bool enable_impeller_; }; } // namespace flutter From 47c1faa5d6e509c41d2a6f12b3d0647257d43e2c Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 5 Jul 2024 16:53:22 +0900 Subject: [PATCH 2/2] Add indentation --- .../platform/tizen/tizen_renderer_egl.cc | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/flutter/shell/platform/tizen/tizen_renderer_egl.cc b/flutter/shell/platform/tizen/tizen_renderer_egl.cc index ab70f17..84643d8 100644 --- a/flutter/shell/platform/tizen/tizen_renderer_egl.cc +++ b/flutter/shell/platform/tizen/tizen_renderer_egl.cc @@ -169,17 +169,17 @@ bool TizenRendererEgl::ChooseEGLConfiguration() { if (enable_impeller_) { EGLint impeller_config_attribs[] = { // clang-format off - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SAMPLE_BUFFERS, 1, - EGL_SAMPLES, 4, - EGL_STENCIL_SIZE, 8, - EGL_DEPTH_SIZE, 0, - EGL_NONE + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SAMPLE_BUFFERS, 1, + EGL_SAMPLES, 4, + EGL_STENCIL_SIZE, 8, + EGL_DEPTH_SIZE, 0, + EGL_NONE // clang-format on }; if (!eglChooseConfig(egl_display_, impeller_config_attribs, configs, @@ -192,15 +192,15 @@ bool TizenRendererEgl::ChooseEGLConfiguration() { } else { EGLint config_attribs[] = { // 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 + 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 }; if (!eglChooseConfig(egl_display_, config_attribs, configs, config_size,