Flutter Engine
gpu_surface_gl_delegate.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_GPU_GPU_SURFACE_GL_DELEGATE_H_
6 #define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_
7 
8 #include "flutter/flow/embedded_views.h"
9 #include "flutter/flow/gl_context_switch.h"
10 #include "flutter/fml/macros.h"
11 #include "flutter/shell/gpu/gpu_surface_delegate.h"
12 #include "third_party/skia/include/core/SkMatrix.h"
13 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
14 
15 namespace flutter {
16 
17 // A structure to represent the frame information which is passed to the
18 // embedder when requesting a frame buffer object.
19 struct GLFrameInfo {
20  uint32_t width;
21  uint32_t height;
22 };
23 
25  public:
26  ~GPUSurfaceGLDelegate() override;
27 
28  // |GPUSurfaceDelegate|
29  ExternalViewEmbedder* GetExternalViewEmbedder() override;
30 
31  // Called to make the main GL context current on the current thread.
32  virtual std::unique_ptr<GLContextResult> GLContextMakeCurrent() = 0;
33 
34  // Called to clear the current GL context on the thread. This may be called on
35  // either the GPU or IO threads.
36  virtual bool GLContextClearCurrent() = 0;
37 
38  // Called to present the main GL surface. This is only called for the main GL
39  // context and not any of the contexts dedicated for IO.
40  virtual bool GLContextPresent(uint32_t fbo_id) = 0;
41 
42  // The ID of the main window bound framebuffer. Typically FBO0.
43  virtual intptr_t GLContextFBO(GLFrameInfo frame_info) const = 0;
44 
45  // The rendering subsystem assumes that the ID of the main window bound
46  // framebuffer remains constant throughout. If this assumption in incorrect,
47  // embedders are required to return true from this method. In such cases,
48  // GLContextFBO(frame_info) will be called again to acquire the new FBO ID for
49  // rendering subsequent frames.
50  virtual bool GLContextFBOResetAfterPresent() const;
51 
52  // Indicates whether or not the surface supports pixel readback as used in
53  // circumstances such as a BackdropFilter.
54  virtual bool SurfaceSupportsReadback() const;
55 
56  // A transformation applied to the onscreen surface before the canvas is
57  // flushed.
58  virtual SkMatrix GLContextSurfaceTransformation() const;
59 
60  virtual sk_sp<const GrGLInterface> GetGLInterface() const;
61 
62  // TODO(chinmaygarde): The presence of this method is to work around the fact
63  // that not all platforms can accept a custom GL proc table. Migrate all
64  // platforms to move GL proc resolution to the embedder and remove this
65  // method.
66  static sk_sp<const GrGLInterface> GetDefaultPlatformGLInterface();
67 
68  using GLProcResolver =
69  std::function<void* /* proc name */ (const char* /* proc address */)>;
70  // Provide a custom GL proc resolver. If no such resolver is present, Skia
71  // will attempt to do GL proc address resolution on its own. Embedders that
72  // have specific opinions on GL API selection or need to add their own
73  // instrumentation to specific GL calls can specify custom GL functions
74  // here.
75  virtual GLProcResolver GetGLProcResolver() const;
76 };
77 
78 } // namespace flutter
79 
80 #endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_
Dart_NativeFunction function
Definition: fuchsia.cc:51
std::function< void *(const char *)> GLProcResolver