зеркало из https://github.com/mozilla/gecko-dev.git
Bug 703428 - Handle invalid stroke options. r=jrmuizel
This commit is contained in:
Родитель
75cbb62c58
Коммит
75add05f0c
|
@ -444,7 +444,9 @@ DrawTargetSkia::Stroke(const Path *aPath,
|
|||
|
||||
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
|
||||
StrokeOptionsToPaint(paint.mPaint, aStrokeOptions);
|
||||
if (!StrokeOptionsToPaint(paint.mPaint, aStrokeOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCanvas->drawPath(skiaPath->GetPath(), paint.mPaint);
|
||||
}
|
||||
|
@ -457,7 +459,9 @@ DrawTargetSkia::StrokeRect(const Rect &aRect,
|
|||
{
|
||||
MarkChanged();
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
|
||||
StrokeOptionsToPaint(paint.mPaint, aStrokeOptions);
|
||||
if (!StrokeOptionsToPaint(paint.mPaint, aStrokeOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCanvas->drawRect(RectToSkRect(aRect), paint.mPaint);
|
||||
}
|
||||
|
@ -471,7 +475,9 @@ DrawTargetSkia::StrokeLine(const Point &aStart,
|
|||
{
|
||||
MarkChanged();
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
|
||||
StrokeOptionsToPaint(paint.mPaint, aStrokeOptions);
|
||||
if (!StrokeOptionsToPaint(paint.mPaint, aStrokeOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCanvas->drawLine(SkFloatToScalar(aStart.x), SkFloatToScalar(aStart.y),
|
||||
SkFloatToScalar(aEnd.x), SkFloatToScalar(aEnd.y),
|
||||
|
|
|
@ -104,14 +104,19 @@ JoinStyleToSkiaJoin(JoinStyle aJoin)
|
|||
return SkPaint::kDefault_Join;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static inline bool
|
||||
StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
|
||||
{
|
||||
// Skia rendewrs 0 width strokes with a width of 1 (and in black),
|
||||
// so we should just skip the draw call entirely.
|
||||
if (!aOptions.mLineWidth) {
|
||||
return false;
|
||||
}
|
||||
aPaint.setStrokeWidth(SkFloatToScalar(aOptions.mLineWidth));
|
||||
aPaint.setStrokeMiter(SkFloatToScalar(aOptions.mMiterLimit));
|
||||
aPaint.setStrokeCap(CapStyleToSkiaCap(aOptions.mLineCap));
|
||||
aPaint.setStrokeJoin(JoinStyleToSkiaJoin(aOptions.mLineJoin));
|
||||
if (aOptions.mDashLength) {
|
||||
if (aOptions.mDashLength > 1) {
|
||||
std::vector<SkScalar> pattern;
|
||||
pattern.resize(aOptions.mDashLength);
|
||||
for (uint32_t i = 0; i < aOptions.mDashLength; i++) {
|
||||
|
@ -124,6 +129,7 @@ StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
|
|||
SkSafeUnref(aPaint.setPathEffect(dash));
|
||||
}
|
||||
aPaint.setStyle(SkPaint::kStroke_Style);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче