зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268638 - Use FailureReason struct. - r=jrmuizel
MozReview-Commit-ID: 4jxtXlToNZS
This commit is contained in:
Родитель
cd59689cf5
Коммит
1ceea00332
|
@ -97,7 +97,7 @@ static const gl::GLFeature kRequiredFeatures[] = {
|
|||
};
|
||||
|
||||
bool
|
||||
WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId)
|
||||
WebGLContext::InitWebGL2(FailureReason* const out_failReason)
|
||||
{
|
||||
MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
|
||||
|
||||
|
@ -107,8 +107,8 @@ WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out
|
|||
{
|
||||
// On desktop, we fake occlusion_query_boolean with occlusion_query if
|
||||
// necessary. (See WebGL2ContextQueries.cpp)
|
||||
*out_failureId = "FEATURE_FAILURE_WEBGL2_OCCL";
|
||||
out_failReason->AssignASCII("WebGL 2 requires occlusion query support.");
|
||||
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL",
|
||||
"WebGL 2 requires occlusion query support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -136,11 +136,10 @@ WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out
|
|||
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->Assign(reason);
|
||||
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL", reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -587,7 +587,8 @@ BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
|
|||
|
||||
static already_AddRefed<gl::GLContext>
|
||||
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
|
||||
WebGLContext* webgl,
|
||||
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||
{
|
||||
const gfx::IntSize dummySize(16, 16);
|
||||
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
||||
|
@ -597,8 +598,10 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
|||
}
|
||||
|
||||
if (!gl) {
|
||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_EGL_INIT",
|
||||
"Error during EGL OpenGL init." });
|
||||
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||
"FEATURE_FAILURE_WEBGL_EGL_INIT",
|
||||
"Error during EGL OpenGL init."
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -607,7 +610,8 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
|||
|
||||
static already_AddRefed<GLContext>
|
||||
CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
|
||||
WebGLContext* webgl,
|
||||
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||
{
|
||||
const gfx::IntSize dummySize(16, 16);
|
||||
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
||||
|
@ -617,8 +621,10 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
|||
}
|
||||
|
||||
if (!gl) {
|
||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_ANGLE_INIT",
|
||||
"Error during ANGLE OpenGL init." });
|
||||
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||
"FEATURE_FAILURE_WEBGL_ANGLE_INIT",
|
||||
"Error during ANGLE OpenGL init."
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -628,7 +634,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<FailureReason>* const out_failReasons)
|
||||
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||
{
|
||||
const gfx::IntSize dummySize(16, 16);
|
||||
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
|
||||
|
@ -639,8 +645,10 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
|||
}
|
||||
|
||||
if (!gl) {
|
||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
|
||||
"Error during native OpenGL init." });
|
||||
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||
"FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
|
||||
"Error during native OpenGL init."
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -672,7 +680,7 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
|||
return false;
|
||||
|
||||
FailureReason reason;
|
||||
if (!InitAndValidateGL(&reason.info, &reason.key)) {
|
||||
if (!InitAndValidateGL(&reason)) {
|
||||
// The fail reason here should be specific enough for now.
|
||||
gl = nullptr;
|
||||
out_failReasons->push_back(reason);
|
||||
|
@ -698,11 +706,11 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
|||
|
||||
reason.info = "Refused to create native OpenGL context because of blacklist"
|
||||
" entry: ";
|
||||
reason.info.Append(blacklistId);
|
||||
reason.info.Append(reason.key);
|
||||
|
||||
out_failReasons->push_back(reason);
|
||||
|
||||
GenerateWarning(text.BeginReading());
|
||||
GenerateWarning(reason.info.BeginReading());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +758,8 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
|||
|
||||
//////
|
||||
|
||||
out_failReasons->push_back(nsLiteralCString("Exhausted GL driver options."));
|
||||
out_failReasons->push_back(FailureReason("FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS",
|
||||
"Exhausted GL driver options."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1198,13 +1198,21 @@ 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);
|
||||
|
||||
|
@ -1223,7 +1231,8 @@ protected:
|
|||
|
||||
// -------------------------------------------------------------------------
|
||||
// Validation functions (implemented in WebGLContextValidate.cpp)
|
||||
bool InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId);
|
||||
bool InitAndValidateGL(FailureReason* const out_failReason);
|
||||
|
||||
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
|
||||
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
|
||||
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
|
||||
|
|
|
@ -648,7 +648,7 @@ FloorPOT(int32_t x)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId)
|
||||
WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
|
||||
|
||||
|
@ -657,18 +657,17 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
|||
// formats back into the authority.
|
||||
mFormatUsage = CreateFormatUsage(gl);
|
||||
if (!mFormatUsage) {
|
||||
*out_failureId = "FEATURE_FAILURE_WEBGL_FORMAT";
|
||||
out_failReason->AssignLiteral("Failed to create mFormatUsage.");
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_FORMAT",
|
||||
"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->Assign(reason);
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_1", reason };
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -757,10 +756,9 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
|||
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->Assign(reason);
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_V_ATRB", reason };
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -773,10 +771,9 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
|||
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->Assign(reason);
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_T_UNIT", reason };
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -932,8 +929,8 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
|||
|
||||
// initialize shader translator
|
||||
if (!ShInitialize()) {
|
||||
*out_failureId = "FEATURE_FAILURE_WEBGL_GLSL";
|
||||
out_failReason->AssignLiteral("GLSL translator initialization failed!");
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLSL",
|
||||
"GLSL translator initialization failed!" };
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -947,16 +944,15 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
|||
// 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->Assign(reason);
|
||||
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_2", reason };
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsWebGL2() &&
|
||||
!InitWebGL2(out_failReason, out_failureId))
|
||||
!InitWebGL2(out_failReason))
|
||||
{
|
||||
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
|
||||
return false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче