Bug 1281259 - Port DXVA to gfxConfig r=jrmuizel

MozReview-Commit-ID: 7Yp3ynxZoFE

--HG--
extra : rebase_source : 8fd65a364e3c8b2e539b47dd034e637a1324516e
This commit is contained in:
eyim 2016-07-14 10:21:06 -04:00
Родитель e22300de9e
Коммит 4446d595fa
8 изменённых файлов: 69 добавлений и 41 удалений

Просмотреть файл

@ -31,6 +31,7 @@
#include "nsServiceManagerUtils.h"
#include "gfxPlatform.h"
#include "mozilla/Snprintf.h"
#include "gfxConfig.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
@ -81,7 +82,7 @@ IsWebMForced(DecoderDoctorDiagnostics* aDiagnostics)
bool mp4supported =
DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4"),
aDiagnostics);
bool hwsupported = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
bool hwsupported = gfx::gfxConfig::IsEnabled(gfx::Feature::HW_VIDEO_DECODING);
return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast();
}

Просмотреть файл

@ -13,6 +13,7 @@
#include "MediaPrefs.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Logging.h"
#include "gfxConfig.h"
namespace mozilla {
@ -52,8 +53,7 @@ AppleDecoderModule::Init()
sIsVTHWAvailable = AppleVTLinker::skPropEnableHWAccel != nullptr;
sCanUseHardwareVideoDecoder = loaded &&
gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
sCanUseHardwareVideoDecoder = loaded && gfxConfig::IsEnabled(gfx::Feature::HW_VIDEO_DECODING);
sInitialized = true;
}

Просмотреть файл

@ -25,6 +25,7 @@
#include "prsystem.h"
#include "mozilla/Maybe.h"
#include "mozilla/StaticMutex.h"
#include "gfxConfig.h"
namespace mozilla {
@ -47,7 +48,7 @@ WMFDecoderModule::~WMFDecoderModule()
void
WMFDecoderModule::Init()
{
sDXVAEnabled = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
sDXVAEnabled = gfx::gfxConfig::IsEnabled(gfx::Feature::HW_VIDEO_DECODING);
}
/* static */

Просмотреть файл

@ -22,8 +22,9 @@ namespace gfx {
_(D3D9_COMPOSITING, Feature, "Direct3D9 Compositing") \
_(OPENGL_COMPOSITING, Feature, "OpenGL Compositing") \
_(DIRECT2D, Feature, "Direct2D") \
_(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \
_(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \
_(GPU_PROCESS, Feature, "GPU Process") \
_(HW_VIDEO_DECODING, Feature, "Hardware Video Decoding") \
/* Add new entries above this comment */
enum class Feature : uint32_t {

Просмотреть файл

@ -996,6 +996,21 @@ void SourceSurfaceDestroyed(void *aData)
delete static_cast<DependentSourceSurfaceUserData*>(aData);
}
/**
* Used to update (enable or disable) hw video decode feature based on pref
* Dummy parameters are used to work with existing RegisterCallback func
*/
static void
UpdateHWDecBasedOnPref(const char* aPref, void* aClosure)
{
FeatureState& hwVideoDecFeature = gfxConfig::GetFeature(Feature::HW_VIDEO_DECODING);
if (!Preferences::GetBool("media.hardware-video-decoding.failed", false))
{
hwVideoDecFeature.UserDisable("Hardware video decoding disabled by user preference.", NS_LITERAL_CSTRING("FEATURE_FAILURE_HW_VIDEO_DEC_DISABLED_BY_PREF"));
}
}
void
gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface *aSurface)
{
@ -2074,8 +2089,6 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
* and remember the values. Changing these preferences during the run will
* not have any effect until we restart.
*/
static mozilla::Atomic<bool> sLayersSupportsHardwareVideoDecoding(false);
static bool sLayersHardwareVideoDecodingFailed = false;
static bool sBufferRotationCheckPref = true;
static bool sPrefBrowserTabsRemoteAutostart = false;
@ -2101,22 +2114,37 @@ gfxPlatform::InitAcceleration()
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
nsCString discardFailureId;
int32_t status;
if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&
FeatureState& hwVideoDecFeature = gfxConfig::GetFeature(Feature::HW_VIDEO_DECODING);
// feature prefs on
if (Preferences::GetBool("media.hardware-video-decoding.enabled", false)
#ifdef XP_WIN
Preferences::GetBool("media.windows-media-foundation.use-dxva", true) &&
&& Preferences::GetBool("media.windows-media-foundation.use-dxva", true)
#endif
NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
discardFailureId, &status))) {
if (status == nsIGfxInfo::FEATURE_STATUS_OK || gfxPrefs::HardwareVideoDecodingForceEnabled()) {
sLayersSupportsHardwareVideoDecoding = true;
}
) {
hwVideoDecFeature.EnableByDefault();
}
// not forced on and prefs not set
else {
hwVideoDecFeature.DisableByDefault(FeatureStatus::Disabled, "HW video decode pref not set.", NS_LITERAL_CSTRING("FEATURE_FAILURE_HW_VIDEO_DEC_DISABLED"));
}
Preferences::AddBoolVarCache(&sLayersHardwareVideoDecodingFailed,
"media.hardware-video-decoding.failed",
false);
// force enabled feature
if (gfxPrefs::HardwareVideoDecodingForceEnabled()) {
hwVideoDecFeature.UserForceEnable("User force-enabled video decoding.");
}
gPlatform->InitHWVideoDecodingConfig(hwVideoDecFeature);
//blocklist
nsCString message;
nsCString failureId;
if (!IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, &message, failureId)) {
hwVideoDecFeature.Disable(FeatureStatus::Blacklisted, message.get(), failureId);
}
Preferences::RegisterCallback(UpdateHWDecBasedOnPref, "media.hardware-video-decoding.failed", NULL, Preferences::ExactMatch);
if (XRE_IsParentProcess()) {
if (gfxPrefs::GPUProcessDevEnabled()) {
@ -2175,15 +2203,6 @@ gfxPlatform::InitCompositorAccelerationPrefs()
}
}
bool
gfxPlatform::CanUseHardwareVideoDecoding()
{
// this function is called from the compositor thread, so it is not
// safe to init the prefs etc. from here.
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
return sLayersSupportsHardwareVideoDecoding && !sLayersHardwareVideoDecodingFailed;
}
bool
gfxPlatform::AccelerateLayersByDefault()
{
@ -2497,4 +2516,4 @@ gfxPlatform::IsGfxInfoStatusOkay(int32_t aFeature, nsCString* aOutMessage, nsCSt
}
return true;
}
}

Просмотреть файл

@ -52,6 +52,7 @@ class ScaledFont;
class DrawEventRecorder;
class VsyncSource;
class DeviceInitData;
class FeatureState;
inline uint32_t
BackendTypeBit(BackendType b)
@ -173,6 +174,8 @@ public:
static void InitLayersIPC();
static void ShutdownLayersIPC();
virtual void InitHWVideoDecodingConfig(mozilla::gfx::FeatureState& hwVideoDecFeature){};
/**
* Initialize ScrollMetadata statics. Does not depend on gfxPlatform.
*/
@ -452,8 +455,6 @@ public:
static bool OffMainThreadCompositingEnabled();
virtual bool CanUseHardwareVideoDecoding();
// Returns a prioritized list of all available compositor backends.
void GetCompositorBackends(bool useAcceleration, nsTArray<mozilla::layers::LayersBackend>& aBackends);

Просмотреть файл

@ -401,15 +401,6 @@ gfxWindowsPlatform::InitAcceleration()
UpdateRenderMode();
}
bool
gfxWindowsPlatform::CanUseHardwareVideoDecoding()
{
if (!gfxPrefs::LayersPreferD3D9() && !mCompositorD3D11TextureSharingWorks) {
return false;
}
return !IsWARP() && gfxPlatform::CanUseHardwareVideoDecoding();
}
bool
gfxWindowsPlatform::InitDWriteSupport()
{
@ -1931,6 +1922,17 @@ InitializeANGLEConfig()
}
void
gfxWindowsPlatform::InitHWVideoDecoodingConfig(FeatureState& hwVideoDecFeature)
{
if (!gfxPrefs::LayersPreferD3D9() && !CompositorD3D11TextureSharingWorks()) {
hwVideoDecFeature.UserDisable("D3d9 not used, and d3d11 texture sharing not working", NS_LITERAL_CSTRING("FEATURE_FAILURE_HW_VIDEO_DEC_D3D_NOT_WORKING"));
}
else if (!IsWARP()) {
hwVideoDecFeature.UserDisable("WARP is disabled.", NS_LITERAL_CSTRING("FEATURE_FAILURE_HW_VIDEO_DEC_NO_WARP"));
}
}
void
gfxWindowsPlatform::InitializeConfig()
{

Просмотреть файл

@ -160,6 +160,11 @@ public:
*/
void VerifyD2DDevice(bool aAttemptForce);
/**
* Check to see that hw video decoding can be enabled, if not disable the feature
*/
void InitHWVideoDecoodingConfig(mozilla::gfx::FeatureState& hwVideoDecFeature);
virtual void GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
Script aRunScript,
nsTArray<const char*>& aFontList) override;
@ -171,8 +176,6 @@ public:
gfxUserFontSet *aUserFontSet,
gfxFloat aDevToCssSize) override;
virtual bool CanUseHardwareVideoDecoding() override;
/**
* Check whether format is supported on a platform or not (if unclear, returns true)
*/