WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 215057
Add glyph origins member to GlyphBuffer
https://bugs.webkit.org/show_bug.cgi?id=215057
Summary
Add glyph origins member to GlyphBuffer
Myles C. Maxfield
Reported
2020-08-01 01:36:24 PDT
Add glyph offsets member to GlyphBuffer
Attachments
Patch
(13.24 KB, patch)
2020-08-01 01:42 PDT
,
Myles C. Maxfield
darin
: review+
Details
Formatted Diff
Diff
Rebased
(13.38 KB, patch)
2020-08-03 22:08 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Rebased
(13.38 KB, patch)
2020-08-03 22:11 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2020-08-01 01:42:42 PDT
Created
attachment 405780
[details]
Patch
Darin Adler
Comment 2
2020-08-01 20:55:20 PDT
Comment on
attachment 405780
[details]
Patch This business where we derive structure from platform structures seems a little strange. Seems like we could do this with some helper functions instead.
Myles C. Maxfield
Comment 3
2020-08-03 15:27:13 PDT
(In reply to Darin Adler from
comment #2
)
> Comment on
attachment 405780
[details]
> Patch > > derive structure from platform structures
Can you explain a little more what you mean by this?
Darin Adler
Comment 4
2020-08-03 15:28:58 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
> Source/WebCore/platform/graphics/GlyphBuffer.h:107 > +struct GlyphBufferOrigin : CGPoint {
This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures".
Myles C. Maxfield
Comment 5
2020-08-03 21:09:46 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >> +struct GlyphBufferOrigin : CGPoint { > > This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures".
Ah, I understand now. What kind of helper functions did you have in mind?
Myles C. Maxfield
Comment 6
2020-08-03 21:15:09 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>> +struct GlyphBufferOrigin : CGPoint { >> >> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". > > Ah, I understand now. > > What kind of helper functions did you have in mind?
I can think of three possibilities: 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint Which of these do you think is best? (And why?)
Myles C. Maxfield
Comment 7
2020-08-03 22:08:45 PDT
Created
attachment 405902
[details]
Rebased
Myles C. Maxfield
Comment 8
2020-08-03 22:11:05 PDT
Created
attachment 405903
[details]
Rebased
Darin Adler
Comment 9
2020-08-04 10:05:21 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>> +struct GlyphBufferOrigin : CGPoint { >>> >>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >> >> Ah, I understand now. >> >> What kind of helper functions did you have in mind? > > I can think of three possibilities: > > 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint > 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint > 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint > > Which of these do you think is best? (And why?)
I would prefer (2). But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code.
Darin Adler
Comment 10
2020-08-04 10:05:55 PDT
Comment on
attachment 405903
[details]
Rebased View in context:
https://bugs.webkit.org/attachment.cgi?id=405903&action=review
> Source/WebCore/platform/graphics/GlyphBuffer.h:319 > + GlyphBufferOrigin origin = m_origins[index1];
auto
Myles C. Maxfield
Comment 11
2020-08-04 10:32:49 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>> +struct GlyphBufferOrigin : CGPoint { >>>> >>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>> >>> Ah, I understand now. >>> >>> What kind of helper functions did you have in mind? >> >> I can think of three possibilities: >> >> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >> >> Which of these do you think is best? (And why?) > > I would prefer (2). > > But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? > > I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. > > I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code.
> Is GlyphBufferOrigin a cross-platform abstraction?
Yes. Cocoa ports use CGPoint so it can be passed directly to CTFontShapeGlyphs() or CTFontTransformGlyphsWIthLanguage(). Other ports use FloatPoint, and convert the FloatPoints to the platform-specific types (whatever Harfbuzz requires) later.
> If so, then does its platform-independent interface involve CGFloat?
Yes, but it shouldn't. I can fix it.
> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it.
FontCascade::drawGlyphBuffer() is one example.
Myles C. Maxfield
Comment 12
2020-08-04 12:20:08 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>>> +struct GlyphBufferOrigin : CGPoint { >>>>> >>>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>>> >>>> Ah, I understand now. >>>> >>>> What kind of helper functions did you have in mind? >>> >>> I can think of three possibilities: >>> >>> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >>> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >>> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >>> >>> Which of these do you think is best? (And why?) >> >> I would prefer (2). >> >> But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? >> >> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. >> >> I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code. > >
Aha! I tried (2) but got: error: static_cast from 'const WebCore::GlyphBufferAdvance *' to 'const CGSize *', which are not related by inheritance, is not allowed This makes total sense, and I think the weird inheritance thing less bad than a call to reinterpret_cast. I'll keep (3) and commit.
Darin Adler
Comment 13
2020-08-04 12:33:06 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>>>> +struct GlyphBufferOrigin : CGPoint { >>>>>> >>>>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>>>> >>>>> Ah, I understand now. >>>>> >>>>> What kind of helper functions did you have in mind? >>>> >>>> I can think of three possibilities: >>>> >>>> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >>>> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >>>> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >>>> >>>> Which of these do you think is best? (And why?) >>> >>> I would prefer (2). >>> >>> But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? >>> >>> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. >>> >>> I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code. >> >> > > Aha! I tried (2) but got: > > error: static_cast from 'const WebCore::GlyphBufferAdvance *' to 'const CGSize *', which are not related by inheritance, is not allowed > > This makes total sense, and I think the weird inheritance thing less bad than a call to reinterpret_cast. I'll keep (3) and commit.
This shows that we have something very unsafe going on. We have an array of GlyphBufferAdvance and we pass it to something expecting an array of CGSize. This works only if we have added no data members. If I added a bool to GlyphBufferAdvance we’d have a lot of failures.
Darin Adler
Comment 14
2020-08-04 12:34:56 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>>>>> +struct GlyphBufferOrigin : CGPoint { >>>>>>> >>>>>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>>>>> >>>>>> Ah, I understand now. >>>>>> >>>>>> What kind of helper functions did you have in mind? >>>>> >>>>> I can think of three possibilities: >>>>> >>>>> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >>>>> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >>>>> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >>>>> >>>>> Which of these do you think is best? (And why?) >>>> >>>> I would prefer (2). >>>> >>>> But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? >>>> >>>> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. >>>> >>>> I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code. >>> >>> >> >> Aha! I tried (2) but got: >> >> error: static_cast from 'const WebCore::GlyphBufferAdvance *' to 'const CGSize *', which are not related by inheritance, is not allowed >> >> This makes total sense, and I think the weird inheritance thing less bad than a call to reinterpret_cast. I'll keep (3) and commit. > > This shows that we have something very unsafe going on. > > We have an array of GlyphBufferAdvance and we pass it to something expecting an array of CGSize. This works only if we have added no data members. If I added a bool to GlyphBufferAdvance we’d have a lot of failures.
We should use (1). GlyphBufferAdvance should be: using GlyphBufferAdvance = FloatSize; and using GlyphBufferAdvance = CGSize; on different platforms. Then we should use non-member functions for the things we need to do in cross-platform code that are different between these two.
Myles C. Maxfield
Comment 15
2020-08-04 14:26:07 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>>>>>> +struct GlyphBufferOrigin : CGPoint { >>>>>>>> >>>>>>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>>>>>> >>>>>>> Ah, I understand now. >>>>>>> >>>>>>> What kind of helper functions did you have in mind? >>>>>> >>>>>> I can think of three possibilities: >>>>>> >>>>>> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >>>>>> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >>>>>> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >>>>>> >>>>>> Which of these do you think is best? (And why?) >>>>> >>>>> I would prefer (2). >>>>> >>>>> But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? >>>>> >>>>> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. >>>>> >>>>> I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code. >>>> >>>> >>> >>> Aha! I tried (2) but got: >>> >>> error: static_cast from 'const WebCore::GlyphBufferAdvance *' to 'const CGSize *', which are not related by inheritance, is not allowed >>> >>> This makes total sense, and I think the weird inheritance thing less bad than a call to reinterpret_cast. I'll keep (3) and commit. >> >> This shows that we have something very unsafe going on. >> >> We have an array of GlyphBufferAdvance and we pass it to something expecting an array of CGSize. This works only if we have added no data members. If I added a bool to GlyphBufferAdvance we’d have a lot of failures. > > We should use (1). > > GlyphBufferAdvance should be: > > using GlyphBufferAdvance = FloatSize; > > and > > using GlyphBufferAdvance = CGSize; > > on different platforms. Then we should use non-member functions for the things we need to do in cross-platform code that are different between these two.
Right, the current code is unsafe. I agree that (1) is better than (3). I did what you suggested, but it turned out to be quite a lot of changes - more than the rest of the patch. So, rather than pollute this one, I'm going to post a second patch to a new bug.
Myles C. Maxfield
Comment 16
2020-08-04 15:02:36 PDT
Committed
r265261
: <
https://trac.webkit.org/changeset/265261
>
Radar WebKit Bug Importer
Comment 17
2020-08-04 15:03:22 PDT
<
rdar://problem/66543482
>
Myles C. Maxfield
Comment 18
2020-08-04 16:14:41 PDT
Comment on
attachment 405780
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405780&action=review
>>>>>>>>>> Source/WebCore/platform/graphics/GlyphBuffer.h:107 >>>>>>>>>> +struct GlyphBufferOrigin : CGPoint { >>>>>>>>> >>>>>>>>> This is an example of deriving a structure from the Cocoa structure "CGPoint". That’s what I meant by "deriving structures from platform structures". >>>>>>>> >>>>>>>> Ah, I understand now. >>>>>>>> >>>>>>>> What kind of helper functions did you have in mind? >>>>>>> >>>>>>> I can think of three possibilities: >>>>>>> >>>>>>> 1) Typedef CGPoint to something like NativePoint, and make freestanding functions that accept and perform operations on NativePoint >>>>>>> 2) Make GlyphBufferOrigin own a CGPoint, rather than be a CGPoint >>>>>>> 3) Keep it as it is now: GlyphBufferOrigin is a CGPoint >>>>>>> >>>>>>> Which of these do you think is best? (And why?) >>>>>> >>>>>> I would prefer (2). >>>>>> >>>>>> But also not sure of the bigger picture. Is GlyphBufferOrigin a cross-platform abstraction? If so, then does it’s platform-independent interface involve CGFloat? >>>>>> >>>>>> I’d like to see what the cross-platform abstraction is and see some examples of platform-independent code using it. >>>>>> >>>>>> I’ve noticed our platform layer current has a lot of cross-platform non-abstraction. Supposedly platform-independent types and typedefs that don’t actually enable any shared platform-independent code. >>>>> >>>>> >>>> >>>> Aha! I tried (2) but got: >>>> >>>> error: static_cast from 'const WebCore::GlyphBufferAdvance *' to 'const CGSize *', which are not related by inheritance, is not allowed >>>> >>>> This makes total sense, and I think the weird inheritance thing less bad than a call to reinterpret_cast. I'll keep (3) and commit. >>> >>> This shows that we have something very unsafe going on. >>> >>> We have an array of GlyphBufferAdvance and we pass it to something expecting an array of CGSize. This works only if we have added no data members. If I added a bool to GlyphBufferAdvance we’d have a lot of failures. >> >> We should use (1). >> >> GlyphBufferAdvance should be: >> >> using GlyphBufferAdvance = FloatSize; >> >> and >> >> using GlyphBufferAdvance = CGSize; >> >> on different platforms. Then we should use non-member functions for the things we need to do in cross-platform code that are different between these two. > > Right, the current code is unsafe. I agree that (1) is better than (3). > > I did what you suggested, but it turned out to be quite a lot of changes - more than the rest of the patch. So, rather than pollute this one, I'm going to post a second patch to a new bug.
https://bugs.webkit.org/show_bug.cgi?id=215143
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug