Flutter Engine
android_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_SHELL_PLATFORM_ANDROID_ANDROID_NATIVE_WINDOW_H_
6 #define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_NATIVE_WINDOW_H_
7 
8 #include "flutter/fml/build_config.h"
9 
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/memory/ref_counted.h"
12 #include "third_party/skia/include/core/SkSize.h"
13 
14 #if OS_ANDROID
15 #include <android/native_window.h>
16 #endif // OS_ANDROID
17 
18 namespace flutter {
19 
21  : public fml::RefCountedThreadSafe<AndroidNativeWindow> {
22  public:
23 #if OS_ANDROID
24  using Handle = ANativeWindow*;
25 #else // OS_ANDROID
26  using Handle = std::nullptr_t;
27 #endif // OS_ANDROID
28 
29  bool IsValid() const;
30 
31  Handle handle() const;
32 
33  SkISize GetSize() const;
34 
35  /// Returns true when this AndroidNativeWindow is not backed by a real window
36  /// (used for testing).
37  bool IsFakeWindow() const { return is_fake_window_; }
38 
39  private:
40  Handle window_;
41  const bool is_fake_window_;
42 
43  /// Creates a native window with the given handle. Handle ownership is assumed
44  /// by this instance of the native window.
45  explicit AndroidNativeWindow(Handle window);
46 
47  explicit AndroidNativeWindow(Handle window, bool is_fake_window);
48 
50 
51  FML_FRIEND_MAKE_REF_COUNTED(AndroidNativeWindow);
52  FML_FRIEND_REF_COUNTED_THREAD_SAFE(AndroidNativeWindow);
53  FML_DISALLOW_COPY_AND_ASSIGN(AndroidNativeWindow);
54 };
55 
56 } // namespace flutter
57 
58 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_NATIVE_WINDOW_H_
struct ANativeWindow ANativeWindow