diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 532d5c38371..99e54175118 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -996,9 +996,10 @@ CanvasRenderingContext2D::~CanvasRenderingContext2D() } #ifdef USE_SKIA_GPU if (mVideoTexture) { - MOZ_ASSERT(gfxPlatform::GetPlatform()->GetSkiaGLGlue(), "null SkiaGLGlue"); - gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->MakeCurrent(); - gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->fDeleteTextures(1, &mVideoTexture); + SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue(); + MOZ_ASSERT(glue); + glue->GetGLContext()->MakeCurrent(); + glue->GetGLContext()->fDeleteTextures(1, &mVideoTexture); } #endif @@ -4481,8 +4482,9 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage, mIsSkiaGL && !srcSurf && aImage.IsHTMLVideoElement() && - gfxPlatform::GetPlatform()->GetSkiaGLGlue()) { + gfxPlatform::GetPlatform()->UseAcceleratedCanvas()) { mozilla::gl::GLContext* gl = gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext(); + MOZ_ASSERT(gl); HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement(); if (!video) { @@ -5653,7 +5655,7 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder, CanvasLayer::Data data; GLuint skiaGLTex = SkiaGLTex(); - if (skiaGLTex) { + if (mIsSkiaGL && skiaGLTex) { SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue(); MOZ_ASSERT(glue); @@ -5707,7 +5709,7 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder, CanvasRenderingContext2DUserData::PreTransactionCallback, userData); GLuint skiaGLTex = SkiaGLTex(); - if (skiaGLTex) { + if (mIsSkiaGL && skiaGLTex) { SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue(); MOZ_ASSERT(glue); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index d2148390e11..e3153b67472 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1239,7 +1239,10 @@ SkiaGLGlue* gfxPlatform::GetSkiaGLGlue() { #ifdef USE_SKIA_GPU - if (!UseAcceleratedCanvas()) { + // Check the accelerated Canvas is enabled for the first time, + // because the callers should check it before using. + if (!mSkiaGlue && + !UseAcceleratedCanvas()) { gfxCriticalNote << "Accelerated Skia canvas is disabled"; return nullptr; }