Move the embedded view preview flag check to a common function. (#6813)

This commit is contained in:
Amir Hardon 2018-11-09 11:24:14 -08:00 committed by GitHub
parent 316f6365a6
commit f5e5d81eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 7 deletions

View File

@ -296,8 +296,6 @@
threadLabel.UTF8String, // label
shell::ThreadHost::Type::UI | shell::ThreadHost::Type::GPU | shell::ThreadHost::Type::IO};
bool embedded_views_preview_enabled = [[[NSBundle mainBundle]
objectForInfoDictionaryKey:@(shell::kEmbeddedViewsPreview)] boolValue];
// Lambda captures by pointers to ObjC objects are fine here because the
// create call is
// synchronous.
@ -310,7 +308,7 @@
return std::make_unique<shell::Rasterizer>(shell.GetTaskRunners());
};
if (embedded_views_preview_enabled) {
if (shell::IsIosEmbeddedViewsPreviewEnabled()) {
// Embedded views requires the gpu and the platform views to be the same.
// The plan is to eventually dynamically merge the threads when there's a
// platform view in the layer tree.

View File

@ -15,8 +15,9 @@
namespace shell {
// The name of the Info.plist flag to enable the embedded iOS views preview.
const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview";
// Returns true if the app explicitly specified to use the iOS view embedding
// mechanism which is still in a release preview.
bool IsIosEmbeddedViewsPreviewEnabled();
class IOSSurface {
public:

View File

@ -11,6 +11,13 @@
namespace shell {
// The name of the Info.plist flag to enable the embedded iOS views preview.
const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview";
bool IsIosEmbeddedViewsPreviewEnabled() {
return [[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue];
}
IOSSurface::IOSSurface(FlutterPlatformViewsController* platform_views_controller)
: platform_views_controller_(platform_views_controller) {}

View File

@ -75,7 +75,7 @@ bool IOSSurfaceGL::GLContextPresent() {
}
flow::ExternalViewEmbedder* IOSSurfaceGL::GetExternalViewEmbedder() {
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) {
if (IsIosEmbeddedViewsPreviewEnabled()) {
return this;
} else {
return nullptr;

View File

@ -127,7 +127,7 @@ bool IOSSurfaceSoftware::PresentBackingStore(sk_sp<SkSurface> backing_store) {
}
flow::ExternalViewEmbedder* IOSSurfaceSoftware::GetExternalViewEmbedder() {
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) {
if (IsIosEmbeddedViewsPreviewEnabled()) {
return this;
} else {
return nullptr;