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
) {
29 java::sdk::Surface::LocalRef surf
= aSurface
->GetSurface();
31 ANativeWindow_fromSurface(jni::GetEnvForThread(), surf
.Get());
34 ~AndroidNativeWindow() {
36 ANativeWindow_release(mNativeWindow
);
37 mNativeWindow
= nullptr;
41 ANativeWindow
* NativeWindow() const { return mNativeWindow
; }
44 ANativeWindow
* mNativeWindow
;
48 } // namespace mozilla
50 #endif // AndroidNativeWindow_h__