- Revision
- 200919
- Author
- [email protected]
- Date
- 2016-05-14 09:54:07 -0700 (Sat, 14 May 2016)
Log Message
Allocate MacGlyphToPathTranslator / CairoGlyphToPathTranslator on the stack
https://bugs.webkit.org/show_bug.cgi?id=157690
Reviewed by Myles C. Maxfield.
Allocate MacGlyphToPathTranslator / CairoGlyphToPathTranslator on the
stack. We also now use the subclass type for the local variable so it
will bypass the vtable for various virtual function calls (if the compiler
was not already smart enough to figure this out).
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::FontCascade::dashesForIntersectionsWithRect):
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::dashesForIntersectionsWithRect):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (200918 => 200919)
--- trunk/Source/WebCore/ChangeLog 2016-05-14 14:59:55 UTC (rev 200918)
+++ trunk/Source/WebCore/ChangeLog 2016-05-14 16:54:07 UTC (rev 200919)
@@ -1,3 +1,20 @@
+2016-05-14 Chris Dumez <[email protected]>
+
+ Allocate MacGlyphToPathTranslator / CairoGlyphToPathTranslator on the stack
+ https://bugs.webkit.org/show_bug.cgi?id=157690
+
+ Reviewed by Myles C. Maxfield.
+
+ Allocate MacGlyphToPathTranslator / CairoGlyphToPathTranslator on the
+ stack. We also now use the subclass type for the local variable so it
+ will bypass the vtable for various virtual function calls (if the compiler
+ was not already smart enough to figure this out).
+
+ * platform/graphics/cairo/FontCairo.cpp:
+ (WebCore::FontCascade::dashesForIntersectionsWithRect):
+ * platform/graphics/cocoa/FontCascadeCocoa.mm:
+ (WebCore::FontCascade::dashesForIntersectionsWithRect):
+
2016-05-13 Chris Dumez <[email protected]>
Unreviewed attempt to fix the iOS build after the protector variables renaming.
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (200918 => 200919)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2016-05-14 14:59:55 UTC (rev 200918)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2016-05-14 16:54:07 UTC (rev 200919)
@@ -221,16 +221,14 @@
, m_translation(AffineTransform().translate(textOrigin.x(), textOrigin.y()))
{
}
-private:
- bool containsMorePaths() override
- {
- return m_index != m_glyphBuffer.size();
- }
- Path path() override;
- std::pair<float, float> extents() override;
- GlyphUnderlineType underlineType() override;
- void advance() override;
+ bool containsMorePaths() final { return m_index != m_glyphBuffer.size(); }
+ Path path() final;
+ std::pair<float, float> extents() final;
+ GlyphUnderlineType underlineType() final;
+ void advance() final;
+
+private:
int m_index;
const TextRun& m_textRun;
const GlyphBuffer& m_glyphBuffer;
@@ -297,9 +295,9 @@
// FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
- std::unique_ptr<GlyphToPathTranslator> translator = std::make_unique<CairoGlyphToPathTranslator>(run, glyphBuffer, origin);
+ CairoGlyphToPathTranslator translator(run, glyphBuffer, origin);
DashArray result;
- for (int index = 0; translator->containsMorePaths(); ++index, translator->advance()) {
+ for (int index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
float centerOfLine = lineExtents.y() + (lineExtents.height() / 2);
GlyphIterationState info = GlyphIterationState(FloatPoint(), FloatPoint(), centerOfLine, lineExtents.x() + lineExtents.width(), lineExtents.x());
const Font* localFontData = glyphBuffer.fontAt(index);
@@ -308,9 +306,9 @@
result.clear();
break;
}
- switch (translator->underlineType()) {
+ switch (translator.underlineType()) {
case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
- Path path = translator->path();
+ Path path = translator.path();
path.apply([&info](const PathElement& pathElement) {
findPathIntersections(info, pathElement);
});
@@ -321,7 +319,7 @@
break;
}
case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
- std::pair<float, float> extents = translator->extents();
+ std::pair<float, float> extents = translator.extents();
result.append(extents.first - lineExtents.x());
result.append(extents.second - lineExtents.x());
break;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (200918 => 200919)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2016-05-14 14:59:55 UTC (rev 200918)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2016-05-14 16:54:07 UTC (rev 200919)
@@ -427,16 +427,13 @@
, m_translation(CGAffineTransformScale(CGAffineTransformMakeTranslation(textOrigin.x(), textOrigin.y()), 1, -1))
{
}
-private:
- bool containsMorePaths() override
- {
- return m_index != m_glyphBuffer.size();
- }
- Path path() override;
- std::pair<float, float> extents() override;
- GlyphUnderlineType underlineType() override;
- void advance() override;
+ bool containsMorePaths() final { return m_index != m_glyphBuffer.size(); }
+ Path path() final;
+ std::pair<float, float> extents() final;
+ GlyphUnderlineType underlineType() final;
+ void advance() final;
+private:
int m_index;
const TextRun& m_textRun;
const GlyphBuffer& m_glyphBuffer;
@@ -489,9 +486,9 @@
// FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
- std::unique_ptr<GlyphToPathTranslator> translator = std::make_unique<MacGlyphToPathTranslator>(run, glyphBuffer, origin);
+ MacGlyphToPathTranslator translator(run, glyphBuffer, origin);
DashArray result;
- for (int index = 0; translator->containsMorePaths(); ++index, translator->advance()) {
+ for (int index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
const Font* localFont = glyphBuffer.fontAt(index);
if (!localFont) {
@@ -499,9 +496,9 @@
result.clear();
break;
}
- switch (translator->underlineType()) {
+ switch (translator.underlineType()) {
case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
- Path path = translator->path();
+ Path path = translator.path();
CGPathApply(path.platformPath(), &info, &findPathIntersections);
if (info.minX < info.maxX) {
result.append(info.minX - lineExtents.x());
@@ -510,7 +507,7 @@
break;
}
case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
- std::pair<float, float> extents = translator->extents();
+ std::pair<float, float> extents = translator.extents();
result.append(extents.first - lineExtents.x());
result.append(extents.second - lineExtents.x());
break;