зеркало из https://github.com/mozilla/pjs.git
b=583844; use correct pack alignment when reading via ReadPixels; also use EXT_bgra correctly; r=bjacob
This commit is contained in:
Родитель
524b4f23fb
Коммит
0fcc469928
|
@ -160,10 +160,9 @@ LayerManagerOGL::Initialize(GLContext *aExistingContext)
|
|||
|
||||
DEBUG_GL_ERROR_CHECK(mGLContext);
|
||||
|
||||
const char *extensionStr =
|
||||
(const char*) mGLContext->fGetString(LOCAL_GL_EXTENSIONS);
|
||||
|
||||
mHasBGRA = (strstr(extensionStr, "EXT_bgra") != nsnull);
|
||||
mHasBGRA =
|
||||
mGLContext->IsExtensionSupported(gl::GLContext::EXT_texture_format_BGRA8888) ||
|
||||
mGLContext->IsExtensionSupported(gl::GLContext::EXT_bgra);
|
||||
|
||||
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
|
@ -282,7 +281,7 @@ LayerManagerOGL::Initialize(GLContext *aExistingContext)
|
|||
* texture rectangle access inside GLSL (sampler2DRect,
|
||||
* texture2DRect).
|
||||
*/
|
||||
if (strstr(extensionStr, "ARB_texture_rectangle") == NULL)
|
||||
if (!mGLContext->IsExtensionSupported(gl::GLContext::ARB_texture_rectangle))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -744,12 +743,22 @@ LayerManagerOGL::CopyToTarget()
|
|||
NS_ASSERTION(imageSurface->Stride() == width * 4,
|
||||
"Image Surfaces being created with weird stride!");
|
||||
|
||||
PRUint32 currentPackAlignment = 0;
|
||||
mGLContext->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, (GLint*)¤tPackAlignment);
|
||||
if (currentPackAlignment != 4) {
|
||||
mGLContext->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
|
||||
}
|
||||
|
||||
mGLContext->fReadPixels(0, 0,
|
||||
width, height,
|
||||
format,
|
||||
LOCAL_GL_UNSIGNED_BYTE,
|
||||
imageSurface->Data());
|
||||
|
||||
if (currentPackAlignment != 4) {
|
||||
mGLContext->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
|
||||
}
|
||||
|
||||
if (!mHasBGRA) {
|
||||
// need to swap B and R bytes
|
||||
for (int j = 0; j < height; ++j) {
|
||||
|
|
|
@ -321,6 +321,7 @@ GLContext::InitWithPrefix(const char *prefix, PRBool trygl)
|
|||
static const char *sExtensionNames[] = {
|
||||
"GL_EXT_framebuffer_object",
|
||||
"GL_ARB_framebuffer_object",
|
||||
"GL_ARB_texture_rectangle",
|
||||
"GL_EXT_bgra",
|
||||
"GL_EXT_texture_format_BGRA8888",
|
||||
"GL_OES_depth24",
|
||||
|
|
|
@ -579,6 +579,7 @@ public:
|
|||
enum GLExtensions {
|
||||
EXT_framebuffer_object,
|
||||
ARB_framebuffer_object,
|
||||
ARB_texture_rectangle,
|
||||
EXT_bgra,
|
||||
EXT_texture_format_BGRA8888,
|
||||
OES_depth24,
|
||||
|
|
Загрузка…
Ссылка в новой задаче