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

Make FLEViewController's view an internal detail #9741

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,6 @@ 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/FLEDartProject.h
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
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginMacOS.h
Expand All @@ -759,9 +756,10 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInput
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEView.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEViewController_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/module.modulemap
FILE: ../../../flutter/shell/platform/embedder/assets/EmbedderInfo.plist
FILE: ../../../flutter/shell/platform/embedder/assets/embedder.modulemap
Expand Down
6 changes: 2 additions & 4 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ _flutter_framework_headers = [
"framework/Headers/FlutterPluginRegistrarMacOS.h",
"framework/Headers/FLEDartProject.h",
"framework/Headers/FLEEngine.h",
"framework/Headers/FLEOpenGLContextHandling.h",
"framework/Headers/FLEReshapeListener.h",
"framework/Headers/FLEView.h",
"framework/Headers/FLEViewController.h",
]

Expand All @@ -58,9 +55,10 @@ shared_library("create_flutter_framework_dylib") {
"framework/Source/FLETextInputModel.mm",
"framework/Source/FLETextInputPlugin.h",
"framework/Source/FLETextInputPlugin.mm",
"framework/Source/FLEView.mm",
"framework/Source/FLEViewController.mm",
"framework/Source/FLEViewController_Internal.h",
"framework/Source/FlutterView.h",
"framework/Source/FlutterView.mm",
]

sources += _flutter_framework_headers
Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions shell/platform/darwin/macos/framework/Headers/FLEReshapeListener.h

This file was deleted.

23 changes: 0 additions & 23 deletions shell/platform/darwin/macos/framework/Headers/FLEView.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#import <Cocoa/Cocoa.h>

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

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

/**
* The view this controller manages. Must be capable of handling text input events, and the OpenGL
* context handling protocols.
*/
@property(nullable) NSView<FLEOpenGLContextHandling>* view;
@interface FLEViewController : NSViewController <FlutterPluginRegistry>

/**
* The Flutter engine associated with this view controller.
Expand Down
3 changes: 0 additions & 3 deletions shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

#import "FLEDartProject.h"
#import "FLEEngine.h"
#import "FLEOpenGLContextHandling.h"
#import "FLEReshapeListener.h"
#import "FLEView.h"
#import "FLEViewController.h"
#import "FlutterBinaryMessenger.h"
#import "FlutterChannels.h"
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/darwin/macos/framework/Source/FLEEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,31 @@ - (void)sendPointerEvent:(const FlutterPointerEvent&)event {
#pragma mark - Private methods

- (bool)engineCallbackOnMakeCurrent {
if (!_viewController.view) {
if (!_viewController.flutterView) {
return false;
}
[_viewController.view makeCurrentContext];
[_viewController.flutterView makeCurrentContext];
return true;
}

- (bool)engineCallbackOnClearCurrent {
if (!_viewController.view) {
if (!_viewController.flutterView) {
return false;
}
[NSOpenGLContext clearCurrentContext];
return true;
}

- (bool)engineCallbackOnPresent {
if (!_viewController.view) {
if (!_viewController.flutterView) {
return false;
}
[_viewController.view onPresent];
[_viewController.flutterView onPresent];
return true;
}

- (bool)engineCallbackOnMakeResourceCurrent {
if (!_viewController.view) {
if (!_viewController.flutterView) {
return false;
}
[_viewController makeResourceContextCurrent];
Expand Down
43 changes: 0 additions & 43 deletions shell/platform/darwin/macos/framework/Source/FLEView.mm

This file was deleted.

26 changes: 13 additions & 13 deletions shell/platform/darwin/macos/framework/Source/FLEViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEReshapeListener.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEView.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"
#import "flutter/shell/platform/embedder/embedder.h"

namespace {
Expand Down Expand Up @@ -68,7 +67,7 @@ void Reset() {
/**
* Private interface declaration for FLEViewController.
*/
@interface FLEViewController ()
@interface FLEViewController () <FlutterViewReshapeListener>

/**
* A list of additional responders to keyboard events. Keybord events are forwarded to all of them.
Expand Down Expand Up @@ -195,16 +194,13 @@ - (instancetype)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBun
return self;
}

- (void)setView:(NSView*)view {
if (_trackingArea) {
[self.view removeTrackingArea:_trackingArea];
}
[super setView:view];
[self configureTrackingArea];
- (void)loadView {
FlutterView* flutterView = [[FlutterView alloc] initWithReshapeListener:self];
self.view = flutterView;
}

- (void)loadView {
self.view = [[FLEView alloc] init];
- (void)viewDidLoad {
[self configureTrackingArea];
}

#pragma mark - Public methods
Expand Down Expand Up @@ -238,6 +234,10 @@ - (BOOL)launchEngineWithProject:(nullable FLEDartProject*)project {

#pragma mark - Framework-internal methods

- (FlutterView*)flutterView {
return static_cast<FlutterView*>(self.view);
}

- (void)addKeyResponder:(NSResponder*)responder {
[self.additionalKeyResponders addObject:responder];
}
Expand Down Expand Up @@ -449,12 +449,12 @@ - (void)setClipboardData:(NSDictionary*)data {
}
}

#pragma mark - FLEReshapeListener
#pragma mark - FlutterViewReshapeListener

/**
* Responds to view reshape by notifying the engine of the change in dimensions.
*/
- (void)viewDidReshape:(NSOpenGLView*)view {
- (void)viewDidReshape:(NSView*)view {
CGSize scaledSize = [view convertRectToBacking:view.bounds].size;
double pixelRatio = view.bounds.size.width == 0 ? 1 : scaledSize.width / view.bounds.size.width;
[_engine updateWindowMetricsWithSize:scaledSize pixelRatio:pixelRatio];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h"

#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"

@interface FLEViewController ()

// The FlutterView for this view controller.
@property(nonatomic, readonly, nullable) FlutterView* flutterView;

/**
* Adds a responder for keyboard events. Key up and key down events are forwarded to all added
* responders.
Expand Down
46 changes: 46 additions & 0 deletions shell/platform/darwin/macos/framework/Source/FlutterView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.

#import <Cocoa/Cocoa.h>

/**
* Listener for view resizing.
*/
@protocol FlutterViewReshapeListener <NSObject>
/**
* Called when the view's backing store changes size.
*/
- (void)viewDidReshape:(nonnull NSView*)view;
@end

/**
* View capable of acting as a rendering target and input source for the Flutter
* engine.
*/
@interface FlutterView : NSOpenGLView

- (nullable instancetype)initWithFrame:(NSRect)frame
reshapeListener:(nonnull id<FlutterViewReshapeListener>)reshapeListener
NS_DESIGNATED_INITIALIZER;

- (nullable instancetype)initWithReshapeListener:
(nonnull id<FlutterViewReshapeListener>)reshapeListener;

- (nullable instancetype)initWithFrame:(NSRect)frameRect
pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
- (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
- (nonnull instancetype)init NS_UNAVAILABLE;

/**
* Sets this view as the current context object for OpenGL drawing.
*/
- (void)makeCurrentContext;

/**
* Called when the OpenGL display should be updated.
*/
- (void)onPresent;

@end
Loading