Bug 1006797 - Only apply the window render offset when actually rendering to the window. r=nical

--HG--
extra : rebase_source : 24f2d8c50e5c0ddfa6683291040a78574d631678
This commit is contained in:
Chris Lord 2014-10-03 13:22:32 +13:00
parent 924a3e27f4
commit bc0a1c5064
3 changed files with 16 additions and 5 deletions

View File

@ -92,6 +92,8 @@ CompositingRenderTargetOGL::InitializeImpl()
NS_ERROR(msg.get());
}
mInitParams.mStatus = InitParams::INITIALIZED;
mCompositor->PrepareViewport(mInitParams.mSize);
mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
if (mInitParams.mInit == INIT_MODE_CLEAR) {
@ -99,7 +101,6 @@ CompositingRenderTargetOGL::InitializeImpl()
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
}
mInitParams.mStatus = InitParams::INITIALIZED;
}
}

View File

@ -84,7 +84,7 @@ public:
const gfx::IntSize& aSize)
{
RefPtr<CompositingRenderTargetOGL> result
= new CompositingRenderTargetOGL(aCompositor, gfx::IntPoint(0, 0), 0, 0);
= new CompositingRenderTargetOGL(aCompositor, gfx::IntPoint(), 0, 0);
result->mInitParams = InitParams(aSize, 0, INIT_MODE_NONE);
result->mInitParams.mStatus = InitParams::INITIALIZED;
return result.forget();
@ -112,6 +112,8 @@ public:
*/
void BindRenderTarget();
bool IsWindow() { return GetFBO() == 0; }
GLuint GetFBO() const
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);

View File

@ -593,7 +593,10 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize)
viewMatrix.PreScale(1.0f, -1.0f);
}
if (!mTarget) {
MOZ_ASSERT(mCurrentRenderTarget, "No destination");
// If we're drawing directly to the window then we want to offset
// drawing by the render offset.
if (!mTarget && mCurrentRenderTarget->IsWindow()) {
viewMatrix.PreTranslate(mRenderOffset.x, mRenderOffset.y);
}
@ -660,8 +663,8 @@ CompositorOGL::SetRenderTarget(CompositingRenderTarget *aSurface)
CompositingRenderTargetOGL* surface
= static_cast<CompositingRenderTargetOGL*>(aSurface);
if (mCurrentRenderTarget != surface) {
surface->BindRenderTarget();
mCurrentRenderTarget = surface;
surface->BindRenderTarget();
}
}
@ -1019,9 +1022,14 @@ CompositorOGL::DrawQuad(const Rect& aRect,
js::ProfileEntry::Category::GRAPHICS);
MOZ_ASSERT(mFrameInProgress, "frame not started");
MOZ_ASSERT(mCurrentRenderTarget, "No destination");
Rect clipRect = aClipRect;
if (!mTarget) {
// aClipRect is in destination coordinate space (after all
// transforms and offsets have been applied) so if our
// drawing is going to be shifted by mRenderOffset then we need
// to shift the clip rect by the same amount.
if (!mTarget && mCurrentRenderTarget->IsWindow()) {
clipRect.MoveBy(mRenderOffset.x, mRenderOffset.y);
}
IntRect intClipRect;