Skip to content

Commit

Permalink
Support imepller in egl renderer (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSUYA authored Jul 8, 2024
1 parent 32f2bc3 commit ee1afba
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
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

0 comments on commit ee1afba

Please sign in to comment.