Backed out changeset ca314c9d5249 (bug 1268638)

--HG--
extra : rebase_source : d15fcba45320c9d5730da7dd01fc57b6703de03b
This commit is contained in:
Carsten "Tomcat" Book 2016-06-23 09:47:22 +02:00
parent a896cc25ca
commit 440b19b445
4 changed files with 36 additions and 49 deletions

View File

@ -97,7 +97,7 @@ static const gl::GLFeature kRequiredFeatures[] = {
};
bool
WebGLContext::InitWebGL2(FailureReason* const out_failReason)
WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId)
{
MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
@ -107,8 +107,8 @@ WebGLContext::InitWebGL2(FailureReason* const out_failReason)
{
// On desktop, we fake occlusion_query_boolean with occlusion_query if
// necessary. (See WebGL2ContextQueries.cpp)
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL",
"WebGL 2 requires occlusion query support.");
*out_failureId = "FEATURE_FAILURE_WEBGL2_OCCL";
out_failReason->AssignASCII("WebGL 2 requires occlusion query support.");
return false;
}
@ -136,10 +136,11 @@ WebGLContext::InitWebGL2(FailureReason* const out_failReason)
exts.Append(gl::GLContext::GetFeatureName(*itr));
}
*out_failureId = "FEATURE_FAILURE_WEBGL2_FEATURE";
const nsPrintfCString reason("WebGL 2 requires support for the following"
" features: %s",
exts.BeginReading());
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL", reason);
out_failReason->Assign(reason);
return false;
}

View File

@ -588,8 +588,7 @@ BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
static already_AddRefed<gl::GLContext>
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl,
std::vector<WebGLContext::FailureReason>* const out_failReasons)
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
@ -599,10 +598,8 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
}
if (!gl) {
out_failReasons->push_back(WebGLContext::FailureReason(
"FEATURE_FAILURE_WEBGL_EGL_INIT",
"Error during EGL OpenGL init."
));
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_EGL_INIT",
"Error during EGL OpenGL init." });
return nullptr;
}
@ -611,8 +608,7 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
static already_AddRefed<GLContext>
CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl,
std::vector<WebGLContext::FailureReason>* const out_failReasons)
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
@ -622,10 +618,8 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
}
if (!gl) {
out_failReasons->push_back(WebGLContext::FailureReason(
"FEATURE_FAILURE_WEBGL_ANGLE_INIT",
"Error during ANGLE OpenGL init."
));
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_ANGLE_INIT",
"Error during ANGLE OpenGL init." });
return nullptr;
}
@ -635,7 +629,7 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
static already_AddRefed<gl::GLContext>
CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl,
std::vector<WebGLContext::FailureReason>* const out_failReasons)
std::vector<FailureReason>* const out_failReasons)
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
@ -646,10 +640,8 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
}
if (!gl) {
out_failReasons->push_back(WebGLContext::FailureReason(
"FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
"Error during native OpenGL init."
));
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
"Error during native OpenGL init." });
return nullptr;
}
@ -681,7 +673,7 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
return false;
FailureReason reason;
if (!InitAndValidateGL(&reason)) {
if (!InitAndValidateGL(&reason.info, &reason.key)) {
// The fail reason here should be specific enough for now.
gl = nullptr;
out_failReasons->push_back(reason);
@ -707,11 +699,11 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
reason.info = "Refused to create native OpenGL context because of blacklist"
" entry: ";
reason.info.Append(reason.key);
reason.info.Append(blacklistId);
out_failReasons->push_back(reason);
GenerateWarning(reason.info.BeginReading());
GenerateWarning(text.BeginReading());
}
}
@ -759,8 +751,7 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
//////
out_failReasons->push_back(FailureReason("FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS",
"Exhausted GL driver options."));
out_failReasons->push_back(nsLiteralCString("Exhausted GL driver options."));
return false;
}

View File

@ -1201,21 +1201,13 @@ protected:
public:
virtual bool IsWebGL2() const = 0;
protected:
bool InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId);
struct FailureReason {
nsCString key; // For reporting.
nsCString info;
FailureReason() { }
template<typename A, typename B>
FailureReason(const A& _key, const B& _info)
: key(nsCString(_key))
, info(nsCString(_info))
{ }
};
protected:
bool InitWebGL2(FailureReason* const out_failReason);
bool CreateAndInitGL(bool forceEnabled,
std::vector<FailureReason>* const out_failReasons);
@ -1234,8 +1226,7 @@ protected:
// -------------------------------------------------------------------------
// Validation functions (implemented in WebGLContextValidate.cpp)
bool InitAndValidateGL(FailureReason* const out_failReason);
bool InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId);
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);

View File

@ -648,7 +648,7 @@ FloorPOT(int32_t x)
}
bool
WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId)
{
MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
@ -657,17 +657,18 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
// formats back into the authority.
mFormatUsage = CreateFormatUsage(gl);
if (!mFormatUsage) {
*out_failReason = { "FEATURE_FAILURE_WEBGL_FORMAT",
"Failed to create mFormatUsage." };
*out_failureId = "FEATURE_FAILURE_WEBGL_FORMAT";
out_failReason->AssignLiteral("Failed to create mFormatUsage.");
return false;
}
GLenum error = gl->fGetError();
if (error != LOCAL_GL_NO_ERROR) {
*out_failureId = "FEATURE_FAILURE_WEBGL_GLERR_1";
const nsPrintfCString reason("GL error 0x%x occurred during OpenGL context"
" initialization, before WebGL initialization!",
error);
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_1", reason };
out_failReason->Assign(reason);
return false;
}
@ -756,9 +757,10 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &mGLMaxVertexAttribs);
if (mGLMaxVertexAttribs < 8) {
*out_failureId = "FEATURE_FAILURE_WEBGL_V_ATRB";
const nsPrintfCString reason("GL_MAX_VERTEX_ATTRIBS: %d is < 8!",
mGLMaxVertexAttribs);
*out_failReason = { "FEATURE_FAILURE_WEBGL_V_ATRB", reason };
out_failReason->Assign(reason);
return false;
}
@ -771,9 +773,10 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
gl->fGetIntegerv(LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mGLMaxTextureUnits);
if (mGLMaxTextureUnits < 8) {
*out_failureId = "FEATURE_FAILURE_WEBGL_T_UNIT";
const nsPrintfCString reason("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d is < 8!",
mGLMaxTextureUnits);
*out_failReason = { "FEATURE_FAILURE_WEBGL_T_UNIT", reason };
out_failReason->Assign(reason);
return false;
}
@ -929,8 +932,8 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
// initialize shader translator
if (!ShInitialize()) {
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLSL",
"GLSL translator initialization failed!" };
*out_failureId = "FEATURE_FAILURE_WEBGL_GLSL";
out_failReason->AssignLiteral("GLSL translator initialization failed!");
return false;
}
@ -944,15 +947,16 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
// getError call will give the correct result.
error = gl->fGetError();
if (error != LOCAL_GL_NO_ERROR) {
*out_failureId = "FEATURE_FAILURE_WEBGL_GLERR_2";
const nsPrintfCString reason("GL error 0x%x occurred during WebGL context"
" initialization!",
error);
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_2", reason };
out_failReason->Assign(reason);
return false;
}
if (IsWebGL2() &&
!InitWebGL2(out_failReason))
!InitWebGL2(out_failReason, out_failureId))
{
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
return false;