зеркало из https://github.com/mozilla/gecko-dev.git
Bug 740963 - [Skia] Handle non-multiple-of-two dash lengths in HelpersSkia::StrokeOptionsToPaint(). r=jrmuizel
This commit is contained in:
Родитель
d8af3e1c29
Коммит
ffbd0273bd
|
@ -118,22 +118,29 @@ StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
|
||||||
aPaint.setStrokeCap(CapStyleToSkiaCap(aOptions.mLineCap));
|
aPaint.setStrokeCap(CapStyleToSkiaCap(aOptions.mLineCap));
|
||||||
aPaint.setStrokeJoin(JoinStyleToSkiaJoin(aOptions.mLineJoin));
|
aPaint.setStrokeJoin(JoinStyleToSkiaJoin(aOptions.mLineJoin));
|
||||||
|
|
||||||
// XXX: According to the webkit code skia seems to only
|
if (aOptions.mDashLength > 0) {
|
||||||
// support dash arrays that are multiples of 2. Therefor,
|
// Skia only supports dash arrays that are multiples of 2.
|
||||||
// We need to double the array when % 2 != 0
|
uint32_t dashCount;
|
||||||
MOZ_ASSERT(aOptions.mDashLength % 2 == 0);
|
|
||||||
if (aOptions.mDashLength > 1) {
|
if (aOptions.mDashLength % 2 == 0) {
|
||||||
|
dashCount = aOptions.mDashLength;
|
||||||
|
} else {
|
||||||
|
dashCount = aOptions.mDashLength * 2;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<SkScalar> pattern;
|
std::vector<SkScalar> pattern;
|
||||||
pattern.resize(aOptions.mDashLength);
|
pattern.resize(dashCount);
|
||||||
for (uint32_t i = 0; i < aOptions.mDashLength; i++) {
|
|
||||||
pattern[i] = SkFloatToScalar(aOptions.mDashPattern[i]);
|
for (uint32_t i = 0; i < dashCount; i++) {
|
||||||
|
pattern[i] = SkFloatToScalar(aOptions.mDashPattern[i % aOptions.mDashLength]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkDashPathEffect* dash = new SkDashPathEffect(&pattern.front(),
|
SkDashPathEffect* dash = new SkDashPathEffect(&pattern.front(),
|
||||||
aOptions.mDashLength,
|
dashCount,
|
||||||
SkFloatToScalar(aOptions.mDashOffset));
|
SkFloatToScalar(aOptions.mDashOffset));
|
||||||
SkSafeUnref(aPaint.setPathEffect(dash));
|
SkSafeUnref(aPaint.setPathEffect(dash));
|
||||||
}
|
}
|
||||||
|
|
||||||
aPaint.setStyle(SkPaint::kStroke_Style);
|
aPaint.setStyle(SkPaint::kStroke_Style);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче