Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / gl / AndroidNativeWindow.h
bloba45fccc0998147ccbc8f1c1d0554af3ac7844b0d
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__
10 #include <jni.h>
11 #include <android/native_window.h>
12 #include <android/native_window_jni.h>
13 #include "mozilla/java/GeckoSurfaceWrappers.h"
14 #include "SurfaceTexture.h"
16 namespace mozilla {
17 namespace gl {
19 class AndroidNativeWindow final {
20 public:
21 AndroidNativeWindow() : mNativeWindow(nullptr) {}
23 explicit AndroidNativeWindow(java::sdk::Surface::Param aSurface) {
24 mNativeWindow =
25 ANativeWindow_fromSurface(jni::GetEnvForThread(), aSurface.Get());
28 explicit AndroidNativeWindow(java::GeckoSurface::Param aSurface) {
29 java::sdk::Surface::LocalRef surf = aSurface->GetSurface();
30 mNativeWindow =
31 ANativeWindow_fromSurface(jni::GetEnvForThread(), surf.Get());
34 ~AndroidNativeWindow() {
35 if (mNativeWindow) {
36 ANativeWindow_release(mNativeWindow);
37 mNativeWindow = nullptr;
41 ANativeWindow* NativeWindow() const { return mNativeWindow; }
43 private:
44 ANativeWindow* mNativeWindow;
47 } // namespace gl
48 } // namespace mozilla
50 #endif // AndroidNativeWindow_h__