| 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"
9 #include "impeller/geometry/size.h"
10 #include "impeller/toolkit/android/proc_table.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
24 ~NativeWindow();
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_
impeller::android::NativeWindow
A wrapper for ANativeWindow https://developer.android.com/ndk/reference/group/a-native-window.
Definition: native_window.h:20
impeller::android::NativeWindow::GetHandle
ANativeWindow * GetHandle() const
Definition: native_window.cc:30
impeller::android
Definition: choreographer.cc:9
impeller::android::NativeWindow::NativeWindow
NativeWindow(ANativeWindow *window)
Definition: native_window.cc:9
impeller::TSize
Definition: size.h:19
impeller::android::NativeWindow::GetSize
ISize GetSize() const
Definition: native_window.cc:21
proc_table.h
impeller::android::NativeWindow::~NativeWindow
~NativeWindow()
impeller::android::NativeWindow::operator=
NativeWindow & operator=(const NativeWindow &)=delete
impeller::android::NativeWindow::IsValid
bool IsValid() const
Definition: native_window.cc:17
impeller::android::GetProcTable
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
size.h