diff --git a/gfx/layers/BufferTexture.cpp b/gfx/layers/BufferTexture.cpp index f7cb72d391c2..31d8d8c97008 100644 --- a/gfx/layers/BufferTexture.cpp +++ b/gfx/layers/BufferTexture.cpp @@ -385,7 +385,8 @@ static bool InitBuffer(uint8_t* buf, size_t bufSize, gfx::SurfaceFormat aFormat, return false; } - if (aAllocFlags & ALLOC_CLEAR_BUFFER) { + if ((aAllocFlags & ALLOC_CLEAR_BUFFER) || + (aAllocFlags & ALLOC_CLEAR_BUFFER_BLACK)) { if (aFormat == gfx::SurfaceFormat::B8G8R8X8) { // Even though BGRX was requested, XRGB_UINT32 is what is meant, // so use 0xFF000000 to put alpha in the right place. @@ -396,6 +397,10 @@ static bool InitBuffer(uint8_t* buf, size_t bufSize, gfx::SurfaceFormat aFormat, } } + if (aAllocFlags & ALLOC_CLEAR_BUFFER_WHITE) { + memset(buf, 0xFF, bufSize); + } + return true; } diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 80a7280de905..5fc44fb7afe9 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -266,7 +266,8 @@ static TextureType GetTextureType(gfx::SurfaceFormat aFormat, if ((layersBackend == LayersBackend::LAYERS_WR && !aKnowsCompositor->UsingSoftwareWebRender()) && (moz2DBackend == gfx::BackendType::DIRECT2D || - moz2DBackend == gfx::BackendType::DIRECT2D1_1) && + moz2DBackend == gfx::BackendType::DIRECT2D1_1 || + (!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT))) && aSize.width <= maxTextureSize && aSize.height <= maxTextureSize && !(aAllocFlags & ALLOC_UPDATE_FROM_SURFACE)) { return TextureType::D3D11; @@ -1194,7 +1195,8 @@ already_AddRefed TextureClient::CreateFromSurface( if (layersBackend == LayersBackend::LAYERS_WR && (moz2DBackend == gfx::BackendType::DIRECT2D || moz2DBackend == gfx::BackendType::DIRECT2D1_1 || - DeviceManagerDx::Get()->GetContentDevice()) && + (!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) && + DeviceManagerDx::Get()->GetContentDevice())) && size.width <= maxTextureSize && size.height <= maxTextureSize) { data = D3D11TextureData::Create(aSurface, aAllocFlags); } @@ -1246,6 +1248,10 @@ already_AddRefed TextureClient::CreateForRawBufferAccess( return nullptr; } + if (aAllocFlags & ALLOC_DISALLOW_BUFFERTEXTURECLIENT) { + return nullptr; + } + if (!gfx::Factory::AllowedSurfaceSize(aSize)) { return nullptr; } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index ef3d028e795c..234901a76443 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -62,6 +62,8 @@ class PTextureChild; class TextureChild; class TextureData; class GPUVideoTextureData; +struct RawTextureBuffer; +class RawYCbCrTextureBuffer; class TextureClient; class ITextureClientRecycleAllocator; #ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index d3a0b8e0d6e1..cbdfc2bd1276 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -288,7 +288,9 @@ D3D11TextureData::D3D11TextureData(ID3D11Texture2D* aTexture, : mSize(aSize), mFormat(aFormat), mNeedsClear(aFlags & ALLOC_CLEAR_BUFFER), + mNeedsClearWhite(aFlags & ALLOC_CLEAR_BUFFER_WHITE), mHasSynchronization(HasKeyedMutex(aTexture)), + mIsForOutOfBandContent(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT), mTexture(aTexture), mAllocationFlags(aFlags) { MOZ_ASSERT(aTexture); @@ -319,7 +321,7 @@ bool D3D11TextureData::Lock(OpenMode aMode) { return false; } - if (NS_IsMainThread()) { + if (NS_IsMainThread() && !mIsForOutOfBandContent) { if (!PrepareDrawTargetInLock(aMode)) { Unlock(); return false; @@ -332,7 +334,8 @@ bool D3D11TextureData::Lock(OpenMode aMode) { bool D3D11TextureData::PrepareDrawTargetInLock(OpenMode aMode) { // Make sure that successful write-lock means we will have a DrawTarget to // write into. - if (!mDrawTarget && (aMode & OpenMode::OPEN_WRITE || mNeedsClear)) { + if (!mDrawTarget && + (aMode & OpenMode::OPEN_WRITE || mNeedsClear || mNeedsClearWhite)) { mDrawTarget = BorrowDrawTarget(); if (!mDrawTarget) { return false; @@ -346,6 +349,11 @@ bool D3D11TextureData::PrepareDrawTargetInLock(OpenMode aMode) { mDrawTarget->ClearRect(Rect(0, 0, mSize.width, mSize.height)); mNeedsClear = false; } + if (mNeedsClearWhite) { + mDrawTarget->FillRect(Rect(0, 0, mSize.width, mSize.height), + ColorPattern(DeviceColor(1.0, 1.0, 1.0, 1.0))); + mNeedsClearWhite = false; + } return true; } @@ -453,7 +461,7 @@ D3D11TextureData* D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, } newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; - if (!NS_IsMainThread()) { + if (!NS_IsMainThread() || !!(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT)) { // On the main thread we use the syncobject to handle synchronization. if (!(aFlags & ALLOC_MANUAL_SYNCHRONIZATION)) { newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 81576b017209..da31251f2896 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -124,7 +124,9 @@ class D3D11TextureData final : public TextureData { gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::Identity; gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; bool mNeedsClear = false; + bool mNeedsClearWhite = false; const bool mHasSynchronization; + const bool mIsForOutOfBandContent; RefPtr mTexture; const TextureAllocationFlags mAllocationFlags;