mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 740963 - [Skia] Handle non-multiple-of-two dash lengths in HelpersSkia::StrokeOptionsToPaint(). r=jrmuizel
This commit is contained in:
parent
3fb5bf234f
commit
b8f758f5bc
@ -118,22 +118,29 @@ StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
|
||||
aPaint.setStrokeCap(CapStyleToSkiaCap(aOptions.mLineCap));
|
||||
aPaint.setStrokeJoin(JoinStyleToSkiaJoin(aOptions.mLineJoin));
|
||||
|
||||
// XXX: According to the webkit code skia seems to only
|
||||
// support dash arrays that are multiples of 2. Therefor,
|
||||
// We need to double the array when % 2 != 0
|
||||
MOZ_ASSERT(aOptions.mDashLength % 2 == 0);
|
||||
if (aOptions.mDashLength > 1) {
|
||||
if (aOptions.mDashLength > 0) {
|
||||
// Skia only supports dash arrays that are multiples of 2.
|
||||
uint32_t dashCount;
|
||||
|
||||
if (aOptions.mDashLength % 2 == 0) {
|
||||
dashCount = aOptions.mDashLength;
|
||||
} else {
|
||||
dashCount = aOptions.mDashLength * 2;
|
||||
}
|
||||
|
||||
std::vector<SkScalar> pattern;
|
||||
pattern.resize(aOptions.mDashLength);
|
||||
for (uint32_t i = 0; i < aOptions.mDashLength; i++) {
|
||||
pattern[i] = SkFloatToScalar(aOptions.mDashPattern[i]);
|
||||
pattern.resize(dashCount);
|
||||
|
||||
for (uint32_t i = 0; i < dashCount; i++) {
|
||||
pattern[i] = SkFloatToScalar(aOptions.mDashPattern[i % aOptions.mDashLength]);
|
||||
}
|
||||
|
||||
SkDashPathEffect* dash = new SkDashPathEffect(&pattern.front(),
|
||||
aOptions.mDashLength,
|
||||
dashCount,
|
||||
SkFloatToScalar(aOptions.mDashOffset));
|
||||
SkSafeUnref(aPaint.setPathEffect(dash));
|
||||
}
|
||||
|
||||
aPaint.setStyle(SkPaint::kStroke_Style);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user