-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CGD2D] Migrate the text drawing code from CGContextCairo. #1729
[CGD2D] Migrate the text drawing code from CGContextCairo. #1729
Conversation
With #1727, all of the enabled drawing tests pass! |
Therefore, this branch will merge into the merge branch. |
// Text Drawing | ||
CGTextDrawingMode textDrawingMode = kCGTextFill; | ||
woc::StrongCF<CGFontRef> font; | ||
CGFloat fontSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps this needs zero initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or the default font size value
// Text Drawing | ||
CGTextDrawingMode textDrawingMode = kCGTextFill; | ||
woc::StrongCF<CGFontRef> font; | ||
CGFloat fontSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or the default font size value
*/ | ||
void CGContextSetTextDrawingMode(CGContextRef context, CGTextDrawingMode mode) { | ||
NOISY_RETURN_IF_NULL(context); | ||
UNIMPLEMENTED(); | ||
auto& state = context->CurrentGState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: oneline these? (context->CurrentGState().textDrawingMode = mode)
297a9b5
to
d073b68
Compare
// * Stroke: fully opaque black | ||
// If a context does not support alpha, the default fill looks like fully opaque black. | ||
CGContextSetRGBFillColor(context, 0, 0, 0, 0); | ||
// * All colors are fully opaque black. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit it is in is titled "Fix the default ... from the reference platform."
UNIMPLEMENTED(); | ||
NOISY_RETURN_IF_NULL(font); | ||
auto& state = context->CurrentGState(); | ||
state.font = font; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context->CurrentGState().font= font;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit*.
*/ | ||
void CGContextSetTextDrawingMode(CGContextRef context, CGTextDrawingMode mode) { | ||
NOISY_RETURN_IF_NULL(context); | ||
UNIMPLEMENTED(); | ||
auto& state = context->CurrentGState(); | ||
state.textDrawingMode = mode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context->CurrentGState().mode= mode;
*/ | ||
void CGContextSelectFont(CGContextRef context, const char* name, CGFloat size, CGTextEncoding encoding) { | ||
NOISY_RETURN_IF_NULL(context); | ||
UNIMPLEMENTED(); | ||
|
||
auto fontName = woc::MakeStrongCF<CFStringRef>(CFStringCreateWithCString(nullptr, name, kCFStringEncodingUTF8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto [](start = 4, length = 4)
we should just give it the correct type, maybe we are over abusing auto here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC explicitly allows the use of auto when the type is unwieldy and immediately expressly identified by the right side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I feel like this could lead to every single instance of woc:MakeStrong/ woc:* end up being auto.
your call.
In reply to: 96745127 [](ancestors = 96745127)
} | ||
|
||
/** | ||
@Status Interoperable | ||
*/ | ||
void CGContextSetFontSize(CGContextRef context, CGFloat ptSize) { | ||
NOISY_RETURN_IF_NULL(context); | ||
UNIMPLEMENTED(); | ||
auto& state = context->CurrentGState(); | ||
state.fontSize = ptSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: context->CurrentGState().fontSize = ptSize;
} | ||
|
||
// Internal: used by CoreText. | ||
void CGContextDrawGlyphRun(CGContextRef context, const DWRITE_GLYPH_RUN* glyphRun) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would be happy if we also check the validity of glyphRun here. It doesn't look like DrawGlyphRunis takes care of this and can crash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only called by proper consumers who are aware of the contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would suggest to add it at least in the actual function (makes sense to validate it, rather than expecting the user to give it in)
In the future someone decide to be less cautious and call it, we would end up with a crash.
@@ -1878,7 +2035,6 @@ void CGContextShowGlyphs(CGContextRef context, const CGGlyph* glyphs, unsigned c | |||
*/ | |||
void CGContextShowGlyphsAtPositions(CGContextRef context, const CGGlyph* glyphs, const CGPoint* Lpositions, size_t count) { | |||
NOISY_RETURN_IF_NULL(context); | |||
// TODO(DH) GH#1070 Merge in CGContextCairo.mm's Glyph Run code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO(DH) GH#1070 Merge in CGContextCairo.mm's Gl [](start = 3, length = 52)
is this being missed? or it's will/not arrive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't exist. The dream isn't real.
// Give array of advances of zero so it will use positions correctly | ||
std::vector<FLOAT> dwriteAdvances(count, 0); | ||
DWRITE_GLYPH_RUN run = { fontFace.Get(), state.fontSize, count, glyphs, dwriteAdvances.data(), positions.data(), FALSE, 0 }; | ||
THROW_IF_FAILED(context->DrawGlyphRun(&run, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THROW_IF_FAILED [](start = 4, length = 15)
i thought we settled on fast fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
//****************************************************************************** | ||
|
||
#import <CoreGraphics/CGGeometry.h> | ||
#import <Starboard.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
d073b68
to
92ed07c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍰
I fixed the legitimate complaints you had before you submitted this status.
|
Fixes #1634.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)