Bug 1273252 - r?jrmuizel - WARP should hit
From 1aea1bd168d6a61165a1038c7debfa1d940c9896 Mon Sep 17 00:00:00 2001
failIfMajorPerformanceCaveat.
---
dom/canvas/WebGLContext.cpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
MozReview-Commit-ID: FDiXSWldsBB
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -880,21 +880,21 @@ WebGLContext::SetDimensions(int32_t sign
disabled |= gfxPlatform::InSafeMode();
if (disabled) {
const nsLiteralCString text("WebGL is currently disabled.");
ThrowEvent_WebGLContextCreationError(text);
return NS_ERROR_FAILURE;
}
- bool failIfPerfCaveat = mOptions.failIfMajorPerformanceCaveat;
- if (gfxPrefs::WebGLDisableFailIfMajorPerformanceCaveat())
- failIfPerfCaveat = false;
+ if (gfxPrefs::WebGLDisableFailIfMajorPerformanceCaveat()) {
+ mOptions.failIfMajorPerformanceCaveat = false;
+ }
- if (failIfPerfCaveat) {
+ if (mOptions.failIfMajorPerformanceCaveat) {
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
if (!HasAcceleratedLayers(gfxInfo)) {
const nsLiteralCString text("failIfMajorPerformanceCaveat: Compositor is not"
" hardware-accelerated.");
ThrowEvent_WebGLContextCreationError(text);
return NS_ERROR_FAILURE;
}
}
@@ -907,18 +907,26 @@ WebGLContext::SetDimensions(int32_t sign
nsCString failReason;
if (!CreateAndInitGL(forceEnabled, &failReason)) {
const nsPrintfCString text("WebGL creation failed: %s",
failReason.BeginReading());
ThrowEvent_WebGLContextCreationError(text);
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(gl);
+ MOZ_ASSERT_IF(mOptions.alpha, gl->Caps().alpha);
- MOZ_ASSERT_IF(mOptions.alpha, gl->Caps().alpha);
+ if (mOptions.failIfMajorPerformanceCaveat) {
+ if (gl->IsWARP()) {
+ const nsLiteralCString text("failIfMajorPerformanceCaveat: Driver is not"
+ " hardware-accelerated.");
+ ThrowEvent_WebGLContextCreationError(text);
+ return NS_ERROR_FAILURE;
+ }
+ }
if (!ResizeBackbuffer(width, height)) {
const nsLiteralCString text("Initializing WebGL backbuffer failed.");
ThrowEvent_WebGLContextCreationError(text);
return NS_ERROR_FAILURE;
}
#ifdef DEBUG