Fix iOS build to account for Shell rasterizer registration updates. (flutter/engine#4295)

This commit is contained in:
Chinmay Garde
2017-10-30 13:54:41 -07:00
committed by GitHub
parent 3dd5e0aceb
commit b94a941d3a
2 changed files with 14 additions and 6 deletions

View File

@@ -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<shell::Rasterizer> rasterizer,
SkCGDrawBitmap(context, bitmap, 0, 0);
}
static fxl::WeakPtr<shell::Rasterizer> GetRandomRasterizer() {
fxl::WeakPtr<shell::Rasterizer> 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<fxl::WeakPtr<shell::Rasterizer>> registered_rasterizers;
shell::Shell::Shared().GetRasterizers(&registered_rasterizers);
for (auto& rasterizer : registered_rasterizers) {
SnapshotRasterizer(rasterizer, context, is_opaque);
}
SnapshotRasterizer(GetRandomRasterizer(), context, is_opaque);
}
void SnapshotContentsSync(CGContextRef context, UIView* view) {

View File

@@ -31,7 +31,7 @@ void PlatformViewIOS::Attach() {
void PlatformViewIOS::Attach(fxl::Closure firstFrameCallback) {
CreateEngine();
PostAddToShellTask();
if (firstFrameCallback) {
firstFrameCallback_ = firstFrameCallback;
rasterizer_->AddNextFrameCallback([weakSelf = GetWeakPtr()] {