Bug 1124430 - Implement GetFragDataLocation. - r=kamidphish

This commit is contained in:
Jeff Gilbert 2015-01-26 17:10:25 -08:00
Родитель e64e389f2a
Коммит e1fba64ee2
3 изменённых файлов: 52 добавлений и 6 удалений

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

@ -4,16 +4,25 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
#include "GLContext.h"
#include "WebGLProgram.h"
namespace mozilla {
// -------------------------------------------------------------------------
// Programs and shaders
GLint
WebGL2Context::GetFragDataLocation(WebGLProgram* program, const nsAString& name)
WebGL2Context::GetFragDataLocation(WebGLProgram* prog, const nsAString& name)
{
MOZ_CRASH("Not Implemented.");
return 0;
if (IsContextLost())
return -1;
if (!ValidateObject("getFragDataLocation: program", prog))
return -1;
return prog->GetFragDataLocation(name);
}
} // namespace mozilla

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

@ -212,6 +212,7 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
webgl::LinkedProgramInfo::LinkedProgramInfo(WebGLProgram* aProg)
: prog(aProg)
, fragDataMap(nullptr)
{ }
////////////////////////////////////////////////////////////////////////////////
@ -417,6 +418,29 @@ WebGLProgram::GetAttribLocation(const nsAString& userName_wide) const
return gl->fGetAttribLocation(mGLName, mappedName.BeginReading());
}
GLint
WebGLProgram::GetFragDataLocation(const nsAString& userName_wide) const
{
if (!ValidateGLSLVariableName(userName_wide, mContext, "getFragDataLocation"))
return -1;
if (!IsLinked()) {
mContext->ErrorInvalidOperation("getFragDataLocation: `program` must be linked.");
return -1;
}
const NS_LossyConvertUTF16toASCII userName(userName_wide);
nsCString mappedName;
if (!LinkInfo()->FindFragData(userName, &mappedName))
return -1;
gl::GLContext* gl = mContext->GL();
gl->MakeCurrent();
return gl->fGetFragDataLocation(mGLName, mappedName.BeginReading());
}
void
WebGLProgram::GetProgramInfoLog(nsAString* const out) const
{

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

@ -38,6 +38,7 @@ struct LinkedProgramInfo MOZ_FINAL
// user-facing `GLActiveInfo::name`s, without any final "[0]".
std::map<nsCString, const WebGLActiveInfo*> attribMap;
std::map<nsCString, const WebGLActiveInfo*> uniformMap;
std::map<nsCString, const nsCString>* fragDataMap;
// Needed for draw call validation.
std::set<GLuint> activeAttribLocs;
@ -66,6 +67,17 @@ struct LinkedProgramInfo MOZ_FINAL
return true;
}
bool FindFragData(const nsCString& baseUserName,
nsCString* const out_baseMappedName) const
{
if (!fragDataMap) {
*out_baseMappedName = baseUserName;
return true;
}
MOZ_CRASH("Not implemented.");
}
bool HasActiveAttrib(GLuint loc) const {
auto itr = activeAttribLocs.find(loc);
return itr != activeAttribLocs.end();
@ -100,6 +112,7 @@ public:
already_AddRefed<WebGLActiveInfo> GetActiveUniform(GLuint index) const;
void GetAttachedShaders(nsTArray<nsRefPtr<WebGLShader>>* const out) const;
GLint GetAttribLocation(const nsAString& name) const;
GLint GetFragDataLocation(const nsAString& name) const;
void GetProgramInfoLog(nsAString* const out) const;
JS::Value GetProgramParameter(GLenum pname) const;
already_AddRefed<WebGLUniformLocation> GetUniformLocation(const nsAString& name) const;