Bug 701269 - Deguarantee that ResizeOffscreenFBO clears its buffers - r=bjacob

This commit is contained in:
Jeff Gilbert 2011-12-19 15:47:54 -08:00
Родитель 98da888bf9
Коммит 760e8ef03b
3 изменённых файлов: 27 добавлений и 21 удалений

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

@ -471,6 +471,8 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
// If we already have a gl context, then we just need to resize it
if (gl) {
MakeContextCurrent();
gl->ResizeOffscreen(gfxIntSize(width, height)); // Doesn't matter if it succeeds (soft-fail)
// It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize
@ -478,6 +480,9 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
mWidth = gl->OffscreenActualSize().width;
mHeight = gl->OffscreenActualSize().height;
mResetLayer = true;
gl->ClearSafely();
return NS_OK;
}
@ -669,11 +674,13 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
// Make sure that we clear this out, otherwise
// we'll end up displaying random memory
gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, gl->GetOffscreenFBO());
gl->fViewport(0, 0, mWidth, mHeight);
gl->fClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl->fClearDepth(1.0f);
gl->fClearStencil(0);
gl->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT);
gl->ClearSafely();
reporter.SetSuccessful();
return NS_OK;

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

@ -1086,8 +1086,10 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
const bool useDrawMSFBO = (samples > 0);
if (!useDrawMSFBO && !aUseReadFBO)
if (!useDrawMSFBO && !aUseReadFBO) {
// Early out, as no FBO resize work is necessary.
return true;
}
const bool firstTime = (mOffscreenDrawFBO == 0 && mOffscreenReadFBO == 0);
@ -1401,20 +1403,11 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
}
#endif
// We're good, and the framebuffer is already attached, so let's
// clear out our new framebuffer; otherwise we'll end up displaying
// random memory. We saved all of these things earlier so that we
// can restore them.
fViewport(0, 0, aSize.width, aSize.height);
// Make sure we know that the buffers are new and thus dirty:
ForceDirtyFBOs();
// Clear the new framebuffer with the full viewport
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, GetOffscreenFBO());
ClearSafely();
// Ok, now restore the GL state back to what it was before the resize took place.
// We're good, and the framebuffer is already attached.
// Now restore the GL state back to what it was before the resize took place.
BindDrawFBO(curBoundFramebufferDraw);
BindReadFBO(curBoundFramebufferRead);
fBindTexture(LOCAL_GL_TEXTURE_2D, curBoundTexture);
@ -1422,7 +1415,9 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
// -don't- restore the viewport the first time through this, since
// the previous one isn't valid.
if (!firstTime)
if (firstTime)
fViewport(0, 0, aSize.width, aSize.height); // XXX This is coming out in 711642
else
fViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
return true;

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

@ -742,16 +742,16 @@ public:
return false;
}
if (!aOffscreen->mOffscreenDrawFBO && !aOffscreen->mOffscreenReadFBO) {
return false;
}
if (!aOffscreen->mSharedContext ||
aOffscreen->mSharedContext != mSharedContext)
{
return false;
}
if (!aOffscreen->mOffscreenTexture) {
return false;
}
fBindTexture(LOCAL_GL_TEXTURE_2D, aOffscreen->mOffscreenTexture);
return true;
@ -770,7 +770,8 @@ public:
void SetFlushGuaranteesResolve(bool aFlushGuaranteesResolve) {
mFlushGuaranteesResolve = aFlushGuaranteesResolve;
}
// Before reads from offscreen texture
void GuaranteeResolve() {
if (mFlushGuaranteesResolve) {
BlitDirtyFBOs();
@ -1053,7 +1054,6 @@ public:
BindReadFBO(read);
}
// Before reads from offscreen texture
void fFinish() {
BeforeGLReadCall();
raw_fFinish();
@ -1423,8 +1423,9 @@ protected:
void UseBlitProgram();
void SetBlitFramebufferForDestTexture(GLuint aTexture);
// helper to create/resize an offscreen FBO,
// Helper to create/resize an offscreen FBO,
// for offscreen implementations that use FBOs.
// Note that it does -not- clear the resized buffers.
bool ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, const bool aDisableAA);
bool ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO) {
if (ResizeOffscreenFBO(aSize, aUseReadFBO, false))
@ -1451,8 +1452,11 @@ protected:
// Clear to transparent black, with 0 depth and stencil,
// while preserving current ClearColor etc. values.
// Useful for resizing offscreen buffers.
public:
void ClearSafely();
protected:
nsDataHashtable<nsVoidPtrHashKey, void*> mUserData;
void SetIsGLES2(bool aIsGLES2) {