Flutter Impeller
native_window.cc
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 
6 
7 namespace impeller::android {
8 
9 NativeWindow::NativeWindow(ANativeWindow* window) : window_(window) {
10  if (window_.get()) {
11  GetProcTable().ANativeWindow_acquire(window_.get());
12  }
13 }
14 
15 NativeWindow::~NativeWindow() = default;
16 
17 bool NativeWindow::IsValid() const {
18  return window_.is_valid();
19 }
20 
22  if (!IsValid()) {
23  return {};
24  }
25  const int32_t width = ANativeWindow_getWidth(window_.get());
26  const int32_t height = ANativeWindow_getHeight(window_.get());
27  return ISize::MakeWH(std::max(width, 0), std::max(height, 0));
28 }
29 
30 ANativeWindow* NativeWindow::GetHandle() const {
31  return window_.get();
32 }
33 
34 } // namespace impeller::android
ANativeWindow * GetHandle() const
NativeWindow(ANativeWindow *window)
Definition: native_window.cc:9
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
static constexpr TSize MakeWH(Type width, Type height)
Definition: size.h:43