LCOV - code coverage report
Current view: top level - gfx/2d - PathRecording.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 26 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_GFX_PATHRECORDING_H_
       7             : #define MOZILLA_GFX_PATHRECORDING_H_
       8             : 
       9             : #include "2D.h"
      10             : #include <vector>
      11             : #include <ostream>
      12             : 
      13             : #include "PathHelpers.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace gfx {
      17             : 
      18           0 : struct PathOp
      19             : {
      20             :   enum OpType {
      21             :     OP_MOVETO = 0,
      22             :     OP_LINETO,
      23             :     OP_BEZIERTO,
      24             :     OP_QUADRATICBEZIERTO,
      25             :     OP_CLOSE
      26             :   };
      27             : 
      28             :   OpType mType;
      29             :   Point mP1;
      30             :   Point mP2;
      31             :   Point mP3;
      32             : };
      33             : 
      34             : const int32_t sPointCount[] = { 1, 1, 3, 2, 0, 0 };
      35             : 
      36             : class PathRecording;
      37             : class DrawEventRecorderPrivate;
      38             : 
      39           0 : class PathBuilderRecording : public PathBuilder
      40             : {
      41             : public:
      42           0 :   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderRecording)
      43           0 :   PathBuilderRecording(PathBuilder *aBuilder, FillRule aFillRule)
      44           0 :     : mPathBuilder(aBuilder), mFillRule(aFillRule)
      45             :   {
      46           0 :   }
      47             : 
      48             :   /* Move the current point in the path, any figure currently being drawn will
      49             :    * be considered closed during fill operations, however when stroking the
      50             :    * closing line segment will not be drawn.
      51             :    */
      52             :   virtual void MoveTo(const Point &aPoint);
      53             :   /* Add a linesegment to the current figure */
      54             :   virtual void LineTo(const Point &aPoint);
      55             :   /* Add a cubic bezier curve to the current figure */
      56             :   virtual void BezierTo(const Point &aCP1,
      57             :                         const Point &aCP2,
      58             :                         const Point &aCP3);
      59             :   /* Add a quadratic bezier curve to the current figure */
      60             :   virtual void QuadraticBezierTo(const Point &aCP1,
      61             :                                  const Point &aCP2);
      62             :   /* Close the current figure, this will essentially generate a line segment
      63             :    * from the current point to the starting point for the current figure
      64             :    */
      65             :   virtual void Close();
      66             : 
      67             :   /* Add an arc to the current figure */
      68           0 :   virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
      69             :                    float aEndAngle, bool aAntiClockwise) {
      70           0 :     ArcToBezier(this, aOrigin, Size(aRadius, aRadius), aStartAngle, aEndAngle,
      71           0 :                 aAntiClockwise);
      72           0 :   }
      73             : 
      74             :   /* Point the current subpath is at - or where the next subpath will start
      75             :    * if there is no active subpath.
      76             :    */
      77             :   virtual Point CurrentPoint() const;
      78             : 
      79             :   virtual already_AddRefed<Path> Finish();
      80             : 
      81           0 :   virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
      82             : 
      83             : private:
      84             :   friend class PathRecording;
      85             : 
      86             :   RefPtr<PathBuilder> mPathBuilder;
      87             :   FillRule mFillRule;
      88             :   std::vector<PathOp> mPathOps;
      89             : };
      90             : 
      91             : class PathRecording : public Path
      92             : {
      93             : public:
      94           0 :   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathRecording)
      95           0 :   PathRecording(Path *aPath, const std::vector<PathOp> aOps, FillRule aFillRule)
      96           0 :     : mPath(aPath), mPathOps(aOps), mFillRule(aFillRule)
      97             :   {
      98           0 :   }
      99             : 
     100             :   ~PathRecording();
     101             : 
     102           0 :   virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
     103             :   virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const;
     104             :   virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
     105             :                                                              FillRule aFillRule) const;
     106           0 :   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
     107           0 :   { return mPath->ContainsPoint(aPoint, aTransform); }
     108           0 :   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
     109             :                                    const Point &aPoint,
     110             :                                    const Matrix &aTransform) const
     111           0 :   { return mPath->StrokeContainsPoint(aStrokeOptions, aPoint, aTransform); }
     112             :   
     113           0 :   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const
     114           0 :   { return mPath->GetBounds(aTransform); }
     115             :   
     116           0 :   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
     117             :                                 const Matrix &aTransform = Matrix()) const
     118           0 :   { return mPath->GetStrokedBounds(aStrokeOptions, aTransform); }
     119             : 
     120           0 :   virtual void StreamToSink(PathSink *aSink) const { mPath->StreamToSink(aSink); }
     121             : 
     122           0 :   virtual FillRule GetFillRule() const { return mFillRule; }
     123             : 
     124             :   void StorePath(std::ostream &aStream) const;
     125             :   static void ReadPathToBuilder(std::istream &aStream, PathBuilder *aBuilder);
     126             : 
     127             : private:
     128             :   friend class DrawTargetWrapAndRecord;
     129             :   friend class DrawTargetRecording;
     130             :   friend class RecordedPathCreation;
     131             : 
     132             :   RefPtr<Path> mPath;
     133             :   std::vector<PathOp> mPathOps;
     134             :   FillRule mFillRule;
     135             : 
     136             :   // Event recorders that have this path in their event stream.
     137             :   std::vector<RefPtr<DrawEventRecorderPrivate>> mStoredRecorders;
     138             : };
     139             : 
     140             : } // namespace gfx
     141             : } // namespace mozilla
     142             : 
     143             : #endif /* MOZILLA_GFX_PATHRECORDING_H_ */

Generated by: LCOV version 1.13