Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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: 3 additions & 3 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ @implementation FlutterEngine {
fml::WeakPtr<FlutterViewController> _viewController;
fml::scoped_nsobject<FlutterObservatoryPublisher> _publisher;

std::unique_ptr<flutter::FlutterPlatformViewsController> _platformViewsController;
std::shared_ptr<flutter::FlutterPlatformViewsController> _platformViewsController;
std::unique_ptr<flutter::ProfilerMetricsIOS> _profiler_metrics;
std::unique_ptr<flutter::SamplingProfiler> _profiler;

Expand Down Expand Up @@ -311,8 +311,8 @@ - (FlutterViewController*)viewController {
- (FlutterPlatformPlugin*)platformPlugin {
return _platformPlugin.get();
}
- (flutter::FlutterPlatformViewsController*)platformViewsController {
return _platformViewsController.get();
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController {
return _platformViewsController;
}
- (FlutterTextInputPlugin*)textInputPlugin {
return _textInputPlugin.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
base64Encode:(bool)base64Encode;

- (FlutterPlatformPlugin*)platformPlugin;
- (flutter::FlutterPlatformViewsController*)platformViewsController;
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController;
- (FlutterTextInputPlugin*)textInputPlugin;
- (void)launchEngine:(NSString*)entrypoint libraryURI:(NSString*)libraryOrNil;
- (BOOL)createShell:(NSString*)entrypoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,16 +884,16 @@ - (instancetype)initWithTarget:(id)target
}

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[_platformViewsController.get()->getFlutterViewController() touchesBegan:touches withEvent:event];
[_platformViewsController->getFlutterViewController() touchesBegan:touches withEvent:event];
_currentTouchPointersCount += touches.count;
}

- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
[_platformViewsController.get()->getFlutterViewController() touchesMoved:touches withEvent:event];
[_platformViewsController->getFlutterViewController() touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
[_platformViewsController.get()->getFlutterViewController() touchesEnded:touches withEvent:event];
[_platformViewsController->getFlutterViewController() touchesEnded:touches withEvent:event];
_currentTouchPointersCount -= touches.count;
// Touches in one touch sequence are sent to the touchesEnded method separately if different
// fingers stop touching the screen at different time. So one touchesEnded method triggering does
Expand All @@ -905,8 +905,7 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
}

- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
[_platformViewsController.get()->getFlutterViewController() touchesCancelled:touches
withEvent:event];
[_platformViewsController->getFlutterViewController() touchesCancelled:touches withEvent:event];
_currentTouchPointersCount = 0;
self.state = UIGestureRecognizerStateFailed;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/framework/Source/FlutterView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type
asBase64Encoded:(BOOL)base64Encode;

- (flutter::FlutterPlatformViewsController*)platformViewsController;
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController;
@end

@interface FlutterView : UIView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ - (void)onPreferredStatusBarStyleUpdated:(NSNotification*)notification {

#pragma mark - Platform views

- (flutter::FlutterPlatformViewsController*)platformViewsController {
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController {
return [_engine.get() platformViewsController];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern NSNotificationName const FlutterViewControllerShowHomeIndicator;

@property(nonatomic, readonly) BOOL isPresentingViewController;
- (fml::WeakPtr<FlutterViewController>)getWeakPtr;
- (flutter::FlutterPlatformViewsController*)platformViewsController;
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,7 @@ - (instancetype)initWithSemanticsObject:(SemanticsObject*)object {
// `accessibilityContainer` and `accessibilityElementAtIndex`.
if (self = [super initWithAccessibilityContainer:object.bridge->view()]) {
_semanticsObject = object;
flutter::FlutterPlatformViewsController* controller =
object.bridge->GetPlatformViewsController();
auto controller = object.bridge->GetPlatformViewsController();
if (controller) {
_platformView = [[controller->GetPlatformViewByID(object.node.platformViewId) view] retain];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ void DispatchSemanticsAction(int32_t id,
}
void AccessibilityObjectDidBecomeFocused(int32_t id) override {}
void AccessibilityObjectDidLoseFocus(int32_t id) override {}
FlutterPlatformViewsController* GetPlatformViewsController() const override { return nil; }
std::shared_ptr<FlutterPlatformViewsController> GetPlatformViewsController() const override {
return nil;
}
std::vector<SemanticsActionObservation> observations;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AccessibilityBridge final : public AccessibilityBridgeIos {

AccessibilityBridge(FlutterViewController* view_controller,
PlatformViewIOS* platform_view,
FlutterPlatformViewsController* platform_views_controller,
std::shared_ptr<FlutterPlatformViewsController> platform_views_controller,
std::unique_ptr<IosDelegate> ios_delegate = nullptr);
~AccessibilityBridge();

Expand All @@ -70,7 +70,7 @@ class AccessibilityBridge final : public AccessibilityBridgeIos {

fml::WeakPtr<AccessibilityBridge> GetWeakPtr();

FlutterPlatformViewsController* GetPlatformViewsController() const override {
std::shared_ptr<FlutterPlatformViewsController> GetPlatformViewsController() const override {
return platform_views_controller_;
};

Expand All @@ -85,7 +85,7 @@ class AccessibilityBridge final : public AccessibilityBridgeIos {

FlutterViewController* view_controller_;
PlatformViewIOS* platform_view_;
FlutterPlatformViewsController* platform_views_controller_;
const std::shared_ptr<FlutterPlatformViewsController> platform_views_controller_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another big win here, nice.

// If the this id is kSemanticObjectIdInvalid, it means either nothing has
// been focused or the focus is currently outside of the flutter application
// (i.e. the status bar or keyboard)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification,
};
} // namespace

AccessibilityBridge::AccessibilityBridge(FlutterViewController* view_controller,
PlatformViewIOS* platform_view,
FlutterPlatformViewsController* platform_views_controller,
std::unique_ptr<IosDelegate> ios_delegate)
AccessibilityBridge::AccessibilityBridge(
FlutterViewController* view_controller,
PlatformViewIOS* platform_view,
std::shared_ptr<FlutterPlatformViewsController> platform_views_controller,
std::unique_ptr<IosDelegate> ios_delegate)
: view_controller_(view_controller),
platform_view_(platform_view),
platform_views_controller_(platform_views_controller),
Expand Down Expand Up @@ -126,7 +127,7 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification,
}

if (object.node.IsPlatformViewNode()) {
FlutterPlatformViewsController* controller = GetPlatformViewsController();
auto controller = GetPlatformViewsController();
if (controller) {
object.platformViewSemanticsContainer = [[[FlutterPlatformViewSemanticsContainer alloc]
initWithSemanticsObject:object] autorelease];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_IOS_H_
#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_IOS_H_

#include <memory>
#include <vector>

#include "flutter/lib/ui/semantics/semantics_node.h"
Expand Down Expand Up @@ -36,7 +37,7 @@ class AccessibilityBridgeIos {
* The input id is the uid of the newly focused SemanticObject.
*/
virtual void AccessibilityObjectDidLoseFocus(int32_t id) = 0;
virtual FlutterPlatformViewsController* GetPlatformViewsController() const = 0;
virtual std::shared_ptr<FlutterPlatformViewsController> GetPlatformViewsController() const = 0;
};

} // namespace flutter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ - (void)testSemanticsDeallocated {
std::string label = "some label";

auto flutterPlatformViewsController =
std::make_unique<flutter::FlutterPlatformViewsController>();
std::make_shared<flutter::FlutterPlatformViewsController>();
flutterPlatformViewsController->SetFlutterView(mockFlutterView);

MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory new] autorelease];
Expand All @@ -252,7 +252,7 @@ - (void)testSemanticsDeallocated {
auto bridge = std::make_unique<flutter::AccessibilityBridge>(
/*view_controller=*/mockFlutterViewController,
/*platform_view=*/platform_view.get(),
/*platform_views_controller=*/flutterPlatformViewsController.get());
/*platform_views_controller=*/flutterPlatformViewsController);

flutter::SemanticsNodeUpdates nodes;
flutter::SemanticsNode semantics_node;
Expand Down
9 changes: 5 additions & 4 deletions shell/platform/darwin/ios/ios_external_view_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ namespace flutter {

class IOSExternalViewEmbedder : public ExternalViewEmbedder {
public:
IOSExternalViewEmbedder(
FlutterPlatformViewsController* platform_views_controller,
std::shared_ptr<IOSContext> context);
IOSExternalViewEmbedder(const std::shared_ptr<FlutterPlatformViewsController>&
platform_views_controller,
std::shared_ptr<IOSContext> context);

// |ExternalViewEmbedder|
virtual ~IOSExternalViewEmbedder() override;

private:
FlutterPlatformViewsController* platform_views_controller_;
const std::shared_ptr<FlutterPlatformViewsController>&
platform_views_controller_;
std::shared_ptr<IOSContext> ios_context_;

// |ExternalViewEmbedder|
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_external_view_embedder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace flutter {

IOSExternalViewEmbedder::IOSExternalViewEmbedder(
FlutterPlatformViewsController* platform_views_controller,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller,
std::shared_ptr<IOSContext> context)
: platform_views_controller_(platform_views_controller), ios_context_(context) {
FML_CHECK(ios_context_);
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/darwin/ios/ios_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class IOSSurface {
static std::unique_ptr<IOSSurface> Create(
std::shared_ptr<IOSContext> context,
fml::scoped_nsobject<CALayer> layer,
FlutterPlatformViewsController* platform_views_controller);
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller);

std::shared_ptr<IOSContext> GetContext() const;

Expand All @@ -49,7 +49,7 @@ class IOSSurface {

protected:
IOSSurface(std::shared_ptr<IOSContext> ios_context,
FlutterPlatformViewsController* platform_views_controller);
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller);

private:
std::shared_ptr<IOSContext> ios_context_;
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
std::unique_ptr<IOSSurface> IOSSurface::Create(
std::shared_ptr<IOSContext> context,
fml::scoped_nsobject<CALayer> layer,
FlutterPlatformViewsController* platform_views_controller) {
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller) {
FML_DCHECK(layer);
FML_DCHECK(context);

Expand Down Expand Up @@ -51,8 +51,9 @@
);
}

IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context,
FlutterPlatformViewsController* platform_views_controller)
IOSSurface::IOSSurface(
std::shared_ptr<IOSContext> ios_context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller)
: ios_context_(std::move(ios_context)) {
FML_DCHECK(ios_context_);
external_view_embedder_ =
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ namespace flutter {

class IOSSurfaceGL final : public IOSSurface, public GPUSurfaceGLDelegate {
public:
IOSSurfaceGL(fml::scoped_nsobject<CAEAGLLayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller = nullptr);
IOSSurfaceGL(
fml::scoped_nsobject<CAEAGLLayer> layer,
std::shared_ptr<IOSContext> context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller = nullptr);

~IOSSurfaceGL() override;

Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface_gl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
return reinterpret_cast<IOSContextGL*>(context.get());
}

IOSSurfaceGL::IOSSurfaceGL(fml::scoped_nsobject<CAEAGLLayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller)
IOSSurfaceGL::IOSSurfaceGL(
fml::scoped_nsobject<CAEAGLLayer> layer,
std::shared_ptr<IOSContext> context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller)
: IOSSurface(context, platform_views_controller) {
render_target_ = CastToGLContext(context)->CreateRenderTarget(std::move(layer));
}
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_metal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetal final : public IOSSurface,
public:
IOSSurfaceMetal(fml::scoped_nsobject<CAMetalLayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller);
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller);

// |IOSSurface|
~IOSSurfaceMetal() override;
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
return reinterpret_cast<IOSContextMetal*>(context.get());
}

IOSSurfaceMetal::IOSSurfaceMetal(fml::scoped_nsobject<CAMetalLayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller)
IOSSurfaceMetal::IOSSurfaceMetal(
fml::scoped_nsobject<CAMetalLayer> layer,
std::shared_ptr<IOSContext> context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller)
: IOSSurface(std::move(context), platform_views_controller), layer_(std::move(layer)) {
if (!layer_) {
return;
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface_software.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ namespace flutter {

class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDelegate {
public:
IOSSurfaceSoftware(fml::scoped_nsobject<CALayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller);
IOSSurfaceSoftware(
fml::scoped_nsobject<CALayer> layer,
std::shared_ptr<IOSContext> context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller);

~IOSSurfaceSoftware() override;

Expand Down
7 changes: 4 additions & 3 deletions shell/platform/darwin/ios/ios_surface_software.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

namespace flutter {

IOSSurfaceSoftware::IOSSurfaceSoftware(fml::scoped_nsobject<CALayer> layer,
std::shared_ptr<IOSContext> context,
FlutterPlatformViewsController* platform_views_controller)
IOSSurfaceSoftware::IOSSurfaceSoftware(
fml::scoped_nsobject<CALayer> layer,
std::shared_ptr<IOSContext> context,
const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller)
: IOSSurface(std::move(context), platform_views_controller), layer_(std::move(layer)) {}

IOSSurfaceSoftware::~IOSSurfaceSoftware() = default;
Expand Down