Refactored Renderer::setViewport to no longer take render target size arguments.

TRAC #22145 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1515 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 04f1b33c
......@@ -1754,8 +1754,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
ProgramBinary *programBinary = mState.currentProgram ? getCurrentProgramBinary() : NULL;
if (!mRenderer->setViewport(viewport, zNear, zFar, mRenderTargetDesc.width, mRenderTargetDesc.height,
programBinary, mDxUniformsDirty))
if (!mRenderer->setViewport(viewport, zNear, zFar, programBinary, mDxUniformsDirty))
{
return false;
}
......
......@@ -88,8 +88,7 @@ class Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize) = 0;
virtual void setScissorRectangle(const gl::Rectangle &scissor) = 0;
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
gl::ProgramBinary *currentProgram, bool forceSetUniforms) = 0;
virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
......
......@@ -368,18 +368,17 @@ void Renderer11::setScissorRectangle(const gl::Rectangle &scissor)
mForceSetScissor = false;
}
bool Renderer11::setViewport(const gl::Rectangle& viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
bool Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
gl::ProgramBinary *currentProgram, bool forceSetUniforms)
{
bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
zNear != mCurNear || zFar != mCurFar;
D3D11_VIEWPORT dxViewport;
dxViewport.TopLeftX = gl::clamp(viewport.x, 0, static_cast<int>(renderTargetWidth));
dxViewport.TopLeftY = gl::clamp(viewport.y, 0, static_cast<int>(renderTargetHeight));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(renderTargetWidth) - static_cast<int>(dxViewport.TopLeftX));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(renderTargetHeight) - static_cast<int>(dxViewport.TopLeftY));
dxViewport.TopLeftX = gl::clamp(viewport.x, 0, static_cast<int>(mRenderTargetDesc.width));
dxViewport.TopLeftY = gl::clamp(viewport.y, 0, static_cast<int>(mRenderTargetDesc.height));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.TopLeftX));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.TopLeftY));
dxViewport.MinDepth = zNear;
dxViewport.MaxDepth = zFar;
......
......@@ -55,8 +55,7 @@ class Renderer11 : public Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
gl::ProgramBinary *currentProgram, bool forceSetUniforms);
virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
......
......@@ -919,18 +919,17 @@ void Renderer9::setScissorRectangle(const gl::Rectangle &scissor)
mForceSetScissor = false;
}
bool Renderer9::setViewport(const gl::Rectangle& viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
bool Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
gl::ProgramBinary *currentProgram, bool forceSetUniforms)
{
bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
zNear != mCurNear || zFar != mCurFar;
D3DVIEWPORT9 dxViewport;
dxViewport.X = gl::clamp(viewport.x, 0, static_cast<int>(renderTargetWidth));
dxViewport.Y = gl::clamp(viewport.y, 0, static_cast<int>(renderTargetHeight));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(renderTargetWidth) - static_cast<int>(dxViewport.X));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(renderTargetHeight) - static_cast<int>(dxViewport.Y));
dxViewport.X = gl::clamp(viewport.x, 0, static_cast<int>(mRenderTargetDesc.width));
dxViewport.Y = gl::clamp(viewport.y, 0, static_cast<int>(mRenderTargetDesc.height));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.X));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.Y));
dxViewport.MinZ = zNear;
dxViewport.MaxZ = zFar;
......
......@@ -90,8 +90,7 @@ class Renderer9 : public Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
gl::ProgramBinary *currentProgram, bool forceSetUniforms);
virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
......
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