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/. */
6 #ifndef MOZILLA_GFX_PATHRECORDING_H_
7 #define MOZILLA_GFX_PATHRECORDING_H_
32 const int32_t sPointCount
[] = { 1, 1, 3, 2, 0, 0 };
35 class DrawEventRecorderPrivate
;
37 class PathBuilderRecording
: public PathBuilder
40 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderRecording
)
41 PathBuilderRecording(PathBuilder
*aBuilder
, FillRule aFillRule
)
42 : mPathBuilder(aBuilder
), mFillRule(aFillRule
)
46 /* Move the current point in the path, any figure currently being drawn will
47 * be considered closed during fill operations, however when stroking the
48 * closing line segment will not be drawn.
50 virtual void MoveTo(const Point
&aPoint
);
51 /* Add a linesegment to the current figure */
52 virtual void LineTo(const Point
&aPoint
);
53 /* Add a cubic bezier curve to the current figure */
54 virtual void BezierTo(const Point
&aCP1
,
57 /* Add a quadratic bezier curve to the current figure */
58 virtual void QuadraticBezierTo(const Point
&aCP1
,
60 /* Close the current figure, this will essentially generate a line segment
61 * from the current point to the starting point for the current figure
65 /* Add an arc to the current figure */
66 virtual void Arc(const Point
&, float, float, float, bool) { }
68 /* Point the current subpath is at - or where the next subpath will start
69 * if there is no active subpath.
71 virtual Point
CurrentPoint() const;
73 virtual TemporaryRef
<Path
> Finish();
76 friend class PathRecording
;
78 RefPtr
<PathBuilder
> mPathBuilder
;
80 std::vector
<PathOp
> mPathOps
;
83 class PathRecording
: public Path
86 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathRecording
)
87 PathRecording(Path
*aPath
, const std::vector
<PathOp
> aOps
, FillRule aFillRule
)
88 : mPath(aPath
), mPathOps(aOps
), mFillRule(aFillRule
)
94 virtual BackendType
GetBackendType() const { return BackendType::RECORDING
; }
95 virtual TemporaryRef
<PathBuilder
> CopyToBuilder(FillRule aFillRule
= FillRule::FILL_WINDING
) const;
96 virtual TemporaryRef
<PathBuilder
> TransformedCopyToBuilder(const Matrix
&aTransform
,
97 FillRule aFillRule
= FillRule::FILL_WINDING
) const;
98 virtual bool ContainsPoint(const Point
&aPoint
, const Matrix
&aTransform
) const
99 { return mPath
->ContainsPoint(aPoint
, aTransform
); }
100 virtual bool StrokeContainsPoint(const StrokeOptions
&aStrokeOptions
,
102 const Matrix
&aTransform
) const
103 { return mPath
->StrokeContainsPoint(aStrokeOptions
, aPoint
, aTransform
); }
105 virtual Rect
GetBounds(const Matrix
&aTransform
= Matrix()) const
106 { return mPath
->GetBounds(aTransform
); }
108 virtual Rect
GetStrokedBounds(const StrokeOptions
&aStrokeOptions
,
109 const Matrix
&aTransform
= Matrix()) const
110 { return mPath
->GetStrokedBounds(aStrokeOptions
, aTransform
); }
112 virtual void StreamToSink(PathSink
*aSink
) const { mPath
->StreamToSink(aSink
); }
114 virtual FillRule
GetFillRule() const { return mFillRule
; }
116 void StorePath(std::ostream
&aStream
) const;
117 static void ReadPathToBuilder(std::istream
&aStream
, PathBuilder
*aBuilder
);
120 friend class DrawTargetRecording
;
121 friend class RecordedPathCreation
;
124 std::vector
<PathOp
> mPathOps
;
127 // Event recorders that have this path in their event stream.
128 std::vector
<DrawEventRecorderPrivate
*> mStoredRecorders
;
134 #endif /* MOZILLA_GFX_PATHRECORDING_H_ */