Bug 635666 - part 3/3 - WebGL crash [@mozilla::WebGLContext::CopyTexSubImage2D] - r=jrmuizel, a=joe

This commit is contained in:
Benoit Jacob 2011-02-24 17:17:34 -05:00
parent 7b38bd3532
commit ad8f7fa5c9
2 changed files with 9 additions and 0 deletions

View File

@ -882,6 +882,12 @@ public:
return const_cast<WebGLTexture*>(this)->ImageInfoAt(level, face);
}
PRBool HasImageInfoAt(size_t level, size_t face) const {
return level <= mMaxLevelWithCustomImages &&
face < mFacesCount &&
ImageInfoAt(level, 0).mIsDefined;
}
static size_t FaceForTarget(WebGLenum target) {
return target == LOCAL_GL_TEXTURE_2D ? 0 : target - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X;
}

View File

@ -809,6 +809,9 @@ WebGLContext::CopyTexSubImage2D(WebGLenum target,
return ErrorInvalidOperation("copyTexSubImage2D: no texture bound to this target");
WebGLint face = WebGLTexture::FaceForTarget(target);
if (!tex->HasImageInfoAt(level, face))
return ErrorInvalidOperation("copyTexSubImage2D: to texture image previously defined for this level and face");
WebGLsizei texWidth = tex->ImageInfoAt(level, face).mWidth;
WebGLsizei texHeight = tex->ImageInfoAt(level, face).mHeight;