Flutter Engine
 
Loading...
Searching...
No Matches
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 <optional>
9
12#include "flutter/fml/macros.h"
13
14#if !SLIMPELLER
15#include "third_party/skia/include/gpu/ganesh/gl/GrGLInterface.h"
16#else
17struct GrGLInterface;
18#endif // !SLIMPELLER
19
20namespace flutter {
21
22// A structure to represent the frame information which is passed to the
23// embedder when requesting a frame buffer object.
25 uint32_t width;
26 uint32_t height;
27};
28
29// A structure to represent the frame buffer information which is returned to
30// the rendering backend after requesting a frame buffer object.
31struct GLFBOInfo {
32 // The frame buffer's ID.
33 uint32_t fbo_id;
34 // The frame buffer's existing damage (i.e. damage since it was last used).
35 const std::optional<DlIRect> existing_damage;
36};
37
38// Information passed during presentation of a frame.
40 uint32_t fbo_id;
41
42 // The frame damage is a hint to compositor telling it which parts of front
43 // buffer need to be updated.
44 const std::optional<DlIRect>& frame_damage;
45
46 // Time at which this frame is scheduled to be presented. This is a hint
47 // that can be passed to the platform to drop queued frames.
48 std::optional<fml::TimePoint> presentation_time = std::nullopt;
49
50 // The buffer damage refers to the region that needs to be set as damaged
51 // within the frame buffer.
52 const std::optional<DlIRect>& buffer_damage;
53};
54
56 public:
58
59 // Called to make the main GL context current on the current thread.
60 virtual std::unique_ptr<GLContextResult> GLContextMakeCurrent() = 0;
61
62 // Called to clear the current GL context on the thread. This may be called on
63 // either the Raster or IO threads.
64 virtual bool GLContextClearCurrent() = 0;
65
66 // Inform the GL Context that there's going to be no writing beyond
67 // the specified region
68 virtual void GLContextSetDamageRegion(const std::optional<DlIRect>& region) {}
69
70 // Called to present the main GL surface. This is only called for the main GL
71 // context and not any of the contexts dedicated for IO.
72 virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0;
73
74 // The information about the main window bound framebuffer. ID is Typically
75 // FBO0.
76 virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const = 0;
77
78 // The rendering subsystem assumes that the ID of the main window bound
79 // framebuffer remains constant throughout. If this assumption in incorrect,
80 // embedders are required to return true from this method. In such cases,
81 // GLContextFBO(frame_info) will be called again to acquire the new FBO ID for
82 // rendering subsequent frames.
83 virtual bool GLContextFBOResetAfterPresent() const;
84
85 // Returns framebuffer info for current backbuffer
87
88 // A transformation applied to the onscreen surface before the canvas is
89 // flushed.
91
92 virtual sk_sp<const GrGLInterface> GetGLInterface() const;
93
94 // TODO(chinmaygarde): The presence of this method is to work around the fact
95 // that not all platforms can accept a custom GL proc table. Migrate all
96 // platforms to move GL proc resolution to the embedder and remove this
97 // method.
98 static sk_sp<const GrGLInterface> GetDefaultPlatformGLInterface();
99
101 std::function<void* /* proc name */ (const char* /* proc address */)>;
102 // Provide a custom GL proc resolver. If no such resolver is present, Skia
103 // will attempt to do GL proc address resolution on its own. Embedders that
104 // have specific opinions on GL API selection or need to add their own
105 // instrumentation to specific GL calls can specify custom GL functions
106 // here.
107 virtual GLProcResolver GetGLProcResolver() const;
108
109 // Whether to allow drawing to the surface when the GPU is disabled
110 virtual bool AllowsDrawingWhenGpuDisabled() const;
111};
112
113} // namespace flutter
114
115#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_
virtual bool AllowsDrawingWhenGpuDisabled() const
virtual std::unique_ptr< GLContextResult > GLContextMakeCurrent()=0
std::function< void *(const char *)> GLProcResolver
static sk_sp< const GrGLInterface > GetDefaultPlatformGLInterface()
virtual bool GLContextClearCurrent()=0
virtual bool GLContextPresent(const GLPresentInfo &present_info)=0
virtual void GLContextSetDamageRegion(const std::optional< DlIRect > &region)
virtual GLProcResolver GetGLProcResolver() const
virtual sk_sp< const GrGLInterface > GetGLInterface() const
virtual bool GLContextFBOResetAfterPresent() const
virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const
virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const =0
virtual DlMatrix GLContextSurfaceTransformation() const
const std::optional< DlIRect > existing_damage
std::optional< fml::TimePoint > presentation_time
const std::optional< DlIRect > & buffer_damage
const std::optional< DlIRect > & frame_damage
A 4x4 matrix using column-major storage.
Definition matrix.h:37