Bug 1785744 [wpt PR 35504] - Recalc style for elements where :toggle() pseudo-class...
[gecko.git] / gfx / gl / AndroidNativeWindow.h
blobe602be7a3f827a93931bf3bdf642146552259530
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 auto surf =
30 java::sdk::Surface::LocalRef(java::sdk::Surface::Ref::From(aSurface));
31 mNativeWindow =
32 ANativeWindow_fromSurface(jni::GetEnvForThread(), surf.Get());
35 ~AndroidNativeWindow() {
36 if (mNativeWindow) {
37 ANativeWindow_release(mNativeWindow);
38 mNativeWindow = nullptr;
42 ANativeWindow* NativeWindow() const { return mNativeWindow; }
44 private:
45 ANativeWindow* mNativeWindow;
48 } // namespace gl
49 } // namespace mozilla
51 #endif // AndroidNativeWindow_h__