diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 20:34:03 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 20:34:03 +0000 |
commit | 80d676726524bbd6586ecf42b99094b041d73270 (patch) | |
tree | 1414a1d6e36ccc19cf858b68b986ff05ab87ac8c /webkit/port/platform | |
parent | bbbd545cc226d409d131afb806e1ae5df3e5aa73 (diff) | |
download | chromium_src-80d676726524bbd6586ecf42b99094b041d73270.zip chromium_src-80d676726524bbd6586ecf42b99094b041d73270.tar.gz chromium_src-80d676726524bbd6586ecf42b99094b041d73270.tar.bz2 |
fix box shadows
We need to apply the context transform to the shadow before
rendering it. There's also a weird case where we have to
flip the y offset if we're not applying the transform. I'm
not sure why this is necessary, but it allows us to pass
canvas-shadow tests.
BUG=5503
Review URL: http://codereview.chromium.org/14125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform')
-rw-r--r-- | webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp b/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp index 6bd586d..fd7968b2 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)))); + 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(); } |