Flutter Engine
ios_surface.h
Go to the documentation of this file.
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 FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_H_
7 
8 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
9 #import "flutter/shell/platform/darwin/ios/ios_external_view_embedder.h"
10 
11 #include <memory>
12 
13 #include "flutter/flow/embedded_views.h"
14 #include "flutter/flow/surface.h"
15 #include "flutter/fml/macros.h"
16 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
17 
18 @class CALayer;
19 
20 namespace flutter {
21 
22 // Returns true if the app explicitly specified to use the iOS view embedding
23 // mechanism which is still in a release preview.
25 
26 class IOSSurface {
27  public:
28  static std::unique_ptr<IOSSurface> Create(
29  std::shared_ptr<IOSContext> context,
31  FlutterPlatformViewsController* platform_views_controller);
32 
33  std::shared_ptr<IOSContext> GetContext() const;
34 
35  std::shared_ptr<IOSExternalViewEmbedder> GetSurfaceExternalViewEmbedder() const;
36 
37  virtual ~IOSSurface();
38 
39  virtual bool IsValid() const = 0;
40 
41  virtual void UpdateStorageSizeIfNecessary() = 0;
42 
43  // Creates a GPU surface. If no GrDirectContext is supplied and the rendering mode
44  // supports one, a new one will be created; otherwise, the software backend
45  // will be used.
46  //
47  // If a GrDirectContext is supplied, creates a secondary surface.
48  virtual std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context = nullptr) = 0;
49 
50  protected:
51  IOSSurface(std::shared_ptr<IOSContext> ios_context,
52  FlutterPlatformViewsController* platform_views_controller);
53 
54  private:
55  std::shared_ptr<IOSContext> ios_context_;
56  std::shared_ptr<IOSExternalViewEmbedder> external_view_embedder_;
57 
58  FML_DISALLOW_COPY_AND_ASSIGN(IOSSurface);
59 };
60 
61 } // namespace flutter
62 
63 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_H_
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:64
virtual std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context=nullptr)=0
IOSSurface(std::shared_ptr< IOSContext > ios_context, FlutterPlatformViewsController *platform_views_controller)
Definition: ios_surface.mm:54
std::shared_ptr< IOSExternalViewEmbedder > GetSurfaceExternalViewEmbedder() const
Definition: ios_surface.mm:68
virtual bool IsValid() const =0
bool IsIosEmbeddedViewsPreviewEnabled()
virtual void UpdateStorageSizeIfNecessary()=0
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, fml::scoped_nsobject< CALayer > layer, FlutterPlatformViewsController *platform_views_controller)
Definition: ios_surface.mm:18