Bug 1183363 - Make EnsureWritablePath and EnsureUserSpacePath always imply EnsureTarget. r=Bas
authorLee Salzman <lsalzman@mozilla.com>
Tue, 14 Jul 2015 00:01:29 -0400
changeset 252880 827fc7ff5fee240f283ab023db31756c7326dc4f
parent 252879 a0910fa98706add41d61707b8d410492800c560e
child 252881 766bade5c8b5d79eb3c58c669de2eb9b1ea1f95e
push id62263
push userryanvm@gmail.com
push dateTue, 14 Jul 2015 22:51:36 +0000
treeherdermozilla-inbound@25f4b1ce54b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1183363
milestone42.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 1183363 - Make EnsureWritablePath and EnsureUserSpacePath always imply EnsureTarget. r=Bas
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2575,17 +2575,16 @@ CanvasRenderingContext2D::BeginPath()
   mPathBuilder = nullptr;
   mDSPathBuilder = nullptr;
   mPathTransformWillUpdate = false;
 }
 
 void
 CanvasRenderingContext2D::Fill(const CanvasWindingRule& winding)
 {
-  EnsureTarget();
   EnsureUserSpacePath(winding);
 
   if (!mPath) {
     return;
   }
 
   mgfx::Rect bounds;
 
@@ -2621,17 +2620,16 @@ void CanvasRenderingContext2D::Fill(cons
          DrawOptions(CurrentState().globalAlpha, UsedOperation()));
 
   Redraw();
 }
 
 void
 CanvasRenderingContext2D::Stroke()
 {
-  EnsureTarget();
   EnsureUserSpacePath();
 
   if (!mPath) {
     return;
   }
 
   const ContextState &state = CurrentState();
 
@@ -2757,18 +2755,16 @@ bool CanvasRenderingContext2D::DrawCusto
   }
 
   return false;
 }
 
 void
 CanvasRenderingContext2D::Clip(const CanvasWindingRule& winding)
 {
-  EnsureTarget();
-
   EnsureUserSpacePath(winding);
 
   if (!mPath) {
     return;
   }
 
   mTarget->PushClip(mPath);
   CurrentState().clipsPushed.push_back(mPath);
@@ -2900,16 +2896,18 @@ CanvasRenderingContext2D::Rect(double x,
     mDSPathBuilder->LineTo(mTarget->GetTransform() * Point(x, y + h));
     mDSPathBuilder->Close();
   }
 }
 
 void
 CanvasRenderingContext2D::EnsureWritablePath()
 {
+  EnsureTarget();
+
   if (mDSPathBuilder) {
     return;
   }
 
   FillRule fillRule = CurrentState().fillRule;
 
   if (mPathBuilder) {
     if (mPathTransformWillUpdate) {
@@ -2918,17 +2916,16 @@ CanvasRenderingContext2D::EnsureWritable
         mPath->TransformedCopyToBuilder(mPathToDS, fillRule);
       mPath = nullptr;
       mPathBuilder = nullptr;
       mPathTransformWillUpdate = false;
     }
     return;
   }
 
-  EnsureTarget();
   if (!mPath) {
     NS_ASSERTION(!mPathTransformWillUpdate, "mPathTransformWillUpdate should be false, if all paths are null");
     mPathBuilder = mTarget->CreatePathBuilder(fillRule);
   } else if (!mPathTransformWillUpdate) {
     mPathBuilder = mPath->CopyToBuilder(fillRule);
   } else {
     mDSPathBuilder =
       mPath->TransformedCopyToBuilder(mPathToDS, fillRule);
@@ -2939,18 +2936,19 @@ CanvasRenderingContext2D::EnsureWritable
 
 void
 CanvasRenderingContext2D::EnsureUserSpacePath(const CanvasWindingRule& winding)
 {
   FillRule fillRule = CurrentState().fillRule;
   if(winding == CanvasWindingRule::Evenodd)
     fillRule = FillRule::FILL_EVEN_ODD;
 
+  EnsureTarget();
+
   if (!mPath && !mPathBuilder && !mDSPathBuilder) {
-    EnsureTarget();
     mPathBuilder = mTarget->CreatePathBuilder(fillRule);
   }
 
   if (mPathBuilder) {
     mPath = mPathBuilder->Finish();
     mPathBuilder = nullptr;
   }
 
@@ -3207,16 +3205,17 @@ CanvasRenderingContext2D::MeasureText(co
   return new TextMetrics(width);
 }
 
 void
 CanvasRenderingContext2D::AddHitRegion(const HitRegionOptions& options, ErrorResult& error)
 {
   RefPtr<gfx::Path> path;
   if (options.mPath) {
+    EnsureTarget();
     path = options.mPath->GetPath(CanvasWindingRule::Nonzero, mTarget);
   }
 
   if (!path) {
     // check if the path is valid
     EnsureUserSpacePath(CanvasWindingRule::Nonzero);
     path = mPath;
   }