Bug 1328932: Back out the diagnostic patch from bug 1318283. r=gw280
authorMilan Sreckovic <milan@mozilla.com>
Tue, 17 Jan 2017 16:58:02 -0500
changeset 377252 6ba01b40808abb8fdcab6c18ddcbb8b7dc25edb5
parent 377251 35ae28472a13c11da225302473849ab037ee3611
child 377253 deb2014e1eb50438f9390a0b5e378d86f3e6b18e
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw280
bugs1328932, 1318283
milestone53.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 1328932: Back out the diagnostic patch from bug 1318283. r=gw280 MozReview-Commit-ID: KRyhWLBuHWM
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -560,17 +560,17 @@ private:
 class AdjustedTarget
 {
 public:
   typedef CanvasRenderingContext2D::ContextState ContextState;
 
   explicit AdjustedTarget(CanvasRenderingContext2D* aCtx,
                           const gfx::Rect *aBounds = nullptr)
   {
-    mTarget = (DrawTarget*)aCtx->mTarget;
+    mTarget = aCtx->mTarget;
 
     // All rects in this function are in the device space of ctx->mTarget.
 
     // In order to keep our temporary surfaces as small as possible, we first
     // calculate what their maximum required bounds would need to be if we
     // were to fill the whole canvas. Everything outside those bounds we don't
     // need to render.
     gfx::Rect r(0, 0, aCtx->mWidth, aCtx->mHeight);
@@ -1714,17 +1714,17 @@ void
 CanvasRenderingContext2D::SetErrorState()
 {
   EnsureErrorTarget();
 
   if (mTarget && mTarget != sErrorTarget) {
     gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
   }
 
-  mTarget = (DrawTarget*)sErrorTarget;
+  mTarget = sErrorTarget;
   mBufferProvider = nullptr;
 
   // clear transforms, clips, etc.
   SetInitialState();
 }
 
 void
 CanvasRenderingContext2D::RegisterAllocation()
@@ -1969,17 +1969,17 @@ CanvasRenderingContext2D::InitializeWith
 {
   RemovePostRefreshObserver();
   mDocShell = aShell;
   AddPostRefreshObserverIfNecessary();
 
   IntSize size = aTarget->GetSize();
   SetDimensions(size.width, size.height);
 
-  mTarget = (DrawTarget*)aTarget;
+  mTarget = aTarget;
   mBufferProvider = new PersistentBufferProviderBasic(aTarget);
 
   if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
     // Cf comment in EnsureTarget
     mTarget->PushClipRect(gfx::Rect(Point(0, 0), Size(mWidth, mHeight)));
   }
 
   return NS_OK;
@@ -3148,18 +3148,16 @@ CanvasRenderingContext2D::BeginPath()
   mPathBuilder = nullptr;
   mDSPathBuilder = nullptr;
   mPathTransformWillUpdate = false;
 }
 
 void
 CanvasRenderingContext2D::Fill(const CanvasWindingRule& aWinding)
 {
-  auto autoNotNull = mTarget.MakeAuto();
-
   EnsureUserSpacePath(aWinding);
 
   if (!mPath) {
     return;
   }
 
   gfx::Rect bounds;
 
@@ -4759,18 +4757,16 @@ CanvasRenderingContext2D::CachedSurfaceF
 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)
 {
-  auto autoNotNull = mTarget.MakeAuto();
-
   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;
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -42,128 +42,16 @@ class HTMLImageElementOrHTMLCanvasElemen
 typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource;
 class ImageData;
 class StringOrCanvasGradientOrCanvasPattern;
 class OwningStringOrCanvasGradientOrCanvasPattern;
 class TextMetrics;
 class CanvasFilterChainObserver;
 class CanvasPath;
 
-template<class T>
-struct MaybeNotNull
-{
-  MOZ_IMPLICIT MaybeNotNull() : mWrapped(nullptr), mEnsure(false) {}
-  MOZ_IMPLICIT MaybeNotNull(T&& aValue) : mWrapped(aValue), mEnsure(false) {}
-  ~MaybeNotNull() {}
-
-  void BeginNotNull() {
-    mEnsure = true;
-  }
-
-  void EndNotNull() {
-    mEnsure = false;
-  }
-
-  void MaybeCheckWrapped() {
-    if (mEnsure && !mWrapped) {
-      MOZ_CRASH("GFX: Setting mTarget to nullptr?");
-    }
-  }
-
-  typename T::element_type* operator->() const {
-    return mWrapped.get();
-  }
-
-  already_AddRefed<typename T::element_type> forget() {
-    already_AddRefed<typename T::element_type>&& ret = mWrapped.forget();
-    MaybeCheckWrapped();
-    return Move(ret);
-  }
-
-  MOZ_IMPLICIT operator bool () {
-    return mWrapped;
-  }
-
-  operator T&() {
-    return mWrapped;
-  }
-
-  operator typename T::element_type*() {
-    return mWrapped.get();
-  }
-
-  bool operator!() const {
-    return !mWrapped;
-  }
-
-  MaybeNotNull& operator=(decltype(nullptr)) {
-    mWrapped = nullptr;
-    MaybeCheckWrapped();
-    return *this;
-  }
-
-  template<class U>
-  MaybeNotNull& operator=(U& aOther){
-    mWrapped = aOther;
-    MaybeCheckWrapped();
-    return *this;
-  }
-
-  template<class U>
-  MaybeNotNull& operator=(U&& aOther){
-    mWrapped = aOther;
-    MaybeCheckWrapped();
-    return *this;
-  }
-
-  struct AutoNotNull
-  {
-    MOZ_IMPLICIT AutoNotNull(MaybeNotNull* aMaybe) : mMaybe(aMaybe)
-    {
-      mMaybe->BeginNotNull();
-    }
-
-    ~AutoNotNull()
-    {
-      mMaybe->EndNotNull();
-    }
-
-    MaybeNotNull* mMaybe;
-  };
-
-  AutoNotNull MakeAuto()
-  {
-    return AutoNotNull(this);
-  }
-
-  T mWrapped;
-
-  bool mEnsure;
-};
-
-template<class T, class U>
-  bool operator!=(const MaybeNotNull<T>& aT, const U& aU) {
-  return aT.mWrapped != aU;
-}
-
-template<class T, class U>
-  bool operator==(const MaybeNotNull<T>& aT, const U& aU) {
-  return aT.mWrapped == aU;
-}
-
-template<class T, class U>
-  bool operator||(const MaybeNotNull<T>& aT, const U& aU) {
-  return aT.mWrapped || aU;
-}
-
-template<class T, class U>
-  bool operator||(const T& aT, const MaybeNotNull<U>& aU) {
-  return aT || aU.mWrapped;
-}
-
 extern const mozilla::gfx::Float SIGMA_MAX;
 
 template<typename T> class Optional;
 
 struct CanvasBidiProcessor;
 class CanvasRenderingContext2DUserData;
 class CanvasDrawObserver;
 class CanvasShutdownObserver;
@@ -878,17 +766,17 @@ protected:
   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.
-  MaybeNotNull<RefPtr<mozilla::gfx::DrawTarget>> mTarget;
+  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