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 <android/native_window.h> 9 #include "flutter/fml/macros.h" 10 #include "flutter/fml/memory/ref_counted.h" 11 #include "flutter/fml/memory/ref_ptr.h" 12 #include "third_party/skia/include/core/SkSize.h" 13 14 namespace flutter { 15 16 class AndroidNativeWindow 17 : public fml::RefCountedThreadSafe<AndroidNativeWindow> { 18 public: 19 using Handle = ANativeWindow*; 20 21 bool IsValid() const; 22 23 Handle handle() const; 24 25 SkISize GetSize() const; 26 27 private: 28 Handle window_; 29 30 /// Creates a native window with the given handle. Handle ownership is assumed 31 /// by this instance of the native window. 32 explicit AndroidNativeWindow(Handle window); 33 34 ~AndroidNativeWindow(); 35 36 FML_FRIEND_MAKE_REF_COUNTED(AndroidNativeWindow); 37 FML_FRIEND_REF_COUNTED_THREAD_SAFE(AndroidNativeWindow); 38 FML_DISALLOW_COPY_AND_ASSIGN(AndroidNativeWindow); 39 }; 40 41 } // namespace flutter 42 43 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_NATIVE_WINDOW_H_ 44