mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
04d1292832
Due to a bug on versions of Android prior to 8.0, attempting to create a SurfaceTexture from an isolated process results in an infinite hang. We must therefore avoid doing this. We currently create a dummy SurfaceTexture in order to call the Surface constructor when instantiating a GeckoSurface from a Parcel. This patch avoids this by making GeckoSurface own a Surface rather than inherit from one. Additionally, for every Surface allocated we create a corresponding "sync" SurfaceTexture in the content processes. This is used when the texture data is required in the content process, eg using video as a WebGL texture upload source. This patch prevents us allocating such SurfaceTextures. If out-of-process WebGL is enabled, video data can still be used as a texture upload source as WebGL resides in the GPU process. However, if out-of-process WebGL is disabled the texture upload will fail. Prior to shipping isolated content processes on affected Android versions, we must therefore ensure we have an alternative solution to using video as a WebGL texture upload source, or that out-of-process WebGL can be relied upon. Differential Revision: https://phabricator.services.mozilla.com/D165970
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
// vim:set ts=2 sts=2 sw=2 et cin:
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef AndroidNativeWindow_h__
|
|
#define AndroidNativeWindow_h__
|
|
|
|
#include <jni.h>
|
|
#include <android/native_window.h>
|
|
#include <android/native_window_jni.h>
|
|
#include "mozilla/java/GeckoSurfaceWrappers.h"
|
|
#include "SurfaceTexture.h"
|
|
|
|
namespace mozilla {
|
|
namespace gl {
|
|
|
|
class AndroidNativeWindow final {
|
|
public:
|
|
AndroidNativeWindow() : mNativeWindow(nullptr) {}
|
|
|
|
explicit AndroidNativeWindow(java::sdk::Surface::Param aSurface) {
|
|
mNativeWindow =
|
|
ANativeWindow_fromSurface(jni::GetEnvForThread(), aSurface.Get());
|
|
}
|
|
|
|
explicit AndroidNativeWindow(java::GeckoSurface::Param aSurface) {
|
|
java::sdk::Surface::LocalRef surf = aSurface->GetSurface();
|
|
mNativeWindow =
|
|
ANativeWindow_fromSurface(jni::GetEnvForThread(), surf.Get());
|
|
}
|
|
|
|
~AndroidNativeWindow() {
|
|
if (mNativeWindow) {
|
|
ANativeWindow_release(mNativeWindow);
|
|
mNativeWindow = nullptr;
|
|
}
|
|
}
|
|
|
|
ANativeWindow* NativeWindow() const { return mNativeWindow; }
|
|
|
|
private:
|
|
ANativeWindow* mNativeWindow;
|
|
};
|
|
|
|
} // namespace gl
|
|
} // namespace mozilla
|
|
|
|
#endif // AndroidNativeWindow_h__
|