Bug 1228287 - Make sure we can't do SkiaGL without the pref set. r=benwa a=ritu
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1191,16 +1191,23 @@ CanvasRenderingContext2D::RedrawUser(con
bool CanvasRenderingContext2D::SwitchRenderingMode(RenderingMode aRenderingMode)
{
if (!IsTargetValid() || mRenderingMode == aRenderingMode) {
return false;
}
#ifdef USE_SKIA_GPU
+ // Do not attempt to switch into GL mode if the platform doesn't allow it.
+ if ((aRenderingMode == RenderingMode::OpenGLBackendMode) &&
+ (!gfxPlatform::GetPlatform()->HaveChoiceOfHWAndSWCanvas() ||
+ !gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas())) {
+ return false;
+ }
+
if (mRenderingMode == RenderingMode::OpenGLBackendMode) {
if (mVideoTexture) {
gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->MakeCurrent();
gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->fDeleteTextures(1, &mVideoTexture);
}
mCurrentVideoSize.width = 0;
mCurrentVideoSize.height = 0;
}
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1161,16 +1161,21 @@ gfxPlatform::InitializeSkiaCacheLimits()
#endif
}
}
SkiaGLGlue*
gfxPlatform::GetSkiaGLGlue()
{
#ifdef USE_SKIA_GPU
+ if (!gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
+ gfxCriticalNote << "Accelerated Skia canvas is disabled";
+ return nullptr;
+ }
+
if (!mSkiaGlue) {
/* Dummy context. We always draw into a FBO.
*
* FIXME: This should be stored in TLS or something, since there needs to be one for each thread using it. As it
* stands, this only works on the main thread.
*/
RefPtr<GLContext> glContext;
glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE |