diff --git a/gfx/thebes/GLContext.cpp b/gfx/thebes/GLContext.cpp index 7c976f234cb0..fbc2ba00d765 100644 --- a/gfx/thebes/GLContext.cpp +++ b/gfx/thebes/GLContext.cpp @@ -383,6 +383,7 @@ GLContext::InitWithPrefix(const char *prefix, PRBool trygl) mViewportStack.AppendElement(nsIntRect(v[0], v[1], v[2], v[3])); fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize); UpdateActualFormat(); } @@ -702,6 +703,9 @@ BasicTextureImage::Resize(const nsIntSize& aSize) PRBool GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize) { + if (!IsOffscreenSizeAllowed(aSize)) + return PR_FALSE; + MakeCurrent(); bool alpha = mCreationFormat.alpha > 0; diff --git a/gfx/thebes/GLContext.h b/gfx/thebes/GLContext.h index 9e79a3f319c4..d1c16183c737 100644 --- a/gfx/thebes/GLContext.h +++ b/gfx/thebes/GLContext.h @@ -994,11 +994,18 @@ protected: return teximage.forget(); } + bool IsOffscreenSizeAllowed(const gfxIntSize& aSize) const { + PRInt32 biggerDimension = NS_MAX(aSize.width, aSize.height); + PRInt32 maxAllowed = NS_MIN(mMaxRenderbufferSize, mMaxTextureSize); + return biggerDimension <= maxAllowed; + } + protected: nsTArray mViewportStack; nsTArray mScissorStack; GLint mMaxTextureSize; + GLint mMaxRenderbufferSize; public: