Bug 683514 - Use GL_EXT_unpack_subimage when available (part 2). r=joe

The previous patch used the extension in GLContext::TexImage2D, but not
TexSubImage2D. This patch corrects that and makes sure to use the extension
in both cases.
This commit is contained in:
Chris Lord 2011-09-14 10:54:54 -07:00
Родитель 21d7a42d89
Коммит 5aa15831e6
1 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -1854,9 +1854,9 @@ GLContext::TexImage2D(GLenum target, GLint level, GLint internalformat,
if (rowLength > mMaxTextureSize)
useUnpackRowLength = false;
if (useUnpackRowLength)
if (useUnpackRowLength) {
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
else if (stride != width * pixelsize) {
} else if (stride != width * pixelsize) {
// Not using the whole row of texture data and GLES doesn't
// support GL_UNPACK_ROW_LENGTH. We need to upload each row
// separately.
@ -1916,9 +1916,18 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
GetAddressAlignment((ptrdiff_t)stride)));
#ifndef USE_GLES2
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, stride/pixelsize);
bool useUnpackRowLength = true;
#else
if (stride != width * pixelsize) {
bool useUnpackRowLength = IsExtensionSupported(EXT_unpack_subimage);
#endif
int rowLength = stride/pixelsize;
if (rowLength > mMaxTextureSize)
useUnpackRowLength = false;
if (useUnpackRowLength) {
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
} else if (stride != width * pixelsize) {
// Not using the whole row of texture data and GLES doesn't
// support GL_UNPACK_ROW_LENGTH. We need to upload each row
// separately.
@ -1940,7 +1949,6 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
return;
}
#endif
fTexSubImage2D(target,
level,
@ -1952,9 +1960,8 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
type,
pixels);
#ifndef USE_GLES2
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
#endif
if (useUnpackRowLength)
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
}