Title: [282734] trunk/Source/WebCore
Revision
282734
Author
[email protected]
Date
2021-09-18 21:25:25 -0700 (Sat, 18 Sep 2021)

Log Message

[Cocoa] Add "Shaping" log channel
https://bugs.webkit.org/show_bug.cgi?id=230440

Reviewed by Darin Adler.

This logging has been useful to me before, so I figure it might be useful to other people.

This new channel is off by default.

No new tests because there is no behavior change.

* platform/Logging.h:
* platform/graphics/coretext/FontCoreText.cpp:
(WebCore::Font::applyTransforms const):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282733 => 282734)


--- trunk/Source/WebCore/ChangeLog	2021-09-19 02:55:42 UTC (rev 282733)
+++ trunk/Source/WebCore/ChangeLog	2021-09-19 04:25:25 UTC (rev 282734)
@@ -1,3 +1,23 @@
+2021-09-18  Myles C. Maxfield  <[email protected]>
+
+        [Cocoa] Add "Shaping" log channel
+        https://bugs.webkit.org/show_bug.cgi?id=230440
+
+        Reviewed by Darin Adler.
+
+        This logging has been useful to me before, so I figure it might be useful to other people.
+
+        This new channel is off by default.
+
+        No new tests because there is no behavior change.
+
+        * platform/Logging.h:
+        * platform/graphics/coretext/FontCoreText.cpp:
+        (WebCore::Font::applyTransforms const):
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+
 2021-09-18  Simon Fraser  <[email protected]>
 
         Move ScrollingMomentumCalculator into the platform directory

Modified: trunk/Source/WebCore/platform/Logging.h (282733 => 282734)


--- trunk/Source/WebCore/platform/Logging.h	2021-09-19 02:55:42 UTC (rev 282733)
+++ trunk/Source/WebCore/platform/Logging.h	2021-09-19 04:25:25 UTC (rev 282734)
@@ -107,6 +107,7 @@
     M(Selection) \
     M(Services) \
     M(ServiceWorker) \
+    M(Shaping) \
     M(SpellingAndGrammar) \
     M(SQLDatabase) \
     M(Storage) \

Modified: trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp (282733 => 282734)


--- trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp	2021-09-19 02:55:42 UTC (rev 282733)
+++ trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp	2021-09-19 04:25:25 UTC (rev 282734)
@@ -32,6 +32,7 @@
 #include "FontCache.h"
 #include "FontCascade.h"
 #include "FontDescription.h"
+#include "Logging.h"
 #include "OpenTypeCG.h"
 #include "SharedBuffer.h"
 #include <CoreText/CoreText.h>
@@ -604,8 +605,11 @@
             range.length = std::min(range.location, -range.length);
             range.location = range.location - range.length;
             glyphBuffer.remove(beginningGlyphIndex + range.location, range.length);
-        } else
+            LOG_WITH_STREAM(Shaping, stream << "Callback called to remove at location " << range.location << " and length " << range.length);
+        } else {
             glyphBuffer.makeHole(beginningGlyphIndex + range.location, range.length, this);
+            LOG_WITH_STREAM(Shaping, stream << "Callback called to insert hole at location " << range.location << " and length " << range.length);
+        }
 
         *newGlyphsPointer = glyphBuffer.glyphs(beginningGlyphIndex);
         *newAdvancesPointer = glyphBuffer.advances(beginningGlyphIndex);
@@ -625,6 +629,34 @@
     for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
         glyphBuffer.offsetsInString(beginningGlyphIndex)[i] -= beginningStringIndex;
 
+    LOG_WITH_STREAM(Shaping,
+        stream << "Simple shaping " << numberOfInputGlyphs << " glyphs in font " << String(adoptCF(CTFontCopyPostScriptName(m_platformData.ctFont())).get()) << ".\n";
+        const auto* glyphs = glyphBuffer.glyphs(beginningGlyphIndex);
+        stream << "Glyphs:";
+        for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
+            stream << " " << glyphs[i];
+        stream << "\n";
+        const auto* advances = glyphBuffer.advances(beginningGlyphIndex);
+        stream << "Advances:";
+        for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
+            stream << " " << FloatSize(advances[i]);
+        stream << "\n";
+        const auto* origins = glyphBuffer.origins(beginningGlyphIndex);
+        stream << "Origins:";
+        for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
+            stream << " " << origins[i];
+        stream << "\n";
+        const auto* offsets = glyphBuffer.offsetsInString(beginningGlyphIndex);
+        stream << "Offsets:";
+        for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
+            stream << " " << offsets[i];
+        stream << "\n";
+        const UChar* codeUnits = upconvertedCharacters.get();
+        stream << "Code Units:";
+        for (unsigned i = 0; i < numberOfInputGlyphs; ++i)
+            stream << " " << codeUnits[i];
+    );
+
     auto initialAdvance = CTFontShapeGlyphs(
         m_platformData.ctFont(),
         glyphBuffer.glyphs(beginningGlyphIndex),
@@ -637,6 +669,36 @@
         localeString.get(),
         handler);
 
+    LOG_WITH_STREAM(Shaping,
+        stream << "Shaping result: " << glyphBuffer.size() - beginningGlyphIndex << " glyphs.\n";
+        const auto* glyphs = glyphBuffer.glyphs(beginningGlyphIndex);
+        stream << "Glyphs:";
+        for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
+            stream << " " << glyphs[i];
+        stream << "\n";
+        const auto* advances = glyphBuffer.advances(beginningGlyphIndex);
+        stream << "Advances:";
+        for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
+            stream << " " << FloatSize(advances[i]);
+        stream << "\n";
+        const auto* origins = glyphBuffer.origins(beginningGlyphIndex);
+        stream << "Origins:";
+        for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
+            stream << " " << origins[i];
+        stream << "\n";
+        const auto* offsets = glyphBuffer.offsetsInString(beginningGlyphIndex);
+        stream << "Offsets:";
+        for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
+            stream << " " << offsets[i];
+        stream << "\n";
+        const UChar* codeUnits = upconvertedCharacters.get();
+        stream << "Code Units:";
+        for (unsigned i = 0; i < glyphBuffer.size() - beginningGlyphIndex; ++i)
+            stream << " " << codeUnits[i];
+        stream << "\n";
+        stream << "Initial advance: " << FloatSize(initialAdvance);
+    );
+
     ASSERT(numberOfInputGlyphs || glyphBuffer.size() == beginningGlyphIndex);
     ASSERT(numberOfInputGlyphs || (!initialAdvance.width && !initialAdvance.height));
 

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (282733 => 282734)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2021-09-19 02:55:42 UTC (rev 282733)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2021-09-19 04:25:25 UTC (rev 282734)
@@ -89,6 +89,31 @@
         for (unsigned i = 0; i < m_glyphCount; ++i)
             m_baseAdvances.uncheckedAppend(baseAdvances[i]);
     }
+
+    LOG_WITH_STREAM(Shaping,
+        stream << "Shaping result: " << m_glyphCount << " glyphs.\n";
+        stream << "Glyphs:";
+        for (unsigned i = 0; i < m_glyphCount; ++i)
+            stream << " " << m_glyphs[i];
+        stream << "\n";
+        stream << "Advances:";
+        for (unsigned i = 0; i < m_glyphCount; ++i)
+            stream << " " << m_baseAdvances[i];
+        stream << "\n";
+        stream << "Origins:";
+        if (m_glyphOrigins.isEmpty())
+            stream << " empty";
+        else {
+            for (unsigned i = 0; i < m_glyphCount; ++i)
+                stream << " " << m_glyphs[i];
+        }
+        stream << "\n";
+        stream << "Offsets:";
+        for (unsigned i = 0; i < m_glyphCount; ++i)
+            stream << " " << m_coreTextIndices[i];
+        stream << "\n";
+        stream << "Initial advance: " << FloatSize(m_initialAdvance);
+    );
 }
 
 struct ProviderInfo {
@@ -136,6 +161,14 @@
 
     RetainPtr<CTLineRef> line;
 
+    LOG_WITH_STREAM(Shaping,
+        stream << "Complex shaping " << length << " code units with info " << String(adoptCF(CFCopyDescription(stringAttributes.get())).get()) << ".\n";
+        stream << "Code Units:";
+        for (unsigned i = 0; i < length; ++i)
+            stream << " " << cp[i];
+        stream << "\n";
+    );
+
     if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) {
         const short ltrForcedEmbeddingLevelValue = 0;
         const short rtlForcedEmbeddingLevelValue = 1;
@@ -154,8 +187,12 @@
         if (!typesetter)
             return;
 
+        LOG_WITH_STREAM(Shaping, stream << "Forcing " << (m_run.ltr() ? "ltr" : "rtl"));
+
         line = adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
     } else {
+        LOG_WITH_STREAM(Shaping, stream << "Not forcing direction");
+
         ProviderInfo info = { cp, length, stringAttributes.get() };
 
         line = adoptCF(CTLineCreateWithUniCharProvider(&provideStringAndAttributes, nullptr, &info));
@@ -173,6 +210,8 @@
 
     CFIndex runCount = CFArrayGetCount(runArray);
 
+    LOG_WITH_STREAM(Shaping, stream << "Result: " << runCount << " runs.");
+
     for (CFIndex r = 0; r < runCount; r++) {
         CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, m_run.ltr() ? r : runCount - 1 - r));
         ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
@@ -211,6 +250,8 @@
         if (m_fallbackFonts && runFont != &m_font.primaryFont())
             m_fallbackFonts->add(font);
 
+        LOG_WITH_STREAM(Shaping, stream << "Run " << r << ":");
+
         m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFont, cp, stringLocation, length, runRange.location, runRange.location + runRange.length));
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to