зеркало из https://github.com/mozilla/gecko-dev.git
Bug 705904 - [5/6] - Kill nsRefPtrHashtables of WebGL objects, allow unreferenced objects to be freed, fix about:memory reporting of deleted objects - r=jgilbert
This patch takes care of WebGLRenderbuffer.
This commit is contained in:
Родитель
b996390ae1
Коммит
5cfb8c36ef
|
@ -237,7 +237,6 @@ WebGLContext::WebGLContext()
|
|||
mShaderValidation = true;
|
||||
|
||||
mMapFramebuffers.Init();
|
||||
mMapRenderbuffers.Init();
|
||||
|
||||
mBlackTexturesAreInitialized = false;
|
||||
mFakeBlackStatus = DoNotNeedFakeBlack;
|
||||
|
@ -348,9 +347,9 @@ WebGLContext::DestroyResourcesAndContext()
|
|||
mTextures.Last()->DeleteOnce();
|
||||
while (mBuffers.Length())
|
||||
mBuffers.Last()->DeleteOnce();
|
||||
DeleteWebGLObjectsHashTable(mMapRenderbuffers);
|
||||
while (mRenderbuffers.Length())
|
||||
mRenderbuffers.Last()->DeleteOnce();
|
||||
DeleteWebGLObjectsHashTable(mMapFramebuffers);
|
||||
DeleteWebGLObjectsHashTable(mMapShaders);
|
||||
while (mShaders.Length())
|
||||
mShaders.Last()->DeleteOnce();
|
||||
while (mPrograms.Length())
|
||||
|
|
|
@ -829,7 +829,7 @@ protected:
|
|||
WebGLFastArray<WebGLProgram*> mPrograms;
|
||||
WebGLFastArray<WebGLShader*> mShaders;
|
||||
nsRefPtrHashtable<nsUint32HashKey, WebGLFramebuffer> mMapFramebuffers;
|
||||
nsRefPtrHashtable<nsUint32HashKey, WebGLRenderbuffer> mMapRenderbuffers;
|
||||
WebGLFastArray<WebGLRenderbuffer*> mRenderbuffers;
|
||||
|
||||
// PixelStore parameters
|
||||
PRUint32 mPixelStorePackAlignment, mPixelStoreUnpackAlignment, mPixelStoreColorspaceConversion;
|
||||
|
@ -1782,6 +1782,7 @@ public:
|
|||
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fGenRenderbuffers(1, &mGLName);
|
||||
mMonotonicHandle = mContext->mRenderbuffers.AppendElement(this);
|
||||
}
|
||||
|
||||
~WebGLRenderbuffer() {
|
||||
|
@ -1791,6 +1792,7 @@ public:
|
|||
void Delete() {
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteRenderbuffers(1, &mGLName);
|
||||
mContext->mRenderbuffers.RemoveElement(mMonotonicHandle);
|
||||
}
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
|
@ -1837,7 +1839,7 @@ protected:
|
|||
WebGLuint mGLName;
|
||||
WebGLenum mInternalFormat;
|
||||
WebGLenum mInternalFormatForGL;
|
||||
|
||||
WebGLMonotonicHandle mMonotonicHandle;
|
||||
bool mHasEverBeenBound;
|
||||
bool mInitialized;
|
||||
|
||||
|
@ -2521,30 +2523,20 @@ class WebGLMemoryReporter
|
|||
return result;
|
||||
}
|
||||
|
||||
static PLDHashOperator RenderbufferMemoryUsageFunction(const PRUint32&, WebGLRenderbuffer *aValue, void *aData)
|
||||
{
|
||||
PRInt64 *result = (PRInt64*) aData;
|
||||
*result += aValue->MemoryUsage();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PRInt64 GetRenderbufferMemoryUsed() {
|
||||
const ContextsArrayType & contexts = Contexts();
|
||||
PRInt64 result = 0;
|
||||
for(size_t i = 0; i < contexts.Length(); ++i) {
|
||||
PRInt64 bufferMemoryUsageForThisContext = 0;
|
||||
contexts[i]->mMapRenderbuffers.EnumerateRead(RenderbufferMemoryUsageFunction, &bufferMemoryUsageForThisContext);
|
||||
result += bufferMemoryUsageForThisContext;
|
||||
}
|
||||
for(size_t i = 0; i < contexts.Length(); ++i)
|
||||
for (size_t r = 0; r < contexts[i]->mRenderbuffers.Length(); ++r)
|
||||
result += contexts[i]->mRenderbuffers[r]->MemoryUsage();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static PRInt64 GetRenderbufferCount() {
|
||||
const ContextsArrayType & contexts = Contexts();
|
||||
PRInt64 result = 0;
|
||||
for(size_t i = 0; i < contexts.Length(); ++i) {
|
||||
result += contexts[i]->mMapRenderbuffers.Count();
|
||||
}
|
||||
for(size_t i = 0; i < contexts.Length(); ++i)
|
||||
result += contexts[i]->mRenderbuffers.Length();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1199,7 +1199,6 @@ WebGLContext::DeleteRenderbuffer(nsIWebGLRenderbuffer *rbobj)
|
|||
BindRenderbuffer(LOCAL_GL_RENDERBUFFER, nsnull);
|
||||
|
||||
rbuf->RequestDelete();
|
||||
mMapRenderbuffers.Remove(rbufname);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -4324,7 +4323,6 @@ WebGLContext::CreateRenderbuffer(nsIWebGLRenderbuffer **retval)
|
|||
|
||||
WebGLRenderbuffer *globj = new WebGLRenderbuffer(this);
|
||||
NS_ADDREF(*retval = globj);
|
||||
mMapRenderbuffers.Put(globj->GLName(), globj);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -526,7 +526,6 @@ WebGLContext::InitAndValidateGL()
|
|||
mBoundRenderbuffer = nsnull;
|
||||
|
||||
mMapFramebuffers.Clear();
|
||||
mMapRenderbuffers.Clear();
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче