Flutter Engine
shell_test_external_view_embedder.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_TEST_EXTERNAL_VIEW_EMBEDDER_H_
6 #define FLUTTER_SHELL_TEST_EXTERNAL_VIEW_EMBEDDER_H_
7 
8 #include "flutter/flow/embedded_views.h"
9 #include "flutter/fml/raster_thread_merger.h"
10 
11 namespace flutter {
12 
13 //------------------------------------------------------------------------------
14 /// @brief The external view embedder used by |ShellTestPlatformViewGL|
15 ///
17  public:
18  using EndFrameCallBack =
19  std::function<void(bool, fml::RefPtr<fml::RasterThreadMerger>)>;
20 
21  ShellTestExternalViewEmbedder(const EndFrameCallBack& end_frame_call_back,
22  PostPrerollResult post_preroll_result,
23  bool support_thread_merging);
24 
26 
27  // Updates the post preroll result so the |PostPrerollAction| after always
28  // returns the new `post_preroll_result`.
29  void UpdatePostPrerollResult(PostPrerollResult post_preroll_result);
30 
31  // Gets the number of times the SubmitFrame method has been called in
32  // the external view embedder.
34 
35  // Returns the size of last submitted frame surface
36  SkISize GetLastSubmittedFrameSize();
37 
38  private:
39  // |ExternalViewEmbedder|
40  void CancelFrame() override;
41 
42  // |ExternalViewEmbedder|
43  void BeginFrame(
44  SkISize frame_size,
45  GrDirectContext* context,
46  double device_pixel_ratio,
47  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
48 
49  // |ExternalViewEmbedder|
50  void PrerollCompositeEmbeddedView(
51  int view_id,
52  std::unique_ptr<EmbeddedViewParams> params) override;
53 
54  // |ExternalViewEmbedder|
55  PostPrerollResult PostPrerollAction(
56  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
57 
58  // |ExternalViewEmbedder|
59  std::vector<SkCanvas*> GetCurrentCanvases() override;
60 
61  // |ExternalViewEmbedder|
62  SkCanvas* CompositeEmbeddedView(int view_id) override;
63 
64  // |ExternalViewEmbedder|
65  void SubmitFrame(GrDirectContext* context,
66  std::unique_ptr<SurfaceFrame> frame) override;
67 
68  // |ExternalViewEmbedder|
69  void EndFrame(
70  bool should_resubmit_frame,
71  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
72 
73  // |ExternalViewEmbedder|
74  SkCanvas* GetRootCanvas() override;
75 
76  // |ExternalViewEmbedder|
77  bool SupportsDynamicThreadMerging() override;
78 
79  const EndFrameCallBack end_frame_call_back_;
80 
81  PostPrerollResult post_preroll_result_;
82 
83  bool support_thread_merging_;
84 
85  std::atomic<int> submitted_frame_count_;
86  std::atomic<SkISize> last_submitted_frame_size_;
87 
88  FML_DISALLOW_COPY_AND_ASSIGN(ShellTestExternalViewEmbedder);
89 };
90 
91 } // namespace flutter
92 
93 #endif // FLUTTER_SHELL_TEST_EXTERNAL_VIEW_EMBEDDER_H_
ShellTestExternalViewEmbedder(const EndFrameCallBack &end_frame_call_back, PostPrerollResult post_preroll_result, bool support_thread_merging)
The external view embedder used by |ShellTestPlatformViewGL|.
std::function< void(bool, fml::RefPtr< fml::RasterThreadMerger >)> EndFrameCallBack
void UpdatePostPrerollResult(PostPrerollResult post_preroll_result)