From 57e99bcde726014633ce5c02c3ebc5b614204102 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 28 May 2014 12:52:13 +0200 Subject: [PATCH] Bug 1016437 - Make TextureImageTextureSourceOGL::Update refuse uploading textures that exceed the maximum texture size if bigimage is disallowed. r=bjacob --- gfx/layers/opengl/TextureHostOGL.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 0cd02bc0001..7f8e938df21 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -251,9 +251,15 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface, (mTexImage->GetSize() != size && !aSrcOffset) || mTexImage->GetContentType() != gfx::ContentForFormat(aSurface->GetFormat())) { if (mFlags & TextureFlags::DISALLOW_BIGIMAGE) { + GLint maxTextureSize; + mGL->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxTextureSize); + if (size.width > maxTextureSize || size.height > maxTextureSize) { + NS_WARNING("Texture exceeds maximum texture size, refusing upload"); + return false; + } // Explicitly use CreateBasicTextureImage instead of CreateTextureImage, - // because CreateTextureImage may still create a tiled texture image - // if the maximum texture size is exceeded. + // because CreateTextureImage might still choose to create a tiled + // texture image. mTexImage = CreateBasicTextureImage(mGL, size, gfx::ContentForFormat(aSurface->GetFormat()), WrapMode(mGL, mFlags),