Bug 1249189 - Use GL_RED to replace GL_ALPHA in YCbCr convert. r=jgilbert

This commit is contained in:
Ethan Lin 2016-02-23 01:51:00 +01:00
parent d0d9fe2a65
commit a199911382
2 changed files with 23 additions and 9 deletions

View File

@ -190,9 +190,9 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
uniform vec2 uCbCrTexScale; \n\
void main() \n\
{ \n\
float y = texture2D(uYTexture, vTexCoord * uYTexScale).a; \n\
float cb = texture2D(uCbTexture, vTexCoord * uCbCrTexScale).a; \n\
float cr = texture2D(uCrTexture, vTexCoord * uCbCrTexScale).a; \n\
float y = texture2D(uYTexture, vTexCoord * uYTexScale).r; \n\
float cb = texture2D(uCbTexture, vTexCoord * uCbCrTexScale).r; \n\
float cr = texture2D(uCrTexture, vTexCoord * uCbCrTexScale).r; \n\
y = (y - 0.06275) * 1.16438; \n\
cb = cb - 0.50196; \n\
cr = cr - 0.50196; \n\
@ -604,9 +604,23 @@ GLBlitHelper::BindAndUploadYUVTexture(Channel which,
MOZ_ASSERT(which < Channel_Max, "Invalid channel!");
GLuint* srcTexArr[3] = {&mSrcTexY, &mSrcTexCb, &mSrcTexCr};
GLuint& tex = *srcTexArr[which];
// RED textures aren't valid in GLES2, and ALPHA textures are not valid in desktop GL Core Profiles.
// So use R8 textures on GL3.0+ and GLES3.0+, but LUMINANCE/LUMINANCE/UNSIGNED_BYTE otherwise.
GLenum format;
GLenum internalFormat;
if (mGL->IsAtLeast(gl::ContextProfile::OpenGLCore, 300) ||
mGL->IsAtLeast(gl::ContextProfile::OpenGLES, 300)) {
format = LOCAL_GL_RED;
internalFormat = LOCAL_GL_R8;
} else {
format = LOCAL_GL_LUMINANCE;
internalFormat = LOCAL_GL_LUMINANCE;
}
if (!tex) {
MOZ_ASSERT(needsAllocation);
tex = CreateTexture(mGL, LOCAL_GL_ALPHA, LOCAL_GL_ALPHA, LOCAL_GL_UNSIGNED_BYTE,
tex = CreateTexture(mGL, internalFormat, format, LOCAL_GL_UNSIGNED_BYTE,
gfx::IntSize(width, height), false);
}
mGL->fActiveTexture(LOCAL_GL_TEXTURE0 + which);
@ -619,17 +633,17 @@ GLBlitHelper::BindAndUploadYUVTexture(Channel which,
0,
width,
height,
LOCAL_GL_ALPHA,
format,
LOCAL_GL_UNSIGNED_BYTE,
data);
} else {
mGL->fTexImage2D(LOCAL_GL_TEXTURE_2D,
0,
LOCAL_GL_ALPHA,
internalFormat,
width,
height,
0,
LOCAL_GL_ALPHA,
format,
LOCAL_GL_UNSIGNED_BYTE,
data);
}

View File

@ -285,8 +285,8 @@ public:
}
if (profile == ContextProfile::OpenGL) {
return profile == ContextProfile::OpenGLCore ||
profile == ContextProfile::OpenGLCompatibility;
return mProfile == ContextProfile::OpenGLCore ||
mProfile == ContextProfile::OpenGLCompatibility;
}
return profile == mProfile;