• 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_PLATFORM_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
7 
8 #include "flutter/fml/closure.h"
9 #include "flutter/fml/macros.h"
10 #include "flutter/shell/platform/embedder/embedder.h"
11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkSurface.h"
13 
14 namespace flutter {
15 
16 //------------------------------------------------------------------------------
17 /// @brief      Describes a surface whose backing store is managed by the
18 ///             embedder. The type of surface depends on the client rendering
19 ///             API used. The embedder is notified of the collection of this
20 ///             render target via a callback.
21 ///
22 class EmbedderRenderTarget {
23  public:
24   //----------------------------------------------------------------------------
25   /// @brief      Creates a render target whose backing store is managed by the
26   ///             embedder. The way this render target is exposed to the engine
27   ///             is via an SkSurface and a callback that is invoked by this
28   ///             object in its destructor.
29   ///
30   /// @param[in]  backing_store   The backing store describing this render
31   ///                             target.
32   /// @param[in]  render_surface  The surface for this target.
33   /// @param[in]  on_release      The callback to invoke (eventually forwarded
34   ///                             to the embedder) when the backing store is no
35   ///                             longer required by the engine.
36   ///
37   EmbedderRenderTarget(FlutterBackingStore backing_store,
38                        sk_sp<SkSurface> render_surface,
39                        fml::closure on_release);
40 
41   //----------------------------------------------------------------------------
42   /// @brief      Destroys this instance of the render target and invokes the
43   ///             callback for the embedder to release its resource associated
44   ///             with the particular backing store.
45   ///
46   ~EmbedderRenderTarget();
47 
48   //----------------------------------------------------------------------------
49   /// @brief      A render surface the rasterizer can use to draw into the
50   ///             backing store of this render target.
51   ///
52   /// @return     The render surface.
53   ///
54   sk_sp<SkSurface> GetRenderSurface();
55 
56   //----------------------------------------------------------------------------
57   /// @brief      The embedder backing store descriptor. This is the descriptor
58   ///             that was given to the engine by the embedder. This descriptor
59   ///             may contain context the embedder can use to associate it
60   ///             resources with the compositor layers when they are given back
61   ///             to it in present callback. The engine does not use this in any
62   ///             way.
63   ///
64   /// @return     The backing store.
65   ///
66   const FlutterBackingStore* GetBackingStore() const;
67 
68  private:
69   FlutterBackingStore backing_store_;
70   sk_sp<SkSurface> render_surface_;
71   fml::closure on_release_;
72 
73   FML_DISALLOW_COPY_AND_ASSIGN(EmbedderRenderTarget);
74 };
75 
76 }  // namespace flutter
77 
78 #endif  // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
79