Bug 952977: Convert PrepareViewport to gfx::Matrix4x4 r=nical

This commit is contained in:
David Zbarsky 2014-01-27 15:25:20 -05:00
parent c2e7c2cd0a
commit 0bbd7b8bd8
11 changed files with 29 additions and 29 deletions

View File

@ -363,7 +363,7 @@ public:
* coordinate space.
*/
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform) = 0;
const gfx::Matrix& aWorldTransform) = 0;
/**
* Whether textures created by this compositor can receive partial updates.

View File

@ -112,7 +112,7 @@ public:
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { }
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform) MOZ_OVERRIDE { }
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE { }
virtual void NotifyLayersTransaction() MOZ_OVERRIDE { }

View File

@ -457,7 +457,7 @@ CompositorD3D11::SetRenderTarget(CompositingRenderTarget* aRenderTarget)
ID3D11RenderTargetView* view = newRT->mRTView;
mCurrentRT = newRT;
mContext->OMSetRenderTargets(1, &view, nullptr);
PrepareViewport(newRT->GetSize(), gfxMatrix());
PrepareViewport(newRT->GetSize(), gfx::Matrix());
}
void
@ -748,7 +748,7 @@ CompositorD3D11::EndFrame()
void
CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform)
const gfx::Matrix& aWorldTransform)
{
D3D11_VIEWPORT viewport;
viewport.MaxDepth = 1.0f;
@ -760,14 +760,14 @@ CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
mContext->RSSetViewports(1, &viewport);
gfxMatrix viewMatrix;
viewMatrix.Translate(-gfxPoint(1.0, -1.0));
Matrix viewMatrix;
viewMatrix.Translate(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.Scale(1.0f, -1.0f);
viewMatrix = aWorldTransform * viewMatrix;
gfx3DMatrix projection = gfx3DMatrix::From2D(viewMatrix);
Matrix4x4 projection = Matrix4x4::From2D(viewMatrix);
projection._33 = 0.0f;
memcpy(&mVSConstants.projection, &projection, sizeof(mVSConstants.projection));

View File

@ -128,7 +128,7 @@ public:
* to a window of the given dimensions.
*/
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform) MOZ_OVERRIDE;
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE { return true; }

View File

@ -188,7 +188,7 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget)
RefPtr<CompositingRenderTargetD3D9> oldRT = mCurrentRT;
mCurrentRT = static_cast<CompositingRenderTargetD3D9*>(aRenderTarget);
mCurrentRT->BindRenderTarget(device());
PrepareViewport(mCurrentRT->GetSize(), gfxMatrix());
PrepareViewport(mCurrentRT->GetSize(), Matrix());
}
static DeviceManagerD3D9::ShaderMode
@ -651,9 +651,9 @@ CompositorD3D9::EndFrame()
void
CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix &aWorldTransform)
const Matrix &aWorldTransform)
{
gfx3DMatrix viewMatrix;
Matrix4x4 viewMatrix;
/*
* Matrix to transform to viewport space ( <-1.0, 1.0> topleft,
* <1.0, -1.0> bottomright)
@ -663,7 +663,7 @@ CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize,
viewMatrix._41 = -1.0f;
viewMatrix._42 = 1.0f;
viewMatrix = gfx3DMatrix::From2D(aWorldTransform) * viewMatrix;
viewMatrix = Matrix4x4::From2D(aWorldTransform) * viewMatrix;
HRESULT hr = device()->SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4);

View File

@ -75,7 +75,7 @@ public:
virtual void AbortFrame() MOZ_OVERRIDE {}
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform) MOZ_OVERRIDE;
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE{ return true; }

View File

@ -55,7 +55,7 @@ CompositingRenderTargetOGL::BindRenderTarget()
}
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform));
}
}
@ -91,7 +91,7 @@ CompositingRenderTargetOGL::InitializeImpl()
NS_ERROR(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform));
mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
if (mInitParams.mInit == INIT_MODE_CLEAR) {
mGL->fClearColor(0.0, 0.0, 0.0, 0.0);

View File

@ -642,7 +642,7 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
void
CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform)
const Matrix& aWorldTransform)
{
// Set the viewport correctly.
mGLContext->fViewport(0, 0, aSize.width, aSize.height);
@ -659,24 +659,24 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
// Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
// 2, 2) and flip the contents.
gfxMatrix viewMatrix;
viewMatrix.Translate(-gfxPoint(1.0, -1.0));
Matrix viewMatrix;
viewMatrix.Translate(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.Scale(1.0f, -1.0f);
if (!mTarget) {
viewMatrix.Translate(gfxPoint(mRenderOffset.x, mRenderOffset.y));
viewMatrix.Translate(mRenderOffset.x, mRenderOffset.y);
}
viewMatrix = aWorldTransform * viewMatrix;
gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix);
matrix3d._33 = 0.0f;
SetLayerProgramProjectionMatrix(matrix3d);
}
void
CompositorOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix)
CompositorOGL::SetLayerProgramProjectionMatrix(const Matrix4x4& aMatrix)
{
for (unsigned int i = 0; i < mPrograms.Length(); ++i) {
for (uint32_t mask = MaskNone; mask < NumMaskTypes; ++mask) {

View File

@ -145,7 +145,7 @@ public:
}
virtual void PrepareViewport(const gfx::IntSize& aSize,
const gfxMatrix& aWorldTransform) MOZ_OVERRIDE;
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
#ifdef MOZ_DUMP_PAINTING
@ -272,7 +272,7 @@ private:
/**
* Updates all layer programs with a new projection matrix.
*/
void SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix);
void SetLayerProgramProjectionMatrix(const gfx::Matrix4x4& aMatrix);
/**
* Helper method for Initialize, creates all valid variations of a program

View File

@ -282,7 +282,7 @@ public:
}
// activates this program and sets its projection matrix, if the program uses one
void CheckAndSetProjectionMatrix(const gfx3DMatrix& aMatrix)
void CheckAndSetProjectionMatrix(const gfx::Matrix4x4& aMatrix)
{
if (mProfile.mHasMatrixProj) {
mIsProjectionMatrixStale = true;
@ -290,7 +290,7 @@ public:
}
}
void SetProjectionMatrix(const gfx3DMatrix& aMatrix) {
void SetProjectionMatrix(const gfx::Matrix4x4& aMatrix) {
SetMatrixUniform(mProfile.LookupUniformLocation("uMatrixProj"), aMatrix);
mIsProjectionMatrixStale = false;
}
@ -365,7 +365,7 @@ public:
static const char* const TexCoordAttrib;
protected:
gfx3DMatrix mProjectionMatrix;
gfx::Matrix4x4 mProjectionMatrix;
// true if the projection matrix needs setting
bool mIsProjectionMatrixStale;

View File

@ -2839,12 +2839,12 @@ GLPresenter::BeginFrame(nsIntSize aRenderSize)
// Matrix to transform (0, 0, width, height) to viewport space (-1.0, 1.0,
// 2, 2) and flip the contents.
gfxMatrix viewMatrix;
viewMatrix.Translate(-gfxPoint(1.0, -1.0));
gfx::Matrix viewMatrix;
viewMatrix.Translate(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aRenderSize.width), 2.0f / float(aRenderSize.height));
viewMatrix.Scale(1.0f, -1.0f);
gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
gfx::Matrix4x4 matrix3d = gfx::Matrix4x4::From2D(viewMatrix);
matrix3d._33 = 0.0f;
mRGBARectProgram->CheckAndSetProjectionMatrix(matrix3d);