Flutter Engine
embedder_surface_gl.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_EMBEDDER_EMBEDDER_SURFACE_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/shell/gpu/gpu_surface_gl.h"
10 #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h"
11 #include "flutter/shell/platform/embedder/embedder_surface.h"
12 
13 namespace flutter {
14 
15 class EmbedderSurfaceGL final : public EmbedderSurface,
16  public GPUSurfaceGLDelegate {
17  public:
18  struct GLDispatchTable {
19  std::function<bool(void)> gl_make_current_callback; // required
20  std::function<bool(void)> gl_clear_current_callback; // required
21  std::function<bool(uint32_t)> gl_present_callback; // required
22  std::function<intptr_t(GLFrameInfo)> gl_fbo_callback; // required
23  std::function<bool(void)> gl_make_resource_current_callback; // optional
24  std::function<SkMatrix(void)>
26  std::function<void*(const char*)> gl_proc_resolver; // optional
27  };
28 
30  GLDispatchTable gl_dispatch_table,
31  bool fbo_reset_after_present,
32  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
33 
34  ~EmbedderSurfaceGL() override;
35 
36  private:
37  bool valid_ = false;
38  GLDispatchTable gl_dispatch_table_;
39  bool fbo_reset_after_present_;
40 
41  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder_;
42 
43  // |EmbedderSurface|
44  bool IsValid() const override;
45 
46  // |EmbedderSurface|
47  std::unique_ptr<Surface> CreateGPUSurface() override;
48 
49  // |EmbedderSurface|
50  sk_sp<GrDirectContext> CreateResourceContext() const override;
51 
52  // |GPUSurfaceGLDelegate|
53  std::unique_ptr<GLContextResult> GLContextMakeCurrent() override;
54 
55  // |GPUSurfaceGLDelegate|
56  bool GLContextClearCurrent() override;
57 
58  // |GPUSurfaceGLDelegate|
59  bool GLContextPresent(uint32_t fbo_id) override;
60 
61  // |GPUSurfaceGLDelegate|
62  intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
63 
64  // |GPUSurfaceGLDelegate|
65  bool GLContextFBOResetAfterPresent() const override;
66 
67  // |GPUSurfaceGLDelegate|
68  SkMatrix GLContextSurfaceTransformation() const override;
69 
70  // |GPUSurfaceGLDelegate|
71  ExternalViewEmbedder* GetExternalViewEmbedder() override;
72 
73  // |GPUSurfaceGLDelegate|
74  GLProcResolver GetGLProcResolver() const override;
75 
77 };
78 
79 } // namespace flutter
80 
81 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_H_
std::function< bool(void)> gl_clear_current_callback
std::function< intptr_t(GLFrameInfo)> gl_fbo_callback
std::function< bool(void)> gl_make_resource_current_callback
EmbedderSurfaceGL(GLDispatchTable gl_dispatch_table, bool fbo_reset_after_present, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
std::function< bool(uint32_t)> gl_present_callback
std::function< void *(const char *)> gl_proc_resolver
std::function< void *(const char *)> GLProcResolver
std::function< SkMatrix(void)> gl_surface_transformation_callback
std::function< bool(void)> gl_make_current_callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27