Bug 1149343 - Part2: Add HW decode blacklisting support on mac. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 31 Mar 2015 14:18:38 +1100
changeset 236909 7779bff82d843585cf55fd97abc53817c86ce22f
parent 236908 f7bbc6c8f0078e3e6b59c503eb70c4bc71113395
child 236910 ab074c8ddb56bf8e70108765895d81a5ef744681
push id57811
push usermwoodrow@mozilla.com
push dateWed, 01 Apr 2015 03:09:58 +0000
treeherdermozilla-inbound@7779bff82d84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1149343
milestone40.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 1149343 - Part2: Add HW decode blacklisting support on mac. r=mattwoodrow
dom/media/fmp4/apple/AppleVDADecoder.cpp
dom/media/fmp4/apple/AppleVTDecoder.cpp
--- a/dom/media/fmp4/apple/AppleVDADecoder.cpp
+++ b/dom/media/fmp4/apple/AppleVDADecoder.cpp
@@ -16,16 +16,17 @@
 #include "MacIOSurfaceImage.h"
 #include "mozilla/ArrayUtils.h"
 #include "nsAutoPtr.h"
 #include "nsCocoaFeatures.h"
 #include "nsThreadUtils.h"
 #include "prlog.h"
 #include "VideoUtils.h"
 #include <algorithm>
+#include "gfxPlatform.h"
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* GetAppleMediaLog();
 #define LOG(...) PR_LOG(GetAppleMediaLog(), PR_LOG_DEBUG, (__VA_ARGS__))
 //#define LOG_MEDIA_SHA1
 #else
 #define LOG(...)
 #endif
@@ -74,16 +75,21 @@ AppleVDADecoder::AppleVDADecoder(const m
 AppleVDADecoder::~AppleVDADecoder()
 {
   MOZ_COUNT_DTOR(AppleVDADecoder);
 }
 
 nsresult
 AppleVDADecoder::Init()
 {
+  if (!gfxPlatform::CanUseHardwareVideoDecoding()) {
+    // This GPU is blacklisted for hardware decoding.
+    return NS_ERROR_FAILURE;
+  }
+
   if (mDecoder) {
     return NS_OK;
   }
   nsresult rv = InitializeSession();
   return rv;
 }
 
 nsresult
--- a/dom/media/fmp4/apple/AppleVTDecoder.cpp
+++ b/dom/media/fmp4/apple/AppleVTDecoder.cpp
@@ -14,16 +14,17 @@
 #include "mp4_demuxer/H264.h"
 #include "MediaData.h"
 #include "MacIOSurfaceImage.h"
 #include "mozilla/ArrayUtils.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "prlog.h"
 #include "VideoUtils.h"
+#include "gfxPlatform.h"
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* GetAppleMediaLog();
 #define LOG(...) PR_LOG(GetAppleMediaLog(), PR_LOG_DEBUG, (__VA_ARGS__))
 //#define LOG_MEDIA_SHA1
 #else
 #define LOG(...)
 #endif
@@ -376,17 +377,23 @@ AppleVTDecoder::CreateDecoderExtensions(
 CFDictionaryRef
 AppleVTDecoder::CreateDecoderSpecification()
 {
   if (!AppleVTLinker::skPropEnableHWAccel) {
     return nullptr;
   }
 
   const void* specKeys[] = { AppleVTLinker::skPropEnableHWAccel };
-  const void* specValues[] = { kCFBooleanTrue };
+  const void* specValues[1];
+  if (gfxPlatform::CanUseHardwareVideoDecoding()) {
+    specValues[0] = kCFBooleanTrue;
+  } else {
+    // This GPU is blacklisted for hardware decoding.
+    specValues[0] = kCFBooleanFalse;
+  }
   static_assert(ArrayLength(specKeys) == ArrayLength(specValues),
                 "Non matching keys/values array size");
 
   return CFDictionaryCreate(kCFAllocatorDefault,
                             specKeys,
                             specValues,
                             ArrayLength(specKeys),
                             &kCFTypeDictionaryKeyCallBacks,