• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SOFTWARE_DELEGATE_H_
6 #define FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_
7 
8 #include "flutter/flow/embedded_views.h"
9 #include "flutter/fml/macros.h"
10 #include "third_party/skia/include/core/SkSurface.h"
11 
12 namespace flutter {
13 
14 //------------------------------------------------------------------------------
15 /// @brief      Interface implemented by all platform surfaces that can present
16 ///             a software backing store to the "screen". The GPU surface
17 ///             abstraction (which abstracts the client rendering API) uses this
18 ///             delegation pattern to tell the platform surface (which abstracts
19 ///             how backing stores fulfilled by the selected client rendering
20 ///             API end up on the "screen" on a particular platform) when the
21 ///             rasterizer needs to allocate and present the software backing
22 ///             store.
23 ///
24 /// @see        |IOSurfaceSoftware|, |AndroidSurfaceSoftware|,
25 ///             |EmbedderSurfaceSoftware|.
26 ///
27 class GPUSurfaceSoftwareDelegate {
28  public:
29   //----------------------------------------------------------------------------
30   /// @brief      Called when the GPU surface needs a new buffer to render a new
31   ///             frame into.
32   ///
33   /// @param[in]  size  The size of the frame.
34   ///
35   /// @return     A raster surface returned by the platform.
36   ///
37   virtual sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) = 0;
38 
39   //----------------------------------------------------------------------------
40   /// @brief      Called by the platform when a frame has been rendered into the
41   ///             backing store and the platform must display it on-screen.
42   ///
43   /// @param[in]  backing_store  The software backing store to present.
44   ///
45   /// @return     Returns if the platform could present the backing store onto
46   ///             the screen.
47   ///
48   virtual bool PresentBackingStore(sk_sp<SkSurface> backing_store) = 0;
49 
50   //----------------------------------------------------------------------------
51   /// @brief      Gets the view embedder that controls how the Flutter layer
52   ///             hierarchy split into multiple chunks should be composited back
53   ///             on-screen. This field is optional and the Flutter rasterizer
54   ///             will render into a single on-screen surface if this call
55   ///             returns a null external view embedder.
56   ///
57   /// @return     The external view embedder, or, null if Flutter is rendering
58   ///             into a single on-screen surface.
59   ///
60   virtual ExternalViewEmbedder* GetExternalViewEmbedder() = 0;
61 };
62 
63 }  // namespace flutter
64 
65 #endif  // FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_
66