Bug 1565717 - Remove all dynamic loading of IOSurface functions. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Wed, 14 Aug 2019 11:06:22 +0000
changeset 488004 6c4665fb2c103b1a0253791f66d7f9ec6ff691f6
parent 488003 35ae2dc9438e211637779380ef36de19a5b2ef39
child 488005 405b6f21b6405b3e5bc0b85a2a5de51d619f1a35
push id36434
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:44:30 +0000
treeherdermozilla-central@144fbfb409b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1565717
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 1565717 - Remove all dynamic loading of IOSurface functions. r=mattwoodrow These functions were made public in 10.6. The oldest version we support is 10.9. Differential Revision: https://phabricator.services.mozilla.com/D41813
dom/media/platforms/apple/AppleDecoderModule.cpp
gfx/2d/MacIOSurface.cpp
gfx/2d/MacIOSurface.h
gfx/thebes/gfxPlatformMac.cpp
--- a/dom/media/platforms/apple/AppleDecoderModule.cpp
+++ b/dom/media/platforms/apple/AppleDecoderModule.cpp
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
 
 #include "AppleATDecoder.h"
 #include "AppleDecoderModule.h"
 #include "AppleVTDecoder.h"
-#include "mozilla/gfx/MacIOSurface.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Logging.h"
 #include "mozilla/gfx/gfxVars.h"
 
 namespace mozilla {
 
 bool AppleDecoderModule::sInitialized = false;
 bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true;
@@ -22,21 +21,17 @@ AppleDecoderModule::AppleDecoderModule()
 AppleDecoderModule::~AppleDecoderModule() {}
 
 /* static */
 void AppleDecoderModule::Init() {
   if (sInitialized) {
     return;
   }
 
-  // Ensure IOSurface framework is loaded.
-  MacIOSurfaceLib::LoadLibrary();
-
-  sCanUseHardwareVideoDecoder =
-      MacIOSurfaceLib::isInit() && gfx::gfxVars::CanUseHardwareVideoDecoding();
+  sCanUseHardwareVideoDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding();
 
   sInitialized = true;
 }
 
 nsresult AppleDecoderModule::Startup() {
   if (!sInitialized) {
     return NS_ERROR_FAILURE;
   }
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -4,169 +4,22 @@
  * 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/. */
 
 #include "MacIOSurface.h"
 #include <IOSurface/IOSurface.h>
 #include <OpenGL/gl.h>
 #include <OpenGL/CGLIOSurface.h>
 #include <QuartzCore/QuartzCore.h>
-#include <dlfcn.h>
 #include "GLConsts.h"
 #include "GLContextCGL.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/RefPtr.h"
 
 using namespace mozilla;
-// IOSurface signatures
-#define IOSURFACE_FRAMEWORK_PATH \
-  "/System/Library/Frameworks/IOSurface.framework/IOSurface"
-
-#define GET_IOSYM(dest, sym_name) \
-  (typeof(dest)) dlsym(sIOSurfaceFramework, sym_name)
-
-MacIOSurfaceLib::LibraryUnloader MacIOSurfaceLib::sLibraryUnloader;
-bool MacIOSurfaceLib::isLoaded = false;
-void* MacIOSurfaceLib::sIOSurfaceFramework;
-IOSurfaceCreateFunc MacIOSurfaceLib::sCreate;
-IOSurfaceGetIDFunc MacIOSurfaceLib::sGetID;
-IOSurfaceLookupFunc MacIOSurfaceLib::sLookup;
-IOSurfaceGetBaseAddressFunc MacIOSurfaceLib::sGetBaseAddress;
-IOSurfaceGetBaseAddressOfPlaneFunc MacIOSurfaceLib::sGetBaseAddressOfPlane;
-IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sWidth;
-IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sHeight;
-IOSurfaceSizeTFunc MacIOSurfaceLib::sPlaneCount;
-IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sBytesPerRow;
-IOSurfaceGetPropertyMaximumFunc MacIOSurfaceLib::sGetPropertyMaximum;
-IOSurfaceVoidFunc MacIOSurfaceLib::sIncrementUseCount;
-IOSurfaceVoidFunc MacIOSurfaceLib::sDecrementUseCount;
-IOSurfaceLockFunc MacIOSurfaceLib::sLock;
-IOSurfaceUnlockFunc MacIOSurfaceLib::sUnlock;
-IOSurfacePixelFormatFunc MacIOSurfaceLib::sPixelFormat;
-
-bool MacIOSurfaceLib::isInit() {
-  // Guard against trying to reload the library
-  // if it is not available.
-  if (!isLoaded) LoadLibrary();
-  MOZ_ASSERT(sIOSurfaceFramework);
-  return sIOSurfaceFramework;
-}
-
-IOSurfacePtr MacIOSurfaceLib::IOSurfaceCreate(CFDictionaryRef properties) {
-  return sCreate(properties);
-}
-
-IOSurfacePtr MacIOSurfaceLib::IOSurfaceLookup(IOSurfaceID aIOSurfaceID) {
-  return sLookup(aIOSurfaceID);
-}
-
-IOSurfaceID MacIOSurfaceLib::IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr) {
-  return sGetID(aIOSurfacePtr);
-}
-
-void* MacIOSurfaceLib::IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr) {
-  return sGetBaseAddress(aIOSurfacePtr);
-}
-
-void* MacIOSurfaceLib::IOSurfaceGetBaseAddressOfPlane(
-    IOSurfacePtr aIOSurfacePtr, size_t planeIndex) {
-  return sGetBaseAddressOfPlane(aIOSurfacePtr, planeIndex);
-}
-
-size_t MacIOSurfaceLib::IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr) {
-  return sPlaneCount(aIOSurfacePtr);
-}
-
-size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr,
-                                          size_t plane) {
-  return sWidth(aIOSurfacePtr, plane);
-}
-
-size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr,
-                                           size_t plane) {
-  return sHeight(aIOSurfacePtr, plane);
-}
-
-size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr,
-                                                size_t plane) {
-  return sBytesPerRow(aIOSurfacePtr, plane);
-}
-
-size_t MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(CFStringRef property) {
-  return sGetPropertyMaximum(property);
-}
-
-OSType MacIOSurfaceLib::IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr) {
-  return sPixelFormat(aIOSurfacePtr);
-}
-
-IOReturn MacIOSurfaceLib::IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
-                                        uint32_t options, uint32_t* seed) {
-  return sLock(aIOSurfacePtr, options, seed);
-}
-
-IOReturn MacIOSurfaceLib::IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
-                                          uint32_t options, uint32_t* seed) {
-  return sUnlock(aIOSurfacePtr, options, seed);
-}
-
-void MacIOSurfaceLib::IOSurfaceIncrementUseCount(IOSurfacePtr aIOSurfacePtr) {
-  sIncrementUseCount(aIOSurfacePtr);
-}
-
-void MacIOSurfaceLib::IOSurfaceDecrementUseCount(IOSurfacePtr aIOSurfacePtr) {
-  sDecrementUseCount(aIOSurfacePtr);
-}
-
-void MacIOSurfaceLib::LoadLibrary() {
-  if (isLoaded) {
-    return;
-  }
-  isLoaded = true;
-  sIOSurfaceFramework =
-      dlopen(IOSURFACE_FRAMEWORK_PATH, RTLD_LAZY | RTLD_LOCAL);
-
-  if (!sIOSurfaceFramework) {
-    return;
-  }
-
-  sCreate = GET_IOSYM(sCreate, "IOSurfaceCreate");
-  sGetID = GET_IOSYM(sGetID, "IOSurfaceGetID");
-  sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidthOfPlane");
-  sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeightOfPlane");
-  sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRowOfPlane");
-  sGetPropertyMaximum =
-      GET_IOSYM(sGetPropertyMaximum, "IOSurfaceGetPropertyMaximum");
-  sLookup = GET_IOSYM(sLookup, "IOSurfaceLookup");
-  sLock = GET_IOSYM(sLock, "IOSurfaceLock");
-  sUnlock = GET_IOSYM(sUnlock, "IOSurfaceUnlock");
-  sIncrementUseCount =
-      GET_IOSYM(sIncrementUseCount, "IOSurfaceIncrementUseCount");
-  sDecrementUseCount =
-      GET_IOSYM(sDecrementUseCount, "IOSurfaceDecrementUseCount");
-  sGetBaseAddress = GET_IOSYM(sGetBaseAddress, "IOSurfaceGetBaseAddress");
-  sGetBaseAddressOfPlane =
-      GET_IOSYM(sGetBaseAddressOfPlane, "IOSurfaceGetBaseAddressOfPlane");
-  sPlaneCount = GET_IOSYM(sPlaneCount, "IOSurfaceGetPlaneCount");
-  sPixelFormat = GET_IOSYM(sPixelFormat, "IOSurfaceGetPixelFormat");
-
-  if (!sCreate || !sGetID || !sLookup || !sGetBaseAddress ||
-      !sGetBaseAddressOfPlane || !sPlaneCount || !sLock || !sUnlock ||
-      !sIncrementUseCount || !sDecrementUseCount || !sWidth || !sHeight ||
-      !sBytesPerRow || !sGetPropertyMaximum) {
-    CloseLibrary();
-  }
-}
-
-void MacIOSurfaceLib::CloseLibrary() {
-  if (sIOSurfaceFramework) {
-    dlclose(sIOSurfaceFramework);
-  }
-  sIOSurfaceFramework = nullptr;
-}
 
 MacIOSurface::MacIOSurface(IOSurfacePtr aIOSurfacePtr,
                            double aContentsScaleFactor, bool aHasAlpha,
                            gfx::YUVColorSpace aColorSpace)
     : mIOSurfacePtr(aIOSurfacePtr),
       mContentsScaleFactor(aContentsScaleFactor),
       mHasAlpha(aHasAlpha),
       mColorSpace(aColorSpace) {
@@ -177,17 +30,17 @@ MacIOSurface::MacIOSurface(IOSurfacePtr 
 MacIOSurface::~MacIOSurface() {
   DecrementUseCount();
   CFRelease(mIOSurfacePtr);
 }
 
 /* static */
 already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(
     int aWidth, int aHeight, double aContentsScaleFactor, bool aHasAlpha) {
-  if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0) return nullptr;
+  if (aContentsScaleFactor <= 0) return nullptr;
 
   CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
       kCFAllocatorDefault, 4, &kCFTypeDictionaryKeyCallBacks,
       &kCFTypeDictionaryValueCallBacks);
   if (!props) return nullptr;
 
   MOZ_ASSERT((size_t)aWidth <= GetMaxWidth());
   MOZ_ASSERT((size_t)aHeight <= GetMaxHeight());
@@ -204,17 +57,17 @@ already_AddRefed<MacIOSurface> MacIOSurf
   ::CFDictionaryAddValue(props, kIOSurfaceWidth, cfWidth);
   ::CFRelease(cfWidth);
   ::CFDictionaryAddValue(props, kIOSurfaceHeight, cfHeight);
   ::CFRelease(cfHeight);
   ::CFDictionaryAddValue(props, kIOSurfaceBytesPerElement, cfBytesPerElem);
   ::CFRelease(cfBytesPerElem);
   ::CFDictionaryAddValue(props, kIOSurfaceIsGlobal, kCFBooleanTrue);
 
-  IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceCreate(props);
+  IOSurfacePtr surfaceRef = ::IOSurfaceCreate(props);
   ::CFRelease(props);
 
   if (!surfaceRef) return nullptr;
 
   RefPtr<MacIOSurface> ioSurface =
       new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
 
   // Release the IOSurface because MacIOSurface retained it
@@ -222,102 +75,99 @@ already_AddRefed<MacIOSurface> MacIOSurf
 
   return ioSurface.forget();
 }
 
 /* static */
 already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(
     IOSurfaceID aIOSurfaceID, double aContentsScaleFactor, bool aHasAlpha,
     gfx::YUVColorSpace aColorSpace) {
-  if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0) return nullptr;
+  if (aContentsScaleFactor <= 0) return nullptr;
 
-  IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
+  IOSurfacePtr surfaceRef = (IOSurfacePtr)::IOSurfaceLookup(aIOSurfaceID);
   if (!surfaceRef) return nullptr;
 
   RefPtr<MacIOSurface> ioSurface = new MacIOSurface(
       surfaceRef, aContentsScaleFactor, aHasAlpha, aColorSpace);
 
   // Release the IOSurface because MacIOSurface retained it
   CFRelease(surfaceRef);
 
   return ioSurface.forget();
 }
 
 IOSurfaceID MacIOSurface::GetIOSurfaceID() const {
-  return MacIOSurfaceLib::IOSurfaceGetID(mIOSurfacePtr);
+  return ::IOSurfaceGetID((IOSurfaceRef)mIOSurfacePtr);
 }
 
 void* MacIOSurface::GetBaseAddress() const {
-  return MacIOSurfaceLib::IOSurfaceGetBaseAddress(mIOSurfacePtr);
+  return ::IOSurfaceGetBaseAddress((IOSurfaceRef)mIOSurfacePtr);
 }
 
 void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex) const {
-  return MacIOSurfaceLib::IOSurfaceGetBaseAddressOfPlane(mIOSurfacePtr,
-                                                         aPlaneIndex);
+  return ::IOSurfaceGetBaseAddressOfPlane((IOSurfaceRef)mIOSurfacePtr,
+                                          aPlaneIndex);
 }
 
 size_t MacIOSurface::GetWidth(size_t plane) const {
   size_t intScaleFactor = ceil(mContentsScaleFactor);
   return GetDevicePixelWidth(plane) / intScaleFactor;
 }
 
 size_t MacIOSurface::GetHeight(size_t plane) const {
   size_t intScaleFactor = ceil(mContentsScaleFactor);
   return GetDevicePixelHeight(plane) / intScaleFactor;
 }
 
 size_t MacIOSurface::GetPlaneCount() const {
-  return MacIOSurfaceLib::IOSurfaceGetPlaneCount(mIOSurfacePtr);
+  return ::IOSurfaceGetPlaneCount((IOSurfaceRef)mIOSurfacePtr);
 }
 
 /*static*/
 size_t MacIOSurface::GetMaxWidth() {
-  if (!MacIOSurfaceLib::isInit()) return -1;
-  return MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(kIOSurfaceWidth);
+  return ::IOSurfaceGetPropertyMaximum(kIOSurfaceWidth);
 }
 
 /*static*/
 size_t MacIOSurface::GetMaxHeight() {
-  if (!MacIOSurfaceLib::isInit()) return -1;
-  return MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(kIOSurfaceHeight);
+  return ::IOSurfaceGetPropertyMaximum(kIOSurfaceHeight);
 }
 
 size_t MacIOSurface::GetDevicePixelWidth(size_t plane) const {
-  return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr, plane);
+  return ::IOSurfaceGetWidthOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
 }
 
 size_t MacIOSurface::GetDevicePixelHeight(size_t plane) const {
-  return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr, plane);
+  return ::IOSurfaceGetHeightOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
 }
 
 size_t MacIOSurface::GetBytesPerRow(size_t plane) const {
-  return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr, plane);
+  return ::IOSurfaceGetBytesPerRowOfPlane((IOSurfaceRef)mIOSurfacePtr, plane);
 }
 
 OSType MacIOSurface::GetPixelFormat() const {
-  return MacIOSurfaceLib::IOSurfaceGetPixelFormat(mIOSurfacePtr);
+  return ::IOSurfaceGetPixelFormat((IOSurfaceRef)mIOSurfacePtr);
 }
 
 void MacIOSurface::IncrementUseCount() {
-  MacIOSurfaceLib::IOSurfaceIncrementUseCount(mIOSurfacePtr);
+  ::IOSurfaceIncrementUseCount((IOSurfaceRef)mIOSurfacePtr);
 }
 
 void MacIOSurface::DecrementUseCount() {
-  MacIOSurfaceLib::IOSurfaceDecrementUseCount(mIOSurfacePtr);
+  ::IOSurfaceDecrementUseCount((IOSurfaceRef)mIOSurfacePtr);
 }
 
-#define READ_ONLY 0x1
 void MacIOSurface::Lock(bool aReadOnly) {
-  MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, aReadOnly ? READ_ONLY : 0,
-                                 nullptr);
+  ::IOSurfaceLock((IOSurfaceRef)mIOSurfacePtr,
+                  aReadOnly ? kIOSurfaceLockReadOnly : 0, nullptr);
 }
 
 void MacIOSurface::Unlock(bool aReadOnly) {
-  MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, aReadOnly ? READ_ONLY : 0,
-                                   nullptr);
+  ::IOSurfaceUnlock((IOSurfaceRef)mIOSurfacePtr,
+                    aReadOnly ? kIOSurfaceLockReadOnly : 0, nullptr);
 }
 
 using mozilla::gfx::IntSize;
 using mozilla::gfx::SourceSurface;
 using mozilla::gfx::SurfaceFormat;
 
 static void MacIOSurfaceBufferDeallocator(void* aClosure) {
   MOZ_ASSERT(aClosure);
--- a/gfx/2d/MacIOSurface.h
+++ b/gfx/2d/MacIOSurface.h
@@ -25,33 +25,16 @@ typedef _CGLContextObject* CGLContextObj
 typedef uint32_t IOSurfaceID;
 
 #  ifdef XP_IOS
 typedef kern_return_t IOReturn;
 typedef int CGLError;
 #  endif
 
 typedef CFTypeRef IOSurfacePtr;
-typedef IOSurfacePtr (*IOSurfaceCreateFunc)(CFDictionaryRef properties);
-typedef IOSurfacePtr (*IOSurfaceLookupFunc)(uint32_t io_surface_id);
-typedef IOSurfaceID (*IOSurfaceGetIDFunc)(IOSurfacePtr io_surface);
-typedef void (*IOSurfaceVoidFunc)(IOSurfacePtr io_surface);
-typedef IOReturn (*IOSurfaceLockFunc)(IOSurfacePtr io_surface, uint32_t options,
-                                      uint32_t* seed);
-typedef IOReturn (*IOSurfaceUnlockFunc)(IOSurfacePtr io_surface,
-                                        uint32_t options, uint32_t* seed);
-typedef void* (*IOSurfaceGetBaseAddressFunc)(IOSurfacePtr io_surface);
-typedef void* (*IOSurfaceGetBaseAddressOfPlaneFunc)(IOSurfacePtr io_surface,
-                                                    size_t planeIndex);
-typedef size_t (*IOSurfaceSizeTFunc)(IOSurfacePtr io_surface);
-typedef size_t (*IOSurfaceSizePlaneTFunc)(IOSurfacePtr io_surface,
-                                          size_t plane);
-typedef size_t (*IOSurfaceGetPropertyMaximumFunc)(CFStringRef property);
-
-typedef OSType (*IOSurfacePixelFormatFunc)(IOSurfacePtr io_surface);
 
 #  ifdef XP_MACOSX
 #    import <OpenGL/OpenGL.h>
 #  else
 #    import <OpenGLES/ES2/gl.h>
 #  endif
 
 #  include "2D.h"
@@ -136,61 +119,10 @@ class MacIOSurface final
   friend class nsCARenderer;
   const IOSurfacePtr mIOSurfacePtr;
   double mContentsScaleFactor;
   bool mHasAlpha;
   mozilla::gfx::YUVColorSpace mColorSpace =
       mozilla::gfx::YUVColorSpace::UNKNOWN;
 };
 
-class MacIOSurfaceLib {
- public:
-  MacIOSurfaceLib() = delete;
-  static void* sIOSurfaceFramework;
-  static bool isLoaded;
-  static IOSurfaceCreateFunc sCreate;
-  static IOSurfaceGetIDFunc sGetID;
-  static IOSurfaceLookupFunc sLookup;
-  static IOSurfaceGetBaseAddressFunc sGetBaseAddress;
-  static IOSurfaceGetBaseAddressOfPlaneFunc sGetBaseAddressOfPlane;
-  static IOSurfaceSizeTFunc sPlaneCount;
-  static IOSurfaceLockFunc sLock;
-  static IOSurfaceUnlockFunc sUnlock;
-  static IOSurfaceVoidFunc sIncrementUseCount;
-  static IOSurfaceVoidFunc sDecrementUseCount;
-  static IOSurfaceSizePlaneTFunc sWidth;
-  static IOSurfaceSizePlaneTFunc sHeight;
-  static IOSurfaceSizePlaneTFunc sBytesPerRow;
-  static IOSurfaceGetPropertyMaximumFunc sGetPropertyMaximum;
-  static IOSurfacePixelFormatFunc sPixelFormat;
-
-  static bool isInit();
-  static IOSurfacePtr IOSurfaceCreate(CFDictionaryRef properties);
-  static IOSurfacePtr IOSurfaceLookup(IOSurfaceID aIOSurfaceID);
-  static IOSurfaceID IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr);
-  static void* IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr);
-  static void* IOSurfaceGetBaseAddressOfPlane(IOSurfacePtr aIOSurfacePtr,
-                                              size_t aPlaneIndex);
-  static size_t IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr);
-  static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr, size_t plane);
-  static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr, size_t plane);
-  static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr,
-                                        size_t plane);
-  static size_t IOSurfaceGetPropertyMaximum(CFStringRef property);
-  static IOReturn IOSurfaceLock(IOSurfacePtr aIOSurfacePtr, uint32_t options,
-                                uint32_t* seed);
-  static IOReturn IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr, uint32_t options,
-                                  uint32_t* seed);
-  static void IOSurfaceIncrementUseCount(IOSurfacePtr aIOSurfacePtr);
-  static void IOSurfaceDecrementUseCount(IOSurfacePtr aIOSurfacePtr);
-  static OSType IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr);
-  static void LoadLibrary();
-  static void CloseLibrary();
-
-  // Static deconstructor
-  static class LibraryUnloader {
-   public:
-    ~LibraryUnloader() { CloseLibrary(); }
-  } sLibraryUnloader;
-};
-
 #endif
 #endif
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -2,17 +2,16 @@
  * 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/. */
 
 #include "gfxPlatformMac.h"
 
 #include "gfxQuartzSurface.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/gfx/MacIOSurface.h"
 
 #include "gfxMacPlatformFontList.h"
 #include "gfxMacFont.h"
 #include "gfxCoreTextShaper.h"
 #include "gfxTextRun.h"
 #include "gfxUserFontSet.h"
 
 #include "nsTArray.h"
@@ -71,18 +70,16 @@ static void DisableFontActivation() {
 }
 
 gfxPlatformMac::gfxPlatformMac() {
   DisableFontActivation();
   mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
 
   InitBackendPrefs(GetBackendPrefs());
 
-  MacIOSurfaceLib::LoadLibrary();
-
   if (nsCocoaFeatures::OnHighSierraOrLater()) {
     mHasNativeColrFontSupport = true;
   }
 }
 
 gfxPlatformMac::~gfxPlatformMac() { gfxCoreTextShaper::Shutdown(); }
 
 BackendPrefsData gfxPlatformMac::GetBackendPrefs() const {