Bug 656215 - check max size for textures and renderbuffers - r=joedrew

This is needed to correctly handle exceedingly large canvases, for example.
This commit is contained in:
Benoit Jacob 2011-05-20 15:53:53 -04:00
parent b5dc4a0330
commit 7e05c500e7
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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<nsIntRect> mViewportStack;
nsTArray<nsIntRect> mScissorStack;
GLint mMaxTextureSize;
GLint mMaxRenderbufferSize;
public: