Skip to content

Commit

Permalink
Bug 814716 - correct the way that we tweak max sizes - r=jgilbert
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Jacob committed Dec 11, 2012
1 parent 068a2a0 commit c4f587e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions content/canvas/src/WebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ WebGLContext::WebGLContext()
mGLMaxTextureUnits = 0;
mGLMaxTextureSize = 0;
mGLMaxCubeMapTextureSize = 0;
mGLMaxRenderbufferSize = 0;
mGLMaxTextureImageUnits = 0;
mGLMaxVertexTextureImageUnits = 0;
mGLMaxVaryingVectors = 0;
Expand Down
1 change: 1 addition & 0 deletions content/canvas/src/WebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ class WebGLContext :
int32_t mGLMaxTextureUnits;
int32_t mGLMaxTextureSize;
int32_t mGLMaxCubeMapTextureSize;
int32_t mGLMaxRenderbufferSize;
int32_t mGLMaxTextureImageUnits;
int32_t mGLMaxVertexTextureImageUnits;
int32_t mGLMaxVaryingVectors;
Expand Down
16 changes: 11 additions & 5 deletions content/canvas/src/WebGLContextGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1965,15 +1965,12 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
case LOCAL_GL_UNPACK_ALIGNMENT:
case LOCAL_GL_PACK_ALIGNMENT:
case LOCAL_GL_SUBPIXEL_BITS:
case LOCAL_GL_MAX_TEXTURE_SIZE:
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
case LOCAL_GL_SAMPLE_BUFFERS:
case LOCAL_GL_SAMPLES:
case LOCAL_GL_MAX_VERTEX_ATTRIBS:
case LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
case LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
case LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS:
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
case LOCAL_GL_RED_BITS:
case LOCAL_GL_GREEN_BITS:
case LOCAL_GL_BLUE_BITS:
Expand All @@ -1996,6 +1993,15 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
return JS::NullValue();
}

case LOCAL_GL_MAX_TEXTURE_SIZE:
return JS::Int32Value(mGLMaxTextureSize);

case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
return JS::Int32Value(mGLMaxCubeMapTextureSize);

case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
return JS::Int32Value(mGLMaxRenderbufferSize);

case LOCAL_GL_MAX_VERTEX_UNIFORM_VECTORS:
return JS::Int32Value(mGLMaxVertexUniformVectors);

Expand Down Expand Up @@ -3376,8 +3382,8 @@ WebGLContext::RenderbufferStorage(WebGLenum target, WebGLenum internalformat, We
if (width < 0 || height < 0)
return ErrorInvalidValue("renderbufferStorage: width and height must be >= 0");

if (!mBoundRenderbuffer || !mBoundRenderbuffer->GLName())
return ErrorInvalidOperation("renderbufferStorage called on renderbuffer 0");
if (width > mGLMaxRenderbufferSize || height > mGLMaxRenderbufferSize)
return ErrorInvalidValue("renderbufferStorage: width or height exceeds maximum renderbuffer size");

// certain OpenGL ES renderbuffer formats may not exist on desktop OpenGL
WebGLenum internalformatForGL = internalformat;
Expand Down
2 changes: 2 additions & 0 deletions content/canvas/src/WebGLContextValidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,11 +912,13 @@ WebGLContext::InitAndValidateGL()
if (MinCapabilityMode()) {
mGLMaxTextureSize = MINVALUE_GL_MAX_TEXTURE_SIZE;
mGLMaxCubeMapTextureSize = MINVALUE_GL_MAX_CUBE_MAP_TEXTURE_SIZE;
mGLMaxRenderbufferSize = MINVALUE_GL_MAX_RENDERBUFFER_SIZE;
mGLMaxTextureImageUnits = MINVALUE_GL_MAX_TEXTURE_IMAGE_UNITS;
mGLMaxVertexTextureImageUnits = MINVALUE_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;
} else {
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mGLMaxTextureSize);
gl->fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mGLMaxCubeMapTextureSize);
gl->fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mGLMaxRenderbufferSize);
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS, &mGLMaxTextureImageUnits);
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mGLMaxVertexTextureImageUnits);
}
Expand Down
1 change: 0 additions & 1 deletion gfx/gl/GLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,6 @@ class GLContext
static bool ListHasExtension(const GLubyte *extensions,
const char *extension);

GLint GetMaxTextureSize() { return mMaxTextureSize; }
GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; }
void SetFlipped(bool aFlipped) { mFlipped = aFlipped; }

Expand Down
7 changes: 5 additions & 2 deletions gfx/gl/GLTextureImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ TiledTextureImage::TiledTextureImage(GLContext* aGL,
, mGL(aGL)
, mTextureState(Created)
{
mTileSize = (!(aFlags & TextureImage::ForceSingleTile) && mGL->WantsSmallTiles())
? 256 : mGL->GetMaxTextureSize();
if (!(aFlags & TextureImage::ForceSingleTile) && mGL->WantsSmallTiles()) {
mTileSize = 256;
} else {
mGL->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, (GLint*) &mTileSize);
}
if (aSize.width != 0 && aSize.height != 0) {
Resize(aSize);
}
Expand Down
3 changes: 2 additions & 1 deletion gfx/layers/opengl/CanvasLayerOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ CanvasLayerOGL::Initialize(const Data& aData)

// Check the maximum texture size supported by GL. glTexImage2D supports
// images of up to 2 + GL_MAX_TEXTURE_SIZE
GLint texSize = gl()->GetMaxTextureSize();
GLint texSize;
gl()->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &texSize);
if (mBounds.width > (2 + texSize) || mBounds.height > (2 + texSize)) {
mDelayedUpdates = true;
MakeTextureIfNeeded(gl(), mTexture);
Expand Down
4 changes: 3 additions & 1 deletion gfx/layers/opengl/LayerManagerOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ LayerManagerOGL::Initialize(bool force)
int32_t
LayerManagerOGL::GetMaxTextureSize() const
{
return mGLContext->GetMaxTextureSize();
int32_t maxSize;
mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxSize);
return maxSize;
}

void
Expand Down

0 comments on commit c4f587e

Please sign in to comment.