Skip to content

Commit

Permalink
Support TizenRendererEvasGL rotate (#343)
Browse files Browse the repository at this point in the history
TizenRendererEvasGL does not rotate the flutter.
elm_win using EvasGL Renderer gives width and height with rotation applied.
The flutter just needs to resize to fit the changed width and height.
  • Loading branch information
JSUYA authored Sep 16, 2022
1 parent 16c67da commit ed3d47e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 21 additions & 19 deletions shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,33 @@ void FlutterTizenView::OnResize(int32_t left,
}

void FlutterTizenView::OnRotate(int32_t degree) {
rotation_degree_ = degree;
// Compute renderer transformation based on the angle of rotation.
double rad = (360 - rotation_degree_) * M_PI / 180;
TizenGeometry geometry = tizen_view_->GetGeometry();
int32_t width = geometry.width;
int32_t height = geometry.height;

double trans_x = 0.0, trans_y = 0.0;
if (rotation_degree_ == 90) {
trans_y = height;
} else if (rotation_degree_ == 180) {
trans_x = width;
trans_y = height;
} else if (rotation_degree_ == 270) {
trans_x = width;
}
if (engine_->renderer()->type() == FlutterDesktopRendererType::kEGL) {
rotation_degree_ = degree;
// Compute renderer transformation based on the angle of rotation.
double rad = (360 - rotation_degree_) * M_PI / 180;
double trans_x = 0.0, trans_y = 0.0;
if (rotation_degree_ == 90) {
trans_y = height;
} else if (rotation_degree_ == 180) {
trans_x = width;
trans_y = height;
} else if (rotation_degree_ == 270) {
trans_x = width;
}

flutter_transformation_ = {
cos(rad), -sin(rad), trans_x, // x
sin(rad), cos(rad), trans_y, // y
0.0, 0.0, 1.0 // perspective
};
flutter_transformation_ = {
cos(rad), -sin(rad), trans_x, // x
sin(rad), cos(rad), trans_y, // y
0.0, 0.0, 1.0 // perspective
};

if (rotation_degree_ == 90 || rotation_degree_ == 270) {
std::swap(width, height);
if (rotation_degree_ == 90 || rotation_degree_ == 270) {
std::swap(width, height);
}
}

engine_->renderer()->ResizeSurface(width, height);
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/tizen/tizen_window_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ void TizenWindowElementary::RegisterEventHandlers() {
auto* self = reinterpret_cast<TizenWindowElementary*>(data);
if (self->view_delegate_) {
if (self->elm_win_ == object) {
// FIXME
FT_UNIMPLEMENTED();
self->view_delegate_->OnRotate(self->GetRotation());
elm_win_wm_rotation_manual_rotation_done(self->elm_win_);
}
Expand Down

0 comments on commit ed3d47e

Please sign in to comment.