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