Changeset View
Changeset View
Standalone View
Standalone View
libbreezecommon/breezeboxshadowrenderer.cpp
Show All 39 Lines | |||||
40 | { | 40 | { | ||
41 | // See https://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement | 41 | // See https://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement | ||
42 | const qreal gaussianScaleFactor = (3.0 * qSqrt(2.0 * M_PI) / 4.0) * 1.5; | 42 | const qreal gaussianScaleFactor = (3.0 * qSqrt(2.0 * M_PI) / 4.0) * 1.5; | ||
43 | return qMax(2, qFloor(stdDev * gaussianScaleFactor + 0.5)); | 43 | return qMax(2, qFloor(stdDev * gaussianScaleFactor + 0.5)); | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | static inline qreal calculateBlurStdDev(int radius) | 46 | static inline qreal calculateBlurStdDev(int radius) | ||
47 | { | 47 | { | ||
48 | // https://www.w3.org/TR/css-backgrounds-3/#shadow-blur says that the resulting | 48 | return radius * 0.5; | ||
49 | // shadow must approximate the image that would be generated by applying to the | | |||
50 | // shadow a Gaussian blur with a standard deviation equal to half the blur radius, | | |||
51 | // but we had been using a slightly different (non-standard compliant) routine to | | |||
52 | // derive the standard deviation before, so in order to not break existing shadow | | |||
53 | // params, we're not following the standard. | | |||
54 | return radius * 0.43; // TODO: Multiply by 0.5 instead. | | |||
55 | } | 49 | } | ||
56 | 50 | | |||
57 | static inline QSize calculateBlurExtent(int radius) | 51 | static inline QSize calculateBlurExtent(int radius) | ||
58 | { | 52 | { | ||
59 | const int blurRadius = calculateBlurRadius(calculateBlurStdDev(radius)); | 53 | const int blurRadius = calculateBlurRadius(calculateBlurStdDev(radius)); | ||
60 | return QSize(blurRadius, blurRadius); | 54 | return QSize(blurRadius, blurRadius); | ||
61 | } | 55 | } | ||
62 | 56 | | |||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |