Fix iOS build to account for Shell rasterizer registration updates. (flutter/engine#4295)
This commit is contained in:
@@ -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(®istered_rasterizers);
|
||||
for (auto& rasterizer : registered_rasterizers) {
|
||||
SnapshotRasterizer(rasterizer, context, is_opaque);
|
||||
}
|
||||
SnapshotRasterizer(GetRandomRasterizer(), context, is_opaque);
|
||||
}
|
||||
|
||||
void SnapshotContentsSync(CGContextRef context, UIView* view) {
|
||||
|
||||
@@ -31,7 +31,7 @@ void PlatformViewIOS::Attach() {
|
||||
|
||||
void PlatformViewIOS::Attach(fxl::Closure firstFrameCallback) {
|
||||
CreateEngine();
|
||||
PostAddToShellTask();
|
||||
|
||||
if (firstFrameCallback) {
|
||||
firstFrameCallback_ = firstFrameCallback;
|
||||
rasterizer_->AddNextFrameCallback([weakSelf = GetWeakPtr()] {
|
||||
|
||||
Reference in New Issue
Block a user