Bug 935297 - Part 1: Add new API to allow streaming paths to arbitrary sinks. r=mattwoodrow
authorBas Schouten <bschouten@mozilla.com>
Thu, 07 Nov 2013 22:10:12 +1300
changeset 153986 d4aa5d0e7431a9c84ade56ffed9cf82546d421cf
parent 153985 cea7b9a8ab99a6e58bb3ab49588741adf6653ed4
child 153987 95da3889f8faa504a6562d2a7de2e30ddae8b0fe
push id25617
push userryanvm@gmail.com
push dateThu, 07 Nov 2013 19:45:30 +0000
treeherdermozilla-central@545887140a1b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs935297
milestone28.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 935297 - Part 1: Add new API to allow streaming paths to arbitrary sinks. r=mattwoodrow
gfx/2d/2D.h
gfx/2d/PathCG.h
gfx/2d/PathCairo.h
gfx/2d/PathD2D.h
gfx/2d/PathRecording.h
gfx/2d/PathSkia.h
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -435,16 +435,21 @@ public:
   /* This function gets the bounds of the stroke of this path using the
    * specified strokeoptions. These bounds are not guaranteed to be tight.
    * A transform may be specified that gives the bounds after application of
    * the transform.
    */
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const = 0;
 
+  /* Take the contents of this path and stream it to another sink, this works
+   * regardless of the backend that might be used for the destination sink.
+   */
+  virtual void StreamToSink(PathSink *aSink) const = 0;
+ 
   /* This gets the fillrule this path's builder was created with. This is not
    * mutable.
    */
   virtual FillRule GetFillRule() const = 0;
 
   virtual Float ComputeLength() { return 0; }
 
   virtual Point ComputePointAtLength(Float aLength,
--- a/gfx/2d/PathCG.h
+++ b/gfx/2d/PathCG.h
@@ -80,16 +80,18 @@ public:
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const;
 
+  virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
+
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   CGMutablePathRef GetPath() const { return mPath; }
 
 private:
   friend class DrawTargetCG;
 
   CGMutablePathRef mPath;
--- a/gfx/2d/PathCairo.h
+++ b/gfx/2d/PathCairo.h
@@ -64,16 +64,18 @@ public:
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
 
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const;
 
+  virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
+
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   void SetPathOnContext(cairo_t *aContext) const;
 
   void AppendPathToBuilder(PathBuilderCairo *aBuilder, const Matrix *aTransform = nullptr) const;
 private:
   void EnsureContainingContext() const;
 
--- a/gfx/2d/PathD2D.h
+++ b/gfx/2d/PathD2D.h
@@ -80,16 +80,18 @@ public:
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
 
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const;
 
+  virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
+
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   ID2D1Geometry *GetGeometry() { return mGeometry; }
 
 private:
   friend class DrawTargetD2D;
   friend class DrawTargetD2D1;
 
--- a/gfx/2d/PathRecording.h
+++ b/gfx/2d/PathRecording.h
@@ -101,17 +101,19 @@ public:
   { return mPath->StrokeContainsPoint(aStrokeOptions, aPoint, aTransform); }
   
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const
   { return mPath->GetBounds(aTransform); }
   
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const
   { return mPath->GetStrokedBounds(aStrokeOptions, aTransform); }
-  
+
+  virtual void StreamToSink(PathSink *aSink) const { mPath->StreamToSink(aSink); }
+
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   void StorePath(std::ostream &aStream) const;
   static void ReadPathToBuilder(std::istream &aStream, PathBuilder *aBuilder);
 
 private:
   friend class DrawTargetRecording;
   friend class RecordedPathCreation;
--- a/gfx/2d/PathSkia.h
+++ b/gfx/2d/PathSkia.h
@@ -61,16 +61,18 @@ public:
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
   
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const;
 
+  virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
+
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   const SkPath& GetPath() const { return mPath; }
 
 private:
   friend class DrawTargetSkia;
   
   SkPath mPath;