Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin separating macOS engine from view controller #9654

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/FlutterMacOS.podspec
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEOpenGLContextHandling.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEReshapeListener.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEView.h
Expand All @@ -747,6 +748,8 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacO
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Info.plist
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEEngine.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEEngine_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ _flutter_framework_headers = [
"framework/Headers/FlutterMacOS.h",
"framework/Headers/FlutterPluginMacOS.h",
"framework/Headers/FlutterPluginRegistrarMacOS.h",
"framework/Headers/FLEEngine.h",
"framework/Headers/FLEOpenGLContextHandling.h",
"framework/Headers/FLEReshapeListener.h",
"framework/Headers/FLEView.h",
Expand All @@ -48,6 +49,8 @@ shared_library("create_flutter_framework_dylib") {
output_name = "$_flutter_framework_name"

sources = [
"framework/Source/FLEEngine.mm",
"framework/Source/FLEEngine_Internal.h",
"framework/Source/FLETextInputModel.h",
"framework/Source/FLETextInputModel.mm",
"framework/Source/FLETextInputPlugin.h",
Expand Down
59 changes: 59 additions & 0 deletions shell/platform/darwin/macos/framework/Headers/FLEEngine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_FLEENGINE_H_
#define FLUTTER_FLEENGINE_H_

#import <Foundation/Foundation.h>

#include "FlutterBinaryMessenger.h"
#include "FlutterMacros.h"
#include "FlutterPluginRegistrarMacOS.h"

@class FLEViewController;

/**
* Coordinates a single instance of execution of a Flutter engine.
*
* TODO(stuartmorgan): Finish aligning this (and ideally merging) with FlutterEngine. Currently
* this is largely usable only as an implementation detail of FLEViewController.
*/
FLUTTER_EXPORT
@interface FLEEngine : NSObject <FlutterPluginRegistry>

/**
* Initializes an engine with the given viewController.
*
* @param viewController The view controller associated with this engine. If nil, the engine
* will be run headless.
*/
- (nonnull instancetype)initWithViewController:(nullable FLEViewController*)viewController;

/**
* Launches the Flutter engine with the provided configuration.
*
* @param assets The path to the flutter_assets folder for the Flutter application to be run.
* @param arguments Arguments to pass to the Flutter engine. See
* https://github.com/flutter/engine/blob/master/shell/common/switches.h
* for details. Not all arguments will apply to embedding mode.
* Note: This API layer will abstract arguments in the future, instead of
* providing a direct passthrough.
* @return YES if the engine launched successfully.
*/
- (BOOL)launchEngineWithAssetsPath:(nonnull NSURL*)assets
commandLineArguments:(nullable NSArray<NSString*>*)arguments;

/**
* The `FLEViewController` associated with this engine, if any.
*/
@property(nonatomic, nullable, readonly, weak) FLEViewController* viewController;

/**
* The `FlutterBinaryMessenger` for communicating with this engine.
*/
@property(nonatomic, nonnull, readonly) id<FlutterBinaryMessenger> binaryMessenger;

@end

#endif // FLUTTER_FLEENGINE_H_
37 changes: 13 additions & 24 deletions shell/platform/darwin/macos/framework/Headers/FLEViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#import <Cocoa/Cocoa.h>

#import "FLEEngine.h"
#import "FLEOpenGLContextHandling.h"
#import "FLEReshapeListener.h"
#import "FlutterBinaryMessenger.h"
#import "FlutterMacros.h"
#import "FlutterPluginRegistrarMacOS.h"

Expand All @@ -29,15 +29,19 @@ typedef NS_ENUM(NSInteger, FlutterMouseTrackingMode) {
* Flutter engine in non-interactive mode, or with a drawable Flutter canvas.
*/
FLUTTER_EXPORT
@interface FLEViewController
: NSViewController <FlutterPluginRegistrar, FlutterPluginRegistry, FLEReshapeListener>
@interface FLEViewController : NSViewController <FlutterPluginRegistry, FLEReshapeListener>

/**
* The view this controller manages when launched in interactive mode (headless set to false). Must
* be capable of handling text input events, and the OpenGL context handling protocols.
* The view this controller manages. Must be capable of handling text input events, and the OpenGL
* context handling protocols.
*/
@property(nullable) NSView<FLEOpenGLContextHandling>* view;

/**
* The Flutter engine associated with this view controller.
*/
@property(nonatomic, nonnull, readonly) FLEEngine* engine;

/**
* The style of mouse tracking to use for the view. Defaults to
* FlutterMouseTrackingModeInKeyWindow.
Expand All @@ -49,28 +53,13 @@ FLUTTER_EXPORT
*
* @param assets The path to the flutter_assets folder for the Flutter application to be run.
* @param arguments Arguments to pass to the Flutter engine. See
* https://github.com/flutter/engine/blob/master/shell/common/switches.h
* for details. Not all arguments will apply to embedding mode.
* Note: This API layer will likely abstract arguments in the future, instead of
* providing a direct passthrough.
* https://github.com/flutter/engine/blob/master/shell/common/switches.h
* for details. Not all arguments will apply to embedding mode.
* Note: This API layer will abstract in the future, instead of providing a direct
* passthrough.
* @return YES if the engine launched successfully.
*/
- (BOOL)launchEngineWithAssetsPath:(nonnull NSURL*)assets
commandLineArguments:(nullable NSArray<NSString*>*)arguments;

/**
* Launches the Flutter engine in headless mode with the provided configuration. In headless mode,
* this controller's view should not be displayed.
*
* See launcheEngineWithAssetsPath:commandLineArguments: for details.
*/
- (BOOL)launchHeadlessEngineWithAssetsPath:(nonnull NSURL*)assets
commandLineArguments:(nullable NSArray<NSString*>*)arguments;

/**
* The `FlutterBinaryMessenger` associated with this FLEViewController (used for communicating
* with channels).
*/
@property(nonatomic, readonly) NSObject<FlutterBinaryMessenger>* _Nonnull binaryMessenger;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLEEngine.h"
#import "FLEOpenGLContextHandling.h"
#import "FLEReshapeListener.h"
#import "FLEView.h"
Expand Down
Loading