Flutter Engine
The Flutter Engine
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 /// This is called implicitly when the surface control is
64 /// collected.
65 ///
66 /// @return `true` If the control will be removed from the hierarchy of
67 /// nodes presented by the system compositor.
68 ///
69 bool RemoveFromParent() const;
70
71 private:
72 struct UniqueASurfaceControlTraits {
73 static ASurfaceControl* InvalidValue() { return nullptr; }
74
75 static bool IsValid(ASurfaceControl* value) {
76 return value != InvalidValue();
77 }
78
79 static void Free(ASurfaceControl* value) {
80 GetProcTable().ASurfaceControl_release(value);
81 }
82 };
83
85};
86
87} // namespace impeller::android
88
89#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...
SurfaceControl(ANativeWindow *window, const char *debug_name=nullptr)
Creates a new surface control and adds it as a child of the given window.
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
static void Free(FreeList *free_list, uword address, intptr_t size, bool is_protected)
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
struct ANativeWindow ANativeWindow