From 379b1ccd1d3ec608e3302e92a9b8eff4848c1e8d Mon Sep 17 00:00:00 2001 From: JerryShih Date: Tue, 9 Jun 2015 10:53:00 -0400 Subject: [PATCH] Bug 1170966 - Check quad's effective region before drawing. r=nical, a=me --- gfx/layers/opengl/CompositorOGL.cpp | 22 +++++++++++++++------- gfx/layers/opengl/CompositorOGL.h | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index e0d46fbdcd86..4b9bdda75975 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -607,6 +607,8 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion, *aRenderBoundsOut = rect; } + mRenderBoundsOut = rect; + GLint width = rect.width; GLint height = rect.height; @@ -950,6 +952,19 @@ CompositorOGL::DrawQuad(const Rect& aRect, DrawVRDistortion(aRect, aClipRect, aEffectChain, aOpacity, aTransform); return; } + + // XXX: This doesn't handle 3D transforms. It also doesn't handled rotated + // quads. Fix me. + Rect destRect = aTransform.TransformBounds(aRect); + mPixelsFilled += destRect.width * destRect.height; + + // Do a simple culling if this rect is out of target buffer. + // Inflate a small size to avoid some numerical imprecision issue. + destRect.Inflate(1, 1); + if (!mRenderBoundsOut.Intersects(destRect)) { + return; + } + LayerScope::DrawBegin(); Rect clipRect = aClipRect; @@ -999,13 +1014,6 @@ CompositorOGL::DrawQuad(const Rect& aRect, maskType = MaskType::MaskNone; } - { - // XXX: This doesn't handle 3D transforms. It also doesn't handled rotated - // quads. Fix me. - const Rect destRect = aTransform.TransformBounds(aRect); - mPixelsFilled += destRect.width * destRect.height; - } - // Determine the color if this is a color shader and fold the opacity into // the color since color shaders don't have an opacity uniform. Color color; diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 8299ec8a3e9a..30efce7fb84b 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -457,6 +457,8 @@ private: FenceHandle mReleaseFenceHandle; ShaderProgramOGL *mCurrentProgram; + gfx::Rect mRenderBoundsOut; + CompositorOGLVRObjects mVR; };