Bug 1340398 - Part 3: Use NV12 format by default. r=mattwoodrow
MozReview-Commit-ID: 1UdM9ANvGuh
--- a/gfx/layers/D3D11ShareHandleImage.cpp
+++ b/gfx/layers/D3D11ShareHandleImage.cpp
@@ -26,17 +26,21 @@ D3D11ShareHandleImage::D3D11ShareHandleI
mPictureRect(aRect)
{
}
bool
D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice)
{
if (aAllocator) {
- mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
+ if (gfxPrefs::PDMWMFUseNV12Format()) {
+ mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::NV12, mSize);
+ } else {
+ mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
+ }
if (mTextureClient) {
mTexture = static_cast<D3D11TextureData*>(mTextureClient->GetInternalData())->GetD3D11Texture();
return true;
}
return false;
} else {
MOZ_ASSERT(aDevice);
CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
@@ -183,20 +187,24 @@ D3D11RecycleAllocator::Allocate(gfx::Sur
aTextureFlags, aAllocFlags,
mDevice, mSurfaceAllocator->GetTextureForwarder());
}
already_AddRefed<TextureClient>
D3D11RecycleAllocator::CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
const gfx::IntSize& aSize)
{
+ TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_DEFAULT;
+ if (gfxPrefs::PDMWMFUseSyncTexture()) {
+ allocFlags = TextureAllocationFlags::ALLOC_MANUAL_SYNCHRONIZATION;
+ }
RefPtr<TextureClient> textureClient =
CreateOrRecycle(aFormat,
aSize,
BackendSelector::Content,
layers::TextureFlags::DEFAULT,
- TextureAllocationFlags::ALLOC_DEFAULT);
+ allocFlags);
return textureClient.forget();
}
} // namespace layers
} // namespace mozilla
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -559,16 +559,18 @@ private:
DECL_GFX_PREF(Once, "layout.scroll.root-frame-containers", LayoutUseContainersForRootFrames, bool, true);
DECL_GFX_PREF(Live, "layout.smaller-painted-layers", LayoutSmallerPaintedLayers, bool, false);
DECL_GFX_PREF(Once, "media.hardware-video-decoding.force-enabled",
HardwareVideoDecodingForceEnabled, bool, false);
#ifdef XP_WIN
DECL_GFX_PREF(Live, "media.windows-media-foundation.allow-d3d11-dxva", PDMWMFAllowD3D11, bool, true);
DECL_GFX_PREF(Live, "media.windows-media-foundation.max-dxva-videos", PDMWMFMaxDXVAVideos, uint32_t, 8);
+ DECL_GFX_PREF(Live, "media.windows-media-foundation.use-nv12-format", PDMWMFUseNV12Format, bool, true);
+ DECL_GFX_PREF(Live, "media.windows-media-foundation.use-sync-texture", PDMWMFUseSyncTexture, bool, true);
DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
#endif
// These affect how line scrolls from wheel events will be accelerated.
DECL_GFX_PREF(Live, "mousewheel.acceleration.factor", MouseWheelAccelerationFactor, int32_t, -1);
DECL_GFX_PREF(Live, "mousewheel.acceleration.start", MouseWheelAccelerationStart, int32_t, -1);