Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1240)

Unified Diff: Source/core/svg/SVGPathByteStreamBuilder.cpp

Issue 1037463002: Rework the SVGPathConsumer interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase; FIXME -> TODO. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPathByteStreamBuilder.h ('k') | Source/core/svg/SVGPathConsumer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPathByteStreamBuilder.cpp
diff --git a/Source/core/svg/SVGPathByteStreamBuilder.cpp b/Source/core/svg/SVGPathByteStreamBuilder.cpp
index fa163fdb4cbb8ee88e3c2e6aac6b22fc29b077d3..bda268b82f0a76a0f08ff5a75d9b94a15e1bf2a8 100644
--- a/Source/core/svg/SVGPathByteStreamBuilder.cpp
+++ b/Source/core/svg/SVGPathByteStreamBuilder.cpp
@@ -18,11 +18,11 @@
*/
#include "config.h"
-
#include "core/svg/SVGPathByteStreamBuilder.h"
+#include "core/svg/SVGPathByteStream.h"
#include "core/svg/SVGPathSeg.h"
-#include "wtf/OwnPtr.h"
+#include "platform/geometry/FloatPoint.h"
namespace blink {
@@ -73,82 +73,57 @@ SVGPathByteStreamBuilder::SVGPathByteStreamBuilder(SVGPathByteStream& byteStream
{
}
-void SVGPathByteStreamBuilder::moveTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegMoveToRel : PathSegMoveToAbs);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegLineToRel : PathSegLineToAbs);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::lineToHorizontal(float x, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegLineToHorizontalRel : PathSegLineToHorizontalAbs);
- buffer.writeFloat(x);
-}
-
-void SVGPathByteStreamBuilder::lineToVertical(float y, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegLineToVerticalRel : PathSegLineToVerticalAbs);
- buffer.writeFloat(y);
-}
-
-void SVGPathByteStreamBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicRel : PathSegCurveToCubicAbs);
- buffer.writeFloatPoint(point1);
- buffer.writeFloatPoint(point2);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToCubicSmoothRel : PathSegCurveToCubicSmoothAbs);
- buffer.writeFloatPoint(point2);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticRel : PathSegCurveToQuadraticAbs);
- buffer.writeFloatPoint(point1);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode)
+void SVGPathByteStreamBuilder::emitSegment(const PathSegmentData& segment)
{
CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegCurveToQuadraticSmoothRel : PathSegCurveToQuadraticSmoothAbs);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode)
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(mode == RelativeCoordinates ? PathSegArcRel : PathSegArcAbs);
- buffer.writeFloat(r1);
- buffer.writeFloat(r2);
- buffer.writeFloat(angle);
- buffer.writeFlag(largeArcFlag);
- buffer.writeFlag(sweepFlag);
- buffer.writeFloatPoint(targetPoint);
-}
-
-void SVGPathByteStreamBuilder::closePath()
-{
- CoalescingBuffer buffer(m_byteStream);
- buffer.writeSegmentType(PathSegClosePath);
+ buffer.writeSegmentType(segment.command);
+
+ switch (segment.command) {
+ case PathSegMoveToRel:
+ case PathSegMoveToAbs:
+ case PathSegLineToRel:
+ case PathSegLineToAbs:
+ case PathSegCurveToQuadraticSmoothRel:
+ case PathSegCurveToQuadraticSmoothAbs:
+ buffer.writeFloatPoint(segment.targetPoint);
+ break;
+ case PathSegLineToHorizontalRel:
+ case PathSegLineToHorizontalAbs:
+ buffer.writeFloat(segment.targetPoint.x());
+ break;
+ case PathSegLineToVerticalRel:
+ case PathSegLineToVerticalAbs:
+ buffer.writeFloat(segment.targetPoint.y());
+ break;
+ case PathSegClosePath:
+ break;
+ case PathSegCurveToCubicRel:
+ case PathSegCurveToCubicAbs:
+ buffer.writeFloatPoint(segment.point1);
+ buffer.writeFloatPoint(segment.point2);
+ buffer.writeFloatPoint(segment.targetPoint);
+ break;
+ case PathSegCurveToCubicSmoothRel:
+ case PathSegCurveToCubicSmoothAbs:
+ buffer.writeFloatPoint(segment.point2);
+ buffer.writeFloatPoint(segment.targetPoint);
+ break;
+ case PathSegCurveToQuadraticRel:
+ case PathSegCurveToQuadraticAbs:
+ buffer.writeFloatPoint(segment.point1);
+ buffer.writeFloatPoint(segment.targetPoint);
+ break;
+ case PathSegArcRel:
+ case PathSegArcAbs:
+ buffer.writeFloatPoint(segment.point1);
+ buffer.writeFloat(segment.point2.x());
+ buffer.writeFlag(segment.arcLarge);
+ buffer.writeFlag(segment.arcSweep);
+ buffer.writeFloatPoint(segment.targetPoint);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
}
} // namespace blink
« no previous file with comments | « Source/core/svg/SVGPathByteStreamBuilder.h ('k') | Source/core/svg/SVGPathConsumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698