Title: [89366] trunk/Source/WebCore
Revision
89366
Author
commit-qu...@webkit.org
Date
2011-06-21 11:05:09 -0700 (Tue, 21 Jun 2011)

Log Message

2011-06-21  Cary Clark  <carycl...@google.com>

        Reviewed by Eric Seidel.

        Update GraphicsContextSkia when the Chromium platform is Mac
        https://bugs.webkit.org/show_bug.cgi?id=62867

        No new tests. This does not modify existing code;
        there is no change in functionality.

        * platform/graphics/skia/GraphicsContextSkia.cpp:
        (WebCore::drawOuterPath):
        (WebCore::drawInnerPath):
        (WebCore::getFocusRingOutset):
        (WebCore::GraphicsContext::drawFocusRing):
        The OS X framework draws a fatter focus ring than the
        Chromium port. Increase the diameter, and add an inner
        stroke with more transparency, to match the look of
        Chromium on Mac when Skia is the rendering engine.

        (WebCore::deviceRGBColorSpaceRef):
        Add deviceRGBColorSpaceRef, a static cache of
        CGColorSpaceCreateDeviceRGB(). This is called by
        the Mac-specific UI when Skia is the rendering engine.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89365 => 89366)


--- trunk/Source/WebCore/ChangeLog	2011-06-21 18:04:17 UTC (rev 89365)
+++ trunk/Source/WebCore/ChangeLog	2011-06-21 18:05:09 UTC (rev 89366)
@@ -1,3 +1,28 @@
+2011-06-21  Cary Clark  <carycl...@google.com>
+
+        Reviewed by Eric Seidel.
+
+        Update GraphicsContextSkia when the Chromium platform is Mac
+        https://bugs.webkit.org/show_bug.cgi?id=62867
+
+        No new tests. This does not modify existing code;
+        there is no change in functionality.
+
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::drawOuterPath):
+        (WebCore::drawInnerPath):
+        (WebCore::getFocusRingOutset):
+        (WebCore::GraphicsContext::drawFocusRing):
+        The OS X framework draws a fatter focus ring than the
+        Chromium port. Increase the diameter, and add an inner
+        stroke with more transparency, to match the look of
+        Chromium on Mac when Skia is the rendering engine.
+
+        (WebCore::deviceRGBColorSpaceRef):
+        Add deviceRGBColorSpaceRef, a static cache of
+        CGColorSpaceCreateDeviceRGB(). This is called by
+        the Mac-specific UI when Skia is the rendering engine.
+
 2011-06-21  Tony Chang  <t...@chromium.org>
 
         Try to fix WinCE build.  Replace cat with perl -ne "print".

Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (89365 => 89366)


--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-06-21 18:04:17 UTC (rev 89365)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-06-21 18:05:09 UTC (rev 89366)
@@ -57,6 +57,10 @@
 #include <wtf/MathExtras.h>
 #include <wtf/UnusedParam.h>
 
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+#include <CoreGraphics/CGColorSpace.h>
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -530,8 +534,39 @@
     // FIXME: implement
 }
 
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
+static inline void drawOuterPath(SkCanvas* canvas, const SkPath& path, SkPaint& paint, int width)
 {
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+    paint.setAlpha(64);
+    paint.setStrokeWidth(width);
+    paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref();
+#else
+    paint.setStrokeWidth(1);
+    paint.setPathEffect(new SkCornerPathEffect(1))->unref();
+#endif
+    canvas->drawPath(path, paint);
+}
+
+static inline void drawInnerPath(SkCanvas* canvas, const SkPath& path, SkPaint& paint, int width)
+{
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+    paint.setAlpha(128);
+    paint.setStrokeWidth(width * 0.5f);
+    canvas->drawPath(path, paint);
+#endif
+}
+
+static inline SkScalar getFocusRingOutset(int width)
+{
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+    return (width * 0.5f) + 0.25f;
+#else
+    return 0.5f;
+#endif
+}
+
+void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
+{
     if (paintingDisabled())
         return;
 
@@ -541,7 +576,7 @@
 
     platformContext()->prepareForSoftwareDraw();
     SkRegion focusRingRegion;
-    const SkScalar focusRingOutset = WebCoreFloatToSkScalar(0.5);
+    const SkScalar focusRingOutset = getFocusRingOutset(width);
     for (unsigned i = 0; i < rectCount; i++) {
         SkIRect r = rects[i];
         r.inset(-focusRingOutset, -focusRingOutset);
@@ -554,10 +589,10 @@
     paint.setStyle(SkPaint::kStroke_Style);
 
     paint.setColor(color.rgb());
-    paint.setStrokeWidth(focusRingOutset * 2);
-    paint.setPathEffect(new SkCornerPathEffect(focusRingOutset * 2))->unref();
     focusRingRegion.getBoundaryPath(&path);
-    platformContext()->canvas()->drawPath(path, paint);
+    SkCanvas* canvas = platformContext()->canvas();
+    drawOuterPath(canvas, path, paint, width);
+    drawInnerPath(canvas, path, paint, width);
 }
 
 // This is only used to draw borders.
@@ -1289,4 +1324,12 @@
     platformContext()->markDirtyRect(rect);
 }
 
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+CGColorSpaceRef deviceRGBColorSpaceRef()
+{
+    static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
+    return deviceSpace;
+}
+#endif
+
 }  // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to