Chromium Code Reviews| Index: webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp |
| diff --git a/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp b/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp |
| index 6bd586d3ff1d49b483154179acff7c26c9513e54..fd7968b2ae7b3f8266ed904d6824d81c07fdbea1 100644 |
| --- a/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp |
| +++ b/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp |
| @@ -930,21 +930,42 @@ void GraphicsContext::setPlatformFillColor(const Color& color) |
| } |
| void GraphicsContext::setPlatformShadow(const IntSize& size, |
| - int blur, |
| + int blur_int, |
| const Color& color) |
| { |
| if (paintingDisabled()) |
| return; |
| + double width = size.width(); |
| + double height = size.height(); |
| + double blur = blur_int; |
| + |
| + if (!m_common->state.shadowsIgnoreTransforms) { |
| + AffineTransform transform = getCTM(); |
| + transform.map(width, height, &width, &height); |
| + |
| + // Transform for the blur |
| + double a = transform.a() * transform.a() + transform.b() * transform.b(); |
| + double b = transform.a() * transform.c() + transform.b() * transform.d(); |
| + double c = b; |
| + double d = transform.c() * transform.c() + transform.d() * transform.d(); |
| + double eigenvalue = sqrt(0.5 * ((a + d) - sqrt(4 * b * c + (a - d) * (a - d)))); |
|
brettw
2008/12/15 19:58:49
Eigenvalues... hard core!
|
| + blur *= eigenvalue; |
| + } else { |
| + // This is weird, but shadows get dropped in the wrong direction for |
| + // canvas elements without this. |
| + height = -height; |
| + } |
| + |
| SkColor c; |
| if (color.isValid()) |
| c = color.rgb(); |
| else |
| c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" apple shadow color. |
| - SkDrawLooper* dl = new SkBlurDrawLooper(SkIntToScalar(blur), |
| - SkIntToScalar(size.width()), |
| - SkIntToScalar(-size.height()), |
| - c); |
| + |
| + // TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0 |
| + // for perf reasons. |
| + SkDrawLooper* dl = new SkBlurDrawLooper(blur, width, height, c); |
| platformContext()->setDrawLooper(dl); |
| dl->unref(); |
| } |