Bug 899435. Tidy up pt 3 - d3d11. r=Bas

This commit is contained in:
Nicholas Cameron 2013-08-01 17:00:47 +12:00
parent d09f989b3d
commit 80251db2ca

View File

@ -567,39 +567,47 @@ CompositorD3D11::BeginFrame(const Rect* aClipRectIn,
Rect* aClipRectOut,
Rect* aRenderBoundsOut)
{
VerifyBufferSize();
UpdateRenderTarget();
nsIntRect rect;
mWidget->GetClientBounds(rect);
if (rect.IsEmpty()) {
if (mSize.width == 0 || mSize.height == 0) {
*aRenderBoundsOut = Rect();
return;
}
mDefaultRT->SetSize(IntSize(rect.width, rect.height));
mContext->IASetInputLayout(mAttachments->mInputLayout);
ID3D11Buffer* buffer = mAttachments->mVertexBuffer;
UINT size = sizeof(Vertex);
UINT offset = 0;
mContext->IASetVertexBuffers(0, 1, &buffer, &size, &offset);
SetRenderTarget(mDefaultRT);
if (aClipRectOut) {
*aClipRectOut = Rect(0, 0, rect.width, rect.height);
*aClipRectOut = Rect(0, 0, mSize.width, mSize.height);
}
if (aRenderBoundsOut) {
*aRenderBoundsOut = Rect(0, 0, rect.width, rect.height);
*aRenderBoundsOut = Rect(0, 0, mSize.width, mSize.height);
}
D3D11_RECT scissor;
if (aClipRectIn) {
scissor.left = aClipRectIn->x;
scissor.right = aClipRectIn->XMost();
scissor.top = aClipRectIn->y;
scissor.bottom = aClipRectIn->YMost();
} else {
scissor.left = scissor.top = 0;
scissor.right = mSize.width;
scissor.bottom = mSize.height;
}
mContext->RSSetScissorRects(1, &scissor);
FLOAT black[] = { 0, 0, 0, 0 };
mContext->ClearRenderTargetView(mDefaultRT->mRTView, black);
mContext->OMSetBlendState(mAttachments->mPremulBlendState, sBlendFactor, 0xFFFFFFFF);
mContext->RSSetState(mAttachments->mRasterizerState);
SetRenderTarget(mDefaultRT);
}
void
@ -653,29 +661,29 @@ CompositorD3D11::EnsureSize()
void
CompositorD3D11::VerifyBufferSize()
{
nsIntRect rect;
mWidget->GetClientBounds(rect);
DXGI_SWAP_CHAIN_DESC swapDesc;
mSwapChain->GetDesc(&swapDesc);
if ((swapDesc.BufferDesc.Width == rect.width &&
swapDesc.BufferDesc.Height == rect.height) || rect.IsEmpty()) {
if ((swapDesc.BufferDesc.Width == mSize.width &&
swapDesc.BufferDesc.Height == mSize.height) ||
mSize.width == 0 || mSize.height == 0) {
return;
}
mDefaultRT = nullptr;
if (gfxWindowsPlatform::IsOptimus()) {
mSwapChain->ResizeBuffers(1, rect.width, rect.height,
mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
DXGI_FORMAT_B8G8R8A8_UNORM,
0);
#ifdef MOZ_METRO
} else if (IsRunningInWindowsMetro()) {
mSwapChain->ResizeBuffers(2, rect.width, rect.height,
mSwapChain->ResizeBuffers(2, mSize.width, mSize.height,
DXGI_FORMAT_B8G8R8A8_UNORM,
0);
#endif
} else {
mSwapChain->ResizeBuffers(1, rect.width, rect.height,
mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE);
}
@ -684,6 +692,9 @@ CompositorD3D11::VerifyBufferSize()
void
CompositorD3D11::UpdateRenderTarget()
{
EnsureSize();
VerifyBufferSize();
if (mDefaultRT) {
return;
}
@ -698,6 +709,7 @@ CompositorD3D11::UpdateRenderTarget()
}
mDefaultRT = new CompositingRenderTargetD3D11(backBuf);
mDefaultRT->SetSize(mSize);
}
bool
@ -705,7 +717,6 @@ CompositorD3D11::CreateShaders()
{
HRESULT hr;
hr = mDevice->CreateVertexShader(LayerQuadVS,
sizeof(LayerQuadVS),
nullptr,
@ -823,7 +834,7 @@ CompositorD3D11::PaintToTarget()
gfxASurface::ImageFormatARGB32);
mTarget->SetSource(tmpSurface);
mTarget->SetOperator(gfxContext::OPERATOR_OVER);
mTarget->SetOperator(gfxContext::OPERATOR_SOURCE);
mTarget->Paint();
mContext->Unmap(readTexture, 0);