Commit 9a8d004a by Jamie Madill

Fix swapchain resize errors when sizing to 0 width or height.

BUG=angle:519 Change-Id: I3d3d0746b2b3027d04c91cc5fdcd301930e3b22a Reviewed-on: https://chromium-review.googlesource.com/178455Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1b6ef526
......@@ -48,83 +48,19 @@ SwapChain11::~SwapChain11()
void SwapChain11::release()
{
if (mSwapChain)
{
mSwapChain->Release();
mSwapChain = NULL;
}
if (mBackBufferTexture)
{
mBackBufferTexture->Release();
mBackBufferTexture = NULL;
}
if (mBackBufferRTView)
{
mBackBufferRTView->Release();
mBackBufferRTView = NULL;
}
if (mOffscreenTexture)
{
mOffscreenTexture->Release();
mOffscreenTexture = NULL;
}
if (mOffscreenRTView)
{
mOffscreenRTView->Release();
mOffscreenRTView = NULL;
}
if (mOffscreenSRView)
{
mOffscreenSRView->Release();
mOffscreenSRView = NULL;
}
if (mDepthStencilTexture)
{
mDepthStencilTexture->Release();
mDepthStencilTexture = NULL;
}
if (mDepthStencilDSView)
{
mDepthStencilDSView->Release();
mDepthStencilDSView = NULL;
}
if (mQuadVB)
{
mQuadVB->Release();
mQuadVB = NULL;
}
if (mPassThroughSampler)
{
mPassThroughSampler->Release();
mPassThroughSampler = NULL;
}
if (mPassThroughIL)
{
mPassThroughIL->Release();
mPassThroughIL = NULL;
}
if (mPassThroughVS)
{
mPassThroughVS->Release();
mPassThroughVS = NULL;
}
if (mPassThroughPS)
{
mPassThroughPS->Release();
mPassThroughPS = NULL;
}
SafeRelease(mSwapChain);
SafeRelease(mBackBufferTexture);
SafeRelease(mBackBufferRTView);
SafeRelease(mOffscreenTexture);
SafeRelease(mOffscreenRTView);
SafeRelease(mOffscreenSRView);
SafeRelease(mDepthStencilTexture);
SafeRelease(mDepthStencilDSView);
SafeRelease(mQuadVB);
SafeRelease(mPassThroughSampler);
SafeRelease(mPassThroughIL);
SafeRelease(mPassThroughVS);
SafeRelease(mPassThroughPS);
if (!mAppCreatedShareHandle)
{
......@@ -134,35 +70,11 @@ void SwapChain11::release()
void SwapChain11::releaseOffscreenTexture()
{
if (mOffscreenTexture)
{
mOffscreenTexture->Release();
mOffscreenTexture = NULL;
}
if (mOffscreenRTView)
{
mOffscreenRTView->Release();
mOffscreenRTView = NULL;
}
if (mOffscreenSRView)
{
mOffscreenSRView->Release();
mOffscreenSRView = NULL;
}
if (mDepthStencilTexture)
{
mDepthStencilTexture->Release();
mDepthStencilTexture = NULL;
}
if (mDepthStencilDSView)
{
mDepthStencilDSView->Release();
mDepthStencilDSView = NULL;
}
SafeRelease(mOffscreenTexture);
SafeRelease(mOffscreenRTView);
SafeRelease(mOffscreenSRView);
SafeRelease(mDepthStencilTexture);
SafeRelease(mDepthStencilDSView);
}
EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight)
......@@ -369,20 +281,17 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
return EGL_BAD_ACCESS;
}
// Can only call resize if we have already created our swap buffer and resources
ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
if (mBackBufferTexture)
// EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
if (backbufferWidth < 1 || backbufferHeight < 1)
{
mBackBufferTexture->Release();
mBackBufferTexture = NULL;
return EGL_SUCCESS;
}
if (mBackBufferRTView)
{
mBackBufferRTView->Release();
mBackBufferRTView = NULL;
}
// Can only call resize if we have already created our swap buffer and resources
ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
SafeRelease(mBackBufferTexture);
SafeRelease(mBackBufferRTView);
// Resize swap chain
DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
......@@ -431,23 +340,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
// Release specific resources to free up memory for the new render target, while the
// old render target still exists for the purpose of preserving its contents.
if (mSwapChain)
{
mSwapChain->Release();
mSwapChain = NULL;
}
if (mBackBufferTexture)
{
mBackBufferTexture->Release();
mBackBufferTexture = NULL;
}
if (mBackBufferRTView)
{
mBackBufferRTView->Release();
mBackBufferRTView = NULL;
}
SafeRelease(mSwapChain);
SafeRelease(mBackBufferTexture);
SafeRelease(mBackBufferRTView);
mSwapInterval = static_cast<unsigned int>(swapInterval);
if (mSwapInterval > 4)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment