Bug 595055 - Use the correct context when deleting textures, so we don't accidentally unset some state like the viewport. r=vlad a=b

This commit is contained in:
Joe Drew 2010-09-09 23:09:39 -04:00
parent cfe8913fec
commit 8ab2818e4f
2 changed files with 19 additions and 5 deletions

View File

@ -44,6 +44,8 @@
#include "prlink.h" #include "prlink.h"
#include "nsThreadUtils.h"
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "GLContext.h" #include "GLContext.h"
#include "GLContextProvider.h" #include "GLContextProvider.h"
@ -436,12 +438,19 @@ GLContext::CreateTextureImage(const nsIntSize& aSize,
BasicTextureImage::~BasicTextureImage() BasicTextureImage::~BasicTextureImage()
{ {
nsRefPtr<GLContext> ctx = mGLContext->GetSharedContext(); GLContext *ctx = mGLContext;
if (!ctx) { if (ctx->IsDestroyed() || !NS_IsMainThread()) {
ctx = mGLContext; ctx = ctx->GetSharedContext();
}
// If we have a context, then we need to delete the texture;
// if we don't have a context (either real or shared),
// then they went away when the contex was deleted, because it
// was the only one that had access to it.
if (ctx && !ctx->IsDestroyed()) {
mGLContext->MakeCurrent();
mGLContext->fDeleteTextures(1, &mTexture);
} }
ctx->MakeCurrent();
ctx->fDeleteTextures(1, &mTexture);
} }
gfxContext* gfxContext*

View File

@ -393,6 +393,11 @@ public:
// the GL function pointers! // the GL function pointers!
void THEBES_API MarkDestroyed(); void THEBES_API MarkDestroyed();
PRBool IsDestroyed() {
// MarkDestroyed will mark all these as null.
return fUseProgram == nsnull;
}
enum NativeDataType { enum NativeDataType {
NativeGLContext, NativeGLContext,
NativeImageSurface, NativeImageSurface,