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