From b94a941d3a9ef26c553279ef3098fddd209d30a6 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 30 Oct 2017 13:54:41 -0700 Subject: [PATCH] Fix iOS build to account for Shell rasterizer registration updates. (flutter/engine#4295) --- .../darwin/ios/framework/Source/FlutterView.mm | 18 +++++++++++++----- .../platform/darwin/ios/platform_view_ios.mm | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm index b38b3bbc79..db6812f5f0 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -7,6 +7,7 @@ #include "flutter/common/settings.h" #include "flutter/common/threads.h" #include "flutter/flow/layers/layer_tree.h" +#include "flutter/shell/common/platform_view.h" #include "flutter/shell/common/rasterizer.h" #include "flutter/shell/common/shell.h" #include "lib/fxl/synchronization/waitable_event.h" @@ -88,17 +89,24 @@ void SnapshotRasterizer(fxl::WeakPtr rasterizer, SkCGDrawBitmap(context, bitmap, 0, 0); } +static fxl::WeakPtr GetRandomRasterizer() { + fxl::WeakPtr rasterizer; + shell::Shell::Shared().IteratePlatformViews([&rasterizer](shell::PlatformView* view) -> bool { + rasterizer = view->rasterizer().GetWeakRasterizerPtr(); + // We just grab the first rasterizer so there is no need to iterate + // further. + return false; + }); + return rasterizer; +} + void SnapshotContents(CGContextRef context, bool is_opaque) { // TODO(chinmaygarde): Currently, there is no way to get the rasterizer for // a particular platform view from the shell. But, for now, we only have one // platform view. So use that. Once we support multiple platform views, the // shell will need to provide a way to get the rasterizer for a specific // platform view. - std::vector> registered_rasterizers; - shell::Shell::Shared().GetRasterizers(®istered_rasterizers); - for (auto& rasterizer : registered_rasterizers) { - SnapshotRasterizer(rasterizer, context, is_opaque); - } + SnapshotRasterizer(GetRandomRasterizer(), context, is_opaque); } void SnapshotContentsSync(CGContextRef context, UIView* view) { diff --git a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm index 8e0e7c4fc2..ba0e87577f 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm @@ -31,7 +31,7 @@ void PlatformViewIOS::Attach() { void PlatformViewIOS::Attach(fxl::Closure firstFrameCallback) { CreateEngine(); - PostAddToShellTask(); + if (firstFrameCallback) { firstFrameCallback_ = firstFrameCallback; rasterizer_->AddNextFrameCallback([weakSelf = GetWeakPtr()] {