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
5 changed files with 13 additions and 7 deletions
@@ -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.
+3 -2
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:
+7
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) {}
+1 -1
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;
@@ -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;