Bug 1286847 - Only enable scissor testing where required in the GL compositor. r?nical
MozReview-Commit-ID: 5mxlDtY1YgK
--- a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp
+++ b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CompositingRenderTargetOGL.h"
#include "GLContext.h"
#include "GLReadTexImageHelper.h"
+#include "ScopedGLHelpers.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
using namespace mozilla::gl;
@@ -64,17 +65,19 @@ CompositingRenderTargetOGL::BindRenderTa
NS_WARNING(msg.get());
}
}
needsClear = mClearOnBind;
}
if (needsClear) {
- mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
+ ScopedGLState scopedScissorTestState(mGL, LOCAL_GL_SCISSOR_TEST, true);
+ ScopedScissorRect autoScissorRect(mGL, 0, 0, mInitParams.mSize.width,
+ mInitParams.mSize.height);
mGL->fClearColor(0.0, 0.0, 0.0, 0.0);
mGL->fClearDepth(0.0);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
}
}
#ifdef MOZ_DUMP_PAINTING
already_AddRefed<DataSourceSurface>
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -697,20 +697,16 @@ CompositorOGL::BeginFrame(const nsIntReg
TexturePoolOGL::Fill(gl());
#endif
// Default blend function implements "OVER"
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
mGLContext->fEnable(LOCAL_GL_BLEND);
- // Make sure SCISSOR is enabled before setting the render target, since the RT
- // assumes scissor is enabled while it does clears.
- mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
-
RefPtr<CompositingRenderTargetOGL> rt =
CompositingRenderTargetOGL::RenderTargetForWindow(this,
IntSize(width, height));
SetRenderTarget(rt);
#ifdef DEBUG
mWindowRenderTarget = mCurrentRenderTarget;
#endif
@@ -1048,18 +1044,19 @@ CompositorOGL::DrawQuad(const Rect& aRec
// 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);
}
- gl()->fScissor(clipRect.x, FlipY(clipRect.y + clipRect.height),
- clipRect.width, clipRect.height);
+ ScopedGLState scopedScissorTestState(mGLContext, LOCAL_GL_SCISSOR_TEST, true);
+ ScopedScissorRect autoScissorRect(mGLContext, clipRect.x, FlipY(clipRect.y + clipRect.height),
+ clipRect.width, clipRect.height);
MaskType maskType;
EffectMask* effectMask;
TextureSourceOGL* sourceMask = nullptr;
gfx::Matrix4x4 maskQuadTransform;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
sourceMask = effectMask->mMaskTexture->AsSourceOGL();