Bug 1355763 - Handle UNPACK_ state for ConvertPlanarYCbCr, and reject blits with _SKIP_* for now. - r=daoshengmu

MozReview-Commit-ID: JsDF66DwTfZ
This commit is contained in:
Jeff Gilbert 2017-04-12 09:22:28 -07:00
Родитель 95c5ba8077
Коммит 3ab253476f
4 изменённых файлов: 85 добавлений и 10 удалений

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

@ -637,6 +637,14 @@ TexUnpackImage::TexOrSubImage(bool isSubImage, bool needsRespec, const char* fun
break;
}
if (webgl->mPixelStore_UnpackSkipPixels ||
webgl->mPixelStore_UnpackSkipRows ||
webgl->mPixelStore_UnpackSkipImages)
{
fallbackReason = "non-zero UNPACK_SKIP_* not yet supported";
break;
}
const auto fnHasPremultMismatch = [&]() {
if (mSrcAlphaType == gfxAlphaType::Opaque)
return false;

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

@ -756,9 +756,13 @@ GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage)
mGL->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, &oldTex[i]);
}
BindAndUploadYUVTexture(Channel_Y, yuvData->mYStride, yuvData->mYSize.height, yuvData->mYChannel, needsAllocation);
BindAndUploadYUVTexture(Channel_Cb, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCbChannel, needsAllocation);
BindAndUploadYUVTexture(Channel_Cr, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCrChannel, needsAllocation);
{
const ResetUnpackState reset(mGL);
BindAndUploadYUVTexture(Channel_Y, yuvData->mYStride, yuvData->mYSize.height, yuvData->mYChannel, needsAllocation);
BindAndUploadYUVTexture(Channel_Cb, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCbChannel, needsAllocation);
BindAndUploadYUVTexture(Channel_Cr, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCrChannel, needsAllocation);
}
if (needsAllocation) {
mGL->fUniform2f(mYTexScaleLoc, (float)yuvData->mYSize.width/yuvData->mYStride, 1.0f);
@ -868,13 +872,8 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
mGL->fViewport(0, 0, destSize.width, destSize.height);
switch (type) {
case ConvertPlanarYCbCr: {
const auto saved = mGL->GetIntAs<GLint>(LOCAL_GL_UNPACK_ALIGNMENT);
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1);
const auto ret = BlitPlanarYCbCrImage(static_cast<PlanarYCbCrImage*>(srcImage));
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, saved);
return ret;
}
case ConvertPlanarYCbCr:
return BlitPlanarYCbCrImage(static_cast<PlanarYCbCrImage*>(srcImage));
#ifdef MOZ_WIDGET_ANDROID
case ConvertSurfaceTexture:

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

@ -530,6 +530,52 @@ ScopedPackState::UnwrapImpl()
mGL->fPixelStorei(LOCAL_GL_PACK_SKIP_ROWS, mSkipRows);
}
////////////////////////////////////////////////////////////////////////
// ResetUnpackState
ResetUnpackState::ResetUnpackState(GLContext* gl)
: ScopedGLWrapper<ResetUnpackState>(gl)
{
const auto fnReset = [&](GLenum pname, GLuint val, GLuint* const out_old) {
mGL->GetUIntegerv(pname, out_old);
if (*out_old != val) {
mGL->fPixelStorei(pname, val);
}
};
// Default is 4, but 1 is more useful.
fnReset(LOCAL_GL_UNPACK_ALIGNMENT, 1, &mAlignment);
if (!mGL->HasPBOState())
return;
mGL->GetUIntegerv(LOCAL_GL_PIXEL_UNPACK_BUFFER_BINDING, &mPBO);
if (mPBO != 0) mGL->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
fnReset(LOCAL_GL_UNPACK_ROW_LENGTH , 0, &mRowLength);
fnReset(LOCAL_GL_UNPACK_IMAGE_HEIGHT, 0, &mImageHeight);
fnReset(LOCAL_GL_UNPACK_SKIP_PIXELS , 0, &mSkipPixels);
fnReset(LOCAL_GL_UNPACK_SKIP_ROWS , 0, &mSkipRows);
fnReset(LOCAL_GL_UNPACK_SKIP_IMAGES , 0, &mSkipImages);
}
void
ResetUnpackState::UnwrapImpl()
{
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, mAlignment);
if (!mGL->HasPBOState())
return;
mGL->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, mPBO);
mGL->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, mRowLength);
mGL->fPixelStorei(LOCAL_GL_UNPACK_IMAGE_HEIGHT, mImageHeight);
mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_PIXELS, mSkipPixels);
mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_ROWS, mSkipRows);
mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_IMAGES, mSkipImages);
}
////////////////////////////////////////////////////////////////////////
// ScopedBindPBO

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

@ -362,6 +362,28 @@ protected:
void UnwrapImpl();
};
struct ResetUnpackState
: public ScopedGLWrapper<ResetUnpackState>
{
friend struct ScopedGLWrapper<ResetUnpackState>;
protected:
GLuint mAlignment;
GLuint mPBO;
GLuint mRowLength;
GLuint mImageHeight;
GLuint mSkipPixels;
GLuint mSkipRows;
GLuint mSkipImages;
public:
explicit ResetUnpackState(GLContext* gl);
protected:
void UnwrapImpl();
};
struct ScopedBindPBO final
: public ScopedGLWrapper<ScopedBindPBO>
{