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

Synchronize Flutter's rendering with CA. #6807

Merged
merged 2 commits into from
Nov 9, 2018
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
2 changes: 1 addition & 1 deletion flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ExternalViewEmbedder {
public:
ExternalViewEmbedder() = default;

virtual void SetFrameSize(SkISize frame_size) = 0;
virtual void BeginFrame(SkISize frame_size) = 0;

virtual void PrerollCompositeEmbeddedView(int view_id) = 0;

Expand Down
2 changes: 1 addition & 1 deletion shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) {
auto external_view_embedder = surface_->GetExternalViewEmbedder();

if (external_view_embedder != nullptr) {
external_view_embedder->SetFrameSize(layer_tree.frame_size());
external_view_embedder->BeginFrame(layer_tree.frame_size());
}

auto compositor_frame = compositor_context_->AcquireFrame(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ + (Class)layerClass {
- (std::unique_ptr<shell::IOSSurfaceGL>)createGLSurfaceWithContext:
(std::shared_ptr<shell::IOSGLContext>)gl_context {
fml::scoped_nsobject<CAEAGLLayer> eagl_layer(reinterpret_cast<CAEAGLLayer*>([self.layer retain]));
// TODO(amirh): We can lower this to iOS 8.0 once we have a Metal rendering backend.
// https://github.com/flutter/flutter/issues/24132
if (@available(iOS 9.0, *)) {
eagl_layer.get().presentsWithTransaction = YES;
}
return std::make_unique<shell::IOSSurfaceGL>(eagl_layer, std::move(gl_context));
}

Expand Down
9 changes: 9 additions & 0 deletions shell/platform/darwin/ios/framework/Source/FlutterView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ + (Class)layerClass {
if ([self.layer isKindOfClass:[CAEAGLLayer class]]) {
fml::scoped_nsobject<CAEAGLLayer> eagl_layer(
reinterpret_cast<CAEAGLLayer*>([self.layer retain]));
if (shell::IsIosEmbeddedViewsPreviewEnabled()) {
// TODO(amirh): We can lower this to iOS 8.0 once we have a Metal rendering backend.
// https://github.com/flutter/flutter/issues/24132
if (@available(iOS 9.0, *)) {
// TODO(amirh): only do this if there's an embedded view.
// https://github.com/flutter/flutter/issues/24133
eagl_layer.get().presentsWithTransaction = YES;
}
}
return std::make_unique<shell::IOSSurfaceGL>(std::move(eagl_layer),
[_delegate platformViewsController]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class IOSSurfaceGL : public IOSSurface,
flow::ExternalViewEmbedder* GetExternalViewEmbedder() override;

// |flow::ExternalViewEmbedder|
void SetFrameSize(SkISize frame_size) override;
void BeginFrame(SkISize frame_size) override;

// |flow::ExternalViewEmbedder|
void PrerollCompositeEmbeddedView(int view_id) override;
Expand Down
8 changes: 6 additions & 2 deletions shell/platform/darwin/ios/ios_surface_gl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@
}
}

void IOSSurfaceGL::SetFrameSize(SkISize frame_size) {
void IOSSurfaceGL::BeginFrame(SkISize frame_size) {
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
FML_CHECK(platform_views_controller != nullptr);
platform_views_controller->SetFrameSize(frame_size);
[CATransaction begin];
}

void IOSSurfaceGL::PrerollCompositeEmbeddedView(int view_id) {
Expand All @@ -111,7 +112,10 @@
if (platform_views_controller == nullptr) {
return true;
}
return platform_views_controller->SubmitFrame(true, std::move(context), context_);

bool submitted = platform_views_controller->SubmitFrame(true, std::move(context), context_);
[CATransaction commit];
return submitted;
}

} // namespace shell
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_software.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class IOSSurfaceSoftware final : public IOSSurface,
flow::ExternalViewEmbedder* GetExternalViewEmbedder() override;

// |flow::ExternalViewEmbedder|
void SetFrameSize(SkISize frame_size) override;
void BeginFrame(SkISize frame_size) override;

// |flow::ExternalViewEmbedder|
void PrerollCompositeEmbeddedView(int view_id) override;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_software.mm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}
}

void IOSSurfaceSoftware::SetFrameSize(SkISize frame_size) {
void IOSSurfaceSoftware::BeginFrame(SkISize frame_size) {
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
FML_CHECK(platform_views_controller != nullptr);
platform_views_controller->SetFrameSize(frame_size);
Expand Down