Bug 1573668 - Teach MacIOSurface about the kCVPixelFormatType_32BGRA pixel format. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Thu, 15 Aug 2019 03:33:58 +0000
changeset 488374 840b81a4581e45f2b2e99e759377d35651159720
parent 488373 4e96530fe5c4d04fa462b55ac29d2d15224f618d
child 488375 ed710f979ba18daa62f49d25dd8d9ff19fab10d8
push id36440
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 03:57:48 +0000
treeherdermozilla-central@a58b7dc85887 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1573668
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1573668 - Teach MacIOSurface about the kCVPixelFormatType_32BGRA pixel format. r=mattwoodrow Depends on D41843 Differential Revision: https://phabricator.services.mozilla.com/D41971
gfx/2d/MacIOSurface.cpp
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -190,37 +190,35 @@ already_AddRefed<SourceSurface> MacIOSur
       mozilla::gfx::Factory::CreateWrappingDataSourceSurface(
           dataCpy, bytesPerRow, IntSize(ioWidth, ioHeight), format,
           &MacIOSurfaceBufferDeallocator, static_cast<void*>(dataCpy));
 
   return surf.forget();
 }
 
 SurfaceFormat MacIOSurface::GetFormat() const {
-  OSType pixelFormat = GetPixelFormat();
-  if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ||
-      pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
-    return SurfaceFormat::NV12;
-  } else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
-    return SurfaceFormat::YUV422;
-  } else {
-    return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
+  switch (GetPixelFormat()) {
+    case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
+    case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
+      return SurfaceFormat::NV12;
+    case kCVPixelFormatType_422YpCbCr8:
+      return SurfaceFormat::YUV422;
+    case kCVPixelFormatType_32BGRA:
+      return HasAlpha() ? SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8;
+    default:
+      return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
   }
 }
 
 SurfaceFormat MacIOSurface::GetReadFormat() const {
-  OSType pixelFormat = GetPixelFormat();
-  if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ||
-      pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
-    return SurfaceFormat::NV12;
-  } else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) {
+  SurfaceFormat format = GetFormat();
+  if (format == SurfaceFormat::YUV422) {
     return SurfaceFormat::R8G8B8X8;
-  } else {
-    return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
   }
+  return format;
 }
 
 CGLError MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx, GLenum target,
                                               GLenum internalFormat,
                                               GLsizei width, GLsizei height,
                                               GLenum format, GLenum type,
                                               GLuint plane) const {
   return ::CGLTexImageIOSurface2D(ctx, target, internalFormat, width, height,