Bug 1169609 - Avoid all-zero patterns that would trigger the CAIRO_STATUS_INVALID_DASH error state. r=jmuizelaar

--HG--
extra : rebase_source : 35a276d5f908c4b108f1b9f8738c31b32b6c34e0
This commit is contained in:
Lee Salzman 2015-06-01 18:02:10 -04:00
parent 26b1a24fe5
commit 1d435054f1

View File

@ -260,11 +260,18 @@ SetCairoStrokeOptions(cairo_t* aCtx, const StrokeOptions& aStrokeOptions)
if (aStrokeOptions.mDashPattern) {
// Convert array of floats to array of doubles
std::vector<double> dashes(aStrokeOptions.mDashLength);
bool nonZero = false;
for (size_t i = 0; i < aStrokeOptions.mDashLength; ++i) {
if (aStrokeOptions.mDashPattern[i] != 0) {
nonZero = true;
}
dashes[i] = aStrokeOptions.mDashPattern[i];
}
cairo_set_dash(aCtx, &dashes[0], aStrokeOptions.mDashLength,
aStrokeOptions.mDashOffset);
// Avoid all-zero patterns that would trigger the CAIRO_STATUS_INVALID_DASH context error state.
if (nonZero) {
cairo_set_dash(aCtx, &dashes[0], aStrokeOptions.mDashLength,
aStrokeOptions.mDashOffset);
}
}
cairo_set_line_join(aCtx, GfxLineJoinToCairoLineJoin(aStrokeOptions.mLineJoin));