From 0bbd7b8bd87ff7b89d104104e042f3e2228a1564 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:20 -0500 Subject: [PATCH] Bug 952977: Convert PrepareViewport to gfx::Matrix4x4 r=nical --- gfx/layers/Compositor.h | 2 +- gfx/layers/basic/BasicCompositor.h | 2 +- gfx/layers/d3d11/CompositorD3D11.cpp | 10 +++++----- gfx/layers/d3d11/CompositorD3D11.h | 2 +- gfx/layers/d3d9/CompositorD3D9.cpp | 8 ++++---- gfx/layers/d3d9/CompositorD3D9.h | 2 +- gfx/layers/opengl/CompositingRenderTargetOGL.cpp | 4 ++-- gfx/layers/opengl/CompositorOGL.cpp | 12 ++++++------ gfx/layers/opengl/CompositorOGL.h | 4 ++-- gfx/layers/opengl/OGLShaderProgram.h | 6 +++--- widget/cocoa/nsChildView.mm | 6 +++--- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 964ce9765df..9ee864aca50 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -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. diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h index 8e807f23520..28ceed610ce 100644 --- a/gfx/layers/basic/BasicCompositor.h +++ b/gfx/layers/basic/BasicCompositor.h @@ -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 { } diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 00ff3d571b7..11ee8285bec 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -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)); diff --git a/gfx/layers/d3d11/CompositorD3D11.h b/gfx/layers/d3d11/CompositorD3D11.h index 106c99c4e35..7da8f3b375c 100644 --- a/gfx/layers/d3d11/CompositorD3D11.h +++ b/gfx/layers/d3d11/CompositorD3D11.h @@ -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; } diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index 6c6402ecf3e..6c06dcd8582 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -188,7 +188,7 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget) RefPtr oldRT = mCurrentRT; mCurrentRT = static_cast(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); diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h index 0e2ee154c02..9c849112f19 100644 --- a/gfx/layers/d3d9/CompositorD3D9.h +++ b/gfx/layers/d3d9/CompositorD3D9.h @@ -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; } diff --git a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp index db2d26cf304..b4dddfbe3fb 100644 --- a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp +++ b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp @@ -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); diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index c34663f197a..4a4d22e9f9b 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -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) { diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index ea9bd34e7b6..6738af80644 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -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 diff --git a/gfx/layers/opengl/OGLShaderProgram.h b/gfx/layers/opengl/OGLShaderProgram.h index 06a69867e79..ec36ac260aa 100644 --- a/gfx/layers/opengl/OGLShaderProgram.h +++ b/gfx/layers/opengl/OGLShaderProgram.h @@ -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; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 69534bfefbc..971b874ffd9 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -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);