Backed out changeset 290917deea87 (bug 1866020) for wrench bustages. CLOSED TREE

This commit is contained in:
Narcis Beleuzu 2023-12-13 11:49:40 +02:00
parent 399de5a9a6
commit 4211076193
18 changed files with 33 additions and 120 deletions

View File

@ -67,17 +67,6 @@ class RenderOrReleaseOutput {
java::Sample::GlobalRef mSample;
};
static bool areSmpte432ColorPrimariesBuggy() {
if (jni::GetAPIVersion() >= 34) {
const auto socManufacturer =
java::sdk::Build::SOC_MANUFACTURER()->ToString();
if (socManufacturer.EqualsASCII("Google")) {
return true;
}
}
return false;
}
class RemoteVideoDecoder final : public RemoteDataDecoder {
public:
// Render the output to the surface when the frame is sent
@ -413,16 +402,9 @@ class RemoteVideoDecoder final : public RemoteDataDecoder {
}
if (ok && (size > 0 || presentationTimeUs >= 0)) {
// On certain devices SMPTE 432 color primaries are rendered incorrectly,
// so we force BT709 to be used instead. The magic number 10 comes from
// libstagefright's kColorStandardDCI_P3.
static bool isSmpte432Buggy = areSmpte432ColorPrimariesBuggy();
bool forceBT709ColorSpace = isSmpte432Buggy && mColorSpace == Some(10);
RefPtr<layers::Image> img = new layers::SurfaceTextureImage(
mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
gl::OriginPos::BottomLeft, mConfig.HasAlpha(), forceBT709ColorSpace,
mTransformOverride);
gl::OriginPos::BottomLeft, mConfig.HasAlpha(), mTransformOverride);
img->AsSurfaceTextureImage()->RegisterSetCurrentCallback(
std::move(releaseSample));

View File

@ -254,8 +254,7 @@ Maybe<layers::SurfaceDescriptor>
SharedSurface_SurfaceTexture::ToSurfaceDescriptor() {
return Some(layers::SurfaceTextureDescriptor(
mSurface->GetHandle(), mDesc.size, gfx::SurfaceFormat::R8G8B8A8,
false /* Do NOT override colorspace */, false /* NOT continuous */,
Nothing() /* Do not override transform */));
false /* NOT continuous */, Nothing() /* Do not override transform */));
}
SurfaceFactory_SurfaceTexture::SurfaceFactory_SurfaceTexture(GLContext& gl)

View File

@ -111,14 +111,13 @@ nsresult GLImage::BuildSurfaceDescriptorBuffer(
SurfaceTextureImage::SurfaceTextureImage(
AndroidSurfaceTextureHandle aHandle, const gfx::IntSize& aSize,
bool aContinuous, gl::OriginPos aOriginPos, bool aHasAlpha,
bool aForceBT709ColorSpace, Maybe<gfx::Matrix4x4> aTransformOverride)
Maybe<gfx::Matrix4x4> aTransformOverride)
: GLImage(ImageFormat::SURFACE_TEXTURE),
mHandle(aHandle),
mSize(aSize),
mContinuous(aContinuous),
mOriginPos(aOriginPos),
mHasAlpha(aHasAlpha),
mForceBT709ColorSpace(aForceBT709ColorSpace),
mTransformOverride(aTransformOverride) {
MOZ_ASSERT(mHandle);
}
@ -127,7 +126,7 @@ Maybe<SurfaceDescriptor> SurfaceTextureImage::GetDesc() {
SurfaceDescriptor sd = SurfaceTextureDescriptor(
mHandle, mSize,
mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::R8G8B8X8,
mForceBT709ColorSpace, false /* NOT continuous */, mTransformOverride);
false /* NOT continuous */, mTransformOverride);
return Some(sd);
}
#endif

View File

@ -54,7 +54,6 @@ class SurfaceTextureImage final : public GLImage {
SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle,
const gfx::IntSize& aSize, bool aContinuous,
gl::OriginPos aOriginPos, bool aHasAlpha,
bool aForceBT709ColorSpace,
Maybe<gfx::Matrix4x4> aTransformOverride);
gfx::IntSize GetSize() const override { return mSize; }
@ -62,7 +61,6 @@ class SurfaceTextureImage final : public GLImage {
bool GetContinuous() const { return mContinuous; }
gl::OriginPos GetOriginPos() const { return mOriginPos; }
bool GetHasAlpha() const { return mHasAlpha; }
bool GetForceBT709ColorSpace() const { return mForceBT709ColorSpace; }
const Maybe<gfx::Matrix4x4>& GetTransformOverride() const {
return mTransformOverride;
}
@ -104,7 +102,6 @@ class SurfaceTextureImage final : public GLImage {
bool mContinuous;
gl::OriginPos mOriginPos;
const bool mHasAlpha;
const bool mForceBT709ColorSpace;
const Maybe<gfx::Matrix4x4> mTransformOverride;
UniquePtr<SetCurrentCallback> mSetCurrentCallback;
};

View File

@ -120,7 +120,6 @@ already_AddRefed<TextureClient> ImageClient::CreateTextureClientForImage(
texture = AndroidSurfaceTextureData::CreateTextureClient(
typedImage->GetHandle(), size, typedImage->GetContinuous(),
typedImage->GetOriginPos(), typedImage->GetHasAlpha(),
typedImage->GetForceBT709ColorSpace(),
typedImage->GetTransformOverride(),
aKnowsCompositor->GetTextureForwarder(), TextureFlags::DEFAULT);
#endif

View File

@ -88,7 +88,6 @@ namespace layers {
IntSize size;
SurfaceFormat format;
bool continuous;
bool forceBT709ColorSpace;
Matrix4x4? transformOverride;
};

View File

@ -38,7 +38,7 @@ class CompositableForwarder;
already_AddRefed<TextureClient> AndroidSurfaceTextureData::CreateTextureClient(
AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous,
gl::OriginPos aOriginPos, bool aHasAlpha, bool aForceBT709ColorSpace,
gl::OriginPos aOriginPos, bool aHasAlpha,
Maybe<gfx::Matrix4x4> aTransformOverride, LayersIPCChannel* aAllocator,
TextureFlags aFlags) {
if (aOriginPos == gl::OriginPos::BottomLeft) {
@ -47,19 +47,17 @@ already_AddRefed<TextureClient> AndroidSurfaceTextureData::CreateTextureClient(
return TextureClient::CreateWithData(
new AndroidSurfaceTextureData(aHandle, aSize, aContinuous, aHasAlpha,
aForceBT709ColorSpace, aTransformOverride),
aTransformOverride),
aFlags, aAllocator);
}
AndroidSurfaceTextureData::AndroidSurfaceTextureData(
AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous,
bool aHasAlpha, bool aForceBT709ColorSpace,
Maybe<gfx::Matrix4x4> aTransformOverride)
bool aHasAlpha, Maybe<gfx::Matrix4x4> aTransformOverride)
: mHandle(aHandle),
mSize(aSize),
mContinuous(aContinuous),
mHasAlpha(aHasAlpha),
mForceBT709ColorSpace(aForceBT709ColorSpace),
mTransformOverride(aTransformOverride) {
MOZ_ASSERT(mHandle);
}
@ -78,7 +76,7 @@ bool AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
aOutDescriptor = SurfaceTextureDescriptor(
mHandle, mSize,
mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::R8G8B8X8,
mContinuous, mForceBT709ColorSpace, mTransformOverride);
mContinuous, mTransformOverride);
return true;
}
@ -161,7 +159,6 @@ bool AndroidNativeWindowTextureData::Serialize(
SurfaceDescriptor& aOutDescriptor) {
aOutDescriptor = SurfaceTextureDescriptor(
mSurface->GetHandle(), mSize, mFormat, false /* not continuous */,
false /* do not override colorspace */,
Some(gfx::Matrix4x4()) /* always use identity transform */);
return true;
}

View File

@ -41,7 +41,7 @@ class AndroidSurfaceTextureData : public TextureData {
public:
static already_AddRefed<TextureClient> CreateTextureClient(
AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous,
gl::OriginPos aOriginPos, bool aHasAlpha, bool aForceBT709ColorSpace,
gl::OriginPos aOriginPos, bool aHasAlpha,
Maybe<gfx::Matrix4x4> aTransformOverride, LayersIPCChannel* aAllocator,
TextureFlags aFlags);
@ -62,14 +62,13 @@ class AndroidSurfaceTextureData : public TextureData {
protected:
AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle,
gfx::IntSize aSize, bool aContinuous,
bool aHasAlpha, bool aForceBT709ColorSpace,
bool aHasAlpha,
Maybe<gfx::Matrix4x4> aTransformOverride);
const AndroidSurfaceTextureHandle mHandle;
const gfx::IntSize mSize;
const bool mContinuous;
const bool mHasAlpha;
const bool mForceBT709ColorSpace;
const Maybe<gfx::Matrix4x4> mTransformOverride;
};

View File

@ -67,9 +67,9 @@ already_AddRefed<TextureHost> CreateTextureHostOGL(
java::GeckoSurfaceTexture::LocalRef surfaceTexture =
java::GeckoSurfaceTexture::Lookup(desc.handle());
result = new SurfaceTextureHost(
aFlags, surfaceTexture, desc.size(), desc.format(), desc.continuous(),
desc.forceBT709ColorSpace(), desc.transformOverride());
result = new SurfaceTextureHost(aFlags, surfaceTexture, desc.size(),
desc.format(), desc.continuous(),
desc.transformOverride());
break;
}
case SurfaceDescriptor::TSurfaceDescriptorAndroidHardwareBuffer: {
@ -495,13 +495,12 @@ void SurfaceTextureSource::DeallocateDeviceData() { mSurfTex = nullptr; }
SurfaceTextureHost::SurfaceTextureHost(
TextureFlags aFlags, mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
gfx::IntSize aSize, gfx::SurfaceFormat aFormat, bool aContinuousUpdate,
bool aForceBT709ColorSpace, Maybe<Matrix4x4> aTransformOverride)
Maybe<Matrix4x4> aTransformOverride)
: TextureHost(TextureHostType::AndroidSurfaceTexture, aFlags),
mSurfTex(aSurfTex),
mSize(aSize),
mFormat(aFormat),
mContinuousUpdate(aContinuousUpdate),
mForceBT709ColorSpace(aForceBT709ColorSpace),
mTransformOverride(aTransformOverride) {
if (!mSurfTex) {
return;
@ -561,15 +560,11 @@ void SurfaceTextureHost::PushResourceUpdates(
TextureHost::NativeTexturePolicy policy =
TextureHost::BackendNativeTexturePolicy(aResources.GetBackendType(),
GetSize());
auto imageType = wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureExternal);
if (policy == TextureHost::NativeTexturePolicy::REQUIRE) {
imageType =
wr::ExternalImageType::TextureHandle(wr::ImageBufferKind::TextureRect);
} else if (mForceBT709ColorSpace) {
imageType = wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureExternalBT709);
}
auto imageType = policy == TextureHost::NativeTexturePolicy::REQUIRE
? wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureRect)
: wr::ExternalImageType::TextureHandle(
wr::ImageBufferKind::TextureExternal);
switch (GetFormat()) {
case gfx::SurfaceFormat::R8G8B8X8:

View File

@ -387,7 +387,7 @@ class SurfaceTextureHost : public TextureHost {
SurfaceTextureHost(TextureFlags aFlags,
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
bool aContinuousUpdate, bool aForceBT709ColorSpace,
bool aContinuousUpdate,
Maybe<gfx::Matrix4x4> aTransformOverride);
virtual ~SurfaceTextureHost();
@ -438,7 +438,6 @@ class SurfaceTextureHost : public TextureHost {
const gfx::IntSize mSize;
const gfx::SurfaceFormat mFormat;
bool mContinuousUpdate;
const bool mForceBT709ColorSpace;
const Maybe<gfx::Matrix4x4> mTransformOverride;
RefPtr<CompositorOGL> mCompositor;
RefPtr<SurfaceTextureSource> mTextureSource;

View File

@ -150,8 +150,6 @@ fn write_optimized_shaders(
) {
flags.remove(ShaderFeatureFlags::TEXTURE_EXTERNAL_ESSL1);
}
// The optimizer cannot handle the required EXT_YUV_target extension
flags.remove(ShaderFeatureFlags::TEXTURE_EXTERNAL_BT709);
flags.remove(ShaderFeatureFlags::DITHERING);
for (shader_name, configs) in get_shader_features(flags) {

View File

@ -15,10 +15,6 @@
#extension GL_OES_EGL_image_external : require
#endif
#ifdef WR_FEATURE_TEXTURE_EXTERNAL_BT709
#extension GL_EXT_YUV_target : require
#endif
#ifdef WR_FEATURE_ADVANCED_BLEND
#extension GL_KHR_blend_equation_advanced : require
#endif
@ -35,9 +31,6 @@
#if defined(WR_FEATURE_TEXTURE_EXTERNAL_ESSL1)
#define TEX_SAMPLE(sampler, tex_coord) texture2D(sampler, tex_coord.xy)
#elif defined(WR_FEATURE_TEXTURE_EXTERNAL_BT709)
// Force conversion from yuv to rgb using BT709 colorspace
#define TEX_SAMPLE(sampler, tex_coord) vec4(yuv_2_rgb(texture(sampler, tex_coord.xy).xyz, itu_709), 1.0);
#else
#define TEX_SAMPLE(sampler, tex_coord) texture(sampler, tex_coord.xy)
#endif
@ -214,10 +207,6 @@ uniform sampler2DRect sColor2;
uniform samplerExternalOES sColor0;
uniform samplerExternalOES sColor1;
uniform samplerExternalOES sColor2;
#elif defined(WR_FEATURE_TEXTURE_EXTERNAL_BT709)
uniform __samplerExternal2DY2YEXT sColor0;
uniform __samplerExternal2DY2YEXT sColor1;
uniform __samplerExternal2DY2YEXT sColor2;
#endif
#ifdef WR_FEATURE_DITHERING

View File

@ -155,7 +155,6 @@ pub fn get_gl_target(target: ImageBufferKind) -> gl::GLuint {
ImageBufferKind::Texture2D => gl::TEXTURE_2D,
ImageBufferKind::TextureRect => gl::TEXTURE_RECTANGLE,
ImageBufferKind::TextureExternal => gl::TEXTURE_EXTERNAL_OES,
ImageBufferKind::TextureExternalBT709 => gl::TEXTURE_EXTERNAL_OES,
}
}

View File

@ -39,27 +39,23 @@ fn get_feature_string(kind: ImageBufferKind, texture_external_version: TextureEx
(ImageBufferKind::TextureRect, _) => "TEXTURE_RECT",
(ImageBufferKind::TextureExternal, TextureExternalVersion::ESSL3) => "TEXTURE_EXTERNAL",
(ImageBufferKind::TextureExternal, TextureExternalVersion::ESSL1) => "TEXTURE_EXTERNAL_ESSL1",
(ImageBufferKind::TextureExternalBT709, _) => "TEXTURE_EXTERNAL_BT709",
}
}
fn has_platform_support(kind: ImageBufferKind, device: &Device) -> bool {
match (kind, device.gl().get_type()) {
fn has_platform_support(kind: ImageBufferKind, gl_type: &GlType) -> bool {
match (kind, gl_type) {
(ImageBufferKind::Texture2D, _) => true,
(ImageBufferKind::TextureRect, GlType::Gles) => false,
(ImageBufferKind::TextureRect, GlType::Gl) => true,
(ImageBufferKind::TextureExternal, GlType::Gles) => true,
(ImageBufferKind::TextureExternal, GlType::Gl) => false,
(ImageBufferKind::TextureExternalBT709, GlType::Gles) => device.supports_extension("GL_EXT_YUV_target"),
(ImageBufferKind::TextureExternalBT709, GlType::Gl) => false,
(ImageBufferKind::TextureRect, &GlType::Gles) => false,
(ImageBufferKind::TextureRect, &GlType::Gl) => true,
(ImageBufferKind::TextureExternal, &GlType::Gles) => true,
(ImageBufferKind::TextureExternal, &GlType::Gl) => false,
}
}
pub const IMAGE_BUFFER_KINDS: [ImageBufferKind; 4] = [
pub const IMAGE_BUFFER_KINDS: [ImageBufferKind; 3] = [
ImageBufferKind::Texture2D,
ImageBufferKind::TextureRect,
ImageBufferKind::TextureExternal,
ImageBufferKind::TextureExternalBT709,
];
const ADVANCED_BLEND_FEATURE: &str = "ADVANCED_BLEND";
@ -834,7 +830,7 @@ impl Shaders {
cs_scale.push(None);
}
for image_buffer_kind in &IMAGE_BUFFER_KINDS {
if has_platform_support(*image_buffer_kind, device) {
if has_platform_support(*image_buffer_kind, &gl_type) {
let feature_string = get_feature_string(
*image_buffer_kind,
texture_external_version,
@ -937,7 +933,7 @@ impl Shaders {
brush_fast_image.push(None);
}
for buffer_kind in 0 .. IMAGE_BUFFER_KINDS.len() {
if !has_platform_support(IMAGE_BUFFER_KINDS[buffer_kind], device)
if !has_platform_support(IMAGE_BUFFER_KINDS[buffer_kind], &gl_type)
// Brush shaders are not ESSL1 compatible
|| (IMAGE_BUFFER_KINDS[buffer_kind] == ImageBufferKind::TextureExternal
&& texture_external_version == TextureExternalVersion::ESSL1)
@ -992,7 +988,7 @@ impl Shaders {
brush_yuv_image.push(None);
}
for image_buffer_kind in &IMAGE_BUFFER_KINDS {
if has_platform_support(*image_buffer_kind, device) {
if has_platform_support(*image_buffer_kind, &gl_type) {
yuv_features.push("YUV");
fast_path_features.push("FAST_PATH");
@ -1365,7 +1361,7 @@ impl CompositorShaders {
}
for image_buffer_kind in &IMAGE_BUFFER_KINDS {
if !has_platform_support(*image_buffer_kind, device) {
if !has_platform_support(*image_buffer_kind, &gl_type) {
continue;
}
@ -1490,10 +1486,7 @@ fn get_shader_feature_flags(gl_type: GlType, texture_external_version: TextureEx
GlType::Gl => ShaderFeatureFlags::GL,
GlType::Gles => {
let texture_external_flag = match texture_external_version {
TextureExternalVersion::ESSL3 => {
ShaderFeatureFlags::TEXTURE_EXTERNAL
| ShaderFeatureFlags::TEXTURE_EXTERNAL_BT709
}
TextureExternalVersion::ESSL3 => ShaderFeatureFlags::TEXTURE_EXTERNAL,
TextureExternalVersion::ESSL1 => ShaderFeatureFlags::TEXTURE_EXTERNAL_ESSL1,
};
ShaderFeatureFlags::GLES | texture_external_flag

View File

@ -117,10 +117,6 @@ pub enum ImageBufferKind {
/// understand, particularly YUV. See
/// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt
TextureExternal = 2,
/// External texture which is forced to be converted from YUV to RGB using BT709 colorspace.
/// This maps to GL_TEXTURE_EXTERNAL_OES in OpenGL, using the EXT_YUV_TARGET extension.
/// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_YUV_target.txt
TextureExternalBT709 = 3,
}
/// Storage format identifier for externally-managed images.

View File

@ -15,8 +15,7 @@ bitflags! {
const DITHERING = 1 << 10;
const TEXTURE_EXTERNAL = 1 << 11;
const TEXTURE_EXTERNAL_ESSL1 = 1 << 12;
const TEXTURE_EXTERNAL_BT709 = 1 << 13;
const DEBUG = 1 << 14;
const DEBUG = 1 << 13;
}
}
@ -139,9 +138,6 @@ pub fn get_shader_features(flags: ShaderFeatureFlags) -> ShaderFeatures {
if flags.contains(ShaderFeatureFlags::TEXTURE_EXTERNAL) {
texture_types.push("TEXTURE_EXTERNAL");
}
if flags.contains(ShaderFeatureFlags::TEXTURE_EXTERNAL_BT709) {
texture_types.push("TEXTURE_EXTERNAL_BT709");
}
let mut image_features: Vec<String> = Vec::new();
for texture_type in &texture_types {
let mut fast = FeatureList::new();

View File

@ -126,8 +126,6 @@ pub fn test_shaders() {
}
// glsl-lang crate fails to parse advanced blend shaders
flags.remove(ShaderFeatureFlags::ADVANCED_BLEND_EQUATION);
// glsl-lang crate fails to parse texture external BT709 shaders
flags.remove(ShaderFeatureFlags::TEXTURE_EXTERNAL_BT709);
for (shader, configs) in get_shader_features(flags) {
for config in configs {

View File

@ -5,7 +5,6 @@
package org.mozilla.gecko.media;
import android.media.MediaFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@ -27,8 +26,6 @@ import java.nio.ByteBuffer;
* <li>{@link MediaFormat#KEY_I_FRAME_INTERVAL}
* <li>{@link MediaFormat#KEY_STRIDE}
* <li>{@link MediaFormat#KEY_SLICE_HEIGHT}
* <li>{@link MediaFormat#KEY_COLOR_RANGE
* <li>{@link MediaFormat#KEY_COLOR_STANDARD}
* <li>"csd-0"
* <li>"csd-1"
* </ul>
@ -121,15 +118,6 @@ public final class FormatParam implements Parcelable {
if (bundle.containsKey(MediaFormat.KEY_SLICE_HEIGHT)) {
mFormat.setInteger(MediaFormat.KEY_SLICE_HEIGHT, bundle.getInt(MediaFormat.KEY_SLICE_HEIGHT));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (bundle.containsKey(MediaFormat.KEY_COLOR_RANGE)) {
mFormat.setInteger(MediaFormat.KEY_COLOR_RANGE, bundle.getInt(MediaFormat.KEY_COLOR_RANGE));
}
if (bundle.containsKey(MediaFormat.KEY_COLOR_STANDARD)) {
mFormat.setInteger(
MediaFormat.KEY_COLOR_STANDARD, bundle.getInt(MediaFormat.KEY_COLOR_STANDARD));
}
}
}
@Override
@ -185,15 +173,6 @@ public final class FormatParam implements Parcelable {
if (mFormat.containsKey(MediaFormat.KEY_SLICE_HEIGHT)) {
bundle.putInt(MediaFormat.KEY_SLICE_HEIGHT, mFormat.getInteger(MediaFormat.KEY_SLICE_HEIGHT));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (mFormat.containsKey(MediaFormat.KEY_COLOR_RANGE)) {
bundle.putInt(MediaFormat.KEY_COLOR_RANGE, mFormat.getInteger(MediaFormat.KEY_COLOR_RANGE));
}
if (mFormat.containsKey(MediaFormat.KEY_COLOR_STANDARD)) {
bundle.putInt(
MediaFormat.KEY_COLOR_STANDARD, mFormat.getInteger(MediaFormat.KEY_COLOR_STANDARD));
}
}
return bundle;
}
}