mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1543359 - P3. Add kCVPixelFormatType_420YpCbCr8BiPlanarFullRange support to MacIOSurface. r=mattwoodrow
This will allow to differentiate full range vs limited range YUV. Differential Revision: https://phabricator.services.mozilla.com/D27211 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0171b0edb2
commit
c070ea1f0e
@ -472,9 +472,10 @@ already_AddRefed<SourceSurface> MacIOSurface::GetAsSurface() {
|
|||||||
|
|
||||||
SurfaceFormat MacIOSurface::GetFormat() const {
|
SurfaceFormat MacIOSurface::GetFormat() const {
|
||||||
OSType pixelFormat = GetPixelFormat();
|
OSType pixelFormat = GetPixelFormat();
|
||||||
if (pixelFormat == '420v') {
|
if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ||
|
||||||
|
pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
|
||||||
return SurfaceFormat::NV12;
|
return SurfaceFormat::NV12;
|
||||||
} else if (pixelFormat == '2vuy') {
|
} else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
|
||||||
return SurfaceFormat::YUV422;
|
return SurfaceFormat::YUV422;
|
||||||
} else {
|
} else {
|
||||||
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
||||||
@ -483,9 +484,10 @@ SurfaceFormat MacIOSurface::GetFormat() const {
|
|||||||
|
|
||||||
SurfaceFormat MacIOSurface::GetReadFormat() const {
|
SurfaceFormat MacIOSurface::GetReadFormat() const {
|
||||||
OSType pixelFormat = GetPixelFormat();
|
OSType pixelFormat = GetPixelFormat();
|
||||||
if (pixelFormat == '420v') {
|
if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ||
|
||||||
|
pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
|
||||||
return SurfaceFormat::NV12;
|
return SurfaceFormat::NV12;
|
||||||
} else if (pixelFormat == '2vuy') {
|
} else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
|
||||||
return SurfaceFormat::R8G8B8X8;
|
return SurfaceFormat::R8G8B8X8;
|
||||||
} else {
|
} else {
|
||||||
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
||||||
@ -512,7 +514,8 @@ CGLError MacIOSurface::CGLTexImageIOSurface2D(
|
|||||||
GLenum internalFormat;
|
GLenum internalFormat;
|
||||||
GLenum format;
|
GLenum format;
|
||||||
GLenum type;
|
GLenum type;
|
||||||
if (pixelFormat == '420v') {
|
if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ||
|
||||||
|
pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
|
||||||
MOZ_ASSERT(GetPlaneCount() == 2);
|
MOZ_ASSERT(GetPlaneCount() == 2);
|
||||||
MOZ_ASSERT(plane < 2);
|
MOZ_ASSERT(plane < 2);
|
||||||
|
|
||||||
@ -530,7 +533,7 @@ CGLError MacIOSurface::CGLTexImageIOSurface2D(
|
|||||||
if (aOutReadFormat) {
|
if (aOutReadFormat) {
|
||||||
*aOutReadFormat = mozilla::gfx::SurfaceFormat::NV12;
|
*aOutReadFormat = mozilla::gfx::SurfaceFormat::NV12;
|
||||||
}
|
}
|
||||||
} else if (pixelFormat == '2vuy') {
|
} else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
|
||||||
MOZ_ASSERT(plane == 0);
|
MOZ_ASSERT(plane == 0);
|
||||||
// The YCBCR_422_APPLE ext is only available in compatibility profile. So,
|
// The YCBCR_422_APPLE ext is only available in compatibility profile. So,
|
||||||
// we should use RGB_422_APPLE for core profile. The difference between
|
// we should use RGB_422_APPLE for core profile. The difference between
|
||||||
|
@ -137,6 +137,9 @@ class MacIOSurface final
|
|||||||
mColorSpace = aColorSpace;
|
mColorSpace = aColorSpace;
|
||||||
}
|
}
|
||||||
mozilla::gfx::YUVColorSpace GetYUVColorSpace() const { return mColorSpace; }
|
mozilla::gfx::YUVColorSpace GetYUVColorSpace() const { return mColorSpace; }
|
||||||
|
bool IsFullRange() const {
|
||||||
|
return GetPixelFormat() == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
|
||||||
|
}
|
||||||
|
|
||||||
// We would like to forward declare NSOpenGLContext, but it is an @interface
|
// We would like to forward declare NSOpenGLContext, but it is an @interface
|
||||||
// and this file is also used from c++, so we use a void *.
|
// and this file is also used from c++, so we use a void *.
|
||||||
|
@ -1008,7 +1008,7 @@ bool GLBlitHelper::BlitImage(layers::MacIOSurfaceImage* const srcImage,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == '2vuy') {
|
if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
|
||||||
fragBody = kFragBody_CrYCb;
|
fragBody = kFragBody_CrYCb;
|
||||||
// APPLE_rgb_422 adds RGB_RAW_422_APPLE for `internalFormat`, but only RGB
|
// APPLE_rgb_422 adds RGB_RAW_422_APPLE for `internalFormat`, but only RGB
|
||||||
// seems to work?
|
// seems to work?
|
||||||
|
Loading…
Reference in New Issue
Block a user