Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
surface_frame.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_FLOW_SURFACE_FRAME_H_
6#define FLUTTER_FLOW_SURFACE_FRAME_H_
7
8#include <memory>
9#include <optional>
10
11#include "flutter/common/graphics/gl_context_switch.h"
12#include "flutter/display_list/dl_builder.h"
13#include "flutter/display_list/skia/dl_sk_canvas.h"
14#include "flutter/fml/macros.h"
15#include "flutter/fml/time/time_point.h"
16
19
20namespace flutter {
21
22// This class represents a frame that has been fully configured for the
23// underlying client rendering API. A frame may only be submitted once.
25 public:
27 std::function<bool(SurfaceFrame& surface_frame, DlCanvas* canvas)>;
28
29 // Information about the underlying framebuffer
31 // Indicates whether or not the surface supports pixel readback as used in
32 // circumstances such as a BackdropFilter.
33 bool supports_readback = false;
34
35 // Indicates that target device supports partial repaint. At very minimum
36 // this means that the surface will provide valid existing damage.
38
39 // For some targets it may be beneficial or even required to snap clip
40 // rect to tile grid. I.e. repainting part of a tile may cause performance
41 // degradation if the tile needs to be decompressed first.
44
45 // This is the area of framebuffer that lags behind the front buffer.
46 //
47 // Correctly providing exiting_damage is necessary for supporting double and
48 // triple buffering. Embedder is responsible for tracking this area for each
49 // of the back buffers used. When doing partial redraw, this area will be
50 // repainted alongside of dirty area determined by diffing current and
51 // last successfully rasterized layer tree;
52 //
53 // If existing damage is unspecified (nullopt), entire frame will be
54 // rasterized (no partial redraw). To signal that there is no existing
55 // damage use an empty SkIRect.
56 std::optional<SkIRect> existing_damage = std::nullopt;
57 };
58
61 const SubmitCallback& submit_callback,
62 SkISize frame_size,
63 std::unique_ptr<GLContextResult> context_result = nullptr,
64 bool display_list_fallback = false);
65
66 struct SubmitInfo {
67 // The frame damage for frame n is the difference between frame n and
68 // frame (n-1), and represents the area that a compositor must recompose.
69 //
70 // Corresponds to EGL_KHR_swap_buffers_with_damage
71 std::optional<SkIRect> frame_damage;
72
73 // The buffer damage for a frame is the area changed since that same buffer
74 // was last used. If the buffer has not been used before, the buffer damage
75 // is the entire area of the buffer.
76 //
77 // Corresponds to EGL_KHR_partial_update
78 std::optional<SkIRect> buffer_damage;
79
80 // Time at which this frame is scheduled to be presented. This is a hint
81 // that can be passed to the platform to drop queued frames.
82 std::optional<fml::TimePoint> presentation_time;
83 };
84
85 bool Submit();
86
87 bool IsSubmitted() const;
88
90
92
93 const FramebufferInfo& framebuffer_info() const { return framebuffer_info_; }
94
96 submit_info_ = submit_info;
97 }
98 const SubmitInfo& submit_info() const { return submit_info_; }
99
101
102 private:
103 bool submitted_ = false;
104
105 DlSkCanvasAdapter adapter_;
106 sk_sp<DisplayListBuilder> dl_builder_;
107 sk_sp<SkSurface> surface_;
108 DlCanvas* canvas_ = nullptr;
109 FramebufferInfo framebuffer_info_;
110 SubmitInfo submit_info_;
111 SubmitCallback submit_callback_;
112 std::unique_ptr<GLContextResult> context_result_;
113
114 bool PerformSubmit();
115
117};
118
119} // namespace flutter
120
121#endif // FLUTTER_FLOW_SURFACE_FRAME_H_
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
Backend implementation of |DlCanvas| for |SkCanvas|.
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> SubmitCallback
void set_submit_info(const SubmitInfo &submit_info)
sk_sp< DisplayList > BuildDisplayList()
sk_sp< SkSurface > SkiaSurface() const
const FramebufferInfo & framebuffer_info() const
const SubmitInfo & submit_info() const
VkSurfaceKHR surface
Definition main.cc:49
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::optional< SkIRect > existing_damage
std::optional< SkIRect > frame_damage
std::optional< fml::TimePoint > presentation_time
std::optional< SkIRect > buffer_damage