• 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 FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_GL_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
10 #include "flutter/shell/gpu/gpu_surface_gl.h"
11 #include "flutter/shell/platform/darwin/ios/ios_gl_context.h"
12 #include "flutter/shell/platform/darwin/ios/ios_gl_render_target.h"
13 #include "flutter/shell/platform/darwin/ios/ios_surface.h"
14 
15 @class CAEAGLLayer;
16 
17 namespace flutter {
18 
19 class IOSSurfaceGL final : public IOSSurface,
20                            public GPUSurfaceGLDelegate,
21                            public ExternalViewEmbedder {
22  public:
23   IOSSurfaceGL(std::shared_ptr<IOSGLContext> context,
24                fml::scoped_nsobject<CAEAGLLayer> layer,
25                FlutterPlatformViewsController* platform_views_controller);
26 
27   IOSSurfaceGL(fml::scoped_nsobject<CAEAGLLayer> layer, std::shared_ptr<IOSGLContext> context);
28 
29   ~IOSSurfaceGL() override;
30 
31   bool IsValid() const override;
32 
33   bool ResourceContextMakeCurrent() override;
34 
35   void UpdateStorageSizeIfNecessary() override;
36 
37   std::unique_ptr<Surface> CreateGPUSurface() override;
38 
39   std::unique_ptr<Surface> CreateSecondaryGPUSurface(GrContext* gr_context);
40 
41   bool GLContextMakeCurrent() override;
42 
43   bool GLContextClearCurrent() override;
44 
45   bool GLContextPresent() override;
46 
47   intptr_t GLContextFBO() const override;
48 
49   bool UseOffscreenSurface() const override;
50 
51   // |GPUSurfaceGLDelegate|
52   ExternalViewEmbedder* GetExternalViewEmbedder() override;
53 
54   // |ExternalViewEmbedder|
55   sk_sp<SkSurface> GetRootSurface() override;
56 
57   // |ExternalViewEmbedder|
58   void CancelFrame() override;
59 
60   // |ExternalViewEmbedder|
61   void BeginFrame(SkISize frame_size, GrContext* context) override;
62 
63   // |ExternalViewEmbedder|
64   void PrerollCompositeEmbeddedView(int view_id,
65                                     std::unique_ptr<flutter::EmbeddedViewParams> params) override;
66 
67   // |ExternalViewEmbedder|
68   PostPrerollResult PostPrerollAction(fml::RefPtr<fml::GpuThreadMerger> gpu_thread_merger) override;
69 
70   // |ExternalViewEmbedder|
71   std::vector<SkCanvas*> GetCurrentCanvases() override;
72 
73   // |ExternalViewEmbedder|
74   SkCanvas* CompositeEmbeddedView(int view_id) override;
75 
76   // |ExternalViewEmbedder|
77   bool SubmitFrame(GrContext* context) override;
78 
79  private:
80   std::shared_ptr<IOSGLContext> context_;
81   std::unique_ptr<IOSGLRenderTarget> render_target_;
82 
83   FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceGL);
84 };
85 
86 }  // namespace flutter
87 
88 #endif  // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_GL_H_
89