Flutter Engine
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 
10 #include "flutter/flow/gl_context_switch.h"
11 #include "flutter/fml/macros.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkSurface.h"
14 
15 namespace flutter {
16 
17 // This class represents a frame that has been fully configured for the
18 // underlying client rendering API. A frame may only be submitted once.
19 class SurfaceFrame {
20  public:
21  using SubmitCallback =
22  std::function<bool(const SurfaceFrame& surface_frame, SkCanvas* canvas)>;
23 
24  SurfaceFrame(sk_sp<SkSurface> surface,
25  bool supports_readback,
26  const SubmitCallback& submit_callback);
27 
28  SurfaceFrame(sk_sp<SkSurface> surface,
29  bool supports_readback,
30  const SubmitCallback& submit_callback,
31  std::unique_ptr<GLContextResult> context_result);
32 
33  ~SurfaceFrame();
34 
35  bool Submit();
36 
37  bool IsSubmitted() const;
38 
39  SkCanvas* SkiaCanvas();
40 
41  sk_sp<SkSurface> SkiaSurface() const;
42 
43  bool supports_readback() { return supports_readback_; }
44 
45  private:
46  bool submitted_ = false;
47  sk_sp<SkSurface> surface_;
48  bool supports_readback_;
49  SubmitCallback submit_callback_;
50  std::unique_ptr<GLContextResult> context_result_;
51 
52  bool PerformSubmit();
53 
54  FML_DISALLOW_COPY_AND_ASSIGN(SurfaceFrame);
55 };
56 
57 } // namespace flutter
58 
59 #endif // FLUTTER_FLOW_SURFACE_FRAME_H_
std::function< bool(const SurfaceFrame &surface_frame, SkCanvas *canvas)> SubmitCallback
Definition: surface_frame.h:22
SkCanvas * SkiaCanvas()
sk_sp< SkSurface > SkiaSurface() const
bool IsSubmitted() const
SurfaceFrame(sk_sp< SkSurface > surface, bool supports_readback, const SubmitCallback &submit_callback)