Flutter Impeller
native_window.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_NATIVE_WINDOW_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_ANDROID_NATIVE_WINDOW_H_
7 
8 #include "flutter/fml/unique_object.h"
11 
12 namespace impeller::android {
13 
14 //------------------------------------------------------------------------------
15 /// @brief A wrapper for ANativeWindow
16 /// https://developer.android.com/ndk/reference/group/a-native-window
17 ///
18 /// This wrapper is only available on Android.
19 ///
20 class NativeWindow {
21  public:
22  explicit NativeWindow(ANativeWindow* window);
23 
25 
26  NativeWindow(const NativeWindow&) = delete;
27 
28  NativeWindow& operator=(const NativeWindow&) = delete;
29 
30  bool IsValid() const;
31 
32  //----------------------------------------------------------------------------
33  /// @return The current size of the native window.
34  ///
35  ISize GetSize() const;
36 
37  ANativeWindow* GetHandle() const;
38 
39  private:
40  struct UniqueANativeWindowTraits {
41  static ANativeWindow* InvalidValue() { return nullptr; }
42 
43  static bool IsValid(ANativeWindow* value) {
44  return value != InvalidValue();
45  }
46 
47  static void Free(ANativeWindow* value) {
48  GetProcTable().ANativeWindow_release(value);
49  }
50  };
51 
52  fml::UniqueObject<ANativeWindow*, UniqueANativeWindowTraits> window_;
53 };
54 
55 } // namespace impeller::android
56 
57 #endif // FLUTTER_IMPELLER_TOOLKIT_ANDROID_NATIVE_WINDOW_H_
A wrapper for ANativeWindow https://developer.android.com/ndk/reference/group/a-native-window.
Definition: native_window.h:20
NativeWindow & operator=(const NativeWindow &)=delete
ANativeWindow * GetHandle() const
NativeWindow(ANativeWindow *window)
Definition: native_window.cc:9
NativeWindow(const NativeWindow &)=delete
int32_t value
const ProcTable & GetProcTable()
Definition: proc_table.cc:12