Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support imepller in egl renderer #70

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flutter/shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void FlutterTizenEngine::CreateRenderer(
},
renderer_.get());
} else {
renderer_ = std::make_unique<TizenRendererEgl>();
renderer_ = std::make_unique<TizenRendererEgl>(
project_->HasArgument("--enable-impeller"));
}
}

Expand Down
67 changes: 46 additions & 21 deletions flutter/shell/platform/tizen/tizen_renderer_egl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

namespace flutter {

TizenRendererEgl::TizenRendererEgl() {}
TizenRendererEgl::TizenRendererEgl(bool enable_impeller)
: enable_impeller_(enable_impeller) {}

TizenRendererEgl::~TizenRendererEgl() {
DestroySurface();
Expand Down Expand Up @@ -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.";
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion flutter/shell/platform/tizen/tizen_renderer_egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace flutter {

class TizenRendererEgl : public TizenRenderer {
public:
explicit TizenRendererEgl();
explicit TizenRendererEgl(bool enable_impeller);

virtual ~TizenRendererEgl();

Expand Down Expand Up @@ -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
Expand Down