Bug 935297 - Part 3: Implement new API to allow streaming paths to arbitrary sinks on Cairo. r=mattwoodrow

This commit is contained in:
Bas Schouten 2013-11-07 22:11:26 +13:00
parent 681b14502b
commit 4a52b4556e
2 changed files with 30 additions and 1 deletions

View File

@ -236,6 +236,35 @@ PathCairo::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
return aTransform.TransformBounds(bounds);
}
void
PathCairo::StreamToSink(PathSink *aSink) const
{
for (size_t i = 0; i < mPathData.size(); i++) {
switch (mPathData[i].header.type) {
case CAIRO_PATH_MOVE_TO:
i++;
aSink->MoveTo(Point(mPathData[i].point.x, mPathData[i].point.y));
break;
case CAIRO_PATH_LINE_TO:
i++;
aSink->LineTo(Point(mPathData[i].point.x, mPathData[i].point.y));
break;
case CAIRO_PATH_CURVE_TO:
aSink->BezierTo(Point(mPathData[i + 1].point.x, mPathData[i + 1].point.y),
Point(mPathData[i + 2].point.x, mPathData[i + 2].point.y),
Point(mPathData[i + 3].point.x, mPathData[i + 3].point.y));
i += 3;
break;
case CAIRO_PATH_CLOSE_PATH:
aSink->Close();
break;
default:
// Corrupt path data!
MOZ_ASSERT(false);
}
}
}
void
PathCairo::EnsureContainingContext() const
{

View File

@ -69,7 +69,7 @@ public:
virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
const Matrix &aTransform = Matrix()) const;
virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
virtual void StreamToSink(PathSink *aSink) const;
virtual FillRule GetFillRule() const { return mFillRule; }