Commit 30b84854 by Jamie Madill Committed by Commit Bot

SwapchainD3D: Take Display instead of Context.

This cleans up another use of the proxy context. Bug: angleproject:2714 Change-Id: Icba5bf76a3e9f811ee571529de16fd8162c76b3a Reviewed-on: https://chromium-review.googlesource.com/1128928Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 7dc43051
......@@ -330,7 +330,7 @@ egl::Error DisplayD3D::waitClient(const gl::Context *context)
for (egl::Surface *surface : mState.surfaceSet)
{
SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface);
ANGLE_TRY(surfaceD3D->checkForOutOfDateSwapChain(context));
ANGLE_TRY(surfaceD3D->checkForOutOfDateSwapChain(this));
}
return egl::NoError();
......@@ -344,13 +344,13 @@ egl::Error DisplayD3D::waitNative(const gl::Context *context, EGLint engine)
if (drawSurface != nullptr)
{
SurfaceD3D *drawSurfaceD3D = GetImplAs<SurfaceD3D>(drawSurface);
ANGLE_TRY(drawSurfaceD3D->checkForOutOfDateSwapChain(context));
ANGLE_TRY(drawSurfaceD3D->checkForOutOfDateSwapChain(this));
}
if (readSurface != nullptr)
{
SurfaceD3D *readSurfaceD3D = GetImplAs<SurfaceD3D>(readSurface);
ANGLE_TRY(readSurfaceD3D->checkForOutOfDateSwapChain(context));
ANGLE_TRY(readSurfaceD3D->checkForOutOfDateSwapChain(this));
}
return egl::NoError();
......
......@@ -12,6 +12,7 @@
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/Format.h"
#include "libANGLE/renderer/d3d/DisplayD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
......@@ -189,7 +190,8 @@ egl::Error SurfaceD3D::resetSwapChain(const egl::Display *display)
}
// This is a bit risky to pass the proxy context here, but it can happen at almost any time.
egl::Error error = resetSwapChain(display->getProxyContext(), width, height);
DisplayD3D *displayD3D = GetImplAs<DisplayD3D>(display);
egl::Error error = resetSwapChain(displayD3D, width, height);
if (error.isError())
{
SafeDelete(mSwapChain);
......@@ -199,7 +201,7 @@ egl::Error SurfaceD3D::resetSwapChain(const egl::Display *display)
return egl::NoError();
}
egl::Error SurfaceD3D::resizeSwapChain(const gl::Context *context,
egl::Error SurfaceD3D::resizeSwapChain(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight)
{
......@@ -207,7 +209,7 @@ egl::Error SurfaceD3D::resizeSwapChain(const gl::Context *context,
ASSERT(mSwapChain);
EGLint status =
mSwapChain->resize(context, std::max(1, backbufferWidth), std::max(1, backbufferHeight));
mSwapChain->resize(displayD3D, std::max(1, backbufferWidth), std::max(1, backbufferHeight));
if (status == EGL_CONTEXT_LOST)
{
......@@ -225,14 +227,14 @@ egl::Error SurfaceD3D::resizeSwapChain(const gl::Context *context,
return egl::NoError();
}
egl::Error SurfaceD3D::resetSwapChain(const gl::Context *context,
egl::Error SurfaceD3D::resetSwapChain(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight)
{
ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
ASSERT(mSwapChain);
EGLint status = mSwapChain->reset(context, std::max(1, backbufferWidth),
EGLint status = mSwapChain->reset(displayD3D, std::max(1, backbufferWidth),
std::max(1, backbufferHeight), mSwapInterval);
if (status == EGL_CONTEXT_LOST)
......@@ -252,7 +254,7 @@ egl::Error SurfaceD3D::resetSwapChain(const gl::Context *context,
return egl::NoError();
}
egl::Error SurfaceD3D::swapRect(const gl::Context *context,
egl::Error SurfaceD3D::swapRect(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
......@@ -275,7 +277,7 @@ egl::Error SurfaceD3D::swapRect(const gl::Context *context,
if (width != 0 && height != 0)
{
EGLint status = mSwapChain->swapRect(context, x, y, width, height);
EGLint status = mSwapChain->swapRect(displayD3D, x, y, width, height);
if (status == EGL_CONTEXT_LOST)
{
......@@ -288,12 +290,12 @@ egl::Error SurfaceD3D::swapRect(const gl::Context *context,
}
}
ANGLE_TRY(checkForOutOfDateSwapChain(context));
ANGLE_TRY(checkForOutOfDateSwapChain(displayD3D));
return egl::NoError();
}
egl::Error SurfaceD3D::checkForOutOfDateSwapChain(const gl::Context *context)
egl::Error SurfaceD3D::checkForOutOfDateSwapChain(DisplayD3D *displayD3D)
{
RECT client;
int clientWidth = getWidth();
......@@ -317,11 +319,11 @@ egl::Error SurfaceD3D::checkForOutOfDateSwapChain(const gl::Context *context)
if (mSwapIntervalDirty)
{
ANGLE_TRY(resetSwapChain(context, clientWidth, clientHeight));
ANGLE_TRY(resetSwapChain(displayD3D, clientWidth, clientHeight));
}
else if (sizeDirty)
{
ANGLE_TRY(resizeSwapChain(context, clientWidth, clientHeight));
ANGLE_TRY(resizeSwapChain(displayD3D, clientWidth, clientHeight));
}
return egl::NoError();
......@@ -329,7 +331,8 @@ egl::Error SurfaceD3D::checkForOutOfDateSwapChain(const gl::Context *context)
egl::Error SurfaceD3D::swap(const gl::Context *context)
{
return swapRect(context, 0, 0, mWidth, mHeight);
DisplayD3D *displayD3D = GetImplAs<DisplayD3D>(context->getCurrentDisplay());
return swapRect(displayD3D, 0, 0, mWidth, mHeight);
}
egl::Error SurfaceD3D::postSubBuffer(const gl::Context *context,
......@@ -338,7 +341,8 @@ egl::Error SurfaceD3D::postSubBuffer(const gl::Context *context,
EGLint width,
EGLint height)
{
return swapRect(context, x, y, width, height);
DisplayD3D *displayD3D = GetImplAs<DisplayD3D>(context->getCurrentDisplay());
return swapRect(displayD3D, x, y, width, height);
}
rx::SwapChainD3D *SurfaceD3D::getSwapChain() const
......
......@@ -19,6 +19,7 @@ class Surface;
namespace rx
{
class DisplayD3D;
class SwapChainD3D;
class RendererD3D;
......@@ -57,7 +58,7 @@ class SurfaceD3D : public SurfaceImpl
egl::Error resetSwapChain(const egl::Display *display);
egl::Error checkForOutOfDateSwapChain(const gl::Context *context);
egl::Error checkForOutOfDateSwapChain(DisplayD3D *displayD3D);
gl::Error getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
......@@ -77,17 +78,9 @@ class SurfaceD3D : public SurfaceImpl
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs);
egl::Error swapRect(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height);
egl::Error resetSwapChain(const gl::Context *context,
int backbufferWidth,
int backbufferHeight);
egl::Error resizeSwapChain(const gl::Context *context,
int backbufferWidth,
int backbufferHeight);
egl::Error swapRect(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height);
egl::Error resetSwapChain(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight);
egl::Error resizeSwapChain(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight);
RendererD3D *mRenderer;
egl::Display *mDisplay;
......
......@@ -34,6 +34,7 @@ class Display;
namespace rx
{
class DisplayD3D;
class RenderTargetD3D;
class SwapChainD3D : angle::NonCopyable
......@@ -45,18 +46,18 @@ class SwapChainD3D : angle::NonCopyable
GLenum depthBufferFormat);
virtual ~SwapChainD3D();
virtual EGLint resize(const gl::Context *context,
virtual EGLint resize(DisplayD3D *displayD3D,
EGLint backbufferWidth,
EGLint backbufferSize) = 0;
virtual EGLint reset(const gl::Context *context,
virtual EGLint reset(DisplayD3D *displayD3D,
EGLint backbufferWidth,
EGLint backbufferHeight,
EGLint swapInterval) = 0;
virtual EGLint swapRect(const gl::Context *context,
EGLint swapInterval) = 0;
virtual EGLint swapRect(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
EGLint height) = 0;
EGLint height) = 0;
virtual void recreate() = 0;
virtual RenderTargetD3D *getColorRenderTarget() = 0;
......
......@@ -153,13 +153,13 @@ void SwapChain11::releaseOffscreenDepthBuffer()
mDepthStencilSRView.reset();
}
EGLint SwapChain11::resetOffscreenBuffers(const gl::Context *context,
EGLint SwapChain11::resetOffscreenBuffers(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight)
{
if (mNeedsOffscreenTexture)
{
EGLint result = resetOffscreenColorBuffer(context, backbufferWidth, backbufferHeight);
EGLint result = resetOffscreenColorBuffer(displayD3D, backbufferWidth, backbufferHeight);
if (result != EGL_SUCCESS)
{
return result;
......@@ -178,7 +178,7 @@ EGLint SwapChain11::resetOffscreenBuffers(const gl::Context *context,
return EGL_SUCCESS;
}
EGLint SwapChain11::resetOffscreenColorBuffer(const gl::Context *context,
EGLint SwapChain11::resetOffscreenColorBuffer(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight)
{
......@@ -350,7 +350,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(const gl::Context *context,
if (mSwapChain)
{
swapRect(context, 0, 0, backbufferWidth, backbufferHeight);
swapRect(displayD3D, 0, 0, backbufferWidth, backbufferHeight);
}
}
......@@ -444,9 +444,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
return EGL_SUCCESS;
}
EGLint SwapChain11::resize(const gl::Context *context,
EGLint backbufferWidth,
EGLint backbufferHeight)
EGLint SwapChain11::resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLint backbufferHeight)
{
TRACE_EVENT0("gpu.angle", "SwapChain11::resize");
ID3D11Device *device = mRenderer->getDevice();
......@@ -526,7 +524,7 @@ EGLint SwapChain11::resize(const gl::Context *context,
mFirstSwap = true;
return resetOffscreenBuffers(context, backbufferWidth, backbufferHeight);
return resetOffscreenBuffers(displayD3D, backbufferWidth, backbufferHeight);
}
DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const
......@@ -557,7 +555,7 @@ DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const
}
}
EGLint SwapChain11::reset(const gl::Context *context,
EGLint SwapChain11::reset(DisplayD3D *displayD3D,
EGLint backbufferWidth,
EGLint backbufferHeight,
EGLint swapInterval)
......@@ -573,7 +571,7 @@ EGLint SwapChain11::reset(const gl::Context *context,
// If the swap chain already exists, just resize
if (mSwapChain != nullptr)
{
return resize(context, backbufferWidth, backbufferHeight);
return resize(displayD3D, backbufferWidth, backbufferHeight);
}
TRACE_EVENT0("gpu.angle", "SwapChain11::reset");
......@@ -646,7 +644,7 @@ EGLint SwapChain11::reset(const gl::Context *context,
mFirstSwap = true;
return resetOffscreenBuffers(context, backbufferWidth, backbufferHeight);
return resetOffscreenBuffers(displayD3D, backbufferWidth, backbufferHeight);
}
void SwapChain11::initPassThroughResources()
......@@ -748,7 +746,7 @@ void SwapChain11::initPassThroughResources()
}
// parameters should be validated/clamped by caller
EGLint SwapChain11::swapRect(const gl::Context *context,
EGLint SwapChain11::swapRect(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
......@@ -756,14 +754,14 @@ EGLint SwapChain11::swapRect(const gl::Context *context,
{
if (mNeedsOffscreenTexture)
{
EGLint result = copyOffscreenToBackbuffer(context, x, y, width, height);
EGLint result = copyOffscreenToBackbuffer(displayD3D, x, y, width, height);
if (result != EGL_SUCCESS)
{
return result;
}
}
EGLint result = present(context, x, y, width, height);
EGLint result = present(displayD3D, x, y, width, height);
if (result != EGL_SUCCESS)
{
return result;
......@@ -774,7 +772,7 @@ EGLint SwapChain11::swapRect(const gl::Context *context,
return EGL_SUCCESS;
}
EGLint SwapChain11::copyOffscreenToBackbuffer(const gl::Context *context,
EGLint SwapChain11::copyOffscreenToBackbuffer(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
......@@ -858,11 +856,7 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(const gl::Context *context,
return EGL_SUCCESS;
}
EGLint SwapChain11::present(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height)
EGLint SwapChain11::present(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height)
{
if (!mSwapChain)
{
......
......@@ -31,14 +31,12 @@ class SwapChain11 final : public SwapChainD3D
EGLint samples);
~SwapChain11() override;
EGLint resize(const gl::Context *context,
EGLint backbufferWidth,
EGLint backbufferHeight) override;
EGLint reset(const gl::Context *context,
EGLint resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLint backbufferHeight) override;
EGLint reset(DisplayD3D *displayD3D,
EGLint backbufferWidth,
EGLint backbufferHeight,
EGLint swapInterval) override;
EGLint swapRect(const gl::Context *context,
EGLint swapRect(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
......@@ -69,22 +67,20 @@ class SwapChain11 final : public SwapChainD3D
void releaseOffscreenColorBuffer();
void releaseOffscreenDepthBuffer();
EGLint resetOffscreenBuffers(const gl::Context *context,
int backbufferWidth,
int backbufferHeight);
EGLint resetOffscreenColorBuffer(const gl::Context *context,
EGLint resetOffscreenBuffers(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight);
EGLint resetOffscreenColorBuffer(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight);
EGLint resetOffscreenDepthBuffer(int backbufferWidth, int backbufferHeight);
DXGI_FORMAT getSwapChainNativeFormat() const;
EGLint copyOffscreenToBackbuffer(const gl::Context *context,
EGLint copyOffscreenToBackbuffer(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
EGLint height);
EGLint present(const gl::Context *context, EGLint x, EGLint y, EGLint width, EGLint height);
EGLint present(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height);
UINT getD3DSamples() const;
Renderer11 *mRenderer;
......
......@@ -79,13 +79,13 @@ static DWORD convertInterval(EGLint interval)
#endif
}
EGLint SwapChain9::resize(const gl::Context *context, int backbufferWidth, int backbufferHeight)
EGLint SwapChain9::resize(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight)
{
// D3D9 does not support resizing swap chains without recreating them
return reset(context, backbufferWidth, backbufferHeight, mSwapInterval);
return reset(displayD3D, backbufferWidth, backbufferHeight, mSwapInterval);
}
EGLint SwapChain9::reset(const gl::Context *context,
EGLint SwapChain9::reset(DisplayD3D *displayD3D,
int backbufferWidth,
int backbufferHeight,
EGLint swapInterval)
......@@ -268,11 +268,7 @@ EGLint SwapChain9::reset(const gl::Context *context,
}
// parameters should be validated/clamped by caller
EGLint SwapChain9::swapRect(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height)
EGLint SwapChain9::swapRect(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height)
{
if (!mSwapChain)
{
......
......@@ -30,13 +30,12 @@ class SwapChain9 : public SwapChainD3D
EGLint orientation);
~SwapChain9() override;
EGLint resize(const gl::Context *context, EGLint backbufferWidth, EGLint backbufferHeight)
override;
EGLint reset(const gl::Context *context,
EGLint resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLint backbufferHeight) override;
EGLint reset(DisplayD3D *displayD3D,
EGLint backbufferWidth,
EGLint backbufferHeight,
EGLint swapInterval) override;
EGLint swapRect(const gl::Context *context,
EGLint swapRect(DisplayD3D *displayD3D,
EGLint x,
EGLint y,
EGLint width,
......
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