Bug 1530471 - remove SkiaGL Canvas2D functionality r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Thu, 28 Feb 2019 14:58:19 +0000
changeset 461775 9dac1bac38598b3da42bb15e8f74e4072ffa370e
parent 461774 d1e480941a33654feb86f4da38efe7f36ede439a
child 461776 4b820d7d2c139589db88828b73687b380ccd3bb6
push id35629
push useropoprus@mozilla.com
push dateFri, 01 Mar 2019 05:20:57 +0000
treeherdermozilla-central@9d39099e5fc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1530471
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530471 - remove SkiaGL Canvas2D functionality r=jrmuizel Depends on D21050 Differential Revision: https://phabricator.services.mozilla.com/D21051
dom/canvas/CanvasImageCache.cpp
dom/canvas/CanvasImageCache.h
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
dom/canvas/OffscreenCanvas.cpp
dom/media/platforms/android/AndroidDecoderModule.cpp
--- a/dom/canvas/CanvasImageCache.cpp
+++ b/dom/canvas/CanvasImageCache.cpp
@@ -22,47 +22,42 @@ namespace mozilla {
 using namespace dom;
 using namespace gfx;
 
 /**
  * Used for images specific to this one canvas. Required
  * due to CORS security.
  */
 struct ImageCacheKey {
-  ImageCacheKey(imgIContainer* aImage, HTMLCanvasElement* aCanvas,
-                bool aIsAccelerated)
-      : mImage(aImage), mCanvas(aCanvas), mIsAccelerated(aIsAccelerated) {}
+  ImageCacheKey(imgIContainer* aImage, HTMLCanvasElement* aCanvas)
+      : mImage(aImage), mCanvas(aCanvas) {}
   nsCOMPtr<imgIContainer> mImage;
   HTMLCanvasElement* mCanvas;
-  bool mIsAccelerated;
 };
 
 /**
  * Cache data needs to be separate from the entry
  * for nsExpirationTracker.
  */
 struct ImageCacheEntryData {
   ImageCacheEntryData(const ImageCacheEntryData& aOther)
       : mImage(aOther.mImage),
         mCanvas(aOther.mCanvas),
-        mIsAccelerated(aOther.mIsAccelerated),
         mSourceSurface(aOther.mSourceSurface),
         mSize(aOther.mSize) {}
   explicit ImageCacheEntryData(const ImageCacheKey& aKey)
       : mImage(aKey.mImage),
-        mCanvas(aKey.mCanvas),
-        mIsAccelerated(aKey.mIsAccelerated) {}
+        mCanvas(aKey.mCanvas) {}
 
   nsExpirationState* GetExpirationState() { return &mState; }
   size_t SizeInBytes() { return mSize.width * mSize.height * 4; }
 
   // Key
   nsCOMPtr<imgIContainer> mImage;
   HTMLCanvasElement* mCanvas;
-  bool mIsAccelerated;
   // Value
   RefPtr<SourceSurface> mSourceSurface;
   IntSize mSize;
   nsExpirationState mState;
 };
 
 class ImageCacheEntry : public PLDHashEntryHdr {
  public:
@@ -71,67 +66,63 @@ class ImageCacheEntry : public PLDHashEn
 
   explicit ImageCacheEntry(const KeyType* aKey)
       : mData(new ImageCacheEntryData(*aKey)) {}
   ImageCacheEntry(const ImageCacheEntry& toCopy)
       : mData(new ImageCacheEntryData(*toCopy.mData)) {}
   ~ImageCacheEntry() {}
 
   bool KeyEquals(KeyTypePointer key) const {
-    return mData->mImage == key->mImage && mData->mCanvas == key->mCanvas &&
-           mData->mIsAccelerated == key->mIsAccelerated;
+    return mData->mImage == key->mImage && mData->mCanvas == key->mCanvas;
   }
 
   static KeyTypePointer KeyToPointer(KeyType& key) { return &key; }
   static PLDHashNumber HashKey(KeyTypePointer key) {
-    return HashGeneric(key->mImage.get(), key->mCanvas, key->mIsAccelerated);
+    return HashGeneric(key->mImage.get(), key->mCanvas);
   }
   enum { ALLOW_MEMMOVE = true };
 
   nsAutoPtr<ImageCacheEntryData> mData;
 };
 
 /**
  * Used for all images across all canvases.
  */
 struct AllCanvasImageCacheKey {
-  AllCanvasImageCacheKey(imgIContainer* aImage, bool aIsAccelerated)
-      : mImage(aImage), mIsAccelerated(aIsAccelerated) {}
+  explicit AllCanvasImageCacheKey(imgIContainer* aImage)
+      : mImage(aImage) {}
 
   nsCOMPtr<imgIContainer> mImage;
-  bool mIsAccelerated;
 };
 
 class AllCanvasImageCacheEntry : public PLDHashEntryHdr {
  public:
   typedef AllCanvasImageCacheKey KeyType;
   typedef const AllCanvasImageCacheKey* KeyTypePointer;
 
   explicit AllCanvasImageCacheEntry(const KeyType* aKey)
-      : mImage(aKey->mImage), mIsAccelerated(aKey->mIsAccelerated) {}
+      : mImage(aKey->mImage) {}
 
   AllCanvasImageCacheEntry(const AllCanvasImageCacheEntry& toCopy)
       : mImage(toCopy.mImage),
-        mIsAccelerated(toCopy.mIsAccelerated),
         mSourceSurface(toCopy.mSourceSurface) {}
 
   ~AllCanvasImageCacheEntry() {}
 
   bool KeyEquals(KeyTypePointer key) const {
-    return mImage == key->mImage && mIsAccelerated == key->mIsAccelerated;
+    return mImage == key->mImage;
   }
 
   static KeyTypePointer KeyToPointer(KeyType& key) { return &key; }
   static PLDHashNumber HashKey(KeyTypePointer key) {
-    return HashGeneric(key->mImage.get(), key->mIsAccelerated);
+    return HashGeneric(key->mImage.get());
   }
   enum { ALLOW_MEMMOVE = true };
 
   nsCOMPtr<imgIContainer> mImage;
-  bool mIsAccelerated;
   RefPtr<SourceSurface> mSourceSurface;
 };
 
 static bool sPrefsInitialized = false;
 static int32_t sCanvasImageCacheLimit = 0;
 
 class ImageCacheObserver;
 
@@ -144,21 +135,20 @@ class ImageCache final : public nsExpira
 
   virtual void NotifyExpired(ImageCacheEntryData* aObject) override {
     mTotal -= aObject->SizeInBytes();
     RemoveObject(aObject);
 
     // Remove from the all canvas cache entry first since nsExpirationTracker
     // will delete aObject.
     mAllCanvasCache.RemoveEntry(
-        AllCanvasImageCacheKey(aObject->mImage, aObject->mIsAccelerated));
+        AllCanvasImageCacheKey(aObject->mImage));
 
     // Deleting the entry will delete aObject since the entry owns aObject.
-    mCache.RemoveEntry(ImageCacheKey(aObject->mImage, aObject->mCanvas,
-                                     aObject->mIsAccelerated));
+    mCache.RemoveEntry(ImageCacheKey(aObject->mImage, aObject->mCanvas));
   }
 
   nsTHashtable<ImageCacheEntry> mCache;
   nsTHashtable<AllCanvasImageCacheEntry> mAllCanvasCache;
   size_t mTotal;
   RefPtr<ImageCacheObserver> mImageCacheObserver;
 };
 
@@ -268,31 +258,30 @@ static already_AddRefed<imgIContainer> G
   }
 
   return imgContainer.forget();
 }
 
 void CanvasImageCache::NotifyDrawImage(Element* aImage,
                                        HTMLCanvasElement* aCanvas,
                                        SourceSurface* aSource,
-                                       const IntSize& aSize,
-                                       bool aIsAccelerated) {
+                                       const IntSize& aSize) {
   if (!gImageCache) {
     gImageCache = new ImageCache();
     nsContentUtils::RegisterShutdownObserver(
         new CanvasImageCacheShutdownObserver());
   }
 
   nsCOMPtr<imgIContainer> imgContainer = GetImageContainer(aImage);
   if (!imgContainer) {
     return;
   }
 
-  AllCanvasImageCacheKey allCanvasCacheKey(imgContainer, aIsAccelerated);
-  ImageCacheKey canvasCacheKey(imgContainer, aCanvas, aIsAccelerated);
+  AllCanvasImageCacheKey allCanvasCacheKey(imgContainer);
+  ImageCacheKey canvasCacheKey(imgContainer, aCanvas);
   ImageCacheEntry* entry = gImageCache->mCache.PutEntry(canvasCacheKey);
 
   if (entry) {
     if (entry->mData->mSourceSurface) {
       // We are overwriting an existing entry.
       gImageCache->mTotal -= entry->mData->SizeInBytes();
       gImageCache->RemoveObject(entry->mData);
       gImageCache->mAllCanvasCache.RemoveEntry(allCanvasCacheKey);
@@ -312,51 +301,49 @@ void CanvasImageCache::NotifyDrawImage(E
 
   if (!sCanvasImageCacheLimit) return;
 
   // Expire the image cache early if its larger than we want it to be.
   while (gImageCache->mTotal > size_t(sCanvasImageCacheLimit))
     gImageCache->AgeOneGeneration();
 }
 
-SourceSurface* CanvasImageCache::LookupAllCanvas(Element* aImage,
-                                                 bool aIsAccelerated) {
+SourceSurface* CanvasImageCache::LookupAllCanvas(Element* aImage) {
   if (!gImageCache) {
     return nullptr;
   }
 
   nsCOMPtr<imgIContainer> imgContainer = GetImageContainer(aImage);
   if (!imgContainer) {
     return nullptr;
   }
 
   AllCanvasImageCacheEntry* entry = gImageCache->mAllCanvasCache.GetEntry(
-      AllCanvasImageCacheKey(imgContainer, aIsAccelerated));
+      AllCanvasImageCacheKey(imgContainer));
   if (!entry) {
     return nullptr;
   }
 
   return entry->mSourceSurface;
 }
 
 SourceSurface* CanvasImageCache::LookupCanvas(Element* aImage,
                                               HTMLCanvasElement* aCanvas,
-                                              IntSize* aSizeOut,
-                                              bool aIsAccelerated) {
+                                              IntSize* aSizeOut) {
   if (!gImageCache) {
     return nullptr;
   }
 
   nsCOMPtr<imgIContainer> imgContainer = GetImageContainer(aImage);
   if (!imgContainer) {
     return nullptr;
   }
 
   ImageCacheEntry* entry = gImageCache->mCache.GetEntry(
-      ImageCacheKey(imgContainer, aCanvas, aIsAccelerated));
+      ImageCacheKey(imgContainer, aCanvas));
   if (!entry) {
     return nullptr;
   }
 
   MOZ_ASSERT(aSizeOut);
 
   gImageCache->MarkUsed(entry->mData);
   *aSizeOut = entry->mData->mSize;
--- a/dom/canvas/CanvasImageCache.h
+++ b/dom/canvas/CanvasImageCache.h
@@ -28,31 +28,28 @@ class CanvasImageCache {
  public:
   /**
    * Notify that image element aImage was drawn to aCanvas element
    * using the first frame of aRequest's image. The data for the surface is
    * in aSurface, and the image size is in aSize.
    */
   static void NotifyDrawImage(dom::Element* aImage,
                               dom::HTMLCanvasElement* aCanvas,
-                              SourceSurface* aSource, const gfx::IntSize& aSize,
-                              bool aIsAccelerated);
+                              SourceSurface* aSource, const gfx::IntSize& aSize);
 
   /**
    * Check whether aImage has recently been drawn any canvas. If we return
    * a non-null surface, then the same image was recently drawn into a canvas.
    */
-  static SourceSurface* LookupAllCanvas(dom::Element* aImage,
-                                        bool aIsAccelerated);
+  static SourceSurface* LookupAllCanvas(dom::Element* aImage);
 
   /**
    * Like the top above, but restricts the lookup to only aCanvas. This is
    * required for CORS security.
    */
   static SourceSurface* LookupCanvas(dom::Element* aImage,
                                      dom::HTMLCanvasElement* aCanvas,
-                                     gfx::IntSize* aSizeOut,
-                                     bool aIsAccelerated);
+                                     gfx::IntSize* aSizeOut);
 };
 
 }  // namespace mozilla
 
 #endif /* CANVASIMAGECACHE_H_ */
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -101,18 +101,16 @@
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/SVGImageElement.h"
 #include "mozilla/dom/SVGMatrix.h"
 #include "mozilla/dom/TextMetrics.h"
 #include "mozilla/dom/SVGMatrix.h"
 #include "mozilla/FloatingPoint.h"
 #include "nsGlobalWindow.h"
-#include "GLContext.h"
-#include "GLContextProvider.h"
 #include "nsIScreenManager.h"
 #include "nsFilterInstance.h"
 #include "nsSVGLength2.h"
 #include "nsDeviceContext.h"
 #include "nsFontMetrics.h"
 #include "Units.h"
 #include "CanvasUtils.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
@@ -120,26 +118,16 @@
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/SVGContentUtils.h"
 #include "mozilla/layers/CanvasClient.h"
 #include "mozilla/layers/WebRenderUserData.h"
 #include "mozilla/layers/WebRenderCanvasRenderer.h"
 
 #undef free  // apparently defined by some windows header, clashing with a
              // free() method in SkTypes.h
-#include "SkiaGLGlue.h"
-#ifdef USE_SKIA
-#  include "SurfaceTypes.h"
-#  include "GLBlitHelper.h"
-#  include "ScopedGLHelpers.h"
-#endif
-
-using mozilla::gl::GLContext;
-using mozilla::gl::GLContextProvider;
-using mozilla::gl::SkiaGLGlue;
 
 #ifdef XP_WIN
 #  include "gfxWindowsPlatform.h"
 #endif
 
 // windows.h (included by chromium code) defines this, in its infinite wisdom
 #undef DrawText
 
@@ -755,115 +743,16 @@ CanvasShutdownObserver::Observe(nsISuppo
   if (mCanvas && strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
     mCanvas->OnShutdown();
     OnShutdown();
   }
 
   return NS_OK;
 }
 
-class CanvasDrawObserver {
- public:
-  explicit CanvasDrawObserver(CanvasRenderingContext2D* aCanvasContext);
-
-  // Only enumerate draw calls that could affect the heuristic
-  enum DrawCallType { PutImageData, GetImageData, DrawImage };
-
-  // This is the one that we call on relevant draw calls and count
-  // GPU vs. CPU preferrable calls...
-  void DidDrawCall(DrawCallType aType);
-
-  // When this returns true, the observer is done making the decisions.
-  // Right now, we expect to get rid of the observer after the FrameEnd
-  // returns true, though the decision could eventually change if the
-  // function calls shift.  If we change to monitor the functions called
-  // and make decisions to change more than once, we would probably want
-  // FrameEnd to reset the timer and counters as it returns true.
-  bool FrameEnd();
-
- private:
-  // These values will be picked up from preferences:
-  int32_t mMinFramesBeforeDecision;
-  float mMinSecondsBeforeDecision;
-  int32_t mMinCallsBeforeDecision;
-
-  CanvasRenderingContext2D* mCanvasContext;
-  int32_t mSoftwarePreferredCalls;
-  int32_t mGPUPreferredCalls;
-  int32_t mFramesRendered;
-  TimeStamp mCreationTime;
-};
-
-// We are not checking for the validity of the preference values.  For example,
-// negative values will have an effect of a quick exit, so no harm done.
-CanvasDrawObserver::CanvasDrawObserver(CanvasRenderingContext2D* aCanvasContext)
-    : mMinFramesBeforeDecision(gfxPrefs::CanvasAutoAccelerateMinFrames()),
-      mMinSecondsBeforeDecision(gfxPrefs::CanvasAutoAccelerateMinSeconds()),
-      mMinCallsBeforeDecision(gfxPrefs::CanvasAutoAccelerateMinCalls()),
-      mCanvasContext(aCanvasContext),
-      mSoftwarePreferredCalls(0),
-      mGPUPreferredCalls(0),
-      mFramesRendered(0),
-      mCreationTime(TimeStamp::NowLoRes()) {}
-
-void CanvasDrawObserver::DidDrawCall(DrawCallType aType) {
-  switch (aType) {
-    case PutImageData:
-    case GetImageData:
-      if (mGPUPreferredCalls == 0 && mSoftwarePreferredCalls == 0) {
-        mCreationTime = TimeStamp::NowLoRes();
-      }
-      mSoftwarePreferredCalls++;
-      break;
-    case DrawImage:
-      if (mGPUPreferredCalls == 0 && mSoftwarePreferredCalls == 0) {
-        mCreationTime = TimeStamp::NowLoRes();
-      }
-      mGPUPreferredCalls++;
-      break;
-  }
-}
-
-// If we return true, the observer is done making the decisions...
-bool CanvasDrawObserver::FrameEnd() {
-  mFramesRendered++;
-
-  // We log the first mMinFramesBeforeDecision frames of any
-  // canvas object then make a call to determine whether it should
-  // be GPU or CPU backed
-  if ((mFramesRendered >= mMinFramesBeforeDecision) ||
-      ((TimeStamp::NowLoRes() - mCreationTime).ToSeconds()) >
-          mMinSecondsBeforeDecision) {
-    // If we don't have enough data, don't bother changing...
-    if (mGPUPreferredCalls > mMinCallsBeforeDecision ||
-        mSoftwarePreferredCalls > mMinCallsBeforeDecision) {
-      CanvasRenderingContext2D::RenderingMode switchToMode;
-      if (mGPUPreferredCalls >= mSoftwarePreferredCalls) {
-        switchToMode =
-            CanvasRenderingContext2D::RenderingMode::OpenGLBackendMode;
-      } else {
-        switchToMode =
-            CanvasRenderingContext2D::RenderingMode::SoftwareBackendMode;
-      }
-      if (switchToMode != mCanvasContext->mRenderingMode) {
-        if (!mCanvasContext->SwitchRenderingMode(switchToMode)) {
-          gfxDebug() << "Canvas acceleration failed mode switch to "
-                     << switchToMode;
-        }
-      }
-    }
-
-    // If we ever redesign this class to constantly monitor the functions
-    // and keep making decisions, we would probably want to reset the counters
-    // and the timers here...
-    return true;
-  }
-  return false;
-}
-
 class CanvasRenderingContext2DUserData : public LayerUserData {
  public:
   explicit CanvasRenderingContext2DUserData(CanvasRenderingContext2D* aContext)
       : mContext(aContext) {
     aContext->mUserDatas.AppendElement(this);
   }
   ~CanvasRenderingContext2DUserData() {
     if (mContext) {
@@ -879,22 +768,16 @@ class CanvasRenderingContext2DUserData :
     context->OnStableState();
   }
 
   static void DidTransactionCallback(void* aData) {
     CanvasRenderingContext2D* context =
         static_cast<CanvasRenderingContext2D*>(aData);
     if (context) {
       context->MarkContextClean();
-      if (context->mDrawObserver) {
-        if (context->mDrawObserver->FrameEnd()) {
-          // Note that this call deletes and nulls out mDrawObserver:
-          context->RemoveDrawObserver();
-        }
-      }
     }
   }
   bool IsForContext(CanvasRenderingContext2D* aContext) {
     return mContext == aContext;
   }
   void Forget() { mContext = nullptr; }
 
  private:
@@ -904,17 +787,16 @@ class CanvasRenderingContext2DUserData :
 NS_IMPL_CYCLE_COLLECTING_ADDREF(CanvasRenderingContext2D)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(CanvasRenderingContext2D)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(CanvasRenderingContext2D)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CanvasRenderingContext2D)
   // Make sure we remove ourselves from the list of demotable contexts (raw
   // pointers), since we're logically destructed at this point.
-  CanvasRenderingContext2D::RemoveDemotableContext(tmp);
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCanvasElement)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocShell)
   for (uint32_t i = 0; i < tmp->mStyleStack.Length(); i++) {
     ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[Style::STROKE]);
     ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[Style::FILL]);
     ImplCycleCollectionUnlink(
         tmp->mStyleStack[i].gradientStyles[Style::STROKE]);
     ImplCycleCollectionUnlink(tmp->mStyleStack[i].gradientStyles[Style::FILL]);
@@ -995,74 +877,54 @@ NS_INTERFACE_MAP_END
 
 /**
  ** CanvasRenderingContext2D impl
  **/
 
 // Initialize our static variables.
 uintptr_t CanvasRenderingContext2D::sNumLivingContexts = 0;
 DrawTarget* CanvasRenderingContext2D::sErrorTarget = nullptr;
-static bool sMaxContextsInitialized = false;
-static int32_t sMaxContexts = 0;
 
 CanvasRenderingContext2D::CanvasRenderingContext2D(
     layers::LayersBackend aCompositorBackend)
-    : mRenderingMode(RenderingMode::OpenGLBackendMode),
-      mCompositorBackend(aCompositorBackend)
-      // these are the default values from the Canvas spec
-      ,
+    : // these are the default values from the Canvas spec
       mWidth(0),
       mHeight(0),
       mZero(false),
       mOpaqueAttrValue(false),
       mContextAttributesHasAlpha(true),
       mOpaque(false),
       mResetLayer(true),
       mIPC(false),
-      mIsSkiaGL(false),
       mHasPendingStableStateCallback(false),
-      mDrawObserver(nullptr),
       mIsEntireFrameInvalid(false),
       mPredictManyRedrawCalls(false),
       mIsCapturedFrameInvalid(false),
       mPathTransformWillUpdate(false),
       mInvalidateCount(0),
       mWriteOnly(false) {
-  if (!sMaxContextsInitialized) {
-    sMaxContexts = gfxPrefs::CanvasAzureAcceleratedLimit();
-    sMaxContextsInitialized = true;
-  }
 
   sNumLivingContexts++;
 
   mShutdownObserver = new CanvasShutdownObserver(this);
   nsContentUtils::RegisterShutdownObserver(mShutdownObserver);
-
-  // The default is to use OpenGL mode
-  if (AllowOpenGLCanvas()) {
-    mDrawObserver = new CanvasDrawObserver(this);
-  } else {
-    mRenderingMode = RenderingMode::SoftwareBackendMode;
-  }
 }
 
 CanvasRenderingContext2D::~CanvasRenderingContext2D() {
-  RemoveDrawObserver();
   RemovePostRefreshObserver();
   RemoveShutdownObserver();
   Reset();
   // Drop references from all CanvasRenderingContext2DUserData to this context
   for (uint32_t i = 0; i < mUserDatas.Length(); ++i) {
     mUserDatas[i]->Forget();
   }
   sNumLivingContexts--;
   if (!sNumLivingContexts) {
     NS_IF_RELEASE(sErrorTarget);
   }
-  RemoveDemotableContext(this);
 }
 
 JSObject* CanvasRenderingContext2D::WrapObject(
     JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
   return CanvasRenderingContext2D_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 bool CanvasRenderingContext2D::ParseColor(const nsAString& aString,
@@ -1223,229 +1085,45 @@ void CanvasRenderingContext2D::Redraw(co
   }
 
   SVGObserverUtils::InvalidateDirectRenderingObservers(mCanvasElement);
 
   mCanvasElement->InvalidateCanvasContent(&aR);
 }
 
 void CanvasRenderingContext2D::DidRefresh() {
-  if (IsTargetValid() && mIsSkiaGL) {
-    SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-    MOZ_ASSERT(glue);
-
-    auto gl = glue->GetGLContext();
-    gl->FlushIfHeavyGLCallsSinceLastFlush();
-  }
 }
 
 void CanvasRenderingContext2D::RedrawUser(const gfxRect& aR) {
   mIsCapturedFrameInvalid = true;
 
   if (mIsEntireFrameInvalid) {
     ++mInvalidateCount;
     return;
   }
 
   gfx::Rect newr = mTarget->GetTransform().TransformBounds(ToRect(aR));
   Redraw(newr);
 }
 
-bool CanvasRenderingContext2D::AllowOpenGLCanvas() const {
-  // If we somehow didn't have the correct compositor in the constructor,
-  // we could do something like this to get it:
-  //
-  // HTMLCanvasElement* el = GetCanvas();
-  // if (el) {
-  //   mCompositorBackend = el->GetCompositorBackendType();
-  // }
-  //
-  // We could have LAYERS_NONE if there was no widget at the time of
-  // canvas creation, but in that case the
-  // HTMLCanvasElement::GetCompositorBackendType would return LAYERS_NONE
-  // as well, so it wouldn't help much.
-  //
-  // XXX Disable SkiaGL on WebRender, since there is a case that R8G8B8X8
-  // is used, but WebRender does not support R8G8B8X8.
-
-  return (mCompositorBackend == LayersBackend::LAYERS_OPENGL) &&
-         gfxPlatform::GetPlatform()->AllowOpenGLCanvas();
-}
-
-bool CanvasRenderingContext2D::SwitchRenderingMode(
-    RenderingMode aRenderingMode) {
-  if (!(IsTargetValid() || mBufferProvider) ||
-      mRenderingMode == aRenderingMode) {
-    return false;
-  }
-
-  MOZ_ASSERT(mBufferProvider);
-
-#ifdef USE_SKIA_GPU
-  // Do not attempt to switch into GL mode if the platform doesn't allow it.
-  if ((aRenderingMode == RenderingMode::OpenGLBackendMode) &&
-      !AllowOpenGLCanvas()) {
-    return false;
-  }
-#endif
-
-  RefPtr<PersistentBufferProvider> oldBufferProvider = mBufferProvider;
-
-  // Return the old target to the buffer provider.
-  // We need to do this before calling EnsureTarget.
-  ReturnTarget();
-  mTarget = nullptr;
-  mBufferProvider = nullptr;
-  mResetLayer = true;
-
-  // Recreate mTarget using the new rendering mode
-  RenderingMode attemptedMode = EnsureTarget(nullptr, aRenderingMode);
-  if (!IsTargetValid()) {
-    return false;
-  }
-
-  if (oldBufferProvider && mTarget) {
-    CopyBufferProvider(*oldBufferProvider, *mTarget,
-                       IntRect(0, 0, mWidth, mHeight));
-  }
-
-  // We succeeded, so update mRenderingMode to reflect reality
-  mRenderingMode = attemptedMode;
-
-  return true;
-}
-
 bool CanvasRenderingContext2D::CopyBufferProvider(
     PersistentBufferProvider& aOld, DrawTarget& aTarget, IntRect aCopyRect) {
   // Borrowing the snapshot must be done after ReturnTarget.
   RefPtr<SourceSurface> snapshot = aOld.BorrowSnapshot();
 
   if (!snapshot) {
     return false;
   }
 
   aTarget.CopySurface(snapshot, aCopyRect, IntPoint());
   aOld.ReturnSnapshot(snapshot.forget());
   return true;
 }
 
 void CanvasRenderingContext2D::Demote() {
-  if (SwitchRenderingMode(RenderingMode::SoftwareBackendMode)) {
-    RemoveDemotableContext(this);
-  }
-}
-
-std::vector<CanvasRenderingContext2D*>&
-CanvasRenderingContext2D::DemotableContexts() {
-  // This is a list of raw pointers to cycle-collected objects. We need to
-  // ensure that we remove elements from it during UNLINK (which can happen
-  // considerably before the actual destructor) since the object is logically
-  // destroyed at that point and will be in an inconsistant state.
-  static std::vector<CanvasRenderingContext2D*> contexts;
-  return contexts;
-}
-
-void CanvasRenderingContext2D::DemoteOldestContextIfNecessary() {
-  MOZ_ASSERT(sMaxContextsInitialized);
-  if (sMaxContexts <= 0) {
-    return;
-  }
-
-  std::vector<CanvasRenderingContext2D*>& contexts = DemotableContexts();
-  if (contexts.size() < (size_t)sMaxContexts) return;
-
-  CanvasRenderingContext2D* oldest = contexts.front();
-  if (oldest->SwitchRenderingMode(RenderingMode::SoftwareBackendMode)) {
-    RemoveDemotableContext(oldest);
-  }
-}
-
-void CanvasRenderingContext2D::AddDemotableContext(
-    CanvasRenderingContext2D* aContext) {
-  MOZ_ASSERT(sMaxContextsInitialized);
-  if (sMaxContexts <= 0) return;
-
-  std::vector<CanvasRenderingContext2D*>::iterator iter = std::find(
-      DemotableContexts().begin(), DemotableContexts().end(), aContext);
-  if (iter != DemotableContexts().end()) return;
-
-  DemotableContexts().push_back(aContext);
-}
-
-void CanvasRenderingContext2D::RemoveDemotableContext(
-    CanvasRenderingContext2D* aContext) {
-  MOZ_ASSERT(sMaxContextsInitialized);
-  if (sMaxContexts <= 0) return;
-
-  std::vector<CanvasRenderingContext2D*>::iterator iter = std::find(
-      DemotableContexts().begin(), DemotableContexts().end(), aContext);
-  if (iter != DemotableContexts().end()) DemotableContexts().erase(iter);
-}
-
-#define MIN_SKIA_GL_DIMENSION 16
-
-bool CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize aSize) {
-  MOZ_ASSERT(NS_IsMainThread());
-
-  int minsize = Preferences::GetInt("gfx.canvas.min-size-for-skia-gl", 128);
-  if (aSize.width < MIN_SKIA_GL_DIMENSION ||
-      aSize.height < MIN_SKIA_GL_DIMENSION ||
-      (aSize.width * aSize.height < minsize * minsize)) {
-    return false;
-  }
-
-  // Maximum pref allows 3 different options:
-  //  0   means unlimited size
-  //  > 0 means use value as an absolute threshold
-  //  < 0 means use the number of screen pixels as a threshold
-  int maxsize = Preferences::GetInt("gfx.canvas.max-size-for-skia-gl", 0);
-
-  // unlimited max size
-  if (!maxsize) {
-    return true;
-  }
-
-  // absolute max size threshold
-  if (maxsize > 0) {
-    return aSize.width <= maxsize && aSize.height <= maxsize;
-  }
-
-  // Cache the number of pixels on the primary screen
-  static int32_t gScreenPixels = -1;
-  if (gScreenPixels < 0) {
-    // Default to historical mobile screen size of 980x480, like FishIEtank.
-    // In addition, allow skia use up to this size even if the screen is
-    // smaller. A lot content expects this size to work well. See Bug 999841
-    if (gfxPlatform::GetPlatform()->HasEnoughTotalSystemMemoryForSkiaGL()) {
-      gScreenPixels = 980 * 480;
-    }
-
-    nsCOMPtr<nsIScreenManager> screenManager =
-        do_GetService("@mozilla.org/gfx/screenmanager;1");
-    if (screenManager) {
-      nsCOMPtr<nsIScreen> primaryScreen;
-      screenManager->GetPrimaryScreen(getter_AddRefs(primaryScreen));
-      if (primaryScreen) {
-        int32_t x, y, width, height;
-        primaryScreen->GetRect(&x, &y, &width, &height);
-
-        gScreenPixels = std::max(gScreenPixels, width * height);
-      }
-    }
-  }
-
-  // Just always use a scale of 1.0. It can be changed if a lot of contents need
-  // it.
-  static double gDefaultScale = 1.0;
-
-  double scale = gDefaultScale > 0 ? gDefaultScale : 1.0;
-  int32_t threshold = ceil(scale * scale * gScreenPixels);
-
-  // screen size acts as max threshold
-  return threshold < 0 || (aSize.width * aSize.height) <= threshold;
 }
 
 void CanvasRenderingContext2D::ScheduleStableStateCallback() {
   if (mHasPendingStableStateCallback) {
     return;
   }
   mHasPendingStableStateCallback = true;
 
@@ -1484,40 +1162,32 @@ void CanvasRenderingContext2D::RestoreCl
         mTarget->PushClip(clipOrTransform.clip);
       } else {
         mTarget->SetTransform(clipOrTransform.transform);
       }
     }
   }
 }
 
-CanvasRenderingContext2D::RenderingMode CanvasRenderingContext2D::EnsureTarget(
-    const gfx::Rect* aCoveredRect, RenderingMode aRenderingMode) {
+bool CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect) {
   if (AlreadyShutDown()) {
     gfxCriticalError() << "Attempt to render into a Canvas2d after shutdown.";
     SetErrorState();
-    return aRenderingMode;
-  }
-
-  // This would make no sense, so make sure we don't get ourselves in a mess
-  MOZ_ASSERT(mRenderingMode != RenderingMode::DefaultBackendMode);
-
-  RenderingMode mode = (aRenderingMode == RenderingMode::DefaultBackendMode)
-                           ? mRenderingMode
-                           : aRenderingMode;
-
-  if (mTarget && mode == mRenderingMode) {
-    return mRenderingMode;
+    return false;
+  }
+
+  if (mTarget) {
+    return true;
   }
 
   // Check that the dimensions are sane
   if (mWidth > gfxPrefs::MaxCanvasSize() ||
       mHeight > gfxPrefs::MaxCanvasSize() || mWidth < 0 || mHeight < 0) {
     SetErrorState();
-    return aRenderingMode;
+    return false;
   }
 
   // If the next drawing command covers the entire canvas, we can skip copying
   // from the previous frame and/or clearing the canvas.
   gfx::Rect canvasRect(0, 0, mWidth, mHeight);
   bool canDiscardContent =
       aCoveredRect && CurrentState()
                           .transform.TransformBounds(*aCoveredRect)
@@ -1537,46 +1207,39 @@ CanvasRenderingContext2D::RenderingMode 
     }
   }
 
   ScheduleStableStateCallback();
 
   IntRect persistedRect =
       canDiscardContent ? IntRect() : IntRect(0, 0, mWidth, mHeight);
 
-  if (mBufferProvider && mode == mRenderingMode) {
+  if (mBufferProvider) {
     mTarget = mBufferProvider->BorrowDrawTarget(persistedRect);
 
     if (mTarget && !mBufferProvider->PreservesDrawingState()) {
       RestoreClipsAndTransformToTarget();
     }
 
     if (mTarget) {
-      return mode;
+      return true;
     }
   }
 
   RefPtr<DrawTarget> newTarget;
   RefPtr<PersistentBufferProvider> newProvider;
 
-  if (mode == RenderingMode::OpenGLBackendMode &&
-      !TrySkiaGLTarget(newTarget, newProvider)) {
-    // Fall back to software.
-    mode = RenderingMode::SoftwareBackendMode;
-  }
-
-  if (mode == RenderingMode::SoftwareBackendMode &&
-      !TrySharedTarget(newTarget, newProvider) &&
+  if (!TrySharedTarget(newTarget, newProvider) &&
       !TryBasicTarget(newTarget, newProvider)) {
     gfxCriticalError(
         CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(GetSize())))
         << "Failed borrow shared and basic targets.";
 
     SetErrorState();
-    return mode;
+    return false;
   }
 
   MOZ_ASSERT(newTarget);
   MOZ_ASSERT(newProvider);
 
   bool needsClear = !canDiscardContent;
   if (newTarget->GetBackendType() == gfx::BackendType::SKIA) {
     // Skia expects the unused X channel to contains 0xFF even for opaque
@@ -1607,17 +1270,17 @@ CanvasRenderingContext2D::RenderingMode 
   // and now we might need one.
   if (mCanvasElement) {
     mCanvasElement->InvalidateCanvas();
   }
   // Calling Redraw() tells our invalidation machinery that the entire
   // canvas is already invalid, which can speed up future drawing.
   Redraw();
 
-  return mode;
+  return true;
 }
 
 void CanvasRenderingContext2D::SetInitialState() {
   // Set up the initial canvas defaults
   mPathBuilder = nullptr;
   mPath = nullptr;
   mDSPathBuilder = nullptr;
   mPathTransformWillUpdate = false;
@@ -1667,67 +1330,16 @@ static already_AddRefed<LayerManager> La
   if (!aCanvasElement) {
     return nullptr;
   }
 
   return nsContentUtils::PersistentLayerManagerForDocument(
       aCanvasElement->OwnerDoc());
 }
 
-bool CanvasRenderingContext2D::TrySkiaGLTarget(
-    RefPtr<gfx::DrawTarget>& aOutDT,
-    RefPtr<layers::PersistentBufferProvider>& aOutProvider) {
-  aOutDT = nullptr;
-  aOutProvider = nullptr;
-
-  mIsSkiaGL = false;
-
-  IntSize size(mWidth, mHeight);
-  if (!AllowOpenGLCanvas() || !CheckSizeForSkiaGL(size)) {
-    return false;
-  }
-
-  RefPtr<LayerManager> layerManager =
-      LayerManagerFromCanvasElement(mCanvasElement);
-
-  if (!layerManager) {
-    return false;
-  }
-
-  DemoteOldestContextIfNecessary();
-  mBufferProvider = nullptr;
-
-#ifdef USE_SKIA_GPU
-  SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-  if (!glue || !glue->GetGrContext() || !glue->GetGLContext()) {
-    return false;
-  }
-
-  SurfaceFormat format = GetSurfaceFormat();
-  aOutDT = Factory::CreateDrawTargetSkiaWithGrContext(glue->GetGrContext(),
-                                                      size, format);
-  if (!aOutDT) {
-    gfxCriticalNote
-        << "Failed to create a SkiaGL DrawTarget, falling back to software\n";
-    return false;
-  }
-
-  MOZ_ASSERT(aOutDT->GetType() == DrawTargetType::HARDWARE_RASTER);
-
-  AddDemotableContext(this);
-  aOutProvider = new PersistentBufferProviderBasic(aOutDT);
-  mIsSkiaGL = true;
-  // Drop a note in the debug builds if we ever use accelerated Skia canvas.
-  gfxWarningOnce() << "Using SkiaGL canvas.";
-#endif
-
-  // could still be null if USE_SKIA_GPU is not #defined.
-  return !!aOutDT;
-}
-
 bool CanvasRenderingContext2D::TrySharedTarget(
     RefPtr<gfx::DrawTarget>& aOutDT,
     RefPtr<layers::PersistentBufferProvider>& aOutProvider) {
   aOutDT = nullptr;
   aOutProvider = nullptr;
 
   if (!mCanvasElement) {
     return false;
@@ -1907,26 +1519,16 @@ CanvasRenderingContext2D::SetContextOpti
   MOZ_ASSERT(!mTarget);
 
   ContextAttributes2D attributes;
   if (!attributes.Init(aCx, aOptions)) {
     aRvForDictionaryInit.Throw(NS_ERROR_UNEXPECTED);
     return NS_ERROR_UNEXPECTED;
   }
 
-  if (Preferences::GetBool("gfx.canvas.willReadFrequently.enable", false)) {
-    // Use software when there is going to be a lot of readback
-    if (attributes.mWillReadFrequently) {
-      // We want to lock into software, so remove the observer that
-      // may potentially change that...
-      RemoveDrawObserver();
-      mRenderingMode = RenderingMode::SoftwareBackendMode;
-    }
-  }
-
   mContextAttributesHasAlpha = attributes.mAlpha;
   UpdateIsOpaque();
 
   return NS_OK;
 }
 
 UniquePtr<uint8_t[]> CanvasRenderingContext2D::GetImageBuffer(
     int32_t* aFormat) {
@@ -4532,17 +4134,17 @@ CanvasRenderingContext2D::CachedSurfaceF
   }
 
   nsCOMPtr<nsIPrincipal> principal;
   if (NS_FAILED(imgRequest->GetImagePrincipal(getter_AddRefs(principal))) ||
       !principal) {
     return res;
   }
 
-  res.mSourceSurface = CanvasImageCache::LookupAllCanvas(aElement, mIsSkiaGL);
+  res.mSourceSurface = CanvasImageCache::LookupAllCanvas(aElement);
   if (!res.mSourceSurface) {
     return res;
   }
 
   int32_t corsmode = imgIRequest::CORS_NONE;
   if (NS_SUCCEEDED(imgRequest->GetCORSMode(&corsmode))) {
     res.mCORSUsed = corsmode != imgIRequest::CORS_NONE;
   }
@@ -4571,20 +4173,16 @@ CanvasRenderingContext2D::CachedSurfaceF
 // are all passed in.
 
 void CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
                                          double aSx, double aSy, double aSw,
                                          double aSh, double aDx, double aDy,
                                          double aDw, double aDh,
                                          uint8_t aOptional_argc,
                                          ErrorResult& aError) {
-  if (mDrawObserver) {
-    mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::DrawImage);
-  }
-
   MOZ_ASSERT(aOptional_argc == 0 || aOptional_argc == 2 || aOptional_argc == 6);
 
   if (!ValidateRect(aDx, aDy, aDw, aDh, true)) {
     return;
   }
   if (aOptional_argc == 6) {
     if (!ValidateRect(aSx, aSy, aSw, aSh, true)) {
       return;
@@ -4635,18 +4233,17 @@ void CanvasRenderingContext2D::DrawImage
       element = img;
     } else {
       HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement();
       video->MarkAsContentSource(
           mozilla::dom::HTMLVideoElement::CallerAPI::DRAW_IMAGE);
       element = video;
     }
 
-    srcSurf = CanvasImageCache::LookupCanvas(element, mCanvasElement, &imgSize,
-                                             mIsSkiaGL);
+    srcSurf = CanvasImageCache::LookupCanvas(element, mCanvasElement, &imgSize);
   }
 
   nsLayoutUtils::DirectDrawInfo drawInfo;
 
   if (!srcSurf) {
     // The canvas spec says that drawImage should draw the first frame
     // of animated images. We also don't want to rasterize vector images.
     uint32_t sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME_IF_IMAGE |
@@ -4687,17 +4284,17 @@ void CanvasRenderingContext2D::DrawImage
     if (mCanvasElement) {
       CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement, res.mPrincipal,
                                             res.mIsWriteOnly, res.mCORSUsed);
     }
 
     if (res.mSourceSurface) {
       if (res.mImageRequest) {
         CanvasImageCache::NotifyDrawImage(
-            element, mCanvasElement, res.mSourceSurface, imgSize, mIsSkiaGL);
+            element, mCanvasElement, res.mSourceSurface, imgSize);
       }
       srcSurf = res.mSourceSurface;
     } else {
       drawInfo = res.mDrawInfo;
     }
   }
 
   if (aOptional_argc == 0) {
@@ -5113,20 +4710,16 @@ void CanvasRenderingContext2D::DrawWindo
 
 //
 // device pixel getting/setting
 //
 
 already_AddRefed<ImageData> CanvasRenderingContext2D::GetImageData(
     JSContext* aCx, double aSx, double aSy, double aSw, double aSh,
     nsIPrincipal& aSubjectPrincipal, ErrorResult& aError) {
-  if (mDrawObserver) {
-    mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::GetImageData);
-  }
-
   if (!mCanvasElement && !mDocShell) {
     NS_ERROR("No canvas element and no docshell in GetImageData!!!");
     aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return nullptr;
   }
 
   // Check only if we have a canvas element; if we were created with a docshell,
   // then it's special internal use.
@@ -5185,20 +4778,16 @@ already_AddRefed<ImageData> CanvasRender
 
   RefPtr<ImageData> imageData = new ImageData(w, h, *array);
   return imageData.forget();
 }
 
 nsresult CanvasRenderingContext2D::GetImageDataArray(
     JSContext* aCx, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight,
     nsIPrincipal& aSubjectPrincipal, JSObject** aRetval) {
-  if (mDrawObserver) {
-    mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::GetImageData);
-  }
-
   MOZ_ASSERT(aWidth && aHeight);
 
   CheckedInt<uint32_t> len = CheckedInt<uint32_t>(aWidth) * aHeight * 4;
   if (!len.isValid()) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
 
   CheckedInt<int32_t> rightMost = CheckedInt<int32_t>(aX) + aWidth;
@@ -5344,20 +4933,16 @@ void CanvasRenderingContext2D::PutImageD
                                  JS::ToInt32(aDirtyY), JS::ToInt32(aDirtyWidth),
                                  JS::ToInt32(aDirtyHeight));
 }
 
 nsresult CanvasRenderingContext2D::PutImageData_explicit(
     int32_t aX, int32_t aY, uint32_t aW, uint32_t aH,
     dom::Uint8ClampedArray* aArray, bool aHasDirtyRect, int32_t aDirtyX,
     int32_t aDirtyY, int32_t aDirtyWidth, int32_t aDirtyHeight) {
-  if (mDrawObserver) {
-    mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::PutImageData);
-  }
-
   if (aW == 0 || aH == 0) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
   IntRect dirtyRect;
   IntRect imageDataRect(0, 0, aW, aH);
 
   if (aHasDirtyRect) {
@@ -5515,39 +5100,21 @@ already_AddRefed<ImageData> CanvasRender
 already_AddRefed<ImageData> CanvasRenderingContext2D::CreateImageData(
     JSContext* aCx, ImageData& aImagedata, ErrorResult& aError) {
   return mozilla::dom::CreateImageData(aCx, this, aImagedata.Width(),
                                        aImagedata.Height(), aError);
 }
 
 static uint8_t g2DContextLayerUserData;
 
-uint32_t CanvasRenderingContext2D::SkiaGLTex() const {
-  if (!mTarget) {
-    return 0;
-  }
-  MOZ_ASSERT(IsTargetValid());
-  return (uint32_t)(uintptr_t)mTarget->GetNativeSurface(
-      NativeSurfaceType::OPENGL_TEXTURE);
-}
-
-void CanvasRenderingContext2D::RemoveDrawObserver() {
-  if (mDrawObserver) {
-    delete mDrawObserver;
-    mDrawObserver = nullptr;
-  }
-}
-
 already_AddRefed<Layer> CanvasRenderingContext2D::GetCanvasLayer(
     nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager) {
-  if (mOpaque || mIsSkiaGL) {
+  if (mOpaque) {
     // If we're opaque then make sure we have a surface so we paint black
     // instead of transparent.
-    // If we're using SkiaGL, then SkiaGLTex() below needs the target to
-    // be accessible.
     EnsureTarget();
   }
 
   // Don't call EnsureTarget() ... if there isn't already a surface, then
   // we have nothing to paint and there is no need to create a surface just
   // to paint nothing. Also, EnsureTarget() can cause creation of a persistent
   // layer manager which must NOT happen during a paint.
   if (!mBufferProvider && !IsTargetValid()) {
@@ -5558,26 +5125,16 @@ already_AddRefed<Layer> CanvasRenderingC
   }
 
   if (!mResetLayer && aOldLayer) {
     auto userData = static_cast<CanvasRenderingContext2DUserData*>(
         aOldLayer->GetUserData(&g2DContextLayerUserData));
 
     CanvasInitializeData data;
 
-    if (mIsSkiaGL) {
-      GLuint skiaGLTex = SkiaGLTex();
-      if (skiaGLTex) {
-        SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-        MOZ_ASSERT(glue);
-        data.mGLContext = glue->GetGLContext();
-        data.mFrontbufferGLTex = skiaGLTex;
-      }
-    }
-
     data.mBufferProvider = mBufferProvider;
 
     if (userData && userData->IsForContext(this) &&
         static_cast<CanvasLayer*>(aOldLayer)
             ->CreateOrGetCanvasRenderer()
             ->IsDataValid(data)) {
       RefPtr<Layer> ret = aOldLayer;
       return ret.forget();
@@ -5614,21 +5171,19 @@ already_AddRefed<Layer> CanvasRenderingC
 
   mResetLayer = false;
 
   return canvasLayer.forget();
 }
 
 bool CanvasRenderingContext2D::UpdateWebRenderCanvasData(
     nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
-  if (mOpaque || mIsSkiaGL) {
+  if (mOpaque) {
     // If we're opaque then make sure we have a surface so we paint black
     // instead of transparent.
-    // If we're using SkiaGL, then SkiaGLTex() below needs the target to
-    // be accessible.
     EnsureTarget();
   }
 
   // Don't call EnsureTarget() ... if there isn't already a surface, then
   // we have nothing to paint and there is no need to create a surface just
   // to paint nothing. Also, EnsureTarget() can cause creation of a persistent
   // layer manager which must NOT happen during a paint.
   if (!mBufferProvider && !IsTargetValid()) {
@@ -5640,25 +5195,16 @@ bool CanvasRenderingContext2D::UpdateWeb
     return false;
   }
 
   CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer();
 
   if (!mResetLayer && renderer) {
     CanvasInitializeData data;
 
-    if (mIsSkiaGL) {
-      GLuint skiaGLTex = SkiaGLTex();
-      if (skiaGLTex) {
-        SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-        MOZ_ASSERT(glue);
-        data.mGLContext = glue->GetGLContext();
-        data.mFrontbufferGLTex = skiaGLTex;
-      }
-    }
     data.mBufferProvider = mBufferProvider;
 
     if (renderer->IsDataValid(data)) {
       return true;
     }
   }
 
   renderer = aCanvasData->CreateCanvasRenderer();
@@ -5690,26 +5236,16 @@ bool CanvasRenderingContext2D::Initializ
     EnsureTarget();
     ReturnTarget();
     if (!mBufferProvider) {
       MarkContextClean();
       return false;
     }
   }
 
-  if (mIsSkiaGL) {
-    GLuint skiaGLTex = SkiaGLTex();
-    if (skiaGLTex) {
-      SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-      MOZ_ASSERT(glue);
-      data.mGLContext = glue->GetGLContext();
-      data.mFrontbufferGLTex = skiaGLTex;
-    }
-  }
-
   data.mBufferProvider = mBufferProvider;
 
   aRenderer->Initialize(data);
   aRenderer->SetDirty();
   return true;
 }
 
 void CanvasRenderingContext2D::MarkContextClean() {
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -371,24 +371,16 @@ class CanvasRenderingContext2D final : p
       CurrentState().imageSmoothingEnabled = aImageSmoothingEnabled;
     }
   }
 
   void DrawWindow(nsGlobalWindowInner& aWindow, double aX, double aY, double aW,
                   double aH, const nsAString& aBgColor, uint32_t aFlags,
                   mozilla::ErrorResult& aError);
 
-  enum RenderingMode {
-    SoftwareBackendMode,
-    OpenGLBackendMode,
-    DefaultBackendMode
-  };
-
-  bool SwitchRenderingMode(RenderingMode aRenderingMode);
-
   // Eventually this should be deprecated. Keeping for now to keep the binding
   // functional.
   void Demote();
 
   nsresult Redraw();
 
   gfx::IntSize GetSize() const { return gfx::IntSize(mWidth, mHeight); }
   virtual int32_t GetWidth() override { return GetSize().width; }
@@ -504,19 +496,16 @@ class CanvasRenderingContext2D final : p
   // Given a point, return hit region ID if it exists
   nsString GetHitRegion(const mozilla::gfx::Point& aPoint) override;
 
   // return true and fills in the bound rect if element has a hit region.
   bool GetHitRegionRect(Element* aElement, nsRect& aRect) override;
 
   void OnShutdown();
 
-  // Check the global setup, as well as the compositor type:
-  bool AllowOpenGLCanvas() const;
-
   /**
    * Update CurrentState().filter with the filter description for
    * CurrentState().filterChain.
    * Flushes the PresShell, so the world can change if you call this function.
    */
   void UpdateFilter();
 
  protected:
@@ -611,27 +600,22 @@ class CanvasRenderingContext2D final : p
   void FillRuleChanged();
 
   /**
    * Create the backing surfacing, if it doesn't exist. If there is an error
    * in creating the target then it will put sErrorTarget in place. If there
    * is in turn an error in creating the sErrorTarget then they would both
    * be null so IsTargetValid() would still return null.
    *
-   * Returns the actual rendering mode being used by the created target.
+   * Returns true on success.
    */
-  RenderingMode EnsureTarget(
-      const gfx::Rect* aCoveredRect = nullptr,
-      RenderingMode aRenderMode = RenderingMode::DefaultBackendMode);
+  bool EnsureTarget(const gfx::Rect* aCoveredRect = nullptr);
 
   void RestoreClipsAndTransformToTarget();
 
-  bool TrySkiaGLTarget(RefPtr<gfx::DrawTarget>& aOutDT,
-                       RefPtr<layers::PersistentBufferProvider>& aOutProvider);
-
   bool TrySharedTarget(RefPtr<gfx::DrawTarget>& aOutDT,
                        RefPtr<layers::PersistentBufferProvider>& aOutProvider);
 
   bool TryBasicTarget(RefPtr<gfx::DrawTarget>& aOutDT,
                       RefPtr<layers::PersistentBufferProvider>& aOutProvider);
 
   void RegisterAllocation();
 
@@ -699,29 +683,16 @@ class CanvasRenderingContext2D final : p
 
   nsString& GetFont() {
     /* will initilize the value if not set, else does nothing */
     GetCurrentFontStyle();
 
     return CurrentState().font;
   }
 
-  // This function maintains a list of raw pointers to cycle-collected
-  // objects. We need to ensure that no entries persist beyond unlink,
-  // since the objects are logically destructed at that point.
-  static std::vector<CanvasRenderingContext2D*>& DemotableContexts();
-  static void DemoteOldestContextIfNecessary();
-
-  static void AddDemotableContext(CanvasRenderingContext2D* aContext);
-  static void RemoveDemotableContext(CanvasRenderingContext2D* aContext);
-
-  RenderingMode mRenderingMode;
-
-  layers::LayersBackend mCompositorBackend;
-
   // Member vars
   int32_t mWidth, mHeight;
 
   // This is true when the canvas is valid, but of zero size, this requires
   // specific behavior on some operations.
   bool mZero;
 
   // The two ways to set the opaqueness of the canvas.
@@ -737,42 +708,31 @@ class CanvasRenderingContext2D final : p
   // mContextAttributesHasAlpha in UpdateIsOpaque().
   bool mOpaque;
 
   // This is true when the next time our layer is retrieved we need to
   // recreate it (i.e. our backing surface changed)
   bool mResetLayer;
   // This is needed for drawing in drawAsyncXULElement
   bool mIPC;
-  // True if the current DrawTarget is using skia-gl, used so we can avoid
-  // requesting the DT from mBufferProvider to check.
-  bool mIsSkiaGL;
 
   bool mHasPendingStableStateCallback;
 
   nsTArray<CanvasRenderingContext2DUserData*> mUserDatas;
 
   // If mCanvasElement is not provided, then a docshell is
   nsCOMPtr<nsIDocShell> mDocShell;
 
   // This is created lazily so it is necessary to call EnsureTarget before
   // accessing it. In the event of an error it will be equal to
   // sErrorTarget.
   RefPtr<mozilla::gfx::DrawTarget> mTarget;
 
   RefPtr<mozilla::layers::PersistentBufferProvider> mBufferProvider;
 
-  uint32_t SkiaGLTex() const;
-
-  // This observes our draw calls at the beginning of the canvas
-  // lifetime and switches to software or GPU mode depending on
-  // what it thinks is best
-  CanvasDrawObserver* mDrawObserver;
-  void RemoveDrawObserver();
-
   RefPtr<CanvasShutdownObserver> mShutdownObserver;
   void RemoveShutdownObserver();
   bool AlreadyShutDown() const { return !mShutdownObserver; }
 
   /**
    * Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
    * Redraw is called, reset to false when Render is called.
    */
@@ -914,18 +874,16 @@ class CanvasRenderingContext2D final : p
   /**
    * Implementation of the fillText, strokeText, and measure functions with
    * the operation abstracted to a flag.
    */
   nsresult DrawOrMeasureText(const nsAString& aText, float aX, float aY,
                              const Optional<double>& aMaxWidth,
                              TextDrawOperation aOp, float* aWidth);
 
-  bool CheckSizeForSkiaGL(mozilla::gfx::IntSize aSize);
-
   // A clip or a transform, recorded and restored in order.
   struct ClipState {
     explicit ClipState(mozilla::gfx::Path* aClip) : clip(aClip) {}
 
     explicit ClipState(const mozilla::gfx::Matrix& aTransform)
         : transform(aTransform) {}
 
     bool IsClip() const { return !!clip; }
--- a/dom/canvas/OffscreenCanvas.cpp
+++ b/dom/canvas/OffscreenCanvas.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerScope.h"
 #include "mozilla/layers/AsyncCanvasRenderer.h"
 #include "mozilla/layers/CanvasClient.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/Telemetry.h"
 #include "CanvasRenderingContext2D.h"
 #include "CanvasUtils.h"
+#include "GLContext.h"
 #include "GLScreenBuffer.h"
 #include "WebGL1Context.h"
 #include "WebGL2Context.h"
 
 namespace mozilla {
 namespace dom {
 
 OffscreenCanvasCloneData::OffscreenCanvasCloneData(
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -21,17 +21,16 @@
   MOZ_LOG(                                                \
       sAndroidDecoderModuleLog, mozilla::LogLevel::Debug, \
       ("AndroidDecoderModule(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #define SLOG(arg, ...)                                        \
   MOZ_LOG(sAndroidDecoderModuleLog, mozilla::LogLevel::Debug, \
           ("%s: " arg, __func__, ##__VA_ARGS__))
 
 using namespace mozilla;
-using namespace mozilla::gl;
 using namespace mozilla::java::sdk;
 using media::TimeUnit;
 
 namespace mozilla {
 
 mozilla::LazyLogModule sAndroidDecoderModuleLog("AndroidDecoderModule");
 
 const nsCString TranslateMimeType(const nsACString& aMimeType) {