Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
surface_control.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_IMPELLER_TOOLKIT_ANDROID_SURFACE_CONTROL_H_
6#define FLUTTER_IMPELLER_TOOLKIT_ANDROID_SURFACE_CONTROL_H_
7
8#include "flutter/fml/unique_object.h"
10
11namespace impeller::android {
12
13//------------------------------------------------------------------------------
14/// @brief A wrapper for ASurfaceControl.
15/// https://developer.android.com/ndk/reference/group/native-activity#asurfacecontrol
16///
17/// Instances of this class represent a node in the hierarchy of
18/// surfaces sent to the system compositor for final composition.
19///
20/// This wrapper is only available on Android API 29 and above.
21///
23 public:
24 //----------------------------------------------------------------------------
25 /// @return `true` if any surface controls can be created on this
26 /// platform.
27 ///
28 static bool IsAvailableOnPlatform();
29
30 //----------------------------------------------------------------------------
31 /// @brief Creates a new surface control and adds it as a child of the
32 /// given window.
33 ///
34 /// @param window The window
35 /// @param[in] debug_name A debug name. See it using
36 /// `adb shell dumpsys SurfaceFlinger` along with
37 /// other control properties. If no debug name is
38 /// specified, the value "Impeller Layer" is used.
39 ///
41 const char* debug_name = nullptr);
42
43 //----------------------------------------------------------------------------
44 /// @brief Removes the surface control from the presentation hierarchy
45 /// managed by the system compositor and release the client side
46 /// reference to the control. At this point, it may be collected
47 /// when the compositor is also done using it.
48 ///
50
52
54
55 bool IsValid() const;
56
57 ASurfaceControl* GetHandle() const;
58
59 //----------------------------------------------------------------------------
60 /// @brief Remove the surface control from the hierarchy of nodes
61 /// presented by the system compositor.
62 ///
63 /// @return `true` If the control will be removed from the hierarchy of
64 /// nodes presented by the system compositor.
65 ///
66 bool RemoveFromParent() const;
67
68 private:
69 struct UniqueASurfaceControlTraits {
70 static ASurfaceControl* InvalidValue() { return nullptr; }
71
72 static bool IsValid(ASurfaceControl* value) {
73 return value != InvalidValue();
74 }
75
76 static void Free(ASurfaceControl* value) {
77 GetProcTable().ASurfaceControl_release(value);
78 }
79 };
80
82};
83
84} // namespace impeller::android
85
86#endif // FLUTTER_IMPELLER_TOOLKIT_ANDROID_SURFACE_CONTROL_H_
A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asur...
SurfaceControl(const SurfaceControl &)=delete
~SurfaceControl()
Removes the surface control from the presentation hierarchy managed by the system compositor and rele...
bool RemoveFromParent() const
Remove the surface control from the hierarchy of nodes presented by the system compositor.
SurfaceControl & operator=(const SurfaceControl &)=delete
ASurfaceControl * GetHandle() const
GLFWwindow * window
Definition main.cc:45
uint8_t value
const ProcTable & GetProcTable()
Definition proc_table.cc:12
struct ANativeWindow ANativeWindow