Title: [213191] trunk/Source/WebCore
Revision
213191
Author
simon.fra...@apple.com
Date
2017-02-28 16:20:24 -0800 (Tue, 28 Feb 2017)

Log Message

Make the repaint indicators show subpixel antialiased text indication a bit more clearly
https://bugs.webkit.org/show_bug.cgi?id=168988

Reviewed by Tim Horton.

Put a more obvious stroke around the repaint count when subpixel-antialiased layer text is enabled.

* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::PlatformCALayer::drawRepaintIndicator):
(WebCore::PlatformCALayer::drawTextAtPoint):
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(PlatformCALayerWin::drawTextAtPoint):
* platform/graphics/ca/win/PlatformCALayerWin.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (213190 => 213191)


--- trunk/Source/WebCore/ChangeLog	2017-03-01 00:07:23 UTC (rev 213190)
+++ trunk/Source/WebCore/ChangeLog	2017-03-01 00:20:24 UTC (rev 213191)
@@ -1,3 +1,20 @@
+2017-02-28  Simon Fraser  <simon.fra...@apple.com>
+
+        Make the repaint indicators show subpixel antialiased text indication a bit more clearly
+        https://bugs.webkit.org/show_bug.cgi?id=168988
+
+        Reviewed by Tim Horton.
+
+        Put a more obvious stroke around the repaint count when subpixel-antialiased layer text is enabled.
+
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (WebCore::PlatformCALayer::drawRepaintIndicator):
+        (WebCore::PlatformCALayer::drawTextAtPoint):
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (PlatformCALayerWin::drawTextAtPoint):
+        * platform/graphics/ca/win/PlatformCALayerWin.h:
+
 2017-02-28  Alex Christensen  <achristen...@webkit.org>
 
         LibWebRTCProvider should check existence of libwebrtc.dylib

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (213190 => 213191)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2017-03-01 00:07:23 UTC (rev 213190)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2017-03-01 00:20:24 UTC (rev 213191)
@@ -116,10 +116,12 @@
         CGContextStrokeRect(context, indicatorBox);
     }
 
+    CGFloat strokeWidthAsPercentageOfFontSize = 0;
+    Color strokeColor;
+
     if (!platformCALayer->isOpaque() && platformCALayer->supportsSubpixelAntialiasedText()) {
-        // Draw a gray shadow behind the repaint count.
-        CGContextSetRGBFillColor(context, 1, 1, 1, 0.4);
-        platformCALayer->drawTextAtPoint(context, indicatorBox.x() + 7, indicatorBox.y() + 24, CGSizeMake(1, -1), 22, text, strlen(text));
+        strokeColor = Color(0, 0, 0, 200);
+        strokeWidthAsPercentageOfFontSize = -4.5; // Negative means "stroke and fill"; see docs for kCTStrokeWidthAttributeName.
     }
 
     if (platformCALayer->acceleratesDrawing())
@@ -127,7 +129,7 @@
     else
         CGContextSetRGBFillColor(context, 1, 1, 1, 1);
     
-    platformCALayer->drawTextAtPoint(context, indicatorBox.x() + 5, indicatorBox.y() + 22, CGSizeMake(1, -1), 22, text, strlen(text));
+    platformCALayer->drawTextAtPoint(context, indicatorBox.x() + 5, indicatorBox.y() + 22, CGSizeMake(1, -1), 22, text, strlen(text), strokeWidthAsPercentageOfFontSize, strokeColor);
     
     CGContextEndTransparencyLayer(context);
 }
@@ -138,13 +140,25 @@
     CGContextTranslateCTM(context, 0, -height);
 }
 
-// This function is needed to work around a bug in Windows CG <rdar://problem/22703470>
-void PlatformCALayer::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length) const
+void PlatformCALayer::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length, CGFloat strokeWidthAsPercentageOfFontSize, Color strokeColor) const
 {
     auto matrix = CGAffineTransformMakeScale(scale.width, scale.height);
     auto font = adoptCF(CTFontCreateWithName(CFSTR("Helvetica"), fontSize, &matrix));
-    CFTypeRef keys[] = { kCTFontAttributeName, kCTForegroundColorFromContextAttributeName };
-    CFTypeRef values[] = { font.get(), kCFBooleanTrue };
+    auto strokeWidthNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &strokeWidthAsPercentageOfFontSize));
+
+    CFTypeRef keys[] = {
+        kCTFontAttributeName,
+        kCTForegroundColorFromContextAttributeName,
+        kCTStrokeWidthAttributeName,
+        kCTStrokeColorAttributeName,
+    };
+    CFTypeRef values[] = {
+        font.get(),
+        kCFBooleanTrue,
+        strokeWidthNumber.get(),
+        cachedCGColor(strokeColor),
+    };
+
     auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     auto string = adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(text), length, kCFStringEncodingUTF8, false, kCFAllocatorNull));
     auto attributedString = adoptCF(CFAttributedStringCreate(kCFAllocatorDefault, string.get(), attributes.get()));

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (213190 => 213191)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2017-03-01 00:07:23 UTC (rev 213190)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2017-03-01 00:20:24 UTC (rev 213191)
@@ -240,7 +240,7 @@
 
     virtual TiledBacking* tiledBacking() = 0;
 
-    virtual void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length) const;
+    virtual void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length, CGFloat strokeWidthAsPercentageOfFontSize = 0, Color strokeColor = Color()) const;
 
     static void flipContext(CGContextRef, CGFloat height);
     

Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (213190 => 213191)


--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp	2017-03-01 00:07:23 UTC (rev 213190)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp	2017-03-01 00:20:24 UTC (rev 213191)
@@ -952,7 +952,7 @@
     return reinterpret_cast<WebTiledBackingLayerWin*>(intern(this))->tiledBacking();
 }
 
-void PlatformCALayerWin::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* message, size_t length) const
+void PlatformCALayerWin::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* message, size_t length, CGFloat, Color) const
 {
     String text(message, length);
 

Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h (213190 => 213191)


--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h	2017-03-01 00:07:23 UTC (rev 213190)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h	2017-03-01 00:20:24 UTC (rev 213191)
@@ -161,7 +161,7 @@
     PlatformCALayer* rootLayer() const override;
     void setNeedsLayout() override;
     void setNeedsCommit() override;
-    void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length) const override;
+    void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, CGSize scale, CGFloat fontSize, const char* text, size_t length, CGFloat strokeWidth, Color strokeColor) const override;
 
     String layerTreeAsString() const override;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to