1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ 6 #define SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ 7 8 #include <memory> 9 10 #include "flutter/fml/closure.h" 11 #include "flutter/fml/macros.h" 12 #include "flutter/fml/memory/weak_ptr.h" 13 #include "flutter/fml/platform/darwin/scoped_nsobject.h" 14 #include "flutter/shell/common/platform_view.h" 15 #include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterTexture.h" 16 #include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" 17 #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" 18 #include "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" 19 #include "flutter/shell/platform/darwin/ios/framework/Source/platform_message_router.h" 20 #include "flutter/shell/platform/darwin/ios/ios_gl_context.h" 21 #include "flutter/shell/platform/darwin/ios/ios_surface.h" 22 23 @class FlutterViewController; 24 25 namespace flutter { 26 27 class PlatformViewIOS final : public PlatformView { 28 public: 29 explicit PlatformViewIOS(PlatformView::Delegate& delegate, flutter::TaskRunners task_runners); 30 31 ~PlatformViewIOS() override; 32 33 PlatformMessageRouter& GetPlatformMessageRouter(); 34 35 fml::WeakPtr<FlutterViewController> GetOwnerViewController() const; 36 void SetOwnerViewController(fml::WeakPtr<FlutterViewController> owner_controller); 37 38 void RegisterExternalTexture(int64_t id, NSObject<FlutterTexture>* texture); 39 40 fml::scoped_nsprotocol<FlutterTextInputPlugin*> GetTextInputPlugin() const; 41 42 void SetTextInputPlugin(fml::scoped_nsprotocol<FlutterTextInputPlugin*> plugin); 43 44 // |PlatformView| 45 void SetSemanticsEnabled(bool enabled) override; 46 47 private: 48 fml::WeakPtr<FlutterViewController> owner_controller_; 49 std::unique_ptr<IOSSurface> ios_surface_; 50 std::shared_ptr<IOSGLContext> gl_context_; 51 PlatformMessageRouter platform_message_router_; 52 std::unique_ptr<AccessibilityBridge> accessibility_bridge_; 53 fml::scoped_nsprotocol<FlutterTextInputPlugin*> text_input_plugin_; 54 fml::closure firstFrameCallback_; 55 56 // |PlatformView| 57 void HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage> message) override; 58 59 // |PlatformView| 60 std::unique_ptr<Surface> CreateRenderingSurface() override; 61 62 // |PlatformView| 63 sk_sp<GrContext> CreateResourceContext() const override; 64 65 // |PlatformView| 66 void SetAccessibilityFeatures(int32_t flags) override; 67 68 // |PlatformView| 69 void UpdateSemantics(flutter::SemanticsNodeUpdates update, 70 flutter::CustomAccessibilityActionUpdates actions) override; 71 72 // |PlatformView| 73 std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override; 74 75 // |PlatformView| 76 void OnPreEngineRestart() const override; 77 78 FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewIOS); 79 }; 80 81 } // namespace flutter 82 83 #endif // SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ 84