1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:set ts=2 sts=2 sw=2 et cin:
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef AndroidNativeWindow_h__
8 #define AndroidNativeWindow_h__
11 #include <android/native_window.h>
12 #include <android/native_window_jni.h>
13 #include "mozilla/java/GeckoSurfaceWrappers.h"
14 #include "SurfaceTexture.h"
19 class AndroidNativeWindow final
{
21 AndroidNativeWindow() : mNativeWindow(nullptr) {}
23 explicit AndroidNativeWindow(java::sdk::Surface::Param aSurface
) {
25 ANativeWindow_fromSurface(jni::GetEnvForThread(), aSurface
.Get());
28 explicit AndroidNativeWindow(java::GeckoSurface::Param aSurface
) {
30 java::sdk::Surface::LocalRef(java::sdk::Surface::Ref::From(aSurface
));
32 ANativeWindow_fromSurface(jni::GetEnvForThread(), surf
.Get());
35 ~AndroidNativeWindow() {
37 ANativeWindow_release(mNativeWindow
);
38 mNativeWindow
= nullptr;
42 ANativeWindow
* NativeWindow() const { return mNativeWindow
; }
45 ANativeWindow
* mNativeWindow
;
49 } // namespace mozilla
51 #endif // AndroidNativeWindow_h__