From 8d03f0b88450f90e51cd487eecb09aa463430578 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 7 Aug 2014 19:08:10 -0700 Subject: [PATCH] Backed out changeset 2422647220de (bug 1038899) for mochitest-2 bustage on a CLOSED TREE --- dom/canvas/WebGLContextGL.cpp | 3 -- dom/canvas/WebGLProgram.cpp | 63 +++++++++++++++++------------------ dom/canvas/WebGLProgram.h | 16 --------- 3 files changed, 30 insertions(+), 52 deletions(-) diff --git a/dom/canvas/WebGLContextGL.cpp b/dom/canvas/WebGLContextGL.cpp index a5b328ec4a9..759d62c1294 100644 --- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -1967,11 +1967,8 @@ WebGLContext::LinkProgram(WebGLProgram *program) if (program == mCurrentProgram) gl->fUseProgram(progname); } - - program->InitializeUniformAndAttributeMaps(); } else { program->SetLinkStatus(false); - program->ClearUniformAndAttributeMaps(); if (ShouldGenerateWarnings()) { diff --git a/dom/canvas/WebGLProgram.cpp b/dom/canvas/WebGLProgram.cpp index ac9b2be0415..975f9fd4194 100644 --- a/dom/canvas/WebGLProgram.cpp +++ b/dom/canvas/WebGLProgram.cpp @@ -14,10 +14,10 @@ using namespace mozilla; /** Takes an ASCII string like "foo[i]", turns it into "foo" and returns "[i]" in bracketPart - * + * * \param string input/output: the string to split, becomes the string without the bracket part * \param bracketPart output: gets the bracket part. - * + * * Notice that if there are multiple brackets like "foo[i].bar[j]", only the last bracket is split. */ static bool SplitLastSquareBracket(nsACString& string, nsCString& bracketPart) @@ -133,38 +133,22 @@ WebGLProgram::UpperBoundNumSamplerUniforms() { return numSamplerUniforms; } -void -WebGLProgram::InitializeUniformAndAttributeMaps() -{ - if (mIdentifierMap) { - mIdentifierMap->Clear(); - } else { - mIdentifierMap = new CStringMap; - } - - if (mIdentifierReverseMap) { - mIdentifierReverseMap->Clear(); - } else { - mIdentifierReverseMap = new CStringMap; - } - - for (size_t i = 0; i < mAttachedShaders.Length(); i++) { - for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) { - const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j]; - mIdentifierMap->Put(attrib.original, attrib.mapped); - mIdentifierReverseMap->Put(attrib.mapped, attrib.original); - } - for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) { - const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j]; - mIdentifierMap->Put(uniform.original, uniform.mapped); - mIdentifierReverseMap->Put(uniform.mapped, uniform.original); - } - } -} - void WebGLProgram::MapIdentifier(const nsACString& name, nsCString *mappedName) { - MOZ_ASSERT(mIdentifierMap); + if (!mIdentifierMap) { + // if the identifier map doesn't exist yet, build it now + mIdentifierMap = new CStringMap; + for (size_t i = 0; i < mAttachedShaders.Length(); i++) { + for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) { + const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j]; + mIdentifierMap->Put(attrib.original, attrib.mapped); + } + for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) { + const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j]; + mIdentifierMap->Put(uniform.original, uniform.mapped); + } + } + } nsCString mutableName(name); nsCString bracketPart; @@ -196,7 +180,20 @@ WebGLProgram::MapIdentifier(const nsACString& name, nsCString *mappedName) { void WebGLProgram::ReverseMapIdentifier(const nsACString& name, nsCString *reverseMappedName) { - MOZ_ASSERT(mIdentifierReverseMap); + if (!mIdentifierReverseMap) { + // if the identifier reverse map doesn't exist yet, build it now + mIdentifierReverseMap = new CStringMap; + for (size_t i = 0; i < mAttachedShaders.Length(); i++) { + for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) { + const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j]; + mIdentifierReverseMap->Put(attrib.mapped, attrib.original); + } + for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) { + const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j]; + mIdentifierReverseMap->Put(uniform.mapped, uniform.original); + } + } + } nsCString mutableName(name); nsCString bracketPart; diff --git a/dom/canvas/WebGLProgram.h b/dom/canvas/WebGLProgram.h index 103807a0b28..ddd2cb0f00d 100644 --- a/dom/canvas/WebGLProgram.h +++ b/dom/canvas/WebGLProgram.h @@ -81,22 +81,6 @@ public: /* Getters for cached program info */ bool IsAttribInUse(unsigned i) const { return mAttribsInUse[i]; } - /* Initialize the maps used by MapIdentifier and ReverseMapIdentifier. This should - * be called after each time the program has been successfully linked. - */ - void InitializeUniformAndAttributeMaps(); - - /* Clear the maps used by MapIdentifier and ReverseMapIdentifier. This should be - * called each time the program has failed to link. - */ - void ClearUniformAndAttributeMaps() { - if (mIdentifierMap) - mIdentifierMap->Clear(); - - if (mIdentifierReverseMap) - mIdentifierReverseMap->Clear(); - } - /* Maps identifier |name| to the mapped identifier |*mappedName| * Both are ASCII strings. */