Bug 145234 - [Cocoa] Use CTFontDrawGlyphs() instead of CGContextShowGlyphsWithAdvances()/CGContextShowGlyphsAtPositions()
Summary: [Cocoa] Use CTFontDrawGlyphs() instead of CGContextShowGlyphsWithAdvances()/C...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on: 145449
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-20 17:46 PDT by Myles C. Maxfield
Modified: 2021-08-19 02:37 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.37 KB, patch)
2015-05-20 17:53 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (5.08 KB, patch)
2015-05-20 19:16 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (5.65 KB, patch)
2015-05-21 17:29 PDT, Myles C. Maxfield
enrica: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2015-05-20 17:46:38 PDT
[Cocoa] Use CTFontDrawGlyphs() instead of CGContextShowGlyphsWithAdvances()/CGContextShowGlyphsAtPositions()
Comment 1 Myles C. Maxfield 2015-05-20 17:53:06 PDT
Created attachment 253480 [details]
Patch
Comment 2 Jon Lee 2015-05-20 18:23:46 PDT
Comment on attachment 253480 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253480&action=review

> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:-386
> -    CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize);

Does the scale end up being applied in CTFontDrawGlyphs?
Comment 3 Myles C. Maxfield 2015-05-20 19:16:26 PDT
Created attachment 253494 [details]
Patch
Comment 4 Myles C. Maxfield 2015-05-20 19:23:14 PDT
Comment on attachment 253480 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253480&action=review

>> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:-386
>> -    CGAffineTransform matrix = useLetterpressEffect || platformData.isColorBitmapFont() ? CGAffineTransformIdentity : CGAffineTransformMakeScale(fontSize, fontSize);
> 
> Does the scale end up being applied in CTFontDrawGlyphs?

No. Our current code draws the text at a size of 1pt into a scaled context. However, this approach is wrong when using CTFontDrawGlyphs() because CT will set the font size for us. Therefore, if we don't get rid of this context scaling, all text appears as if its point size was squared. (Note that [drawFont matrix] is just a scale by fontSize).
Comment 5 Enrica Casucci 2015-05-21 11:01:08 PDT
Comment on attachment 253494 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253494&action=review

> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:-219
> -        CGContextSetTextMatrix(context, savedMatrix);

I'm not sure I understand why it is ok to remove the line above.

> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:386
>  #endif

Could you explain this piece of code? From what I understand you removed a font scaling transform, but you also removed line 392. I won't be able to review this unless I fully understand it.
Comment 6 Myles C. Maxfield 2015-05-21 16:42:47 PDT
Comment on attachment 253494 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253494&action=review

>> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:-219
>> -        CGContextSetTextMatrix(context, savedMatrix);
> 
> I'm not sure I understand why it is ok to remove the line above.

Upon investigation, it appears that it isn't okay. The fact that no tests failed is troubling. I will investigate more.

>> Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm:386
>>  #endif
> 
> Could you explain this piece of code? From what I understand you removed a font scaling transform, but you also removed line 392. I won't be able to review this unless I fully understand it.

See my previous comment to jonlee. I think that should explain it.
Comment 7 Myles C. Maxfield 2015-05-21 16:55:34 PDT
(In reply to comment #4)
> (Note that [drawFont matrix] is just a scale by fontSize).

This is incorrect. It is often just a scale, but it might not be.
Comment 8 Myles C. Maxfield 2015-05-21 17:29:47 PDT
Created attachment 253561 [details]
Patch
Comment 9 Enrica Casucci 2015-05-22 14:33:15 PDT
Comment on attachment 253561 [details]
Patch

Looks good now.
Comment 10 Myles C. Maxfield 2015-05-22 14:43:27 PDT
Committed r184796: <http://trac.webkit.org/changeset/184796>
Comment 11 Antti Koivisto 2015-05-28 13:47:37 PDT
This might have been 2% PLT regression. Can we roll out to confirm?
Comment 12 Myles C. Maxfield 2015-05-28 15:13:10 PDT
But I measured it :(

Go ahead, but make sure you also roll out http://trac.webkit.org/changeset/184832 first.
Comment 13 WebKit Commit Bot 2015-05-28 16:17:05 PDT
Re-opened since this is blocked by bug 145449
Comment 14 Myles C. Maxfield 2015-05-28 16:23:02 PDT
Rolled out in https://bugs.webkit.org/show_bug.cgi?id=145449
Comment 15 Myles C. Maxfield 2021-08-19 02:36:22 PDT
This is done.
Comment 16 Radar WebKit Bug Importer 2021-08-19 02:37:18 PDT
<rdar://problem/82116941>