Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp

Issue 14125: fix box shadows (Closed)
Patch Set: reflow Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** Copyright 2006, Google Inc. 2 ** Copyright 2006, Google Inc.
3 ** 3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License"); 4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License. 5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at 6 ** You may obtain a copy of the License at
7 ** 7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0 8 ** http://www.apache.org/licenses/LICENSE-2.0
9 ** 9 **
10 ** Unless required by applicable law or agreed to in writing, software 10 ** Unless required by applicable law or agreed to in writing, software
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 923 }
924 924
925 void GraphicsContext::setPlatformFillColor(const Color& color) 925 void GraphicsContext::setPlatformFillColor(const Color& color)
926 { 926 {
927 if (paintingDisabled()) 927 if (paintingDisabled())
928 return; 928 return;
929 platformContext()->setFillColor(color.rgb()); 929 platformContext()->setFillColor(color.rgb());
930 } 930 }
931 931
932 void GraphicsContext::setPlatformShadow(const IntSize& size, 932 void GraphicsContext::setPlatformShadow(const IntSize& size,
933 int blur, 933 int blur_int,
934 const Color& color) 934 const Color& color)
935 { 935 {
936 if (paintingDisabled()) 936 if (paintingDisabled())
937 return; 937 return;
938 938
939 double width = size.width();
940 double height = size.height();
941 double blur = blur_int;
942
943 if (!m_common->state.shadowsIgnoreTransforms) {
944 AffineTransform transform = getCTM();
945 transform.map(width, height, &width, &height);
946
947 // Transform for the blur
948 double a = transform.a() * transform.a() + transform.b() * transform.b() ;
949 double b = transform.a() * transform.c() + transform.b() * transform.d() ;
950 double c = b;
951 double d = transform.c() * transform.c() + transform.d() * transform.d() ;
952 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!
953 blur *= eigenvalue;
954 } else {
955 // This is weird, but shadows get dropped in the wrong direction for
956 // canvas elements without this.
957 height = -height;
958 }
959
939 SkColor c; 960 SkColor c;
940 if (color.isValid()) 961 if (color.isValid())
941 c = color.rgb(); 962 c = color.rgb();
942 else 963 else
943 c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" apple shadow color. 964 c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" apple shadow color.
944 SkDrawLooper* dl = new SkBlurDrawLooper(SkIntToScalar(blur), 965
945 SkIntToScalar(size.width()), 966 // TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0
946 SkIntToScalar(-size.height()), 967 // for perf reasons.
947 c); 968 SkDrawLooper* dl = new SkBlurDrawLooper(blur, width, height, c);
948 platformContext()->setDrawLooper(dl); 969 platformContext()->setDrawLooper(dl);
949 dl->unref(); 970 dl->unref();
950 } 971 }
951 972
952 void GraphicsContext::setPlatformStrokeColor(const Color& strokecolor) 973 void GraphicsContext::setPlatformStrokeColor(const Color& strokecolor)
953 { 974 {
954 if (paintingDisabled()) 975 if (paintingDisabled())
955 return; 976 return;
956 platformContext()->setStrokeColor(strokecolor.rgb()); 977 platformContext()->setStrokeColor(strokecolor.rgb());
957 } 978 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1100
1080 void GraphicsContext::translate(float w, float h) 1101 void GraphicsContext::translate(float w, float h)
1081 { 1102 {
1082 if (paintingDisabled()) 1103 if (paintingDisabled())
1083 return; 1104 return;
1084 platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w), 1105 platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w),
1085 WebCoreFloatToSkScalar(h)); 1106 WebCoreFloatToSkScalar(h));
1086 } 1107 }
1087 1108
1088 } // namespace WebCore 1109 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698