Bug 1349799 - Part 2: Adding high power context creation flag; r?jgilbert
Using the high power context flag by default, unless giving a
low_power powerPreference attritube when asking for creating WebGL context.
MozReview-Commit-ID: EZZysuu4yet
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -497,16 +497,23 @@ BaseCaps(const WebGLContextOptions& opti
" to blacklisting.");
baseCaps.antialias = false;
}
}
return baseCaps;
}
+static gl::CreateContextFlags
+ContextFlagWithPowerPreference(gl::CreateContextFlags aFlag,
+ dom::WebGLPowerPreference aPower) {
+ return (aPower == dom::WebGLPowerPreference::Low_power)
+ ? aFlag : (aFlag | gl::CreateContextFlags::HIGH_POWER);
+}
+
////////////////////////////////////////
static already_AddRefed<gl::GLContext>
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl,
std::vector<WebGLContext::FailureReason>* const out_failReasons)
{
const gfx::IntSize dummySize(16, 16);
@@ -586,17 +593,19 @@ WebGLContext::CreateAndInitGLWith(FnCrea
{
std::queue<gl::SurfaceCaps> fallbackCaps;
PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
MOZ_RELEASE_ASSERT(!gl, "GFX: Already have a context.");
RefPtr<gl::GLContext> potentialGL;
while (!fallbackCaps.empty()) {
const gl::SurfaceCaps& caps = fallbackCaps.front();
- potentialGL = fnCreateGL(caps, flags, this, out_failReasons);
+ potentialGL = fnCreateGL(caps,
+ ContextFlagWithPowerPreference(flags, mOptions.powerPreference),
+ this, out_failReasons);
if (potentialGL)
break;
fallbackCaps.pop();
}
if (!potentialGL) {
out_failReasons->push_back(FailureReason("FEATURE_FAILURE_WEBGL_EXHAUSTED_CAPS",
"Exhausted GL driver caps."));
--- a/gfx/gl/GLContextTypes.h
+++ b/gfx/gl/GLContextTypes.h
@@ -52,15 +52,17 @@ enum class CreateContextFlags : int8_t {
FORCE_ENABLE_HARDWARE = 1 << 1,
/* Don't force discrete GPU to be used (if applicable) */
ALLOW_OFFLINE_RENDERER = 1 << 2,
// Ask for ES3 if possible
PREFER_ES3 = 1 << 3,
NO_VALIDATION = 1 << 4,
PREFER_ROBUSTNESS = 1 << 5,
+
+ HIGH_POWER = 1 << 6,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
} /* namespace gl */
} /* namespace mozilla */
#endif /* GLCONTEXT_TYPES_H_ */