• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  private:
45   fml::WeakPtr<FlutterViewController> owner_controller_;
46   std::unique_ptr<IOSSurface> ios_surface_;
47   std::shared_ptr<IOSGLContext> gl_context_;
48   PlatformMessageRouter platform_message_router_;
49   fml::scoped_nsprotocol<FlutterTextInputPlugin*> text_input_plugin_;
50   fml::closure firstFrameCallback_;
51 
52   // |PlatformView|
53   void HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage> message) override;
54 
55   // |PlatformView|
56   std::unique_ptr<Surface> CreateRenderingSurface() override;
57 
58   // |PlatformView|
59   sk_sp<GrContext> CreateResourceContext() const override;
60 
61   // |PlatformView|
62   void SetAccessibilityFeatures(int32_t flags);
63 
64   // |PlatformView|
65   std::unique_ptr<VsyncWaiter> CreateVSyncWaiter(int32_t platform) override;
66 
67   // |PlatformView|
68   void OnPreEngineRestart() const override;
69 
70   FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewIOS);
71 };
72 
73 }  // namespace flutter
74 
75 #endif  // SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_
76