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

This commit is contained in:
Bas Schouten 2013-11-07 22:11:48 +13:00
Родитель 7809eea55c
Коммит e4b4010ae6
3 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -250,6 +250,12 @@ IntRectToSkIRect(const IntRect& aRect)
return SkIRect::MakeXYWH(aRect.x, aRect.y, aRect.width, aRect.height);
}
static inline Point
SkPointToPoint(const SkPoint &aPoint)
{
return Point(SkScalarToFloat(aPoint.x()), SkScalarToFloat(aPoint.y()));
}
static inline SkShader::TileMode
ExtendModeToTileMode(ExtendMode aMode)
{

Просмотреть файл

@ -209,5 +209,39 @@ PathSkia::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
return aTransform.TransformBounds(bounds);
}
void
PathSkia::StreamToSink(PathSink *aSink) const
{
SkPath::RawIter iter(mPath);
SkPoint points[4];
SkPath::Verb currentVerb;
while ((currentVerb = iter.next(points)) != SkPath::kDone_Verb) {
switch (currentVerb) {
case SkPath::kMove_Verb:
aSink->MoveTo(SkPointToPoint(points[0]));
break;
case SkPath::kLine_Verb:
aSink->LineTo(SkPointToPoint(points[1]));
break;
case SkPath::kCubic_Verb:
aSink->BezierTo(SkPointToPoint(points[1]),
SkPointToPoint(points[2]),
SkPointToPoint(points[3]));
break;
case SkPath::kQuad_Verb:
aSink->QuadraticBezierTo(SkPointToPoint(points[1]),
SkPointToPoint(points[2]));
break;
case SkPath::kClose_Verb:
aSink->Close();
break;
default:
MOZ_ASSERT(false);
// Unexpected verb found in path!
}
}
}
}
}

Просмотреть файл

@ -66,7 +66,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; }