Backed out changeset d303f553f817 (bug 1289640)

This commit is contained in:
Iris Hsiao 2016-08-02 16:51:36 +08:00
parent 6d48efa876
commit c9e5c33bd4

View File

@ -226,7 +226,7 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
}
RefPtr<ID3D11Device> device =
gfx::DeviceManagerD3D11::Get()->GetContentDevice();
gfx::DeviceManagerD3D11::Get()->GetImageBridgeDevice();
LayersBackend backend = aClient->GetForwarder()->GetCompositorBackendType();
if (!device || backend != LayersBackend::LAYERS_D3D11) {
@ -237,10 +237,8 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
return nullptr;
}
if (mData.mYStride < 0 || mData.mCbCrStride < 0) {
// D3D11 only supports unsigned stride values.
return nullptr;
}
RefPtr<ID3D11DeviceContext> ctx;
device->GetImmediateContext(getter_AddRefs(ctx));
CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM,
mData.mYSize.width, mData.mYSize.height, 1, 1);
@ -248,29 +246,31 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
RefPtr<ID3D11Texture2D> textureY;
D3D11_SUBRESOURCE_DATA yData = { mData.mYChannel, (UINT)mData.mYStride, 0 };
HRESULT hr = device->CreateTexture2D(&newDesc, &yData, getter_AddRefs(textureY));
HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
newDesc.Width = mData.mCbCrSize.width;
newDesc.Height = mData.mCbCrSize.height;
RefPtr<ID3D11Texture2D> textureCb;
D3D11_SUBRESOURCE_DATA cbData = { mData.mCbChannel, (UINT)mData.mCbCrStride, 0 };
hr = device->CreateTexture2D(&newDesc, &cbData, getter_AddRefs(textureCb));
hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCb));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
RefPtr<ID3D11Texture2D> textureCr;
D3D11_SUBRESOURCE_DATA crData = { mData.mCrChannel, (UINT)mData.mCbCrStride, 0 };
hr = device->CreateTexture2D(&newDesc, &crData, getter_AddRefs(textureCr));
hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCr));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
// Even though the textures we created are meant to be protected by a keyed mutex,
// it appears that D3D doesn't include the initial memory upload within this
// synchronization. Add an empty lock/unlock pair since that appears to
// be sufficient to make sure we synchronize.
{
AutoLockTexture lockY(textureY);
AutoLockTexture lockCb(textureCb);
AutoLockTexture lockCr(textureCr);
ctx->UpdateSubresource(textureY, 0, nullptr, mData.mYChannel,
mData.mYStride, mData.mYStride * mData.mYSize.height);
ctx->UpdateSubresource(textureCb, 0, nullptr, mData.mCbChannel,
mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
ctx->UpdateSubresource(textureCr, 0, nullptr, mData.mCrChannel,
mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
}
mTextureClient = TextureClient::CreateWithData(